Fix various settings tabs and dialogs

* Delete / Undelete Themes and Mascots
* Themes only add [custom] if they're not already User Themes
This commit is contained in:
Zixaphir 2013-05-08 04:48:23 -07:00
parent 7696301598
commit 6c4e4b6b9f
6 changed files with 266 additions and 186 deletions

View File

@ -11306,18 +11306,12 @@
ThemeTools = { ThemeTools = {
init: function(key) { init: function(key) {
var colorInput, div, fileInput, header, input, item, layout, themecontent, _i, _j, _len, _len1, _ref; var colorInput, div, fileInput, header, input, item, layout, nodes, themeContent, _i, _j, _len, _len1, _ref;
Conf['editMode'] = "theme"; Conf['editMode'] = "theme";
if (Themes[key]) { if (key) {
editTheme = JSON.parse(JSON.stringify(Themes[key])); editTheme = JSON.parse(JSON.stringify(Themes[key]));
$.get("userThemes", {}, function(items) { editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
if (items[key]) {
return editTheme["Theme"] = key;
} else {
return editTheme["Theme"] = key += " [custom]";
}
});
} else { } else {
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])); editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
editTheme["Theme"] = "Untitled"; editTheme["Theme"] = "Untitled";
@ -11341,7 +11335,8 @@
}); });
} }
$.add($("#themebar", ThemeTools.dialog), header); $.add($("#themebar", ThemeTools.dialog), header);
themecontent = $("#themecontent", ThemeTools.dialog); themeContent = $("#themecontent", ThemeTools.dialog);
nodes = [];
for (_j = 0, _len1 = layout.length; _j < _len1; _j++) { for (_j = 0, _len1 = layout.length; _j < _len1; _j++) {
item = layout[_j]; item = layout[_j];
if (!editTheme[item]) { if (!editTheme[item]) {
@ -11416,10 +11411,9 @@
} }
return editTheme[this.name] = this.value; return editTheme[this.name] = this.value;
}); });
Style.addStyle(editTheme); nodes.push(div);
$.add(themecontent, div);
} }
$.add(themecontent, div); Style.addStyle(editTheme);
if (!editTheme["Custom CSS"]) { if (!editTheme["Custom CSS"]) {
editTheme["Custom CSS"] = ""; editTheme["Custom CSS"] = "";
} }
@ -11431,11 +11425,12 @@
editTheme["Custom CSS"] = this.value; editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.themeCSS.textContent = Style.theme(editTheme);
}); });
$.add(themecontent, div); nodes.push(div);
$.on($('#save > a', ThemeTools.dialog), 'click', function() { $.on($('#save > a', ThemeTools.dialog), 'click', function() {
return ThemeTools.save(editTheme); return ThemeTools.save(editTheme);
}); });
$.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close);
$.add(themeContent, nodes);
$.add(d.body, ThemeTools.dialog); $.add(d.body, ThemeTools.dialog);
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.themeCSS.textContent = Style.theme(editTheme);
}, },
@ -13694,7 +13689,9 @@
for (_i = 0, _len = keys.length; _i < _len; _i++) { for (_i = 0, _len = keys.length; _i < _len; _i++) {
name = keys[_i]; name = keys[_i];
theme = Themes[name]; theme = Themes[name];
if (!theme["Deleted"]) { if (theme["Deleted"]) {
continue;
}
div = $.el('div', { div = $.el('div', {
className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''),
id: name, id: name,
@ -13707,7 +13704,6 @@
$.on(div, 'click', cb.select); $.on(div, 'click', cb.select);
$.add(suboptions, div); $.add(suboptions, div);
} }
}
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a> / <a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden> / <a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden> / <a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden> / <a id=tUndelete href='javascript:;'>Undelete Theme</a>" innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a> / <a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden> / <a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden> / <a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden> / <a id=tUndelete href='javascript:;'>Undelete Theme</a>"
@ -13735,14 +13731,22 @@
return this.nextSibling.click(); return this.nextSibling.click();
}); });
$.on($('#tUndelete', div), 'click', function() { $.on($('#tUndelete', div), 'click', function() {
var themes;
$.rm($.id("themeContainer")); $.rm($.id("themeContainer"));
return Settings.openSection(themes, 'undelete'); themes = {
open: Settings.themes,
hyphenatedTitle: 'themes'
};
return Settings.openSection.apply(themes, ['undelete']);
}); });
} else { } else {
for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) {
name = keys[_j]; name = keys[_j];
theme = Themes[name]; theme = Themes[name];
if (theme["Deleted"]) { if (!theme["Deleted"]) {
continue;
}
div = $.el('div', { div = $.el('div', {
id: name, id: name,
className: theme, className: theme,
@ -13751,14 +13755,19 @@
$.on(div, 'click', cb.restore); $.on(div, 'click', cb.restore);
$.add(suboptions, div); $.add(suboptions, div);
} }
}
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a href='javascript:;'>Return</a>" innerHTML: "<a href='javascript:;'>Return</a>"
}); });
$.on($('a', div), 'click', function() { $.on($('a', div), 'click', function() {
var themes;
themes = {
open: Settings.themes,
hyphenatedTitle: 'themes'
};
$.rm($.id("themeContainer")); $.rm($.id("themeContainer"));
return Settings.openSection(themes); return Settings.openSection.call(themes);
}); });
} }
$.add(parentdiv, suboptions); $.add(parentdiv, suboptions);
@ -13890,12 +13899,17 @@
return MascotTools.importMascot(e); return MascotTools.importMascot(e);
}); });
$.on($('#undelete', batchmascots), 'click', function() { $.on($('#undelete', batchmascots), 'click', function() {
var mascots;
if (!(Conf["Deleted Mascots"].length > 0)) { if (!(Conf["Deleted Mascots"].length > 0)) {
alert("No mascots have been deleted."); alert("No mascots have been deleted.");
return; return;
} }
$.rm($.id("mascotContainer")); mascots = {
return Settings.mascotTab.dialog(Settings.el, 'undelete'); open: Settings.mascots,
hyphenatedTitle: 'mascots'
};
return Settings.openSection.apply(mascots, ['restore']);
}); });
} else { } else {
categories = $.el("div", { categories = $.el("div", {
@ -13922,8 +13936,13 @@
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>"
}); });
$.on($('#return', batchmascots), 'click', function() { $.on($('#return', batchmascots), 'click', function() {
$.rm($.id("mascotContainer")); var mascots;
return Settings.section('mascots');
mascots = {
open: Settings.mascots,
hyphenatedTitle: 'mascots'
};
return Settings.openSection.apply(mascots);
}); });
} }
$.add(parentdiv, [suboptions, batchmascots, mascotHide]); $.add(parentdiv, [suboptions, batchmascots, mascotHide]);
@ -14055,7 +14074,8 @@
} }
}, },
"delete": function(e) { "delete": function(e) {
var container, settheme; var container, settheme,
_this = this;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -14073,26 +14093,28 @@
} }
} }
Themes[this.name]["Deleted"] = true; Themes[this.name]["Deleted"] = true;
return $.get("userThemes", {}, function() { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = items['userThemes']; userThemes = _arg.userThemes;
userThemes[this.name] = Themes[this.name]; userThemes[_this.name] = Themes[_this.name];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
return $.rm(container); return $.rm(container);
}); });
} }
}, },
restore: function() { restore: function() {
var _this = this;
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
Themes[this.id]["Deleted"] = false; Themes[this.id]["Deleted"] = false;
return $.get("userThemes", {}, function(item) { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = item["userThemes"]; userThemes = _arg.userThemes;
userThemes[this.id] = Themes[this.id]; userThemes[_this.id] = Themes[_this.id];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
return $.rm(this); return $.rm(_this);
}); });
} }
} }

