Redundancy reduction

This commit is contained in:
Zixaphir 2013-08-06 16:51:19 -07:00
parent 7a093b26ee
commit ee0f931cc8
3 changed files with 11 additions and 18 deletions

View File

@ -11085,7 +11085,7 @@
innerHTML: "<img>" innerHTML: "<img>"
}), }),
change: function(mascot) { change: function(mascot) {
var el, image; var el;
el = this.el.firstElementChild; el = this.el.firstElementChild;
if (!Conf['Mascots']) { if (!Conf['Mascots']) {
@ -11107,8 +11107,7 @@
} else if (!Conf['Silhouettize Mascots']) { } else if (!Conf['Silhouettize Mascots']) {
$.rmClass(doc, 'silhouettize-mascots'); $.rmClass(doc, 'silhouettize-mascots');
} }
image = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image; el.src = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image;
el.src = image;
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.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}";
}, },
toggle: function() { toggle: function() {
@ -11249,7 +11248,7 @@
return $.add(d.body, dialog); return $.add(d.body, dialog);
}, },
input: function(item, name) { input: function(item, name) {
var div, value; var value;
if (Array.isArray(editMascot[name])) { if (Array.isArray(editMascot[name])) {
if (Style.lightTheme) { if (Style.lightTheme) {
@ -11261,11 +11260,10 @@
value = editMascot[name]; value = editMascot[name];
} }
editMascot[name] = value; editMascot[name] = value;
div = $.el("div", { return $.el("div", {
className: "mascotvar", className: "mascotvar",
innerHTML: "<div class=optionlabel>" + item[0] + "</div><div class=option><input type=" + item[2] + " class=field name='" + name + "' placeholder='" + item[0] + "' value='" + value + "'></div>" innerHTML: "<div class=optionlabel>" + item[0] + "</div><div class=option><input type=" + item[2] + " class=field name='" + name + "' placeholder='" + item[0] + "' value='" + value + "'></div>"
}); });
return div;
}, },
uploadImage: function(evt, el) { uploadImage: function(evt, el) {
var file, reader; var file, reader;

View File

@ -11072,7 +11072,7 @@
innerHTML: "<img>" innerHTML: "<img>"
}), }),
change: function(mascot) { change: function(mascot) {
var el, image; var el;
el = this.el.firstElementChild; el = this.el.firstElementChild;
if (!Conf['Mascots']) { if (!Conf['Mascots']) {
@ -11094,8 +11094,7 @@
} else if (!Conf['Silhouettize Mascots']) { } else if (!Conf['Silhouettize Mascots']) {
$.rmClass(doc, 'silhouettize-mascots'); $.rmClass(doc, 'silhouettize-mascots');
} }
image = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image; el.src = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image;
el.src = image;
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.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}";
}, },
toggle: function() { toggle: function() {
@ -11236,7 +11235,7 @@
return $.add(d.body, dialog); return $.add(d.body, dialog);
}, },
input: function(item, name) { input: function(item, name) {
var div, value; var value;
if (Array.isArray(editMascot[name])) { if (Array.isArray(editMascot[name])) {
if (Style.lightTheme) { if (Style.lightTheme) {
@ -11248,11 +11247,10 @@
value = editMascot[name]; value = editMascot[name];
} }
editMascot[name] = value; editMascot[name] = value;
div = $.el("div", { return $.el("div", {
className: "mascotvar", className: "mascotvar",
innerHTML: "<div class=optionlabel>" + item[0] + "</div><div class=option><input type=" + item[2] + " class=field name='" + name + "' placeholder='" + item[0] + "' value='" + value + "'></div>" innerHTML: "<div class=optionlabel>" + item[0] + "</div><div class=option><input type=" + item[2] + " class=field name='" + name + "' placeholder='" + item[0] + "' value='" + value + "'></div>"
}); });
return div;
}, },
uploadImage: function(evt, el) { uploadImage: function(evt, el) {
var file, reader; var file, reader;

View File

@ -34,10 +34,11 @@ MascotTools =
if mascot.silhouette and not Conf['Silhouettize Mascots'] if mascot.silhouette and not Conf['Silhouettize Mascots']
$.addClass doc, 'silhouettize-mascots' $.addClass doc, 'silhouettize-mascots'
else unless Conf['Silhouettize Mascots'] else unless Conf['Silhouettize Mascots']
$.rmClass doc, 'silhouettize-mascots' $.rmClass doc, 'silhouettize-mascots'
image = el.src =
if Array.isArray mascot.image if Array.isArray mascot.image
if Style.lightTheme if Style.lightTheme
mascot.image[1] mascot.image[1]
@ -46,8 +47,6 @@ MascotTools =
else else
mascot.image mascot.image
el.src = image
Style.mascot.textContent = """<%= grunt.file.read('src/General/css/mascot.css') %>""" Style.mascot.textContent = """<%= grunt.file.read('src/General/css/mascot.css') %>"""
toggle: -> toggle: ->
@ -231,12 +230,10 @@ MascotTools =
editMascot[name] = value editMascot[name] = value
div = $.el "div", $.el "div",
className: "mascotvar" className: "mascotvar"
innerHTML: "<div class=optionlabel>#{item[0]}</div><div class=option><input type=#{item[2]} class=field name='#{name}' placeholder='#{item[0]}' value='#{value}'></div>" innerHTML: "<div class=optionlabel>#{item[0]}</div><div class=option><input type=#{item[2]} class=field name='#{name}' placeholder='#{item[0]}' value='#{value}'></div>"
return div
uploadImage: (evt, el) -> uploadImage: (evt, el) ->
file = evt.target.files[0] file = evt.target.files[0]
reader = new FileReader() reader = new FileReader()