diff --git a/builds/appchan-x.js b/builds/appchan-x.js index 951d346a8..72afffb6f 100644 --- a/builds/appchan-x.js +++ b/builds/appchan-x.js @@ -11306,18 +11306,12 @@ ThemeTools = { 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"; - if (Themes[key]) { + if (key) { editTheme = JSON.parse(JSON.stringify(Themes[key])); - $.get("userThemes", {}, function(items) { - if (items[key]) { - return editTheme["Theme"] = key; - } else { - return editTheme["Theme"] = key += " [custom]"; - } - }); + editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]"; } else { editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])); editTheme["Theme"] = "Untitled"; @@ -11341,7 +11335,8 @@ }); } $.add($("#themebar", ThemeTools.dialog), header); - themecontent = $("#themecontent", ThemeTools.dialog); + themeContent = $("#themecontent", ThemeTools.dialog); + nodes = []; for (_j = 0, _len1 = layout.length; _j < _len1; _j++) { item = layout[_j]; if (!editTheme[item]) { @@ -11416,10 +11411,9 @@ } return editTheme[this.name] = this.value; }); - Style.addStyle(editTheme); - $.add(themecontent, div); + nodes.push(div); } - $.add(themecontent, div); + Style.addStyle(editTheme); if (!editTheme["Custom CSS"]) { editTheme["Custom CSS"] = ""; } @@ -11431,11 +11425,12 @@ editTheme["Custom CSS"] = this.value; return Style.themeCSS.textContent = Style.theme(editTheme); }); - $.add(themecontent, div); + nodes.push(div); $.on($('#save > a', ThemeTools.dialog), 'click', function() { return ThemeTools.save(editTheme); }); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); + $.add(themeContent, nodes); $.add(d.body, ThemeTools.dialog); return Style.themeCSS.textContent = Style.theme(editTheme); }, @@ -13694,19 +13689,20 @@ for (_i = 0, _len = keys.length; _i < _len; _i++) { name = keys[_i]; theme = Themes[name]; - if (!theme["Deleted"]) { - div = $.el('div', { - className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), - id: name, - innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594 >>edit >>export >>delete
>>27582902
Post content is right here.

Selected

" - }); - div.style.backgroundColor = theme['Background Color']; - $.on($('a.edit', div), 'click', cb.edit); - $.on($('a.export', div), 'click', cb["export"]); - $.on($('a.delete', div), 'click', cb["delete"]); - $.on(div, 'click', cb.select); - $.add(suboptions, div); + if (theme["Deleted"]) { + continue; } + div = $.el('div', { + className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), + id: name, + innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594 >>edit >>export >>delete
>>27582902
Post content is right here.

Selected

" + }); + div.style.backgroundColor = theme['Background Color']; + $.on($('a.edit', div), 'click', cb.edit); + $.on($('a.export', div), 'click', cb["export"]); + $.on($('a.delete', div), 'click', cb["delete"]); + $.on(div, 'click', cb.select); + $.add(suboptions, div); } div = $.el('div', { id: 'addthemes', @@ -13735,30 +13731,43 @@ return this.nextSibling.click(); }); $.on($('#tUndelete', div), 'click', function() { + var themes; + $.rm($.id("themeContainer")); - return Settings.openSection(themes, 'undelete'); + themes = { + open: Settings.themes, + hyphenatedTitle: 'themes' + }; + return Settings.openSection.apply(themes, ['undelete']); }); } else { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { name = keys[_j]; theme = Themes[name]; - if (theme["Deleted"]) { - div = $.el('div', { - id: name, - className: theme, - innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594
>>27582902
I forgive you for using VLC to open me. ;__;
" - }); - $.on(div, 'click', cb.restore); - $.add(suboptions, div); + if (!theme["Deleted"]) { + continue; } + div = $.el('div', { + id: name, + className: theme, + innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594
>>27582902
I forgive you for using VLC to open me. ;__;
" + }); + $.on(div, 'click', cb.restore); + $.add(suboptions, div); } div = $.el('div', { id: 'addthemes', innerHTML: "Return" }); $.on($('a', div), 'click', function() { + var themes; + + themes = { + open: Settings.themes, + hyphenatedTitle: 'themes' + }; $.rm($.id("themeContainer")); - return Settings.openSection(themes); + return Settings.openSection.call(themes); }); } $.add(parentdiv, suboptions); @@ -13890,12 +13899,17 @@ return MascotTools.importMascot(e); }); $.on($('#undelete', batchmascots), 'click', function() { + var mascots; + if (!(Conf["Deleted Mascots"].length > 0)) { alert("No mascots have been deleted."); return; } - $.rm($.id("mascotContainer")); - return Settings.mascotTab.dialog(Settings.el, 'undelete'); + mascots = { + open: Settings.mascots, + hyphenatedTitle: 'mascots' + }; + return Settings.openSection.apply(mascots, ['restore']); }); } else { categories = $.el("div", { @@ -13922,8 +13936,13 @@ innerHTML: "Return" }); $.on($('#return', batchmascots), 'click', function() { - $.rm($.id("mascotContainer")); - return Settings.section('mascots'); + var mascots; + + mascots = { + open: Settings.mascots, + hyphenatedTitle: 'mascots' + }; + return Settings.openSection.apply(mascots); }); } $.add(parentdiv, [suboptions, batchmascots, mascotHide]); @@ -14055,7 +14074,8 @@ } }, "delete": function(e) { - var container, settheme; + var container, settheme, + _this = this; e.preventDefault(); e.stopPropagation(); @@ -14073,26 +14093,28 @@ } } Themes[this.name]["Deleted"] = true; - return $.get("userThemes", {}, function() { + return $.get("userThemes", {}, function(_arg) { var userThemes; - userThemes = items['userThemes']; - userThemes[this.name] = Themes[this.name]; + userThemes = _arg.userThemes; + userThemes[_this.name] = Themes[_this.name]; $.set('userThemes', userThemes); return $.rm(container); }); } }, restore: function() { + var _this = this; + if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { Themes[this.id]["Deleted"] = false; - return $.get("userThemes", {}, function(item) { + return $.get("userThemes", {}, function(_arg) { var userThemes; - userThemes = item["userThemes"]; - userThemes[this.id] = Themes[this.id]; + userThemes = _arg.userThemes; + userThemes[_this.id] = Themes[_this.id]; $.set('userThemes', userThemes); - return $.rm(this); + return $.rm(_this); }); } } diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 470556724..91561b4a1 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -11327,18 +11327,12 @@ ThemeTools = { 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"; - if (Themes[key]) { + if (key) { editTheme = JSON.parse(JSON.stringify(Themes[key])); - $.get("userThemes", {}, function(items) { - if (items[key]) { - return editTheme["Theme"] = key; - } else { - return editTheme["Theme"] = key += " [custom]"; - } - }); + editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]"; } else { editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])); editTheme["Theme"] = "Untitled"; @@ -11362,7 +11356,8 @@ }); } $.add($("#themebar", ThemeTools.dialog), header); - themecontent = $("#themecontent", ThemeTools.dialog); + themeContent = $("#themecontent", ThemeTools.dialog); + nodes = []; for (_j = 0, _len1 = layout.length; _j < _len1; _j++) { item = layout[_j]; if (!editTheme[item]) { @@ -11437,10 +11432,9 @@ } return editTheme[this.name] = this.value; }); - Style.addStyle(editTheme); - $.add(themecontent, div); + nodes.push(div); } - $.add(themecontent, div); + Style.addStyle(editTheme); if (!editTheme["Custom CSS"]) { editTheme["Custom CSS"] = ""; } @@ -11452,11 +11446,12 @@ editTheme["Custom CSS"] = this.value; return Style.themeCSS.textContent = Style.theme(editTheme); }); - $.add(themecontent, div); + nodes.push(div); $.on($('#save > a', ThemeTools.dialog), 'click', function() { return ThemeTools.save(editTheme); }); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); + $.add(themeContent, nodes); $.add(d.body, ThemeTools.dialog); return Style.themeCSS.textContent = Style.theme(editTheme); }, @@ -13713,19 +13708,20 @@ for (_i = 0, _len = keys.length; _i < _len; _i++) { name = keys[_i]; theme = Themes[name]; - if (!theme["Deleted"]) { - div = $.el('div', { - className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), - id: name, - innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594 >>edit >>export >>delete
>>27582902
Post content is right here.

Selected

" - }); - div.style.backgroundColor = theme['Background Color']; - $.on($('a.edit', div), 'click', cb.edit); - $.on($('a.export', div), 'click', cb["export"]); - $.on($('a.delete', div), 'click', cb["delete"]); - $.on(div, 'click', cb.select); - $.add(suboptions, div); + if (theme["Deleted"]) { + continue; } + div = $.el('div', { + className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), + id: name, + innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594 >>edit >>export >>delete
>>27582902
Post content is right here.

Selected

" + }); + div.style.backgroundColor = theme['Background Color']; + $.on($('a.edit', div), 'click', cb.edit); + $.on($('a.export', div), 'click', cb["export"]); + $.on($('a.delete', div), 'click', cb["delete"]); + $.on(div, 'click', cb.select); + $.add(suboptions, div); } div = $.el('div', { id: 'addthemes', @@ -13754,30 +13750,43 @@ return this.nextSibling.click(); }); $.on($('#tUndelete', div), 'click', function() { + var themes; + $.rm($.id("themeContainer")); - return Settings.openSection(themes, 'undelete'); + themes = { + open: Settings.themes, + hyphenatedTitle: 'themes' + }; + return Settings.openSection.apply(themes, ['undelete']); }); } else { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { name = keys[_j]; theme = Themes[name]; - if (theme["Deleted"]) { - div = $.el('div', { - id: name, - className: theme, - innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594
>>27582902
I forgive you for using VLC to open me. ;__;
" - }); - $.on(div, 'click', cb.restore); - $.add(suboptions, div); + if (!theme["Deleted"]) { + continue; } + div = $.el('div', { + id: name, + className: theme, + innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594
>>27582902
I forgive you for using VLC to open me. ;__;
" + }); + $.on(div, 'click', cb.restore); + $.add(suboptions, div); } div = $.el('div', { id: 'addthemes', innerHTML: "Return" }); $.on($('a', div), 'click', function() { + var themes; + + themes = { + open: Settings.themes, + hyphenatedTitle: 'themes' + }; $.rm($.id("themeContainer")); - return Settings.openSection(themes); + return Settings.openSection.call(themes); }); } $.add(parentdiv, suboptions); @@ -13909,12 +13918,17 @@ return MascotTools.importMascot(e); }); $.on($('#undelete', batchmascots), 'click', function() { + var mascots; + if (!(Conf["Deleted Mascots"].length > 0)) { alert("No mascots have been deleted."); return; } - $.rm($.id("mascotContainer")); - return Settings.mascotTab.dialog(Settings.el, 'undelete'); + mascots = { + open: Settings.mascots, + hyphenatedTitle: 'mascots' + }; + return Settings.openSection.apply(mascots, ['restore']); }); } else { categories = $.el("div", { @@ -13941,8 +13955,13 @@ innerHTML: "Return" }); $.on($('#return', batchmascots), 'click', function() { - $.rm($.id("mascotContainer")); - return Settings.section('mascots'); + var mascots; + + mascots = { + open: Settings.mascots, + hyphenatedTitle: 'mascots' + }; + return Settings.openSection.apply(mascots); }); } $.add(parentdiv, [suboptions, batchmascots, mascotHide]); @@ -14074,7 +14093,8 @@ } }, "delete": function(e) { - var container, settheme; + var container, settheme, + _this = this; e.preventDefault(); e.stopPropagation(); @@ -14092,26 +14112,28 @@ } } Themes[this.name]["Deleted"] = true; - return $.get("userThemes", {}, function() { + return $.get("userThemes", {}, function(_arg) { var userThemes; - userThemes = items['userThemes']; - userThemes[this.name] = Themes[this.name]; + userThemes = _arg.userThemes; + userThemes[_this.name] = Themes[_this.name]; $.set('userThemes', userThemes); return $.rm(container); }); } }, restore: function() { + var _this = this; + if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { Themes[this.id]["Deleted"] = false; - return $.get("userThemes", {}, function(item) { + return $.get("userThemes", {}, function(_arg) { var userThemes; - userThemes = item["userThemes"]; - userThemes[this.id] = Themes[this.id]; + userThemes = _arg.userThemes; + userThemes[_this.id] = Themes[_this.id]; $.set('userThemes', userThemes); - return $.rm(this); + return $.rm(_this); }); } } diff --git a/builds/crx.crx b/builds/crx.crx index 257f6fc37..17ff1d2e6 100644 Binary files a/builds/crx.crx and b/builds/crx.crx differ diff --git a/builds/crx/script.js b/builds/crx/script.js index 864054091..e5343c659 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -11310,18 +11310,12 @@ ThemeTools = { 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"; - if (Themes[key]) { + if (key) { editTheme = JSON.parse(JSON.stringify(Themes[key])); - $.get("userThemes", {}, function(items) { - if (items[key]) { - return editTheme["Theme"] = key; - } else { - return editTheme["Theme"] = key += " [custom]"; - } - }); + editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]"; } else { editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])); editTheme["Theme"] = "Untitled"; @@ -11345,7 +11339,8 @@ }); } $.add($("#themebar", ThemeTools.dialog), header); - themecontent = $("#themecontent", ThemeTools.dialog); + themeContent = $("#themecontent", ThemeTools.dialog); + nodes = []; for (_j = 0, _len1 = layout.length; _j < _len1; _j++) { item = layout[_j]; if (!editTheme[item]) { @@ -11420,10 +11415,9 @@ } return editTheme[this.name] = this.value; }); - Style.addStyle(editTheme); - $.add(themecontent, div); + nodes.push(div); } - $.add(themecontent, div); + Style.addStyle(editTheme); if (!editTheme["Custom CSS"]) { editTheme["Custom CSS"] = ""; } @@ -11435,11 +11429,12 @@ editTheme["Custom CSS"] = this.value; return Style.themeCSS.textContent = Style.theme(editTheme); }); - $.add(themecontent, div); + nodes.push(div); $.on($('#save > a', ThemeTools.dialog), 'click', function() { return ThemeTools.save(editTheme); }); $.on($('#close > a', ThemeTools.dialog), 'click', ThemeTools.close); + $.add(themeContent, nodes); $.add(d.body, ThemeTools.dialog); return Style.themeCSS.textContent = Style.theme(editTheme); }, @@ -13698,19 +13693,20 @@ for (_i = 0, _len = keys.length; _i < _len; _i++) { name = keys[_i]; theme = Themes[name]; - if (!theme["Deleted"]) { - div = $.el('div', { - className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), - id: name, - innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594 >>edit >>export >>delete
>>27582902
Post content is right here.

Selected

" - }); - div.style.backgroundColor = theme['Background Color']; - $.on($('a.edit', div), 'click', cb.edit); - $.on($('a.export', div), 'click', cb["export"]); - $.on($('a.delete', div), 'click', cb["delete"]); - $.on(div, 'click', cb.select); - $.add(suboptions, div); + if (theme["Deleted"]) { + continue; } + div = $.el('div', { + className: "theme " + (name === Conf['theme'] ? 'selectedtheme' : ''), + id: name, + innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594 >>edit >>export >>delete
>>27582902
Post content is right here.

Selected

" + }); + div.style.backgroundColor = theme['Background Color']; + $.on($('a.edit', div), 'click', cb.edit); + $.on($('a.export', div), 'click', cb["export"]); + $.on($('a.delete', div), 'click', cb["delete"]); + $.on(div, 'click', cb.select); + $.add(suboptions, div); } div = $.el('div', { id: 'addthemes', @@ -13739,30 +13735,43 @@ return this.nextSibling.click(); }); $.on($('#tUndelete', div), 'click', function() { + var themes; + $.rm($.id("themeContainer")); - return Settings.openSection(themes, 'undelete'); + themes = { + open: Settings.themes, + hyphenatedTitle: 'themes' + }; + return Settings.openSection.apply(themes, ['undelete']); }); } else { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { name = keys[_j]; theme = Themes[name]; - if (theme["Deleted"]) { - div = $.el('div', { - id: name, - className: theme, - innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594
>>27582902
I forgive you for using VLC to open me. ;__;
" - }); - $.on(div, 'click', cb.restore); - $.add(suboptions, div); + if (!theme["Deleted"]) { + continue; } + div = $.el('div', { + id: name, + className: theme, + innerHTML: "
" + name + " " + theme['Author'] + " (SAGE) " + theme['Author Tripcode'] + " No.27583594
>>27582902
I forgive you for using VLC to open me. ;__;
" + }); + $.on(div, 'click', cb.restore); + $.add(suboptions, div); } div = $.el('div', { id: 'addthemes', innerHTML: "Return" }); $.on($('a', div), 'click', function() { + var themes; + + themes = { + open: Settings.themes, + hyphenatedTitle: 'themes' + }; $.rm($.id("themeContainer")); - return Settings.openSection(themes); + return Settings.openSection.call(themes); }); } $.add(parentdiv, suboptions); @@ -13894,12 +13903,17 @@ return MascotTools.importMascot(e); }); $.on($('#undelete', batchmascots), 'click', function() { + var mascots; + if (!(Conf["Deleted Mascots"].length > 0)) { alert("No mascots have been deleted."); return; } - $.rm($.id("mascotContainer")); - return Settings.mascotTab.dialog(Settings.el, 'undelete'); + mascots = { + open: Settings.mascots, + hyphenatedTitle: 'mascots' + }; + return Settings.openSection.apply(mascots, ['restore']); }); } else { categories = $.el("div", { @@ -13926,8 +13940,13 @@ innerHTML: "Return" }); $.on($('#return', batchmascots), 'click', function() { - $.rm($.id("mascotContainer")); - return Settings.section('mascots'); + var mascots; + + mascots = { + open: Settings.mascots, + hyphenatedTitle: 'mascots' + }; + return Settings.openSection.apply(mascots); }); } $.add(parentdiv, [suboptions, batchmascots, mascotHide]); @@ -14059,7 +14078,8 @@ } }, "delete": function(e) { - var container, settheme; + var container, settheme, + _this = this; e.preventDefault(); e.stopPropagation(); @@ -14077,26 +14097,28 @@ } } Themes[this.name]["Deleted"] = true; - return $.get("userThemes", {}, function() { + return $.get("userThemes", {}, function(_arg) { var userThemes; - userThemes = items['userThemes']; - userThemes[this.name] = Themes[this.name]; + userThemes = _arg.userThemes; + userThemes[_this.name] = Themes[_this.name]; $.set('userThemes', userThemes); return $.rm(container); }); } }, restore: function() { + var _this = this; + if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { Themes[this.id]["Deleted"] = false; - return $.get("userThemes", {}, function(item) { + return $.get("userThemes", {}, function(_arg) { var userThemes; - userThemes = item["userThemes"]; - userThemes[this.id] = Themes[this.id]; + userThemes = _arg.userThemes; + userThemes[_this.id] = Themes[_this.id]; $.set('userThemes', userThemes); - return $.rm(this); + return $.rm(_this); }); } } diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 5efba17b6..e6203514d 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -107,7 +107,7 @@ Settings = hyphenatedTitle = title.toLowerCase().replace /\s+/g, '-' Settings.sections.push {title, hyphenatedTitle, open} - openSection: (mode)-> + openSection: (mode) -> if selected = $ '.tab-selected', Settings.dialog $.rmClass selected, 'tab-selected' $.addClass $(".tab-#{@hyphenatedTitle}", Settings.dialog), 'tab-selected' @@ -549,12 +549,12 @@ Settings = for name in keys theme = Themes[name] - unless theme["Deleted"] + continue if theme["Deleted"] - div = $.el 'div', - className: "theme #{if name is Conf['theme'] then 'selectedtheme' else ''}" - id: name - innerHTML: " + div = $.el 'div', + className: "theme #{if name is Conf['theme'] then 'selectedtheme' else ''}" + id: name + innerHTML: "
@@ -598,14 +598,14 @@ Settings =
" - div.style.backgroundColor = theme['Background Color'] + div.style.backgroundColor = theme['Background Color'] - $.on $('a.edit', div), 'click', cb.edit - $.on $('a.export', div), 'click', cb.export - $.on $('a.delete', div), 'click', cb.delete - $.on div, 'click', cb.select + $.on $('a.edit', div), 'click', cb.edit + $.on $('a.export', div), 'click', cb.export + $.on $('a.delete', div), 'click', cb.delete + $.on div, 'click', cb.select - $.add suboptions, div + $.add suboptions, div div = $.el 'div', id: 'addthemes' @@ -639,19 +639,24 @@ Settings = $.on $('#tUndelete', div), 'click', -> $.rm $.id "themeContainer" - Settings.openSection themes, 'undelete' + + themes = + open: Settings.themes + hyphenatedTitle: 'themes' + + Settings.openSection.apply themes, ['undelete'] else for name in keys theme = Themes[name] - if theme["Deleted"] + continue unless theme["Deleted"] - div = $.el 'div', - id: name - className: theme - innerHTML: " + div = $.el 'div', + id: name + className: theme + innerHTML: "
#{name} @@ -670,17 +675,21 @@ Settings =
" - $.on div, 'click', cb.restore + $.on div, 'click', cb.restore - $.add suboptions, div + $.add suboptions, div div = $.el 'div', id: 'addthemes' innerHTML: "Return" $.on $('a', div), 'click', -> + themes = + open: Settings.themes + hyphenatedTitle: 'themes' + $.rm $.id "themeContainer" - Settings.openSection themes + Settings.openSection.call themes $.add parentdiv, suboptions $.add parentdiv, div @@ -815,8 +824,10 @@ Settings = unless Conf["Deleted Mascots"].length > 0 alert "No mascots have been deleted." return - $.rm $.id "mascotContainer" - Settings.mascotTab.dialog Settings.el, 'undelete' + mascots = + open: Settings.mascots + hyphenatedTitle: 'mascots' + Settings.openSection.apply mascots, ['restore'] else categories = $.el "div", @@ -845,8 +856,10 @@ Settings = innerHTML: "Return" $.on $('#return', batchmascots), 'click', -> - $.rm $.id "mascotContainer" - Settings.section 'mascots' + mascots = + open: Settings.mascots + hyphenatedTitle: 'mascots' + Settings.openSection.apply mascots $.add parentdiv, [suboptions, batchmascots, mascotHide] @@ -973,8 +986,7 @@ Settings = $.set 'theme', Conf['theme'] Themes[@name]["Deleted"] = true - $.get "userThemes", {}, -> - userThemes = items['userThemes'] + $.get "userThemes", {}, ({userThemes}) => userThemes[@name] = Themes[@name] $.set 'userThemes', userThemes $.rm container @@ -982,8 +994,8 @@ Settings = restore: -> if confirm "Are you sure you want to restore \"#{@id}\"?" Themes[@id]["Deleted"] = false - $.get "userThemes", {}, (item) -> - userThemes = item["userThemes"] + + $.get "userThemes", {}, ({userThemes}) => userThemes[@id] = Themes[@id] $.set 'userThemes', userThemes $.rm @ diff --git a/src/Theming/Themes.coffee b/src/Theming/Themes.coffee index a820501f4..04249fb68 100644 --- a/src/Theming/Themes.coffee +++ b/src/Theming/Themes.coffee @@ -6,16 +6,15 @@ ThemeTools = init: (key) -> Conf['editMode'] = "theme" - if Themes[key] + if key editTheme = JSON.parse(JSON.stringify(Themes[key])) - $.get "userThemes", {}, (items) -> - if items[key] - editTheme["Theme"] = key - else - editTheme["Theme"] = key += " [custom]" + editTheme["Theme"] = if Conf['userThemes'][key] + key + else + key += " [custom]" else editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B'])) - editTheme["Theme"] = "Untitled" + editTheme["Theme"] = "Untitled" editTheme["Author"] = "Author" editTheme["Author Tripcode"] = "Unknown" @@ -102,8 +101,10 @@ ThemeTools = $.on input, 'blur', -> editTheme[@name] = @value $.add $("#themebar", ThemeTools.dialog), header - themecontent = $("#themecontent", ThemeTools.dialog) + themeContent = $("#themecontent", ThemeTools.dialog) + nodes = [] + for item in layout unless editTheme[item] editTheme[item] = '' @@ -168,11 +169,9 @@ ThemeTools = editTheme[@name] = @value - Style.addStyle(editTheme) + nodes.push div - $.add themecontent, div - - $.add themecontent, div + Style.addStyle(editTheme) unless editTheme["Custom CSS"] editTheme["Custom CSS"] = "" @@ -185,12 +184,15 @@ ThemeTools = editTheme["Custom CSS"] = @value Style.themeCSS.textContent = Style.theme editTheme - $.add themecontent, div + nodes.push div $.on $('#save > a', ThemeTools.dialog), 'click', -> ThemeTools.save editTheme $.on $('#close > a', ThemeTools.dialog), 'click', ThemeTools.close + + $.add themeContent, nodes + $.add d.body, ThemeTools.dialog Style.themeCSS.textContent = Style.theme editTheme