View File

@ -11327,18 +11327,12 @@
ThemeTools = { ThemeTools = {
init: function(key) { init: function(key) {
var colorInput, div, fileInput, header, input, item, layout, themecontent, _i, _j, _len, _len1, _ref; var colorInput, div, fileInput, header, input, item, layout, nodes, themeContent, _i, _j, _len, _len1, _ref;
Conf['editMode'] = "theme"; Conf['editMode'] = "theme";
if (Themes[key]) { if (key) {
editTheme = JSON.parse(JSON.stringify(Themes[key])); editTheme = JSON.parse(JSON.stringify(Themes[key]));
$.get("userThemes", {}, function(items) { editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
if (items[key]) {
return editTheme["Theme"] = key;
} else {
return editTheme["Theme"] = key += " [custom]";
}
});
} else { } else {
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])); editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
editTheme["Theme"] = "Untitled"; editTheme["Theme"] = "Untitled";
@ -11362,7 +11356,8 @@
}); });
} }
$.add($("#themebar", ThemeTools.dialog), header); $.add($("#themebar", ThemeTools.dialog), header);
themecontent = $("#themecontent", ThemeTools.dialog); themeContent = $("#themecontent", ThemeTools.dialog);
nodes = [];
for (_j = 0, _len1 = layout.length; _j < _len1; _j++) { for (_j = 0, _len1 = layout.length; _j < _len1; _j++) {
item = layout[_j]; item = layout[_j];
if (!editTheme[item]) { if (!editTheme[item]) {
@ -11437,10 +11432,9 @@
} }
return editTheme[this.name] = this.value; return editTheme[this.name] = this.value;
}); });
Style.addStyle(editTheme); nodes.push(div);
$.add(themecontent, div);
} }
$.add(themecontent, div); Style.addStyle(editTheme);
if (!editTheme["Custom CSS"]) { if (!editTheme["Custom CSS"]) {
editTheme["Custom CSS"] = ""; editTheme["Custom CSS"] = "";
} }
@ -11452,11 +11446,12 @@
editTheme["Custom CSS"] = this.value; editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.themeCSS.textContent = Style.theme(editTheme);
}); });
$.add(themecontent, div); nodes.push(div);
$.on($('#save > a', ThemeTools.dialog), 'click', function() { $.on($('#save > a', ThemeTools.dialog), 'click', function() {
return ThemeTools.save(editTheme); return ThemeTools.save(editTheme);
}); });
$.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close);
$.add(themeContent, nodes);
$.add(d.body, ThemeTools.dialog); $.add(d.body, ThemeTools.dialog);
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.themeCSS.textContent = Style.theme(editTheme);
}, },
@ -13713,7 +13708,9 @@
for (_i = 0, _len = keys.length; _i < _len; _i++) { for (_i = 0, _len = keys.length; _i < _len; _i++) {
name = keys[_i]; name = keys[_i];
theme = Themes[name]; theme = Themes[name];
if (!theme["Deleted"]) { if (theme["Deleted"]) {
continue;
}
div = $.el('div', { div = $.el('div', {
className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''),
id: name, id: name,
@ -13726,7 +13723,6 @@
$.on(div, 'click', cb.select); $.on(div, 'click', cb.select);
$.add(suboptions, div); $.add(suboptions, div);
} }
}
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a> / <a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden> / <a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden> / <a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden> / <a id=tUndelete href='javascript:;'>Undelete Theme</a>" innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a> / <a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden> / <a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden> / <a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden> / <a id=tUndelete href='javascript:;'>Undelete Theme</a>"
@ -13754,14 +13750,22 @@
return this.nextSibling.click(); return this.nextSibling.click();
}); });
$.on($('#tUndelete', div), 'click', function() { $.on($('#tUndelete', div), 'click', function() {
var themes;
$.rm($.id("themeContainer")); $.rm($.id("themeContainer"));
return Settings.openSection(themes, 'undelete'); themes = {
open: Settings.themes,
hyphenatedTitle: 'themes'
};
return Settings.openSection.apply(themes, ['undelete']);
}); });
} else { } else {
for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) {
name = keys[_j]; name = keys[_j];
theme = Themes[name]; theme = Themes[name];
if (theme["Deleted"]) { if (!theme["Deleted"]) {
continue;
}
div = $.el('div', { div = $.el('div', {
id: name, id: name,
className: theme, className: theme,
@ -13770,14 +13774,19 @@
$.on(div, 'click', cb.restore); $.on(div, 'click', cb.restore);
$.add(suboptions, div); $.add(suboptions, div);
} }
}
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a href='javascript:;'>Return</a>" innerHTML: "<a href='javascript:;'>Return</a>"
}); });
$.on($('a', div), 'click', function() { $.on($('a', div), 'click', function() {
var themes;
themes = {
open: Settings.themes,
hyphenatedTitle: 'themes'
};
$.rm($.id("themeContainer")); $.rm($.id("themeContainer"));
return Settings.openSection(themes); return Settings.openSection.call(themes);
}); });
} }
$.add(parentdiv, suboptions); $.add(parentdiv, suboptions);
@ -13909,12 +13918,17 @@
return MascotTools.importMascot(e); return MascotTools.importMascot(e);
}); });
$.on($('#undelete', batchmascots), 'click', function() { $.on($('#undelete', batchmascots), 'click', function() {
var mascots;
if (!(Conf["Deleted Mascots"].length > 0)) { if (!(Conf["Deleted Mascots"].length > 0)) {
alert("No mascots have been deleted."); alert("No mascots have been deleted.");
return; return;
} }
$.rm($.id("mascotContainer")); mascots = {
return Settings.mascotTab.dialog(Settings.el, 'undelete'); open: Settings.mascots,
hyphenatedTitle: 'mascots'
};
return Settings.openSection.apply(mascots, ['restore']);
}); });
} else { } else {
categories = $.el("div", { categories = $.el("div", {
@ -13941,8 +13955,13 @@
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>"
}); });
$.on($('#return', batchmascots), 'click', function() { $.on($('#return', batchmascots), 'click', function() {
$.rm($.id("mascotContainer")); var mascots;
return Settings.section('mascots');
mascots = {
open: Settings.mascots,
hyphenatedTitle: 'mascots'
};
return Settings.openSection.apply(mascots);
}); });
} }
$.add(parentdiv, [suboptions, batchmascots, mascotHide]); $.add(parentdiv, [suboptions, batchmascots, mascotHide]);
@ -14074,7 +14093,8 @@
} }
}, },
"delete": function(e) { "delete": function(e) {
var container, settheme; var container, settheme,
_this = this;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -14092,26 +14112,28 @@
} }
} }
Themes[this.name]["Deleted"] = true; Themes[this.name]["Deleted"] = true;
return $.get("userThemes", {}, function() { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = items['userThemes']; userThemes = _arg.userThemes;
userThemes[this.name] = Themes[this.name]; userThemes[_this.name] = Themes[_this.name];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
return $.rm(container); return $.rm(container);
}); });
} }
}, },
restore: function() { restore: function() {
var _this = this;
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
Themes[this.id]["Deleted"] = false; Themes[this.id]["Deleted"] = false;
return $.get("userThemes", {}, function(item) { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = item["userThemes"]; userThemes = _arg.userThemes;
userThemes[this.id] = Themes[this.id]; userThemes[_this.id] = Themes[_this.id];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
return $.rm(this); return $.rm(_this);
}); });
} }
} }

