From 24d2f47c52e973006135b21e11756ae77fb747a9 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 6 Aug 2013 18:22:46 -0700 Subject: [PATCH] Stop using $.extend for Style --- builds/appchan-x.user.js | 22 ++++++++++++---------- builds/crx/script.js | 22 ++++++++++++---------- src/Theming/Style.coffee | 25 +++++++++++++++++-------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 8f2cb7ce6..8893d9a52 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -11568,22 +11568,24 @@ }); } }, + addSheet: function(_arg) { + var id, key, text; + + key = _arg[0], text = _arg[1], id = _arg[2]; + return Style[key] = $.addStyle(text, id); + }, setup: function() { - var theme; + var i, item, items, theme; theme = Themes[Conf['theme']] || Themes['Yotsuba B']; Style.svg = $.el('div', { id: 'svg_filters' }); - $.extend(Style, { - layoutCSS: $.addStyle(Style.layout, 'layout'), - themeCSS: $.addStyle(Style.theme(theme), 'theme'), - emojiCSS: $.addStyle(Emoji.css(), 'emoji'), - dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic'), - icons: $.addStyle("", 'icons'), - paddingSheet: $.addStyle("", 'padding'), - mascot: $.addStyle("", 'mascotSheet') - }); + items = [['layoutCSS', Style.layout, 'layout'], ['themeCSS', Style.theme(theme), 'theme'], ['emojiCSS', Emoji.css(), 'emoji'], ['dynamicCSS', Style.dynamic(), 'dynamic'], ['icons', "", 'icons'], ['paddingSheet', "", 'padding'], ['mascot', "", 'mascotSheet']]; + i = 0; + while (item = items[i++]) { + Style.addSheet(item); + } $.addStyle(JSColor.css(), 'jsColor'); if (d.head) { this.remStyle(); diff --git a/builds/crx/script.js b/builds/crx/script.js index 2a1255cd0..84f2ca1d8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -11556,22 +11556,24 @@ }); } }, + addSheet: function(_arg) { + var id, key, text; + + key = _arg[0], text = _arg[1], id = _arg[2]; + return Style[key] = $.addStyle(text, id); + }, setup: function() { - var theme; + var i, item, items, theme; theme = Themes[Conf['theme']] || Themes['Yotsuba B']; Style.svg = $.el('div', { id: 'svg_filters' }); - $.extend(Style, { - layoutCSS: $.addStyle(Style.layout, 'layout'), - themeCSS: $.addStyle(Style.theme(theme), 'theme'), - emojiCSS: $.addStyle(Emoji.css(), 'emoji'), - dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic'), - icons: $.addStyle("", 'icons'), - paddingSheet: $.addStyle("", 'padding'), - mascot: $.addStyle("", 'mascotSheet') - }); + items = [['layoutCSS', Style.layout, 'layout'], ['themeCSS', Style.theme(theme), 'theme'], ['emojiCSS', Emoji.css(), 'emoji'], ['dynamicCSS', Style.dynamic(), 'dynamic'], ['icons', "", 'icons'], ['paddingSheet', "", 'padding'], ['mascot', "", 'mascotSheet']]; + i = 0; + while (item = items[i++]) { + Style.addSheet(item); + } $.addStyle(JSColor.css(), 'jsColor'); if (d.head) { this.remStyle(); diff --git a/src/Theming/Style.coffee b/src/Theming/Style.coffee index df51a9ffc..db2f2355f 100644 --- a/src/Theming/Style.coffee +++ b/src/Theming/Style.coffee @@ -47,18 +47,27 @@ Style = $.on exLink, "click", -> setTimeout Rice.nodes, 100 + addSheet: ([key, text, id]) -> + Style[key] = $.addStyle text, id + setup: -> theme = Themes[Conf['theme']] or Themes['Yotsuba B'] Style.svg = $.el 'div', id: 'svg_filters' - $.extend Style, - layoutCSS: $.addStyle Style.layout, 'layout' - themeCSS: $.addStyle Style.theme(theme), 'theme' - emojiCSS: $.addStyle Emoji.css(), 'emoji' - dynamicCSS: $.addStyle Style.dynamic(), 'dynamic' - icons: $.addStyle "", 'icons' - paddingSheet: $.addStyle "", 'padding' - mascot: $.addStyle "", 'mascotSheet' + + items = [ + ['layoutCSS', Style.layout, 'layout'] + ['themeCSS', Style.theme(theme), 'theme'] + ['emojiCSS', Emoji.css(), 'emoji'] + ['dynamicCSS', Style.dynamic(), 'dynamic'] + ['icons', "", 'icons'] + ['paddingSheet', "", 'padding'] + ['mascot', "", 'mascotSheet'] + ] + + i = 0 + while item = items[i++] + Style.addSheet item # Non-customizable $.addStyle JSColor.css(), 'jsColor'