Fix "New Theme" button. Close #367

This commit is contained in:
Zixaphir 2013-06-20 21:39:42 -07:00
parent 088f41b956
commit 6ddfc0d5a6
3 changed files with 32 additions and 38 deletions

View File

@ -11675,11 +11675,12 @@
ThemeTools = {
init: function(key) {
var colorInput, div, fileInput, header, input, item, layout, nodes, themeContent, _i, _j, _len, _len1, _ref;
var colorInput, div, fileInput, header, input, item, layout, theme, themeContent, _i, _j, _len, _len1, _ref;
Conf['editMode'] = "theme";
if (key) {
editTheme = JSON.parse(JSON.stringify(Themes[key]));
theme = Themes[key];
if (theme) {
editTheme = JSON.parse(JSON.stringify(theme));
editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
} else {
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
@ -11694,7 +11695,7 @@
innerHTML: "<div id=themebar></div><hr><div id=themecontent></div><div id=save> <a href='javascript:;'>Save</a></div><div id=upload> <a href='javascript:;'>Select Image</a></div><div id=close> <a href='javascript:;'>Close</a></div>"
});
header = $.el("div", {
innerHTML: "<input class='field subject' name='Theme' placeholder='Theme' value='" + key + "'> by<input class='field name' name='Author' placeholder='Author' value='" + editTheme['Author'] + "'><input class='field postertrip' name='Author Tripcode' placeholder='Author Tripcode' value='" + editTheme['Author Tripcode'] + "'>"
innerHTML: "<input class='field subject' name='Theme' placeholder='Theme' value='" + key + "'> by\n<input class='field name' name='Author' placeholder='Author' value='" + editTheme['Author'] + "'>\n<input class='field postertrip' name='Author Tripcode' placeholder='Author Tripcode' value='" + editTheme['Author Tripcode'] + "'>"
});
_ref = $$("input", header);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -11703,9 +11704,8 @@
return editTheme[this.name] = this.value;
});
}
$.add($("#themebar", ThemeTools.dialog), header);
themeContent = $("#themecontent", ThemeTools.dialog);
nodes = [];
$.add($('#themebar', ThemeTools.dialog), header);
themeContent = $('#themecontent', ThemeTools.dialog);
for (_j = 0, _len1 = layout.length; _j < _len1; _j++) {
item = layout[_j];
if (!editTheme[item]) {
@ -11785,7 +11785,7 @@
editTheme[this.name] = this.value;
return Style.addStyle(editTheme);
});
nodes.push(div);
$.add(themeContent, div);
}
Style.addStyle(editTheme);
if (!editTheme["Custom CSS"]) {
@ -11799,12 +11799,11 @@
editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme);
});
nodes.push(div);
$.add(themeContent, 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);
},

View File

@ -11664,11 +11664,12 @@
ThemeTools = {
init: function(key) {
var colorInput, div, fileInput, header, input, item, layout, nodes, themeContent, _i, _j, _len, _len1, _ref;
var colorInput, div, fileInput, header, input, item, layout, theme, themeContent, _i, _j, _len, _len1, _ref;
Conf['editMode'] = "theme";
if (key) {
editTheme = JSON.parse(JSON.stringify(Themes[key]));
theme = Themes[key];
if (theme) {
editTheme = JSON.parse(JSON.stringify(theme));
editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
} else {
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
@ -11683,7 +11684,7 @@
innerHTML: "<div id=themebar></div><hr><div id=themecontent></div><div id=save> <a href='javascript:;'>Save</a></div><div id=upload> <a href='javascript:;'>Select Image</a></div><div id=close> <a href='javascript:;'>Close</a></div>"
});
header = $.el("div", {
innerHTML: "<input class='field subject' name='Theme' placeholder='Theme' value='" + key + "'> by<input class='field name' name='Author' placeholder='Author' value='" + editTheme['Author'] + "'><input class='field postertrip' name='Author Tripcode' placeholder='Author Tripcode' value='" + editTheme['Author Tripcode'] + "'>"
innerHTML: "<input class='field subject' name='Theme' placeholder='Theme' value='" + key + "'> by\n<input class='field name' name='Author' placeholder='Author' value='" + editTheme['Author'] + "'>\n<input class='field postertrip' name='Author Tripcode' placeholder='Author Tripcode' value='" + editTheme['Author Tripcode'] + "'>"
});
_ref = $$("input", header);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -11692,9 +11693,8 @@
return editTheme[this.name] = this.value;
});
}
$.add($("#themebar", ThemeTools.dialog), header);
themeContent = $("#themecontent", ThemeTools.dialog);
nodes = [];
$.add($('#themebar', ThemeTools.dialog), header);
themeContent = $('#themecontent', ThemeTools.dialog);
for (_j = 0, _len1 = layout.length; _j < _len1; _j++) {
item = layout[_j];
if (!editTheme[item]) {
@ -11774,7 +11774,7 @@
editTheme[this.name] = this.value;
return Style.addStyle(editTheme);
});
nodes.push(div);
$.add(themeContent, div);
}
Style.addStyle(editTheme);
if (!editTheme["Custom CSS"]) {
@ -11788,12 +11788,11 @@
editTheme["Custom CSS"] = this.value;
return Style.themeCSS.textContent = Style.theme(editTheme);
});
nodes.push(div);
$.add(themeContent, 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);
},

View File

@ -5,22 +5,21 @@
ThemeTools =
init: (key) ->
Conf['editMode'] = "theme"
theme = Themes[key]
if key
editTheme = JSON.parse(JSON.stringify(Themes[key]))
if theme
editTheme = JSON.parse JSON.stringify theme
editTheme["Theme"] = if Conf['userThemes'][key]
key
else
key += " [custom]"
else
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']))
editTheme["Theme"] = "Untitled"
editTheme["Author"] = "Author"
editTheme = JSON.parse JSON.stringify Themes['Yotsuba B']
editTheme["Theme"] = "Untitled"
editTheme["Author"] = "Author"
editTheme["Author Tripcode"] = "Unknown"
# Objects are not guaranteed to have any type of arrangement, so we use a presorted
# array to generate the layout of of the theme editor.
# (Themes aren't even guaranteed to have any of these values, actually)
# Manual Sort
layout = [
"Background Image"
"Background Attachment"
@ -90,19 +89,18 @@ ThemeTools =
"
header = $.el "div",
innerHTML: "
innerHTML: """
<input class='field subject' name='Theme' placeholder='Theme' value='#{key}'> by
<input class='field name' name='Author' placeholder='Author' value='#{editTheme['Author']}'>
<input class='field postertrip' name='Author Tripcode' placeholder='Author Tripcode' value='#{editTheme['Author Tripcode']}'>"
<input class='field postertrip' name='Author Tripcode' placeholder='Author Tripcode' value='#{editTheme['Author Tripcode']}'>
"""
# Setup inputs that are not generated from the layout variable.
for input in $$("input", header)
$.on input, 'blur', ->
editTheme[@name] = @value
$.add $("#themebar", ThemeTools.dialog), header
themeContent = $("#themecontent", ThemeTools.dialog)
nodes = []
$.add $('#themebar', ThemeTools.dialog), header
themeContent = $ '#themecontent', ThemeTools.dialog
for item in layout
unless editTheme[item]
@ -173,7 +171,7 @@ ThemeTools =
editTheme[@name] = @value
Style.addStyle(editTheme)
nodes.push div
$.add themeContent, div
Style.addStyle(editTheme)
@ -188,15 +186,13 @@ ThemeTools =
editTheme["Custom CSS"] = @value
Style.themeCSS.textContent = Style.theme editTheme
nodes.push div
$.add themeContent, 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