Binary file not shown.

View File

@ -11310,18 +11310,12 @@
ThemeTools = { ThemeTools = {
init: function(key) { init: function(key) {
var colorInput, div, fileInput, header, input, item, layout, themecontent, _i, _j, _len, _len1, _ref; var colorInput, div, fileInput, header, input, item, layout, nodes, themeContent, _i, _j, _len, _len1, _ref;
Conf['editMode'] = "theme"; Conf['editMode'] = "theme";
if (Themes[key]) { if (key) {
editTheme = JSON.parse(JSON.stringify(Themes[key])); editTheme = JSON.parse(JSON.stringify(Themes[key]));
$.get("userThemes", {}, function(items) { editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
if (items[key]) {
return editTheme["Theme"] = key;
} else {
return editTheme["Theme"] = key += " [custom]";
}
});
} else { } else {
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])); editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
editTheme["Theme"] = "Untitled"; editTheme["Theme"] = "Untitled";
@ -11345,7 +11339,8 @@
}); });
} }
$.add($("#themebar", ThemeTools.dialog), header); $.add($("#themebar", ThemeTools.dialog), header);
themecontent = $("#themecontent", ThemeTools.dialog); themeContent = $("#themecontent", ThemeTools.dialog);
nodes = [];
for (_j = 0, _len1 = layout.length; _j < _len1; _j++) { for (_j = 0, _len1 = layout.length; _j < _len1; _j++) {
item = layout[_j]; item = layout[_j];
if (!editTheme[item]) { if (!editTheme[item]) {
@ -11420,10 +11415,9 @@
} }
return editTheme[this.name] = this.value; return editTheme[this.name] = this.value;
}); });
Style.addStyle(editTheme); nodes.push(div);
$.add(themecontent, div);
} }
$.add(themecontent, div); Style.addStyle(editTheme);
if (!editTheme["Custom CSS"]) { if (!editTheme["Custom CSS"]) {
editTheme["Custom CSS"] = ""; editTheme["Custom CSS"] = "";
} }
@ -11435,11 +11429,12 @@
editTheme["Custom CSS"] = this.value; editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.themeCSS.textContent = Style.theme(editTheme);
}); });
$.add(themecontent, div); nodes.push(div);
$.on($('#save > a', ThemeTools.dialog), 'click', function() { $.on($('#save > a', ThemeTools.dialog), 'click', function() {
return ThemeTools.save(editTheme); return ThemeTools.save(editTheme);
}); });
$.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close);
$.add(themeContent, nodes);
$.add(d.body, ThemeTools.dialog); $.add(d.body, ThemeTools.dialog);
return Style.themeCSS.textContent = Style.theme(editTheme); return Style.themeCSS.textContent = Style.theme(editTheme);
}, },
@ -13698,7 +13693,9 @@
for (_i = 0, _len = keys.length; _i < _len; _i++) { for (_i = 0, _len = keys.length; _i < _len; _i++) {
name = keys[_i]; name = keys[_i];
theme = Themes[name]; theme = Themes[name];
if (!theme["Deleted"]) { if (theme["Deleted"]) {
continue;
}
div = $.el('div', { div = $.el('div', {
className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''),
id: name, id: name,
@ -13711,7 +13708,6 @@
$.on(div, 'click', cb.select); $.on(div, 'click', cb.select);
$.add(suboptions, div); $.add(suboptions, div);
} }
}
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a> / <a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden> / <a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden> / <a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden> / <a id=tUndelete href='javascript:;'>Undelete Theme</a>" innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a> / <a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden> / <a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden> / <a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden> / <a id=tUndelete href='javascript:;'>Undelete Theme</a>"
@ -13739,14 +13735,22 @@
return this.nextSibling.click(); return this.nextSibling.click();
}); });
$.on($('#tUndelete', div), 'click', function() { $.on($('#tUndelete', div), 'click', function() {
var themes;
$.rm($.id("themeContainer")); $.rm($.id("themeContainer"));
return Settings.openSection(themes, 'undelete'); themes = {
open: Settings.themes,
hyphenatedTitle: 'themes'
};
return Settings.openSection.apply(themes, ['undelete']);
}); });
} else { } else {
for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) {
name = keys[_j]; name = keys[_j];
theme = Themes[name]; theme = Themes[name];
if (theme["Deleted"]) { if (!theme["Deleted"]) {
continue;
}
div = $.el('div', { div = $.el('div', {
id: name, id: name,
className: theme, className: theme,
@ -13755,14 +13759,19 @@
$.on(div, 'click', cb.restore); $.on(div, 'click', cb.restore);
$.add(suboptions, div); $.add(suboptions, div);
} }
}
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a href='javascript:;'>Return</a>" innerHTML: "<a href='javascript:;'>Return</a>"
}); });
$.on($('a', div), 'click', function() { $.on($('a', div), 'click', function() {
var themes;
themes = {
open: Settings.themes,
hyphenatedTitle: 'themes'
};
$.rm($.id("themeContainer")); $.rm($.id("themeContainer"));
return Settings.openSection(themes); return Settings.openSection.call(themes);
}); });
} }
$.add(parentdiv, suboptions); $.add(parentdiv, suboptions);
@ -13894,12 +13903,17 @@
return MascotTools.importMascot(e); return MascotTools.importMascot(e);
}); });
$.on($('#undelete', batchmascots), 'click', function() { $.on($('#undelete', batchmascots), 'click', function() {
var mascots;
if (!(Conf["Deleted Mascots"].length > 0)) { if (!(Conf["Deleted Mascots"].length > 0)) {
alert("No mascots have been deleted."); alert("No mascots have been deleted.");
return; return;
} }
$.rm($.id("mascotContainer")); mascots = {
return Settings.mascotTab.dialog(Settings.el, 'undelete'); open: Settings.mascots,
hyphenatedTitle: 'mascots'
};
return Settings.openSection.apply(mascots, ['restore']);
}); });
} else { } else {
categories = $.el("div", { categories = $.el("div", {
@ -13926,8 +13940,13 @@
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>"
}); });
$.on($('#return', batchmascots), 'click', function() { $.on($('#return', batchmascots), 'click', function() {
$.rm($.id("mascotContainer")); var mascots;
return Settings.section('mascots');
mascots = {
open: Settings.mascots,
hyphenatedTitle: 'mascots'
};
return Settings.openSection.apply(mascots);
}); });
} }
$.add(parentdiv, [suboptions, batchmascots, mascotHide]); $.add(parentdiv, [suboptions, batchmascots, mascotHide]);
@ -14059,7 +14078,8 @@
} }
}, },
"delete": function(e) { "delete": function(e) {
var container, settheme; var container, settheme,
_this = this;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -14077,26 +14097,28 @@
} }
} }
Themes[this.name]["Deleted"] = true; Themes[this.name]["Deleted"] = true;
return $.get("userThemes", {}, function() { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = items['userThemes']; userThemes = _arg.userThemes;
userThemes[this.name] = Themes[this.name]; userThemes[_this.name] = Themes[_this.name];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
return $.rm(container); return $.rm(container);
}); });
} }
}, },
restore: function() { restore: function() {
var _this = this;
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
Themes[this.id]["Deleted"] = false; Themes[this.id]["Deleted"] = false;
return $.get("userThemes", {}, function(item) { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = item["userThemes"]; userThemes = _arg.userThemes;
userThemes[this.id] = Themes[this.id]; userThemes[_this.id] = Themes[_this.id];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
return $.rm(this); return $.rm(_this);
}); });
} }
} }

