styleText moved into helpers
authorDarren <darren@darrenwhitlen.com>
Mon, 14 Apr 2014 10:06:39 +0000 (11:06 +0100)
committerDarren <darren@darrenwhitlen.com>
Mon, 14 Apr 2014 10:06:39 +0000 (11:06 +0100)
client/build.js
client/src/helpers/utils.js
client/src/views/texttheme.js [deleted file]
server/settingsgenerator.js

index 0956e0754b05c2b678aed5faaac4bbede564254f..746cd6c42f2b42c3e8fc981ad1dbdad0c359d647 100644 (file)
@@ -81,7 +81,6 @@ var source_files = [
     __dirname + '/src/views/userbox.js',\r
     __dirname + '/src/views/channeltools.js',\r
     __dirname + '/src/views/channelinfo.js',\r
-    __dirname + '/src/views/texttheme.js',\r
     __dirname + '/src/applets/settings.js',\r
     __dirname + '/src/applets/chanlist.js',\r
     __dirname + '/src/applets/scripteditor.js',\r
index 9c32e02ac3b562d6ec1cfb6095aaa1b72f9add4a..e07c16b48d23d07349836cbb0c6f1225c2d9a89a 100644 (file)
@@ -505,11 +505,46 @@ function parseISO8601(str) {
 
 // Simplyfy the translation syntax
 function translateText(string_id, params) {
-    if (params === undefined) var params = '';
-    
+    params = params || '';
+
     return _kiwi.global.i18n.translate(string_id).fetch(params);
 }
-// Simplyfy the text styling syntax
+
+/**
+ * Simplyfy the text styling syntax
+ *
+ * Syntax:
+ *   %N: nickname
+ *   %C: channel
+ *   %J: ident
+ *   %H: host
+ *   %R: realname
+ *   %C[digit]: color
+ *   %B: bold
+ *   %I: italic
+ *   %U: underline
+ *   %O: cancel styles
+ *   %T: translated text
+ **/
 function styleText(string_id, params) {
-    return _kiwi.global.text_theme.styleText(string_id, params);
+    var style, text;
+
+    style = formatToIrcMsg(_kiwi.global.text_theme.options[string_id]);
+
+    // Bring member info back to first level of params
+    if (params['%M']) {
+        _.each(params['%M'], function(val, key) {
+            params[key] = val;
+        });
+    }
+
+    // Do the magic. Use the shorthand syntax to produce output.
+    text = style.replace(/%([TJHNCR])/g, function(match, key) {
+        key = '%' + key;
+
+        if (typeof params[key.toUpperCase()] !== 'undefined')
+            return params[key.toUpperCase()];
+    });
+
+    return text;
 }
\ No newline at end of file
diff --git a/client/src/views/texttheme.js b/client/src/views/texttheme.js
deleted file mode 100644 (file)
index c85f1c2..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * TEXT THEMES SYNTAX
- * 
- * %N: nickname
- * %C[digit]: color
- * %C: channel
- * %J: ident
- * %H: host
- * %R: realname
- * %B: bold
- * %I: italic
- * %U: underline
- * %O: cancel styles
- * %T: translated text
- **/
-
-_kiwi.view.TextTheme = _kiwi.view.Panel.extend({
-       initialize: function(text_theme) {
-               this.text_theme = text_theme;
-       },
-       styleText: function(string_id, params) {
-               var style, text;
-               
-               style = formatToIrcMsg(_kiwi.global.text_theme.options[string_id]);
-               
-               // Bring member info back to first level of params
-               if (params['%M']) {
-                       for(key in params['%M']) {
-                               params[key] = params['%M'][key];
-                       }
-               }
-
-               // Do the magic. Use the shorthand syntax to produce output.
-               text = style.replace(/%([TJHNCR])/g, function(match, key) {
-                       key = '%' + key;
-
-                       if (typeof params[key.toUpperCase()] !== 'undefined')
-                               return params[key.toUpperCase()];
-               });
-               return text;
-       }
-});
\ No newline at end of file
index 0f8b878f7abb417d048ebc614436b4f81e41dcad..2c8360e6dc99c4b8344660a57b22e2d3440dcb85 100644 (file)
@@ -244,7 +244,6 @@ function addScripts(vars, debug) {
             'src/views/userbox.js',
             'src/views/channeltools.js',
             'src/views/channelinfo.js',
-            'src/views/texttheme.js',
             'src/applets/settings.js',
             'src/applets/chanlist.js',
             'src/applets/scripteditor.js',