Fix "New Theme" button. Close #367
This commit is contained in:
parent
088f41b956
commit
6ddfc0d5a6
@ -11675,11 +11675,12 @@
|
|||||||
|
|
||||||
ThemeTools = {
|
ThemeTools = {
|
||||||
init: function(key) {
|
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";
|
Conf['editMode'] = "theme";
|
||||||
if (key) {
|
theme = Themes[key];
|
||||||
editTheme = JSON.parse(JSON.stringify(Themes[key]));
|
if (theme) {
|
||||||
|
editTheme = JSON.parse(JSON.stringify(theme));
|
||||||
editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
|
editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
|
||||||
} else {
|
} else {
|
||||||
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
|
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>"
|
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", {
|
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);
|
_ref = $$("input", header);
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
@ -11703,9 +11704,8 @@
|
|||||||
return editTheme[this.name] = this.value;
|
return editTheme[this.name] = this.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$.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]) {
|
||||||
@ -11785,7 +11785,7 @@
|
|||||||
editTheme[this.name] = this.value;
|
editTheme[this.name] = this.value;
|
||||||
return Style.addStyle(editTheme);
|
return Style.addStyle(editTheme);
|
||||||
});
|
});
|
||||||
nodes.push(div);
|
$.add(themeContent, div);
|
||||||
}
|
}
|
||||||
Style.addStyle(editTheme);
|
Style.addStyle(editTheme);
|
||||||
if (!editTheme["Custom CSS"]) {
|
if (!editTheme["Custom CSS"]) {
|
||||||
@ -11799,12 +11799,11 @@
|
|||||||
editTheme["Custom CSS"] = this.value;
|
editTheme["Custom CSS"] = this.value;
|
||||||
return Style.themeCSS.textContent = Style.theme(editTheme);
|
return Style.themeCSS.textContent = Style.theme(editTheme);
|
||||||
});
|
});
|
||||||
nodes.push(div);
|
$.add(themeContent, 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);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -11664,11 +11664,12 @@
|
|||||||
|
|
||||||
ThemeTools = {
|
ThemeTools = {
|
||||||
init: function(key) {
|
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";
|
Conf['editMode'] = "theme";
|
||||||
if (key) {
|
theme = Themes[key];
|
||||||
editTheme = JSON.parse(JSON.stringify(Themes[key]));
|
if (theme) {
|
||||||
|
editTheme = JSON.parse(JSON.stringify(theme));
|
||||||
editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
|
editTheme["Theme"] = Conf['userThemes'][key] ? key : key += " [custom]";
|
||||||
} else {
|
} else {
|
||||||
editTheme = JSON.parse(JSON.stringify(Themes['Yotsuba B']));
|
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>"
|
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", {
|
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);
|
_ref = $$("input", header);
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
@ -11692,9 +11693,8 @@
|
|||||||
return editTheme[this.name] = this.value;
|
return editTheme[this.name] = this.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$.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]) {
|
||||||
@ -11774,7 +11774,7 @@
|
|||||||
editTheme[this.name] = this.value;
|
editTheme[this.name] = this.value;
|
||||||
return Style.addStyle(editTheme);
|
return Style.addStyle(editTheme);
|
||||||
});
|
});
|
||||||
nodes.push(div);
|
$.add(themeContent, div);
|
||||||
}
|
}
|
||||||
Style.addStyle(editTheme);
|
Style.addStyle(editTheme);
|
||||||
if (!editTheme["Custom CSS"]) {
|
if (!editTheme["Custom CSS"]) {
|
||||||
@ -11788,12 +11788,11 @@
|
|||||||
editTheme["Custom CSS"] = this.value;
|
editTheme["Custom CSS"] = this.value;
|
||||||
return Style.themeCSS.textContent = Style.theme(editTheme);
|
return Style.themeCSS.textContent = Style.theme(editTheme);
|
||||||
});
|
});
|
||||||
nodes.push(div);
|
$.add(themeContent, 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);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,22 +5,21 @@
|
|||||||
ThemeTools =
|
ThemeTools =
|
||||||
init: (key) ->
|
init: (key) ->
|
||||||
Conf['editMode'] = "theme"
|
Conf['editMode'] = "theme"
|
||||||
|
theme = Themes[key]
|
||||||
|
|
||||||
if key
|
if theme
|
||||||
editTheme = JSON.parse(JSON.stringify(Themes[key]))
|
editTheme = JSON.parse JSON.stringify theme
|
||||||
editTheme["Theme"] = if Conf['userThemes'][key]
|
editTheme["Theme"] = if Conf['userThemes'][key]
|
||||||
key
|
key
|
||||||
else
|
else
|
||||||
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"
|
||||||
editTheme["Author"] = "Author"
|
editTheme["Author"] = "Author"
|
||||||
editTheme["Author Tripcode"] = "Unknown"
|
editTheme["Author Tripcode"] = "Unknown"
|
||||||
|
|
||||||
# Objects are not guaranteed to have any type of arrangement, so we use a presorted
|
# Manual Sort
|
||||||
# array to generate the layout of of the theme editor.
|
|
||||||
# (Themes aren't even guaranteed to have any of these values, actually)
|
|
||||||
layout = [
|
layout = [
|
||||||
"Background Image"
|
"Background Image"
|
||||||
"Background Attachment"
|
"Background Attachment"
|
||||||
@ -90,19 +89,18 @@ ThemeTools =
|
|||||||
"
|
"
|
||||||
|
|
||||||
header = $.el "div",
|
header = $.el "div",
|
||||||
innerHTML: "
|
innerHTML: """
|
||||||
<input class='field subject' name='Theme' placeholder='Theme' value='#{key}'> by
|
<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 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.
|
# Setup inputs that are not generated from the layout variable.
|
||||||
for input in $$("input", header)
|
for input in $$("input", header)
|
||||||
$.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]
|
||||||
@ -173,7 +171,7 @@ ThemeTools =
|
|||||||
editTheme[@name] = @value
|
editTheme[@name] = @value
|
||||||
Style.addStyle(editTheme)
|
Style.addStyle(editTheme)
|
||||||
|
|
||||||
nodes.push div
|
$.add themeContent, div
|
||||||
|
|
||||||
Style.addStyle(editTheme)
|
Style.addStyle(editTheme)
|
||||||
|
|
||||||
@ -188,15 +186,13 @@ ThemeTools =
|
|||||||
editTheme["Custom CSS"] = @value
|
editTheme["Custom CSS"] = @value
|
||||||
Style.themeCSS.textContent = Style.theme editTheme
|
Style.themeCSS.textContent = Style.theme editTheme
|
||||||
|
|
||||||
nodes.push div
|
$.add themeContent, 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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user