View File

@ -549,7 +549,7 @@ Settings =
for name in keys for name in keys
theme = Themes[name] theme = Themes[name]
unless theme["Deleted"] continue if theme["Deleted"]
div = $.el 'div', div = $.el 'div',
className: "theme #{if name is Conf['theme'] then 'selectedtheme' else ''}" className: "theme #{if name is Conf['theme'] then 'selectedtheme' else ''}"
@ -639,14 +639,19 @@ Settings =
$.on $('#tUndelete', div), 'click', -> $.on $('#tUndelete', div), 'click', ->
$.rm $.id "themeContainer" $.rm $.id "themeContainer"
Settings.openSection themes, 'undelete'
themes =
open: Settings.themes
hyphenatedTitle: 'themes'
Settings.openSection.apply themes, ['undelete']
else else
for name in keys for name in keys
theme = Themes[name] theme = Themes[name]
if theme["Deleted"] continue unless theme["Deleted"]
div = $.el 'div', div = $.el 'div',
id: name id: name
@ -679,8 +684,12 @@ Settings =
innerHTML: "<a href='javascript:;'>Return</a>" innerHTML: "<a href='javascript:;'>Return</a>"
$.on $('a', div), 'click', -> $.on $('a', div), 'click', ->
themes =
open: Settings.themes
hyphenatedTitle: 'themes'
$.rm $.id "themeContainer" $.rm $.id "themeContainer"
Settings.openSection themes Settings.openSection.call themes
$.add parentdiv, suboptions $.add parentdiv, suboptions
$.add parentdiv, div $.add parentdiv, div
@ -815,8 +824,10 @@ Settings =
unless Conf["Deleted Mascots"].length > 0 unless Conf["Deleted Mascots"].length > 0
alert "No mascots have been deleted." alert "No mascots have been deleted."
return return
$.rm $.id "mascotContainer" mascots =
Settings.mascotTab.dialog Settings.el, 'undelete' open: Settings.mascots
hyphenatedTitle: 'mascots'
Settings.openSection.apply mascots, ['restore']
else else
categories = $.el "div", categories = $.el "div",
@ -845,8 +856,10 @@ Settings =
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>"
$.on $('#return', batchmascots), 'click', -> $.on $('#return', batchmascots), 'click', ->
$.rm $.id "mascotContainer" mascots =
Settings.section 'mascots' open: Settings.mascots
hyphenatedTitle: 'mascots'
Settings.openSection.apply mascots
$.add parentdiv, [suboptions, batchmascots, mascotHide] $.add parentdiv, [suboptions, batchmascots, mascotHide]
@ -973,8 +986,7 @@ Settings =
$.set 'theme', Conf['theme'] $.set 'theme', Conf['theme']
Themes[@name]["Deleted"] = true Themes[@name]["Deleted"] = true
$.get "userThemes", {}, -> $.get "userThemes", {}, ({userThemes}) =>
userThemes = items['userThemes']
userThemes[@name] = Themes[@name] userThemes[@name] = Themes[@name]
$.set 'userThemes', userThemes $.set 'userThemes', userThemes
$.rm container $.rm container
@ -982,8 +994,8 @@ Settings =
restore: -> restore: ->
if confirm "Are you sure you want to restore \"#{@id}\"?" if confirm "Are you sure you want to restore \"#{@id}\"?"
Themes[@id]["Deleted"] = false Themes[@id]["Deleted"] = false
$.get "userThemes", {}, (item) ->
userThemes = item["userThemes"] $.get "userThemes", {}, ({userThemes}) =>
userThemes[@id] = Themes[@id] userThemes[@id] = Themes[@id]
$.set 'userThemes', userThemes $.set 'userThemes', userThemes
$.rm @ $.rm @

