Reading over this, I'm probably going rewrite this all anyways.

It's just a giant mess. Unsorted, very flat, very unorganized.
Everything is just kinda strewn about with no regards to structure.
This is my code and I have no one to blame but myself.
This commit is contained in:
Zixaphir 2014-01-02 01:51:23 -07:00
parent b49c0577d6
commit 2181553795
7 changed files with 96 additions and 93 deletions

View File

@ -12406,7 +12406,7 @@
valueElement.previousSibling.value = value; valueElement.previousSibling.value = value;
editTheme[valueElement.previousSibling.name] = value; editTheme[valueElement.previousSibling.name] = value;
setTimeout(function() { setTimeout(function() {
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}); });
} }
if (!(flags & leaveStyle) && styleElement) { if (!(flags & leaveStyle) && styleElement) {
@ -12675,7 +12675,7 @@
el.src = mascot.image; el.src = mascot.image;
$.off(img = this.el.firstElementChild, 'error', MascotTools.error); $.off(img = this.el.firstElementChild, 'error', MascotTools.error);
$.replace(img, el); $.replace(img, el);
return Style.mascot.textContent = "#mascot img {\nheight: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\nwidth: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n}\n#mascot {\nmargin: " + (mascot.vOffset || 0) + "px " + (mascot.hOffset || 0) + "px;\n}\n.sidebar-large #mascot {\nleft: " + (mascot.center ? 25 : 0) + "px;\nright: " + (mascot.center ? 25 : 0) + "px;\n}\n.mascot-position-above-post-form.post-form-style-fixed #mascot {\ntransform: translateY(-" + (QR.nodes ? QR.nodes.el.getBoundingClientRect().height : 0) + "px);\n}"; return Style.sheets.mascots.textContent = "#mascot img {\nheight: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\nwidth: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n}\n#mascot {\nmargin: " + (mascot.vOffset || 0) + "px " + (mascot.hOffset || 0) + "px;\n}\n.sidebar-large #mascot {\nleft: " + (mascot.center ? 25 : 0) + "px;\nright: " + (mascot.center ? 25 : 0) + "px;\n}\n.mascot-position-above-post-form.post-form-style-fixed #mascot {\ntransform: translateY(-" + (QR.nodes ? QR.nodes.el.getBoundingClientRect().height : 0) + "px);\n}";
}, },
error: function() { error: function() {
var ctx, el, var ctx, el,
@ -13109,14 +13109,15 @@
}; };
Style = { Style = {
sheets: {},
init: function() { init: function() {
var i, item, items, theme; var i, item, items, theme;
theme = Themes[Conf['theme']] || Themes['Yotsuba B'];
Style.svgs = {}; Style.svgs = {};
items = [['layoutCSS', Style.layout, 'layout'], ['themeCSS', Style.theme(theme), 'theme'], ['emojiCSS', Emoji.css(), 'emoji'], ['dynamicCSS', Style.dynamic(), 'dynamic'], ['paddingSheet', "", 'padding'], ['mascot', "", 'mascotSheet']]; theme = Themes[Conf['theme']] || Themes['Yotsuba B'];
items = [['layout', Style.layout], ['theme', Style.theme(theme)], ['emoji', Emoji.css()], ['dynamic', Style.dynamic()], ['padding', ""], ['mascots', ""]];
i = 0; i = 0;
while (item = items[i++]) { while (item = items[i++]) {
Style[item[0]] = $.addStyle(item[1], item[2]); Style.sheets[item[0]] = $.addStyle(item[1], item[0]);
} }
$.addStyle(JSColor.css(), 'jsColor'); $.addStyle(JSColor.css(), 'jsColor');
$.asap((function() { $.asap((function() {
@ -13129,7 +13130,7 @@
return $.ready(this.readyInit); return $.ready(this.readyInit);
}, },
asapInit: function() { asapInit: function() {
var cat, hyphenated, name, setting, title, _ref; var cat, hyphenated, name, pages, setting, title, _ref;
$.addClass(doc, 'gecko'); $.addClass(doc, 'gecko');
$.addClass(doc, 'fourchan-x'); $.addClass(doc, 'fourchan-x');
$.addClass(doc, 'appchan-x'); $.addClass(doc, 'appchan-x');
@ -13147,28 +13148,28 @@
} }
} }
if (g.VIEW === 'index') { if (g.VIEW === 'index') {
pages = function(name, text) {
var action, el, elA;
el = $(".pagelist > ." + name);
elA = $.el('a', {
textContent: text
});
if ((action = el.firstElementChild).nodeName === 'FORM') {
elA.href = 'javascript:;';
$.on(elA, 'click', function() {
return action.firstElementChild.click();
});
}
return $.add(el, elA);
};
return $.asap((function() { return $.asap((function() {
return $('.mPagelist'); return $('.mPagelist');
}), function() { }), function() {
Style.pages('prev', '<'); pages('prev', '<');
return Style.pages('next', '>'); return pages('next', '>');
}); });
} }
}, },
pages: function(name, text) {
var action, el, elA;
el = $(".pagelist > ." + name);
elA = $.el('a', {
textContent: text
});
if ((action = el.firstElementChild).nodeName === 'FORM') {
elA.href = 'javascript:;';
$.on(elA, 'click', function() {
return action.firstElementChild.click();
});
}
return $.add(el, elA);
},
readyInit: function() { readyInit: function() {
var exLink; var exLink;
Style.padding(); Style.padding();
@ -13315,7 +13316,7 @@
var navHeight, pageHeight, _ref; var navHeight, pageHeight, _ref;
navHeight = Header.bar.offsetHeight; navHeight = Header.bar.offsetHeight;
pageHeight = (_ref = $('.pagelist', d.body)) != null ? _ref.offsetHeight : void 0; pageHeight = (_ref = $('.pagelist', d.body)) != null ? _ref.offsetHeight : void 0;
return Style.paddingSheet.textContent = ("body { padding-bottom: 15px; padding-top: 15px; } .fourchan-ss-navigation.fixed.top-header:not(.autohide) body::before { top: " + navHeight + "px; } .fourchan-ss-navigation.fixed.bottom-header:not(.autohide) body::before { bottom: " + navHeight + "px; } .top-header:not(.autohide) body { padding-top: " + (navHeight + 1) + "px; } .bottom-header:not(.autohide) body { padding-bottom: " + (navHeight + 1) + "px; } ") + (pageHeight ? ".fourchan-ss-navigation.index.pagination-sticky-top body::before, .fourchan-ss-navigation.index.pagination-top body::before { top: " + pageHeight + "px; } .fourchan-ss-navigation.index.pagination-sticky-bottom body::before, .fourchan-ss-navigation.index.pagination-bottom body::before { bottom: " + pageHeight + "px; } .index.pagination-sticky-top body, .index.pagination-top body { padding-top: " + (pageHeight + 1) + "px; } .index.pagination-sticky-bottom body, .index.pagination-bottom body { padding-bottom: " + (pageHeight + 1) + "px; }" : ''); return Style.sheets.padding.textContent = ("body { padding-bottom: 15px; padding-top: 15px; } .fourchan-ss-navigation.fixed.top-header:not(.autohide) body::before { top: " + navHeight + "px; } .fourchan-ss-navigation.fixed.bottom-header:not(.autohide) body::before { bottom: " + navHeight + "px; } .top-header:not(.autohide) body { padding-top: " + (navHeight + 1) + "px; } .bottom-header:not(.autohide) body { padding-bottom: " + (navHeight + 1) + "px; } ") + (pageHeight ? ".fourchan-ss-navigation.index.pagination-sticky-top body::before, .fourchan-ss-navigation.index.pagination-top body::before { top: " + pageHeight + "px; } .fourchan-ss-navigation.index.pagination-sticky-bottom body::before, .fourchan-ss-navigation.index.pagination-bottom body::before { bottom: " + pageHeight + "px; } .index.pagination-sticky-top body, .index.pagination-top body { padding-top: " + (pageHeight + 1) + "px; } .index.pagination-sticky-bottom body, .index.pagination-bottom body { padding-bottom: " + (pageHeight + 1) + "px; }" : '');
}, },
color: function(hex) { color: function(hex) {
this.hex = "#" + hex; this.hex = "#" + hex;
@ -13451,7 +13452,7 @@
}); });
$.on($('textarea', div), 'blur', function() { $.on($('textarea', div), 'blur', function() {
editTheme["Custom CSS"] = this.value; editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}); });
$.add(themeContent, div); $.add(themeContent, div);
$.on($('#save > a', ThemeTools.dialog), 'click', function() { $.on($('#save > a', ThemeTools.dialog), 'click', function() {
@ -13459,7 +13460,7 @@
}); });
$.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close);
$.add(d.body, ThemeTools.dialog); $.add(d.body, ThemeTools.dialog);
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}, },
apply: function() { apply: function() {
var depth, i, len, toggle1, toggle2; var depth, i, len, toggle1, toggle2;
@ -13493,7 +13494,7 @@
this.nextSibling.color.importColor(); this.nextSibling.color.importColor();
} }
editTheme[this.name] = this.value; editTheme[this.name] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}, },
uploadImage: function(evt, el) { uploadImage: function(evt, el) {
var file, reader; var file, reader;
@ -13504,7 +13505,7 @@
val = "url(\"" + evt.target.result + "\")"; val = "url(\"" + evt.target.result + "\")";
el.previousSibling.value = val; el.previousSibling.value = val;
editTheme["Background Image"] = val; editTheme["Background Image"] = val;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}; };
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
@ -13649,7 +13650,7 @@
}, },
close: function() { close: function() {
Conf['editMode'] = false; Conf['editMode'] = false;
Style.themeCSS.textContent = Style.theme(Themes[Conf['theme']]); Style.sheets.theme.textContent = Style.theme(Themes[Conf['theme']]);
$.rm($.id('themeConf')); $.rm($.id('themeConf'));
return Settings.open('Themes'); return Settings.open('Themes');
} }
@ -16126,7 +16127,7 @@
}, },
value: function() { value: function() {
$.cb.value.call(this); $.cb.value.call(this);
return Style.dynamicCSS.textContent = Style.dynamic(); return Style.sheets.dynamicCSS.textContent = Style.dynamic();
}, },
select: function() { select: function() {
var hyphenated, option, _i, _len, _ref; var hyphenated, option, _i, _len, _ref;
@ -16252,7 +16253,7 @@
} }
Conf['theme'] = this.id; Conf['theme'] = this.id;
$.addClass(this, 'selectedtheme'); $.addClass(this, 'selectedtheme');
return Style.themeCSS.textContent = Style.theme(Themes[this.id]); return Style.sheets.theme.textContent = Style.theme(Themes[this.id]);
}, },
edit: function(e) { edit: function(e) {
e.preventDefault(); e.preventDefault();

View File

@ -12411,7 +12411,7 @@
valueElement.previousSibling.value = value; valueElement.previousSibling.value = value;
editTheme[valueElement.previousSibling.name] = value; editTheme[valueElement.previousSibling.name] = value;
setTimeout(function() { setTimeout(function() {
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}); });
} }
if (!(flags & leaveStyle) && styleElement) { if (!(flags & leaveStyle) && styleElement) {
@ -12680,7 +12680,7 @@
el.src = mascot.image; el.src = mascot.image;
$.off(img = this.el.firstElementChild, 'error', MascotTools.error); $.off(img = this.el.firstElementChild, 'error', MascotTools.error);
$.replace(img, el); $.replace(img, el);
return Style.mascot.textContent = "#mascot img {\nheight: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\nwidth: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n}\n#mascot {\nmargin: " + (mascot.vOffset || 0) + "px " + (mascot.hOffset || 0) + "px;\n}\n.sidebar-large #mascot {\nleft: " + (mascot.center ? 25 : 0) + "px;\nright: " + (mascot.center ? 25 : 0) + "px;\n}\n.mascot-position-above-post-form.post-form-style-fixed #mascot {\n-webkit-transform: translateY(-" + (QR.nodes ? QR.nodes.el.getBoundingClientRect().height : 0) + "px);\n}"; return Style.sheets.mascots.textContent = "#mascot img {\nheight: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\nwidth: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n}\n#mascot {\nmargin: " + (mascot.vOffset || 0) + "px " + (mascot.hOffset || 0) + "px;\n}\n.sidebar-large #mascot {\nleft: " + (mascot.center ? 25 : 0) + "px;\nright: " + (mascot.center ? 25 : 0) + "px;\n}\n.mascot-position-above-post-form.post-form-style-fixed #mascot {\n-webkit-transform: translateY(-" + (QR.nodes ? QR.nodes.el.getBoundingClientRect().height : 0) + "px);\n}";
}, },
error: function() { error: function() {
var ctx, el, var ctx, el,
@ -13114,18 +13114,19 @@
}; };
Style = { Style = {
sheets: {},
init: function() { init: function() {
var i, item, items, theme; var i, item, items, theme;
theme = Themes[Conf['theme']] || Themes['Yotsuba B'];
Style.svgs = { Style.svgs = {
el: $.el('div', { el: $.el('div', {
id: 'svg_filters' id: 'svg_filters'
}) })
}; };
items = [['layoutCSS', Style.layout, 'layout'], ['themeCSS', Style.theme(theme), 'theme'], ['emojiCSS', Emoji.css(), 'emoji'], ['dynamicCSS', Style.dynamic(), 'dynamic'], ['paddingSheet', "", 'padding'], ['mascot', "", 'mascotSheet']]; theme = Themes[Conf['theme']] || Themes['Yotsuba B'];
items = [['layout', Style.layout], ['theme', Style.theme(theme)], ['emoji', Emoji.css()], ['dynamic', Style.dynamic()], ['padding', ""], ['mascots', ""]];
i = 0; i = 0;
while (item = items[i++]) { while (item = items[i++]) {
Style[item[0]] = $.addStyle(item[1], item[2]); Style.sheets[item[0]] = $.addStyle(item[1], item[0]);
} }
$.addStyle(JSColor.css(), 'jsColor'); $.addStyle(JSColor.css(), 'jsColor');
$.asap((function() { $.asap((function() {
@ -13138,7 +13139,7 @@
return $.ready(this.readyInit); return $.ready(this.readyInit);
}, },
asapInit: function() { asapInit: function() {
var cat, hyphenated, name, setting, title, _ref; var cat, hyphenated, name, pages, setting, title, _ref;
$.addClass(doc, 'blink'); $.addClass(doc, 'blink');
$.addClass(doc, 'fourchan-x'); $.addClass(doc, 'fourchan-x');
$.addClass(doc, 'appchan-x'); $.addClass(doc, 'appchan-x');
@ -13157,28 +13158,28 @@
} }
} }
if (g.VIEW === 'index') { if (g.VIEW === 'index') {
pages = function(name, text) {
var action, el, elA;
el = $(".pagelist > ." + name);
elA = $.el('a', {
textContent: text
});
if ((action = el.firstElementChild).nodeName === 'FORM') {
elA.href = 'javascript:;';
$.on(elA, 'click', function() {
return action.firstElementChild.click();
});
}
return $.add(el, elA);
};
return $.asap((function() { return $.asap((function() {
return $('.mPagelist'); return $('.mPagelist');
}), function() { }), function() {
Style.pages('prev', '<'); pages('prev', '<');
return Style.pages('next', '>'); return pages('next', '>');
}); });
} }
}, },
pages: function(name, text) {
var action, el, elA;
el = $(".pagelist > ." + name);
elA = $.el('a', {
textContent: text
});
if ((action = el.firstElementChild).nodeName === 'FORM') {
elA.href = 'javascript:;';
$.on(elA, 'click', function() {
return action.firstElementChild.click();
});
}
return $.add(el, elA);
},
readyInit: function() { readyInit: function() {
var exLink; var exLink;
Style.padding(); Style.padding();
@ -13326,7 +13327,7 @@
var navHeight, pageHeight, _ref; var navHeight, pageHeight, _ref;
navHeight = Header.bar.offsetHeight; navHeight = Header.bar.offsetHeight;
pageHeight = (_ref = $('.pagelist', d.body)) != null ? _ref.offsetHeight : void 0; pageHeight = (_ref = $('.pagelist', d.body)) != null ? _ref.offsetHeight : void 0;
return Style.paddingSheet.textContent = ("body { padding-bottom: 15px; padding-top: 15px; } .fourchan-ss-navigation.fixed.top-header:not(.autohide) body::before { top: " + navHeight + "px; } .fourchan-ss-navigation.fixed.bottom-header:not(.autohide) body::before { bottom: " + navHeight + "px; } .top-header:not(.autohide) body { padding-top: " + (navHeight + 1) + "px; } .bottom-header:not(.autohide) body { padding-bottom: " + (navHeight + 1) + "px; } ") + (pageHeight ? ".fourchan-ss-navigation.index.pagination-sticky-top body::before, .fourchan-ss-navigation.index.pagination-top body::before { top: " + pageHeight + "px; } .fourchan-ss-navigation.index.pagination-sticky-bottom body::before, .fourchan-ss-navigation.index.pagination-bottom body::before { bottom: " + pageHeight + "px; } .index.pagination-sticky-top body, .index.pagination-top body { padding-top: " + (pageHeight + 1) + "px; } .index.pagination-sticky-bottom body, .index.pagination-bottom body { padding-bottom: " + (pageHeight + 1) + "px; }" : ''); return Style.sheets.padding.textContent = ("body { padding-bottom: 15px; padding-top: 15px; } .fourchan-ss-navigation.fixed.top-header:not(.autohide) body::before { top: " + navHeight + "px; } .fourchan-ss-navigation.fixed.bottom-header:not(.autohide) body::before { bottom: " + navHeight + "px; } .top-header:not(.autohide) body { padding-top: " + (navHeight + 1) + "px; } .bottom-header:not(.autohide) body { padding-bottom: " + (navHeight + 1) + "px; } ") + (pageHeight ? ".fourchan-ss-navigation.index.pagination-sticky-top body::before, .fourchan-ss-navigation.index.pagination-top body::before { top: " + pageHeight + "px; } .fourchan-ss-navigation.index.pagination-sticky-bottom body::before, .fourchan-ss-navigation.index.pagination-bottom body::before { bottom: " + pageHeight + "px; } .index.pagination-sticky-top body, .index.pagination-top body { padding-top: " + (pageHeight + 1) + "px; } .index.pagination-sticky-bottom body, .index.pagination-bottom body { padding-bottom: " + (pageHeight + 1) + "px; }" : '');
}, },
color: function(hex) { color: function(hex) {
this.hex = "#" + hex; this.hex = "#" + hex;
@ -13462,7 +13463,7 @@
}); });
$.on($('textarea', div), 'blur', function() { $.on($('textarea', div), 'blur', function() {
editTheme["Custom CSS"] = this.value; editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}); });
$.add(themeContent, div); $.add(themeContent, div);
$.on($('#save > a', ThemeTools.dialog), 'click', function() { $.on($('#save > a', ThemeTools.dialog), 'click', function() {
@ -13470,7 +13471,7 @@
}); });
$.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close);
$.add(d.body, ThemeTools.dialog); $.add(d.body, ThemeTools.dialog);
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}, },
apply: function() { apply: function() {
var depth, i, len, toggle1, toggle2; var depth, i, len, toggle1, toggle2;
@ -13504,7 +13505,7 @@
this.nextSibling.color.importColor(); this.nextSibling.color.importColor();
} }
editTheme[this.name] = this.value; editTheme[this.name] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}, },
uploadImage: function(evt, el) { uploadImage: function(evt, el) {
var file, reader; var file, reader;
@ -13515,7 +13516,7 @@
val = "url(\"" + evt.target.result + "\")"; val = "url(\"" + evt.target.result + "\")";
el.previousSibling.value = val; el.previousSibling.value = val;
editTheme["Background Image"] = val; editTheme["Background Image"] = val;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.sheets.theme.textContent = Style.theme(editTheme);
}; };
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
@ -13660,7 +13661,7 @@
}, },
close: function() { close: function() {
Conf['editMode'] = false; Conf['editMode'] = false;
Style.themeCSS.textContent = Style.theme(Themes[Conf['theme']]); Style.sheets.theme.textContent = Style.theme(Themes[Conf['theme']]);
$.rm($.id('themeConf')); $.rm($.id('themeConf'));
return Settings.open('Themes'); return Settings.open('Themes');
} }
@ -16135,7 +16136,7 @@
}, },
value: function() { value: function() {
$.cb.value.call(this); $.cb.value.call(this);
return Style.dynamicCSS.textContent = Style.dynamic(); return Style.sheets.dynamicCSS.textContent = Style.dynamic();
}, },
select: function() { select: function() {
var hyphenated, option, _i, _len, _ref; var hyphenated, option, _i, _len, _ref;
@ -16258,7 +16259,7 @@
} }
Conf['theme'] = this.id; Conf['theme'] = this.id;
$.addClass(this, 'selectedtheme'); $.addClass(this, 'selectedtheme');
return Style.themeCSS.textContent = Style.theme(Themes[this.id]); return Style.sheets.theme.textContent = Style.theme(Themes[this.id]);
}, },
edit: function(e) { edit: function(e) {
e.preventDefault(); e.preventDefault();

View File

@ -783,7 +783,7 @@ Settings =
value: -> value: ->
$.cb.value.call @ $.cb.value.call @
Style.dynamicCSS.textContent = Style.dynamic() Style.sheets.dynamicCSS.textContent = Style.dynamic()
select: -> select: ->
$.cb.value.call @ $.cb.value.call @
@ -888,7 +888,7 @@ Settings =
$.set "theme", @id $.set "theme", @id
Conf['theme'] = @id Conf['theme'] = @id
$.addClass @, 'selectedtheme' $.addClass @, 'selectedtheme'
Style.themeCSS.textContent = Style.theme Themes[@id] Style.sheets.theme.textContent = Style.theme Themes[@id]
edit: (e) -> edit: (e) ->
e.preventDefault() e.preventDefault()

View File

@ -59,7 +59,7 @@ JSColor =
valueElement.previousSibling.value = value valueElement.previousSibling.value = value
editTheme[valueElement.previousSibling.name] = value editTheme[valueElement.previousSibling.name] = value
setTimeout -> Style.themeCSS.textContent = Style.theme editTheme setTimeout -> Style.sheets.theme.textContent = Style.theme editTheme
if not (flags & leaveStyle) and styleElement if not (flags & leaveStyle) and styleElement
styleElement.style.backgroundColor = '#' + @toString() styleElement.style.backgroundColor = '#' + @toString()

View File

@ -41,7 +41,7 @@ MascotTools =
$.replace img, el $.replace img, el
Style.mascot.textContent = """<%= grunt.file.read('src/General/css/mascot.css') %>""" Style.sheets.mascots.textContent = """<%= grunt.file.read('src/General/css/mascot.css') %>"""
error: -> error: ->
@src = MascotTools.imageError if MascotTools.imageError @src = MascotTools.imageError if MascotTools.imageError

View File

@ -1,6 +1,6 @@
Style = Style =
sheets: {}
init: -> init: ->
theme = Themes[Conf['theme']] or Themes['Yotsuba B']
Style.svgs = { Style.svgs = {
<% if (type === 'crx') { %> <% if (type === 'crx') { %>
el: $.el 'div', el: $.el 'div',
@ -8,18 +8,19 @@ Style =
<% } %> <% } %>
} }
theme = Themes[Conf['theme']] or Themes['Yotsuba B']
items = [ items = [
['layoutCSS', Style.layout, 'layout'] ['layout', Style.layout]
['themeCSS', Style.theme(theme), 'theme'] ['theme', Style.theme theme]
['emojiCSS', Emoji.css(), 'emoji'] ['emoji', Emoji.css()]
['dynamicCSS', Style.dynamic(), 'dynamic'] ['dynamic', Style.dynamic()]
['paddingSheet', "", 'padding'] ['padding', ""]
['mascot', "", 'mascotSheet'] ['mascots', ""]
] ]
i = 0 i = 0
while item = items[i++] while item = items[i++]
Style[item[0]] = $.addStyle item[1], item[2] Style.sheets[item[0]] = $.addStyle item[1], item[0]
# Non-customizable # Non-customizable
$.addStyle JSColor.css(), 'jsColor' $.addStyle JSColor.css(), 'jsColor'
@ -29,7 +30,7 @@ Style =
$.asap (-> d.body), @asapInit $.asap (-> d.body), @asapInit
$.on window, "resize", Style.padding $.on window, "resize", Style.padding
$.ready @readyInit $.ready @readyInit
asapInit: -> asapInit: ->
<% if (type === 'crx') { %> <% if (type === 'crx') { %>
$.addClass doc, 'blink' $.addClass doc, 'blink'
@ -51,21 +52,21 @@ Style =
$.addClass doc, hyphenated $.addClass doc, hyphenated
if g.VIEW is 'index' if g.VIEW is 'index'
pages = (name, text) ->
el = $ ".pagelist > .#{name}"
elA = $.el 'a',
textContent: text
if (action = el.firstElementChild).nodeName is 'FORM'
elA.href = 'javascript:;'
$.on elA, 'click', ->
action.firstElementChild.click()
$.add el, elA
$.asap (-> $ '.mPagelist'), -> $.asap (-> $ '.mPagelist'), ->
Style.pages 'prev', '<' pages 'prev', '<'
Style.pages 'next', '>' pages 'next', '>'
pages: (name, text) ->
el = $ ".pagelist > .#{name}"
elA = $.el 'a',
textContent: text
if (action = el.firstElementChild).nodeName is 'FORM'
elA.href = 'javascript:;'
$.on elA, 'click', ->
action.firstElementChild.click()
$.add el, elA
readyInit: -> readyInit: ->
Style.padding() Style.padding()
@ -201,7 +202,7 @@ Style =
padding: -> padding: ->
navHeight = Header.bar.offsetHeight navHeight = Header.bar.offsetHeight
pageHeight = ($ '.pagelist', d.body)?.offsetHeight pageHeight = ($ '.pagelist', d.body)?.offsetHeight
Style.paddingSheet.textContent = """<%= grunt.file.read('src/General/css/padding.nav.css').replace(/\s+/g, ' ').trim() %> """ + Style.sheets.padding.textContent = """<%= grunt.file.read('src/General/css/padding.nav.css').replace(/\s+/g, ' ').trim() %> """ +
if pageHeight if pageHeight
"""<%= grunt.file.read('src/General/css/padding.pages.css').replace(/\s+/g, ' ').trim() %>""" """<%= grunt.file.read('src/General/css/padding.pages.css').replace(/\s+/g, ' ').trim() %>"""
else '' else ''

View File

@ -159,7 +159,7 @@ ThemeTools =
$.on $('textarea', div), 'blur', -> $.on $('textarea', div), 'blur', ->
editTheme["Custom CSS"] = @value editTheme["Custom CSS"] = @value
Style.themeCSS.textContent = Style.theme editTheme Style.sheets.theme.textContent = Style.theme editTheme
$.add themeContent, div $.add themeContent, div
@ -169,7 +169,7 @@ ThemeTools =
$.on $('#close > a', ThemeTools.dialog), 'click', ThemeTools.close $.on $('#close > a', ThemeTools.dialog), 'click', ThemeTools.close
$.add d.body, ThemeTools.dialog $.add d.body, ThemeTools.dialog
Style.themeCSS.textContent = Style.theme editTheme Style.sheets.theme.textContent = Style.theme editTheme
apply: -> apply: ->
depth = 0 depth = 0
@ -194,7 +194,7 @@ ThemeTools =
@nextSibling.color.importColor() @nextSibling.color.importColor()
editTheme[@name] = @value editTheme[@name] = @value
Style.themeCSS.textContent = Style.theme editTheme Style.sheets.theme.textContent = Style.theme editTheme
uploadImage: (evt, el) -> uploadImage: (evt, el) ->
file = evt.target.files[0] file = evt.target.files[0]
@ -205,7 +205,7 @@ ThemeTools =
el.previousSibling.value = val el.previousSibling.value = val
editTheme["Background Image"] = val editTheme["Background Image"] = val
Style.themeCSS.textContent = Style.theme editTheme Style.sheets.theme.textContent = Style.theme editTheme
reader.readAsDataURL file reader.readAsDataURL file
@ -347,6 +347,6 @@ ThemeTools =
close: -> close: ->
Conf['editMode'] = false Conf['editMode'] = false
Style.themeCSS.textContent = Style.theme Themes[Conf['theme']] Style.sheets.theme.textContent = Style.theme Themes[Conf['theme']]
$.rm $.id 'themeConf' $.rm $.id 'themeConf'
Settings.open 'Themes' Settings.open 'Themes'