Rethink some mascot options.

This commit is contained in:
Zixaphir 2013-05-31 19:09:24 -07:00
parent 271aeb9bf7
commit 8144b38023
6 changed files with 151 additions and 148 deletions

View File

@ -10918,12 +10918,20 @@
MascotTools = { MascotTools = {
init: function(mascot) { init: function(mascot) {
var el, location; var el, name;
if (!(mascot && (mascot.image != null))) { if (!(mascot && (mascot.image != null))) {
mascot = Mascots[Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)]]; if (!Conf[g.MASCOTSTRING].length) {
return;
}
name = Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)];
mascot = Mascots[name];
Conf['mascot'] = name;
} }
this.el = el = $('#mascot img', d.body); if (!this.el) {
this.el = $('#mascot img', d.body);
}
el = this.el;
if (!Conf['Mascots'] || (Conf['Hide Mascots on Catalog'] && g.VIEW === 'catalog')) { if (!Conf['Mascots'] || (Conf['Hide Mascots on Catalog'] && g.VIEW === 'catalog')) {
if (el) { if (el) {
return el.src = ""; return el.src = "";
@ -10939,29 +10947,18 @@
$.rmClass(doc, 'mascot-position-bottom'); $.rmClass(doc, 'mascot-position-bottom');
} }
if (!mascot) { if (!mascot) {
if (!(mascot = Mascots[Conf["mascot"]])) { if (name && !(mascot = Mascots[name])) {
if (el) { if (el) {
el.src = ""; el.src = "";
} else { } else {
null; null;
} }
Conf[g.MASCOTSTRING].remove(Conf["mascot"]); Conf[g.MASCOTSTRING].remove(name);
return MascotTools.init(); return MascotTools.init();
} }
} }
MascotTools.addMascot(mascot); MascotTools.addMascot(mascot);
if (Conf["Sidebar Location"] === 'left') { return Style.mascot.textContent = "#mascot {\n display: none;\n}\n.mascots #mascot {\n display: block;\n}\n.sidebar-location-left #mascot img {\n -moz-box-sizingtransform: scaleX(-1);\n}\n.sidebar-location-right.mascot-location-sidebar #mascot img,\n.sidebar-location-left #mascot img {\n right: 0;\n left: auto;\n margin-right: " + mascot.hOffset + "px;\n}\n.sidebar-location-right.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-left.sidebar-large #mascot img {\n right: " + (mascot.center ? 25 : 0) + "px;\n}\n.sidebar-location-left.mascot-location-sidebar #mascot img,\n.sidebar-location-right #mascot img {\n left: 0;\n right: auto;\n margin-left: " + mascot.hOffset + "px;\n}\n.sidebar-location-left.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-right.sidebar-large #mascot img {\n left: " + (mascot.center ? 25 : 0) + "px;\n}\n#mascot img {\n position: fixed;\n z-index: -1;\n bottom: 20.1em;\n height: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\n width: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n margin-bottom: " + (mascot.vOffset || 0) + "px;\n cursor: pointer;\n}\n.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,\n.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.bottom.fixed:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img {\n bottom: 1.5em;\n}\n.fourchan-ss-navigation.bottom.fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom #mascot img {\n bottom: 21.6em;\n}\n.fourchan-ss-navigation.bottom.fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.post-form-decorations #mascot img {\n bottom: 21.8em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade #mascot img {\n bottom: 22.9em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img {\n bottom: 23.1em;\n}\n.mascot-position-bottom #mascot img,\n.mascot-position-default.posting-disabled #mascot img {\n bottom: 0;\n}\n.mascots-overlap-posts #mascot img {\n z-index: 3;\n}\n.mascot-position-middle #mascot img {\n bottom: 50%;\n -moz-box-sizingtransform: translateY(50%);\n}\n.mascot-position-top #mascot img {\n bottom: auto !important;\n top: 17px;\n}\n.grayscale-mascots #mascot img {\n filter: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filters\"><feColorMatrix id=\"color\" type=\"saturate\" values=\"0\" /></filter></svg>#filters');\n}";
if (Conf["Mascot Location"] === "sidebar") {
location = 'left';
} else {
location = 'right';
}
} else if (Conf["Mascot Location"] === "sidebar") {
location = 'right';
} else {
location = 'left';
}
return Style.mascot.textContent = "#mascot {\n display: none;\n}\n.mascots #mascot {\n display: block;\n}\n.sidebar-location-left #mascot img {\n -moz-box-sizingtransform: scaleX(-1);\n}\n.sidebar-location-right.mascot-location-sidebar #mascot img,\n.sidebar-location-left #mascot img {\n right: 0;\n left: auto;\n margin-right: " + mascot.hOffset + "px;\n}\n.sidebar-location-right.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-left.sidebar-large #mascot img {\n right: " + (mascot.center ? 25 : 0) + "px;\n}\n.sidebar-location-left.mascot-location-sidebar #mascot img,\n.sidebar-location-right #mascot img {\n left: 0;\n right: auto;\n margin-left: " + mascot.hOffset + "px;\n}\n.sidebar-location-left.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-right.sidebar-large #mascot img {\n left: " + (mascot.center ? 25 : 0) + "px;\n}\n#mascot img {\n position: fixed;\n z-index: -1;\n bottom: 20.1em;\n height: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\n width: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n margin-bottom: " + (mascot.vOffset || 0) + "px;\n pointer-events: none;\n}\n.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,\n.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.bottom.fixed:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img {\n bottom: 1.5em;\n}\n.fourchan-ss-navigation.bottom.fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom #mascot img {\n bottom: 21.6em;\n}\n.fourchan-ss-navigation.bottom.fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.post-form-decorations #mascot img {\n bottom: 21.8em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade #mascot img {\n bottom: 22.9em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img {\n bottom: 23.1em;\n}\n.mascot-position-bottom #mascot img,\n.mascot-position-default.posting-disabled #mascot img {\n bottom: 0;\n}\n.mascots-overlap-posts #mascot img {\n z-index: 3;\n}\n.mascot-position-middle #mascot img {\n bottom: 50%;\n -moz-box-sizingtransform: translateY(50%);\n}\n.mascot-position-top #mascot img {\n bottom: auto !important;\n top: 17px;\n}\n.grayscale-mascots #mascot img {\n filter: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filters\"><feColorMatrix id=\"color\" type=\"saturate\" values=\"0\" /></filter></svg>#filters');\n}";
}, },
categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'], categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'],
dialog: function(key) { dialog: function(key) {
@ -10975,7 +10972,7 @@
} }
editMascot.name = key || ''; editMascot.name = key || '';
MascotTools.addMascot(editMascot); MascotTools.addMascot(editMascot);
MascotTools.init(_conf["mascot"]); MascotTools.init(editMascot);
layout = { layout = {
name: ["Mascot Name", "", "text"], name: ["Mascot Name", "", "text"],
image: ["Image", "", "text"], image: ["Image", "", "text"],
@ -11003,7 +11000,7 @@
$.on(input, 'blur', function() { $.on(input, 'blur', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); MascotTools.addMascot(editMascot);
return MascotTools.init(_conf["mascot"]); return MascotTools.init(editMascot);
}); });
fileInput = $.el('input', { fileInput = $.el('input', {
type: "file", type: "file",
@ -11028,14 +11025,12 @@
return alert("Mascot names must start with a letter."); return alert("Mascot names must start with a letter.");
} }
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} else { } else {
$.on(input, 'blur', function() { $.on(input, 'blur', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} }
break; break;
@ -11043,8 +11038,7 @@
div = this.input(item, name); div = this.input(item, name);
$.on($('input', div), 'blur', function() { $.on($('input', div), 'blur', function() {
editMascot[this.name] = parseInt(this.value); editMascot[this.name] = parseInt(this.value);
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
break; break;
case "select": case "select":
@ -11064,8 +11058,7 @@
setting.value = value; setting.value = value;
$.on($('select', div), 'change', function() { $.on($('select', div), 'change', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
break; break;
case "checkbox": case "checkbox":
@ -11076,8 +11069,7 @@
}); });
$.on($('input', div), 'click', function() { $.on($('input', div), 'click', function() {
editMascot[this.name] = this.checked ? true : false; editMascot[this.name] = this.checked ? true : false;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} }
nodes.push(div); nodes.push(div);
@ -11125,16 +11117,19 @@
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
addMascot: function(mascot) { addMascot: function(mascot) {
var el; var div, el, image;
image = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image;
if (el = this.el) { if (el = this.el) {
return el.src = Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image; return el.src = image;
} else { } else {
this.el = el = $.el('div', { div = $.el('div', {
id: "mascot", id: "mascot",
innerHTML: "<img src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'>" innerHTML: "<img src='" + image + "'>"
}); });
return $.add(d.body, el); this.el = div.firstElementChild;
$.on(this.el, 'mousedown', MascotTools.click);
return $.add(d.body, div);
} }
}, },
save: function(mascot) { save: function(mascot) {
@ -11184,6 +11179,10 @@
return alert("Mascot \"" + name + "\" saved."); return alert("Mascot \"" + name + "\" saved.");
}); });
}, },
click: function(e) {
e.preventDefault();
return MascotTools.init();
},
close: function() { close: function() {
Conf['editMode'] = false; Conf['editMode'] = false;
editMascot = {}; editMascot = {};
@ -11448,10 +11447,10 @@
$.extend(Style, { $.extend(Style, {
layoutCSS: $.addStyle(Style.layout, 'layout'), layoutCSS: $.addStyle(Style.layout, 'layout'),
themeCSS: $.addStyle(Style.theme(theme), 'theme'), themeCSS: $.addStyle(Style.theme(theme), 'theme'),
dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic'),
icons: $.addStyle("", 'icons'), icons: $.addStyle("", 'icons'),
paddingSheet: $.addStyle("", 'padding'), paddingSheet: $.addStyle("", 'padding'),
mascot: $.addStyle("", 'mascotSheet'), mascot: $.addStyle("", 'mascotSheet')
dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic')
}); });
$.addStyle(JSColor.css(), 'jsColor'); $.addStyle(JSColor.css(), 'jsColor');
if (d.head) { if (d.head) {
@ -11502,7 +11501,6 @@
if (!theme) { if (!theme) {
theme = Themes[_conf['theme']] || Themes['Yotsuba B']; theme = Themes[_conf['theme']] || Themes['Yotsuba B'];
} }
MascotTools.init(_conf["mascot"]);
Style.dynamicCSS.textContent = Style.dynamic(); Style.dynamicCSS.textContent = Style.dynamic();
Style.iconPositions(); Style.iconPositions();
return Style.padding(); return Style.padding();
@ -14441,8 +14439,9 @@
MascotTools.init(); MascotTools.init();
} }
} else { } else {
Conf['mascot'] = this.id;
Conf[g.MASCOTSTRING].push(this.id); Conf[g.MASCOTSTRING].push(this.id);
MascotTools.init(this.id); MascotTools.init(Mascots[this.id]);
} }
$.toggleClass(this, 'enabled'); $.toggleClass(this, 'enabled');
return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING]); return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING]);