View File

@ -6,13 +6,12 @@ ThemeTools =
init: (key) -> init: (key) ->
Conf['editMode'] = "theme" Conf['editMode'] = "theme"
if Themes[key] if key
editTheme = JSON.parse(JSON.stringify(Themes[key])) editTheme = JSON.parse(JSON.stringify(Themes[key]))
$.get "userThemes", {}, (items) -> editTheme["Theme"] = if Conf['userThemes'][key]
if items[key] key
editTheme["Theme"] = key
else else
editTheme["Theme"] = key += " [custom]" key += " [custom]"
else else
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])) editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']))
editTheme["Theme"] = "Untitled" editTheme["Theme"] = "Untitled"
@ -102,7 +101,9 @@ ThemeTools =
$.on input, 'blur', -> $.on input, 'blur', ->
editTheme[@name] = @value editTheme[@name] = @value
$.add $("#themebar", ThemeTools.dialog), header $.add $("#themebar", ThemeTools.dialog), header
themecontent = $("#themecontent", ThemeTools.dialog) themeContent = $("#themecontent", ThemeTools.dialog)
nodes = []
for item in layout for item in layout
unless editTheme[item] unless editTheme[item]
@ -168,12 +169,10 @@ ThemeTools =
editTheme[@name] = @value editTheme[@name] = @value
nodes.push div
Style.addStyle(editTheme) Style.addStyle(editTheme)
$.add themecontent, div
$.add themecontent, div
unless editTheme["Custom CSS"] unless editTheme["Custom CSS"]
editTheme["Custom CSS"] = "" editTheme["Custom CSS"] = ""
@ -185,12 +184,15 @@ ThemeTools =
editTheme["Custom CSS"] = @value editTheme["Custom CSS"] = @value
Style.themeCSS.textContent = Style.theme editTheme Style.themeCSS.textContent = Style.theme editTheme
$.add themecontent, div nodes.push div
$.on $('#save > a', ThemeTools.dialog), 'click', -> $.on $('#save > a', ThemeTools.dialog), 'click', ->
ThemeTools.save editTheme ThemeTools.save editTheme
$.on $('#close > a', ThemeTools.dialog), 'click', ThemeTools.close $.on $('#close > a', ThemeTools.dialog), 'click', ThemeTools.close
$.add themeContent, nodes
$.add d.body, ThemeTools.dialog $.add d.body, ThemeTools.dialog
Style.themeCSS.textContent = Style.theme editTheme Style.themeCSS.textContent = Style.theme editTheme