View File

@ -10912,12 +10912,20 @@
MascotTools = { MascotTools = {
init: function(mascot) { init: function(mascot) {
var el, location; var el, name;
if (!(mascot && (mascot.image != null))) { if (!(mascot && (mascot.image != null))) {
mascot = Mascots[Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)]]; if (!Conf[g.MASCOTSTRING].length) {
return;
}
name = Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)];
mascot = Mascots[name];
Conf['mascot'] = name;
} }
this.el = el = $('#mascot img', d.body); if (!this.el) {
this.el = $('#mascot img', d.body);
}
el = this.el;
if (!Conf['Mascots'] || (Conf['Hide Mascots on Catalog'] && g.VIEW === 'catalog')) { if (!Conf['Mascots'] || (Conf['Hide Mascots on Catalog'] && g.VIEW === 'catalog')) {
if (el) { if (el) {
return el.src = ""; return el.src = "";
@ -10933,29 +10941,18 @@
$.rmClass(doc, 'mascot-position-bottom'); $.rmClass(doc, 'mascot-position-bottom');
} }
if (!mascot) { if (!mascot) {
if (!(mascot = Mascots[Conf["mascot"]])) { if (name && !(mascot = Mascots[name])) {
if (el) { if (el) {
el.src = ""; el.src = "";
} else { } else {
null; null;
} }
Conf[g.MASCOTSTRING].remove(Conf["mascot"]); Conf[g.MASCOTSTRING].remove(name);
return MascotTools.init(); return MascotTools.init();
} }
} }
MascotTools.addMascot(mascot); MascotTools.addMascot(mascot);
if (Conf["Sidebar Location"] === 'left') { return Style.mascot.textContent = "#mascot {\n display: none;\n}\n.mascots #mascot {\n display: block;\n}\n.sidebar-location-left #mascot img {\n -moz-box-sizingtransform: scaleX(-1);\n}\n.sidebar-location-right.mascot-location-sidebar #mascot img,\n.sidebar-location-left #mascot img {\n right: 0;\n left: auto;\n margin-right: " + mascot.hOffset + "px;\n}\n.sidebar-location-right.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-left.sidebar-large #mascot img {\n right: " + (mascot.center ? 25 : 0) + "px;\n}\n.sidebar-location-left.mascot-location-sidebar #mascot img,\n.sidebar-location-right #mascot img {\n left: 0;\n right: auto;\n margin-left: " + mascot.hOffset + "px;\n}\n.sidebar-location-left.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-right.sidebar-large #mascot img {\n left: " + (mascot.center ? 25 : 0) + "px;\n}\n#mascot img {\n position: fixed;\n z-index: -1;\n bottom: 20.1em;\n height: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\n width: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n margin-bottom: " + (mascot.vOffset || 0) + "px;\n cursor: pointer;\n}\n.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,\n.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.bottom.fixed:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img {\n bottom: 1.5em;\n}\n.fourchan-ss-navigation.bottom.fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom #mascot img {\n bottom: 21.6em;\n}\n.fourchan-ss-navigation.bottom.fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.post-form-decorations #mascot img {\n bottom: 21.8em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade #mascot img {\n bottom: 22.9em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img {\n bottom: 23.1em;\n}\n.mascot-position-bottom #mascot img,\n.mascot-position-default.posting-disabled #mascot img {\n bottom: 0;\n}\n.mascots-overlap-posts #mascot img {\n z-index: 3;\n}\n.mascot-position-middle #mascot img {\n bottom: 50%;\n -moz-box-sizingtransform: translateY(50%);\n}\n.mascot-position-top #mascot img {\n bottom: auto !important;\n top: 17px;\n}\n.grayscale-mascots #mascot img {\n filter: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filters\"><feColorMatrix id=\"color\" type=\"saturate\" values=\"0\" /></filter></svg>#filters');\n}";
if (Conf["Mascot Location"] === "sidebar") {
location = 'left';
} else {
location = 'right';
}
} else if (Conf["Mascot Location"] === "sidebar") {
location = 'right';
} else {
location = 'left';
}
return Style.mascot.textContent = "#mascot {\n display: none;\n}\n.mascots #mascot {\n display: block;\n}\n.sidebar-location-left #mascot img {\n -moz-box-sizingtransform: scaleX(-1);\n}\n.sidebar-location-right.mascot-location-sidebar #mascot img,\n.sidebar-location-left #mascot img {\n right: 0;\n left: auto;\n margin-right: " + mascot.hOffset + "px;\n}\n.sidebar-location-right.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-left.sidebar-large #mascot img {\n right: " + (mascot.center ? 25 : 0) + "px;\n}\n.sidebar-location-left.mascot-location-sidebar #mascot img,\n.sidebar-location-right #mascot img {\n left: 0;\n right: auto;\n margin-left: " + mascot.hOffset + "px;\n}\n.sidebar-location-left.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-right.sidebar-large #mascot img {\n left: " + (mascot.center ? 25 : 0) + "px;\n}\n#mascot img {\n position: fixed;\n z-index: -1;\n bottom: 20.1em;\n height: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\n width: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n margin-bottom: " + (mascot.vOffset || 0) + "px;\n pointer-events: none;\n}\n.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,\n.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.bottom.fixed:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img {\n bottom: 1.5em;\n}\n.fourchan-ss-navigation.bottom.fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom #mascot img {\n bottom: 21.6em;\n}\n.fourchan-ss-navigation.bottom.fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.post-form-decorations #mascot img {\n bottom: 21.8em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade #mascot img {\n bottom: 22.9em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img {\n bottom: 23.1em;\n}\n.mascot-position-bottom #mascot img,\n.mascot-position-default.posting-disabled #mascot img {\n bottom: 0;\n}\n.mascots-overlap-posts #mascot img {\n z-index: 3;\n}\n.mascot-position-middle #mascot img {\n bottom: 50%;\n -moz-box-sizingtransform: translateY(50%);\n}\n.mascot-position-top #mascot img {\n bottom: auto !important;\n top: 17px;\n}\n.grayscale-mascots #mascot img {\n filter: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filters\"><feColorMatrix id=\"color\" type=\"saturate\" values=\"0\" /></filter></svg>#filters');\n}";
}, },
categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'], categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'],
dialog: function(key) { dialog: function(key) {
@ -10969,7 +10966,7 @@
} }
editMascot.name = key || ''; editMascot.name = key || '';
MascotTools.addMascot(editMascot); MascotTools.addMascot(editMascot);
MascotTools.init(_conf["mascot"]); MascotTools.init(editMascot);
layout = { layout = {
name: ["Mascot Name", "", "text"], name: ["Mascot Name", "", "text"],
image: ["Image", "", "text"], image: ["Image", "", "text"],
@ -10997,7 +10994,7 @@
$.on(input, 'blur', function() { $.on(input, 'blur', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); MascotTools.addMascot(editMascot);
return MascotTools.init(_conf["mascot"]); return MascotTools.init(editMascot);
}); });
fileInput = $.el('input', { fileInput = $.el('input', {
type: "file", type: "file",
@ -11022,14 +11019,12 @@
return alert("Mascot names must start with a letter."); return alert("Mascot names must start with a letter.");
} }
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} else { } else {
$.on(input, 'blur', function() { $.on(input, 'blur', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} }
break; break;
@ -11037,8 +11032,7 @@
div = this.input(item, name); div = this.input(item, name);
$.on($('input', div), 'blur', function() { $.on($('input', div), 'blur', function() {
editMascot[this.name] = parseInt(this.value); editMascot[this.name] = parseInt(this.value);
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
break; break;
case "select": case "select":
@ -11058,8 +11052,7 @@
setting.value = value; setting.value = value;
$.on($('select', div), 'change', function() { $.on($('select', div), 'change', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
break; break;
case "checkbox": case "checkbox":
@ -11070,8 +11063,7 @@
}); });
$.on($('input', div), 'click', function() { $.on($('input', div), 'click', function() {
editMascot[this.name] = this.checked ? true : false; editMascot[this.name] = this.checked ? true : false;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} }
nodes.push(div); nodes.push(div);
@ -11119,16 +11111,19 @@
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
addMascot: function(mascot) { addMascot: function(mascot) {
var el; var div, el, image;
image = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image;
if (el = this.el) { if (el = this.el) {
return el.src = Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image; return el.src = image;
} else { } else {
this.el = el = $.el('div', { div = $.el('div', {
id: "mascot", id: "mascot",
innerHTML: "<img src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'>" innerHTML: "<img src='" + image + "'>"
}); });
return $.add(d.body, el); this.el = div.firstElementChild;
$.on(this.el, 'mousedown', MascotTools.click);
return $.add(d.body, div);
} }
}, },
save: function(mascot) { save: function(mascot) {
@ -11178,6 +11173,10 @@
return alert("Mascot \"" + name + "\" saved."); return alert("Mascot \"" + name + "\" saved.");
}); });
}, },
click: function(e) {
e.preventDefault();
return MascotTools.init();
},
close: function() { close: function() {
Conf['editMode'] = false; Conf['editMode'] = false;
editMascot = {}; editMascot = {};
@ -11442,10 +11441,10 @@
$.extend(Style, { $.extend(Style, {
layoutCSS: $.addStyle(Style.layout, 'layout'), layoutCSS: $.addStyle(Style.layout, 'layout'),
themeCSS: $.addStyle(Style.theme(theme), 'theme'), themeCSS: $.addStyle(Style.theme(theme), 'theme'),
dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic'),
icons: $.addStyle("", 'icons'), icons: $.addStyle("", 'icons'),
paddingSheet: $.addStyle("", 'padding'), paddingSheet: $.addStyle("", 'padding'),
mascot: $.addStyle("", 'mascotSheet'), mascot: $.addStyle("", 'mascotSheet')
dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic')
}); });
$.addStyle(JSColor.css(), 'jsColor'); $.addStyle(JSColor.css(), 'jsColor');
if (d.head) { if (d.head) {
@ -11496,7 +11495,6 @@
if (!theme) { if (!theme) {
theme = Themes[_conf['theme']] || Themes['Yotsuba B']; theme = Themes[_conf['theme']] || Themes['Yotsuba B'];
} }
MascotTools.init(_conf["mascot"]);
Style.dynamicCSS.textContent = Style.dynamic(); Style.dynamicCSS.textContent = Style.dynamic();
Style.iconPositions(); Style.iconPositions();
return Style.padding(); return Style.padding();
@ -14440,8 +14438,9 @@
MascotTools.init(); MascotTools.init();
} }
} else { } else {
Conf['mascot'] = this.id;
Conf[g.MASCOTSTRING].push(this.id); Conf[g.MASCOTSTRING].push(this.id);
MascotTools.init(this.id); MascotTools.init(Mascots[this.id]);
} }
$.toggleClass(this, 'enabled'); $.toggleClass(this, 'enabled');
return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING]); return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING]);

View File

@ -10895,12 +10895,20 @@
MascotTools = { MascotTools = {
init: function(mascot) { init: function(mascot) {
var el, location; var el, name;
if (!(mascot && (mascot.image != null))) { if (!(mascot && (mascot.image != null))) {
mascot = Mascots[Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)]]; if (!Conf[g.MASCOTSTRING].length) {
return;
}
name = Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)];
mascot = Mascots[name];
Conf['mascot'] = name;
} }
this.el = el = $('#mascot img', d.body); if (!this.el) {
this.el = $('#mascot img', d.body);
}
el = this.el;
if (!Conf['Mascots'] || (Conf['Hide Mascots on Catalog'] && g.VIEW === 'catalog')) { if (!Conf['Mascots'] || (Conf['Hide Mascots on Catalog'] && g.VIEW === 'catalog')) {
if (el) { if (el) {
return el.src = ""; return el.src = "";
@ -10916,29 +10924,18 @@
$.rmClass(doc, 'mascot-position-bottom'); $.rmClass(doc, 'mascot-position-bottom');
} }
if (!mascot) { if (!mascot) {
if (!(mascot = Mascots[Conf["mascot"]])) { if (name && !(mascot = Mascots[name])) {
if (el) { if (el) {
el.src = ""; el.src = "";
} else { } else {
null; null;
} }
Conf[g.MASCOTSTRING].remove(Conf["mascot"]); Conf[g.MASCOTSTRING].remove(name);
return MascotTools.init(); return MascotTools.init();
} }
} }
MascotTools.addMascot(mascot); MascotTools.addMascot(mascot);
if (Conf["Sidebar Location"] === 'left') { return Style.mascot.textContent = "#mascot {\n display: none;\n}\n.mascots #mascot {\n display: block;\n}\n.sidebar-location-left #mascot img {\n box-sizingtransform: scaleX(-1);\n}\n.sidebar-location-right.mascot-location-sidebar #mascot img,\n.sidebar-location-left #mascot img {\n right: 0;\n left: auto;\n margin-right: " + mascot.hOffset + "px;\n}\n.sidebar-location-right.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-left.sidebar-large #mascot img {\n right: " + (mascot.center ? 25 : 0) + "px;\n}\n.sidebar-location-left.mascot-location-sidebar #mascot img,\n.sidebar-location-right #mascot img {\n left: 0;\n right: auto;\n margin-left: " + mascot.hOffset + "px;\n}\n.sidebar-location-left.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-right.sidebar-large #mascot img {\n left: " + (mascot.center ? 25 : 0) + "px;\n}\n#mascot img {\n position: fixed;\n z-index: -1;\n bottom: 20.1em;\n height: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\n width: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n margin-bottom: " + (mascot.vOffset || 0) + "px;\n cursor: pointer;\n}\n.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,\n.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.bottom.fixed:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img {\n bottom: 1.5em;\n}\n.fourchan-ss-navigation.bottom.fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom #mascot img {\n bottom: 21.6em;\n}\n.fourchan-ss-navigation.bottom.fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.post-form-decorations #mascot img {\n bottom: 21.8em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade #mascot img {\n bottom: 22.9em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img {\n bottom: 23.1em;\n}\n.mascot-position-bottom #mascot img,\n.mascot-position-default.posting-disabled #mascot img {\n bottom: 0;\n}\n.mascots-overlap-posts #mascot img {\n z-index: 3;\n}\n.mascot-position-middle #mascot img {\n bottom: 50%;\n box-sizingtransform: translateY(50%);\n}\n.mascot-position-top #mascot img {\n bottom: auto !important;\n top: 17px;\n}\n.grayscale-mascots #mascot img {\n filter: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filters\"><feColorMatrix id=\"color\" type=\"saturate\" values=\"0\" /></filter></svg>#filters');\n}";
if (Conf["Mascot Location"] === "sidebar") {
location = 'left';
} else {
location = 'right';
}
} else if (Conf["Mascot Location"] === "sidebar") {
location = 'right';
} else {
location = 'left';
}
return Style.mascot.textContent = "#mascot {\n display: none;\n}\n.mascots #mascot {\n display: block;\n}\n.sidebar-location-left #mascot img {\n box-sizingtransform: scaleX(-1);\n}\n.sidebar-location-right.mascot-location-sidebar #mascot img,\n.sidebar-location-left #mascot img {\n right: 0;\n left: auto;\n margin-right: " + mascot.hOffset + "px;\n}\n.sidebar-location-right.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-left.sidebar-large #mascot img {\n right: " + (mascot.center ? 25 : 0) + "px;\n}\n.sidebar-location-left.mascot-location-sidebar #mascot img,\n.sidebar-location-right #mascot img {\n left: 0;\n right: auto;\n margin-left: " + mascot.hOffset + "px;\n}\n.sidebar-location-left.sidebar-large.mascot-location-sidebar #mascot img,\n.sidebar-location-right.sidebar-large #mascot img {\n left: " + (mascot.center ? 25 : 0) + "px;\n}\n#mascot img {\n position: fixed;\n z-index: -1;\n bottom: 20.1em;\n height: " + (mascot.height && isNaN(parseFloat(mascot.height)) ? mascot.height : mascot.height ? parseInt(mascot.height, 10) + 'px' : 'auto') + ";\n width: " + (mascot.width && isNaN(parseFloat(mascot.width)) ? mascot.width : mascot.width ? parseInt(mascot.width, 10) + 'px' : 'auto') + ";\n margin-bottom: " + (mascot.vOffset || 0) + "px;\n pointer-events: none;\n}\n.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,\n.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.mascot-position-bottom #mascot img,\n.fourchan-ss-navigation.bottom.fixed:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom:not(.post-form-style-fixed):not(.post-form-style-transparent-fade) #mascot img {\n bottom: 1.5em;\n}\n.fourchan-ss-navigation.bottom.fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom #mascot img {\n bottom: 21.6em;\n}\n.fourchan-ss-navigation.bottom.fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.post-form-decorations #mascot img {\n bottom: 21.8em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade #mascot img {\n bottom: 22.9em;\n}\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-fixed.post-form-decorations #mascot img,\n.fourchan-ss-navigation.bottom.fixed.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img,\n.fourchan-ss-navigation.index.pagination-sticky-bottom.show-post-form-header.post-form-style-transparent-fade.post-form-decorations #mascot img {\n bottom: 23.1em;\n}\n.mascot-position-bottom #mascot img,\n.mascot-position-default.posting-disabled #mascot img {\n bottom: 0;\n}\n.mascots-overlap-posts #mascot img {\n z-index: 3;\n}\n.mascot-position-middle #mascot img {\n bottom: 50%;\n box-sizingtransform: translateY(50%);\n}\n.mascot-position-top #mascot img {\n bottom: auto !important;\n top: 17px;\n}\n.grayscale-mascots #mascot img {\n filter: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filters\"><feColorMatrix id=\"color\" type=\"saturate\" values=\"0\" /></filter></svg>#filters');\n}";
}, },
categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'], categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'],
dialog: function(key) { dialog: function(key) {
@ -10952,7 +10949,7 @@
} }
editMascot.name = key || ''; editMascot.name = key || '';
MascotTools.addMascot(editMascot); MascotTools.addMascot(editMascot);
MascotTools.init(_conf["mascot"]); MascotTools.init(editMascot);
layout = { layout = {
name: ["Mascot Name", "", "text"], name: ["Mascot Name", "", "text"],
image: ["Image", "", "text"], image: ["Image", "", "text"],
@ -10980,7 +10977,7 @@
$.on(input, 'blur', function() { $.on(input, 'blur', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); MascotTools.addMascot(editMascot);
return MascotTools.init(_conf["mascot"]); return MascotTools.init(editMascot);
}); });
fileInput = $.el('input', { fileInput = $.el('input', {
type: "file", type: "file",
@ -11005,14 +11002,12 @@
return alert("Mascot names must start with a letter."); return alert("Mascot names must start with a letter.");
} }
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} else { } else {
$.on(input, 'blur', function() { $.on(input, 'blur', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} }
break; break;
@ -11020,8 +11015,7 @@
div = this.input(item, name); div = this.input(item, name);
$.on($('input', div), 'blur', function() { $.on($('input', div), 'blur', function() {
editMascot[this.name] = parseInt(this.value); editMascot[this.name] = parseInt(this.value);
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
break; break;
case "select": case "select":
@ -11041,8 +11035,7 @@
setting.value = value; setting.value = value;
$.on($('select', div), 'change', function() { $.on($('select', div), 'change', function() {
editMascot[this.name] = this.value; editMascot[this.name] = this.value;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
break; break;
case "checkbox": case "checkbox":
@ -11053,8 +11046,7 @@
}); });
$.on($('input', div), 'click', function() { $.on($('input', div), 'click', function() {
editMascot[this.name] = this.checked ? true : false; editMascot[this.name] = this.checked ? true : false;
MascotTools.addMascot(editMascot); return MascotTools.init(editMascot);
return Style.addStyle();
}); });
} }
nodes.push(div); nodes.push(div);
@ -11102,16 +11094,19 @@
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
addMascot: function(mascot) { addMascot: function(mascot) {
var el; var div, el, image;
image = Array.isArray(mascot.image) ? Style.lightTheme ? mascot.image[1] : mascot.image[0] : mascot.image;
if (el = this.el) { if (el = this.el) {
return el.src = Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image; return el.src = image;
} else { } else {
this.el = el = $.el('div', { div = $.el('div', {
id: "mascot", id: "mascot",
innerHTML: "<img src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'>" innerHTML: "<img src='" + image + "'>"
}); });
return $.add(d.body, el); this.el = div.firstElementChild;
$.on(this.el, 'mousedown', MascotTools.click);
return $.add(d.body, div);
} }
}, },
save: function(mascot) { save: function(mascot) {
@ -11161,6 +11156,10 @@
return alert("Mascot \"" + name + "\" saved."); return alert("Mascot \"" + name + "\" saved.");
}); });
}, },
click: function(e) {
e.preventDefault();
return MascotTools.init();
},
close: function() { close: function() {
Conf['editMode'] = false; Conf['editMode'] = false;
editMascot = {}; editMascot = {};
@ -11426,10 +11425,10 @@
$.extend(Style, { $.extend(Style, {
layoutCSS: $.addStyle(Style.layout, 'layout'), layoutCSS: $.addStyle(Style.layout, 'layout'),
themeCSS: $.addStyle(Style.theme(theme), 'theme'), themeCSS: $.addStyle(Style.theme(theme), 'theme'),
dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic'),
icons: $.addStyle("", 'icons'), icons: $.addStyle("", 'icons'),
paddingSheet: $.addStyle("", 'padding'), paddingSheet: $.addStyle("", 'padding'),
mascot: $.addStyle("", 'mascotSheet'), mascot: $.addStyle("", 'mascotSheet')
dynamicCSS: $.addStyle(Style.dynamic(), 'dynamic')
}); });
$.addStyle(JSColor.css(), 'jsColor'); $.addStyle(JSColor.css(), 'jsColor');
if (d.head) { if (d.head) {
@ -11480,7 +11479,6 @@
if (!theme) { if (!theme) {
theme = Themes[_conf['theme']] || Themes['Yotsuba B']; theme = Themes[_conf['theme']] || Themes['Yotsuba B'];
} }
MascotTools.init(_conf["mascot"]);
Style.dynamicCSS.textContent = Style.dynamic(); Style.dynamicCSS.textContent = Style.dynamic();
Style.iconPositions(); Style.iconPositions();
return Style.padding(); return Style.padding();
@ -14419,8 +14417,9 @@
MascotTools.init(); MascotTools.init();
} }
} else { } else {
Conf['mascot'] = this.id;
Conf[g.MASCOTSTRING].push(this.id); Conf[g.MASCOTSTRING].push(this.id);
MascotTools.init(this.id); MascotTools.init(Mascots[this.id]);
} }
$.toggleClass(this, 'enabled'); $.toggleClass(this, 'enabled');
return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING]); return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING]);

View File

@ -889,8 +889,9 @@ Settings =
if Conf['mascot'] is @id if Conf['mascot'] is @id
MascotTools.init() MascotTools.init()
else else
Conf['mascot'] = @id
Conf[g.MASCOTSTRING].push @id Conf[g.MASCOTSTRING].push @id
MascotTools.init @id MascotTools.init Mascots[@id]
$.toggleClass @, 'enabled' $.toggleClass @, 'enabled'
$.set g.MASCOTSTRING, Conf[g.MASCOTSTRING] $.set g.MASCOTSTRING, Conf[g.MASCOTSTRING]

View File

@ -1,9 +1,15 @@
MascotTools = MascotTools =
init: (mascot) -> init: (mascot) ->
unless mascot and mascot.image? unless mascot and mascot.image?
mascot = Mascots[Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)]] return unless Conf[g.MASCOTSTRING].length
name = Conf[g.MASCOTSTRING][Math.floor(Math.random() * Conf[g.MASCOTSTRING].length)]
mascot = Mascots[name]
Conf['mascot'] = name
@el = el = $('#mascot img', d.body) unless @el
@el = $ '#mascot img', d.body
el = @el
if !Conf['Mascots'] or (Conf['Hide Mascots on Catalog'] and g.VIEW is 'catalog') if !Conf['Mascots'] or (Conf['Hide Mascots on Catalog'] and g.VIEW is 'catalog')
return if el then el.src = "" else null return if el then el.src = "" else null
@ -16,23 +22,13 @@ MascotTools =
$.rmClass doc, 'mascot-position-bottom' $.rmClass doc, 'mascot-position-bottom'
unless mascot unless mascot
unless mascot = Mascots[Conf["mascot"]] if name and not mascot = Mascots[name]
if el then el.src = "" else null if el then el.src = "" else null
Conf[g.MASCOTSTRING].remove Conf["mascot"] Conf[g.MASCOTSTRING].remove name
return MascotTools.init() return MascotTools.init()
MascotTools.addMascot mascot MascotTools.addMascot mascot
if Conf["Sidebar Location"] is 'left'
if Conf["Mascot Location"] is "sidebar"
location = 'left'
else
location = 'right'
else if Conf["Mascot Location"] is "sidebar"
location = 'right'
else
location = 'left'
Style.mascot.textContent = """ Style.mascot.textContent = """
#mascot { #mascot {
display: none; display: none;
@ -84,7 +80,7 @@ MascotTools =
'auto' 'auto'
}; };
margin-bottom: #{mascot.vOffset or 0}px; margin-bottom: #{mascot.vOffset or 0}px;
pointer-events: none; cursor: pointer;
} }
.fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img, .fourchan-ss-navigation.bottom.fixed.posting-disabled #mascot img,
.fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img, .fourchan-ss-navigation.bottom.fixed.mascot-position-bottom #mascot img,
@ -149,7 +145,7 @@ MascotTools =
editMascot = {} editMascot = {}
editMascot.name = key or '' editMascot.name = key or ''
MascotTools.addMascot editMascot MascotTools.addMascot editMascot
MascotTools.init _conf["mascot"] MascotTools.init editMascot
layout = layout =
name: [ name: [
"Mascot Name" "Mascot Name"
@ -234,7 +230,7 @@ MascotTools =
$.on input, 'blur', -> $.on input, 'blur', ->
editMascot[@name] = @value editMascot[@name] = @value
MascotTools.addMascot editMascot MascotTools.addMascot editMascot
MascotTools.init _conf["mascot"] MascotTools.init editMascot
fileInput = $.el 'input', fileInput = $.el 'input',
type: "file" type: "file"
@ -258,22 +254,19 @@ MascotTools =
if (@value isnt "") and !/^[a-z]/i.test @value if (@value isnt "") and !/^[a-z]/i.test @value
return alert "Mascot names must start with a letter." return alert "Mascot names must start with a letter."
editMascot[@name] = @value editMascot[@name] = @value
MascotTools.addMascot editMascot MascotTools.init editMascot
Style.addStyle()
else else
$.on input, 'blur', -> $.on input, 'blur', ->
editMascot[@name] = @value editMascot[@name] = @value
MascotTools.addMascot editMascot MascotTools.init editMascot
Style.addStyle()
when "number" when "number"
div = @input item, name div = @input item, name
$.on $('input', div), 'blur', -> $.on $('input', div), 'blur', ->
editMascot[@name] = parseInt @value editMascot[@name] = parseInt @value
MascotTools.addMascot editMascot MascotTools.init editMascot
Style.addStyle()
when "select" when "select"
value = editMascot[name] or item[1] value = editMascot[name] or item[1]
@ -289,8 +282,7 @@ MascotTools =
$.on $('select', div), 'change', -> $.on $('select', div), 'change', ->
editMascot[@name] = @value editMascot[@name] = @value
MascotTools.addMascot editMascot MascotTools.init editMascot
Style.addStyle()
when "checkbox" when "checkbox"
value = editMascot[name] or item[1] value = editMascot[name] or item[1]
@ -299,8 +291,7 @@ MascotTools =
innerHTML: "<label><input type=#{item[2]} class=field name='#{name}' #{if value then 'checked'}>#{item[0]}</label>" innerHTML: "<label><input type=#{item[2]} class=field name='#{name}' #{if value then 'checked'}>#{item[0]}</label>"
$.on $('input', div), 'click', -> $.on $('input', div), 'click', ->
editMascot[@name] = if @checked then true else false editMascot[@name] = if @checked then true else false
MascotTools.addMascot editMascot MascotTools.init editMascot
Style.addStyle()
nodes.push div nodes.push div
$.add $("#mascotcontent", dialog), nodes $.add $("#mascotcontent", dialog), nodes
@ -343,14 +334,25 @@ MascotTools =
reader.readAsDataURL file reader.readAsDataURL file
addMascot: (mascot) -> addMascot: (mascot) ->
image =
if Array.isArray mascot.image
if Style.lightTheme
mascot.image[1]
else
mascot.image[0]
else mascot.image
if el = @el if el = @el
el.src = if Array.isArray(mascot.image) then (if Style.lightTheme then mascot.image[1] else mascot.image[0]) else mascot.image el.src = image
else else
@el = el = $.el 'div', div = $.el 'div',
id: "mascot" id: "mascot"
innerHTML: "<img src='#{if Array.isArray(mascot.image) then (if Style.lightTheme then mascot.image[1] else mascot.image[0]) else mascot.image}'>" innerHTML: "<img src='#{image}'>"
$.add d.body, el @el = div.firstElementChild
$.on @el, 'mousedown', MascotTools.click
$.add d.body, div
save: (mascot) -> save: (mascot) ->
{name, image} = mascot {name, image} = mascot
@ -390,6 +392,10 @@ MascotTools =
$.set 'userMascots', userMascots $.set 'userMascots', userMascots
alert "Mascot \"#{name}\" saved." alert "Mascot \"#{name}\" saved."
click: (e) ->
e.preventDefault()
MascotTools.init()
close: -> close: ->
Conf['editMode'] = false Conf['editMode'] = false
editMascot = {} editMascot = {}

View File

@ -74,10 +74,10 @@ Style =
$.extend Style, $.extend Style,
layoutCSS: $.addStyle Style.layout, 'layout' layoutCSS: $.addStyle Style.layout, 'layout'
themeCSS: $.addStyle Style.theme(theme), 'theme' themeCSS: $.addStyle Style.theme(theme), 'theme'
dynamicCSS: $.addStyle Style.dynamic(), 'dynamic'
icons: $.addStyle "", 'icons' icons: $.addStyle "", 'icons'
paddingSheet: $.addStyle "", 'padding' paddingSheet: $.addStyle "", 'padding'
mascot: $.addStyle "", 'mascotSheet' mascot: $.addStyle "", 'mascotSheet'
dynamicCSS: $.addStyle Style.dynamic(), 'dynamic'
# Non-customizable # Non-customizable
$.addStyle JSColor.css(), 'jsColor' $.addStyle JSColor.css(), 'jsColor'
@ -120,7 +120,6 @@ Style =
unless theme unless theme
theme = Themes[_conf['theme']] or Themes['Yotsuba B'] theme = Themes[_conf['theme']] or Themes['Yotsuba B']
MascotTools.init _conf["mascot"]
Style.dynamicCSS.textContent = Style.dynamic() Style.dynamicCSS.textContent = Style.dynamic()
Style.iconPositions() Style.iconPositions()
Style.padding() Style.padding()