God, what was I doing?
This commit is contained in:
parent
2181553795
commit
d9cab09436
@ -12717,7 +12717,7 @@
|
||||
},
|
||||
categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'],
|
||||
dialog: function(key) {
|
||||
var container, dialog, div, fileInput, input, item, layout, name, option, optionHTML, setting, value, _i, _len, _ref;
|
||||
var container, dialog, div, fileInput, fileRice, imageFn, input, item, layout, name, nameFn, option, optionHTML, saveCheck, saveVal, setting, updateMascot, value, _i, _len, _ref;
|
||||
Conf['editMode'] = 'mascot';
|
||||
if (Mascots[key]) {
|
||||
editMascot = JSON.parse(JSON.stringify(Mascots[key]));
|
||||
@ -12743,6 +12743,38 @@
|
||||
innerHTML: "<div id=mascotcontent><center>\nPROTIP: Shift-Click the Mascot Image field to upload your own images!\n<br><a href='https://github.com/zixaphir/appchan-x/issues/126#issuecomment-14365049'>This may have some caveats.</a></center></div><div id=save><a href='javascript:;'>Save Mascot</a></div><div id=close><a href='javascript:;'>Close</a></div>"
|
||||
});
|
||||
container = $("#mascotcontent", dialog);
|
||||
fileRice = function(e) {
|
||||
if (e.shiftKey) {
|
||||
return this.nextSibling.click();
|
||||
}
|
||||
};
|
||||
updateMascot = function() {
|
||||
return MascotTools.change(editMascot);
|
||||
};
|
||||
saveVal = function() {
|
||||
editMascot[this.name] = this.value;
|
||||
return updateMascot();
|
||||
};
|
||||
imageFn = function() {
|
||||
if (MascotTools.URL === this.value) {
|
||||
return MascotTools.change(editMascot);
|
||||
} else if (MascotTools.URL) {
|
||||
URL.revokeObjectURL(MascotTools.URL);
|
||||
delete MascotTools.URL;
|
||||
}
|
||||
return saveVal.call(this);
|
||||
};
|
||||
nameFn = function() {
|
||||
this.value = this.value.replace(/[^a-z-_0-9]/ig, "_");
|
||||
if ((this.value !== "") && !/^[a-z]/i.test(this.value)) {
|
||||
return alert("Mascot names must start with a letter.");
|
||||
}
|
||||
return saveVal.call(this);
|
||||
};
|
||||
saveCheck = function() {
|
||||
editMascot[this.name] = this.checked ? true : false;
|
||||
return updateMascot();
|
||||
};
|
||||
for (name in layout) {
|
||||
item = layout[name];
|
||||
value = editMascot[name] || (editMascot[name] = item[1]);
|
||||
@ -12752,53 +12784,27 @@
|
||||
input = $('input', div);
|
||||
switch (name) {
|
||||
case 'image':
|
||||
$.on(input, 'blur', function() {
|
||||
if (MascotTools.URL === this.value) {
|
||||
return MascotTools.change(editMascot);
|
||||
} else if (MascotTools.URL) {
|
||||
URL.revokeObjectURL(MascotTools.URL);
|
||||
delete MascotTools.URL;
|
||||
}
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on(input, 'blur', imageFn);
|
||||
fileInput = $.el('input', {
|
||||
type: "file",
|
||||
accept: "image/*",
|
||||
title: "imagefile",
|
||||
hidden: "hidden"
|
||||
});
|
||||
$.on(input, 'click', function(e) {
|
||||
if (e.shiftKey) {
|
||||
return this.nextSibling.click();
|
||||
}
|
||||
});
|
||||
$.on(input, 'click', FileRice);
|
||||
$.on(fileInput, 'change', MascotTools.uploadImage);
|
||||
$.after(input, fileInput);
|
||||
break;
|
||||
case 'name':
|
||||
$.on(input, 'blur', function() {
|
||||
this.value = this.value.replace(/[^a-z-_0-9]/ig, "_");
|
||||
if ((this.value !== "") && !/^[a-z]/i.test(this.value)) {
|
||||
return alert("Mascot names must start with a letter.");
|
||||
}
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on(input, 'blur', nameFn);
|
||||
break;
|
||||
default:
|
||||
$.on(input, 'blur', function() {
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on(input, 'blur', saveVal);
|
||||
}
|
||||
break;
|
||||
case "number":
|
||||
div = this.input(item, name);
|
||||
$.on($('input', div), 'blur', function() {
|
||||
editMascot[this.name] = parseInt(this.value);
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on($('input', div), 'blur', saveVal);
|
||||
break;
|
||||
case "select":
|
||||
optionHTML = "<div class=optionlabel>" + item[0] + "</div><div class=option><select name='" + name + "' value='" + value + "'><br>";
|
||||
@ -12814,20 +12820,14 @@
|
||||
});
|
||||
setting = $("select", div);
|
||||
setting.value = value;
|
||||
$.on($('select', div), 'change', function() {
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on($('select', div), 'change', saveVal);
|
||||
break;
|
||||
case "checkbox":
|
||||
div = $.el("div", {
|
||||
className: "mascotvar",
|
||||
innerHTML: "<label><input type=" + item[2] + " class=field name='" + name + "' " + (value ? 'checked' : void 0) + ">" + item[0] + "</label>"
|
||||
});
|
||||
$.on($('input', div), 'click', function() {
|
||||
editMascot[this.name] = this.checked ? true : false;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on($('input', div), 'click', saveCheck);
|
||||
}
|
||||
$.add(container, div);
|
||||
}
|
||||
|
||||
@ -12722,7 +12722,7 @@
|
||||
},
|
||||
categories: ['Anime', 'Ponies', 'Questionable', 'Silhouette', 'Western'],
|
||||
dialog: function(key) {
|
||||
var container, dialog, div, fileInput, input, item, layout, name, option, optionHTML, setting, value, _i, _len, _ref;
|
||||
var container, dialog, div, fileInput, fileRice, imageFn, input, item, layout, name, nameFn, option, optionHTML, saveCheck, saveVal, setting, updateMascot, value, _i, _len, _ref;
|
||||
Conf['editMode'] = 'mascot';
|
||||
if (Mascots[key]) {
|
||||
editMascot = JSON.parse(JSON.stringify(Mascots[key]));
|
||||
@ -12748,6 +12748,38 @@
|
||||
innerHTML: "<div id=mascotcontent><center>\nPROTIP: Shift-Click the Mascot Image field to upload your own images!\n<br><a href='https://github.com/zixaphir/appchan-x/issues/126#issuecomment-14365049'>This may have some caveats.</a></center></div><div id=save><a href='javascript:;'>Save Mascot</a></div><div id=close><a href='javascript:;'>Close</a></div>"
|
||||
});
|
||||
container = $("#mascotcontent", dialog);
|
||||
fileRice = function(e) {
|
||||
if (e.shiftKey) {
|
||||
return this.nextSibling.click();
|
||||
}
|
||||
};
|
||||
updateMascot = function() {
|
||||
return MascotTools.change(editMascot);
|
||||
};
|
||||
saveVal = function() {
|
||||
editMascot[this.name] = this.value;
|
||||
return updateMascot();
|
||||
};
|
||||
imageFn = function() {
|
||||
if (MascotTools.URL === this.value) {
|
||||
return MascotTools.change(editMascot);
|
||||
} else if (MascotTools.URL) {
|
||||
URL.revokeObjectURL(MascotTools.URL);
|
||||
delete MascotTools.URL;
|
||||
}
|
||||
return saveVal.call(this);
|
||||
};
|
||||
nameFn = function() {
|
||||
this.value = this.value.replace(/[^a-z-_0-9]/ig, "_");
|
||||
if ((this.value !== "") && !/^[a-z]/i.test(this.value)) {
|
||||
return alert("Mascot names must start with a letter.");
|
||||
}
|
||||
return saveVal.call(this);
|
||||
};
|
||||
saveCheck = function() {
|
||||
editMascot[this.name] = this.checked ? true : false;
|
||||
return updateMascot();
|
||||
};
|
||||
for (name in layout) {
|
||||
item = layout[name];
|
||||
value = editMascot[name] || (editMascot[name] = item[1]);
|
||||
@ -12757,53 +12789,27 @@
|
||||
input = $('input', div);
|
||||
switch (name) {
|
||||
case 'image':
|
||||
$.on(input, 'blur', function() {
|
||||
if (MascotTools.URL === this.value) {
|
||||
return MascotTools.change(editMascot);
|
||||
} else if (MascotTools.URL) {
|
||||
URL.revokeObjectURL(MascotTools.URL);
|
||||
delete MascotTools.URL;
|
||||
}
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on(input, 'blur', imageFn);
|
||||
fileInput = $.el('input', {
|
||||
type: "file",
|
||||
accept: "image/*",
|
||||
title: "imagefile",
|
||||
hidden: "hidden"
|
||||
});
|
||||
$.on(input, 'click', function(e) {
|
||||
if (e.shiftKey) {
|
||||
return this.nextSibling.click();
|
||||
}
|
||||
});
|
||||
$.on(input, 'click', FileRice);
|
||||
$.on(fileInput, 'change', MascotTools.uploadImage);
|
||||
$.after(input, fileInput);
|
||||
break;
|
||||
case 'name':
|
||||
$.on(input, 'blur', function() {
|
||||
this.value = this.value.replace(/[^a-z-_0-9]/ig, "_");
|
||||
if ((this.value !== "") && !/^[a-z]/i.test(this.value)) {
|
||||
return alert("Mascot names must start with a letter.");
|
||||
}
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on(input, 'blur', nameFn);
|
||||
break;
|
||||
default:
|
||||
$.on(input, 'blur', function() {
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on(input, 'blur', saveVal);
|
||||
}
|
||||
break;
|
||||
case "number":
|
||||
div = this.input(item, name);
|
||||
$.on($('input', div), 'blur', function() {
|
||||
editMascot[this.name] = parseInt(this.value);
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on($('input', div), 'blur', saveVal);
|
||||
break;
|
||||
case "select":
|
||||
optionHTML = "<div class=optionlabel>" + item[0] + "</div><div class=option><select name='" + name + "' value='" + value + "'><br>";
|
||||
@ -12819,20 +12825,14 @@
|
||||
});
|
||||
setting = $("select", div);
|
||||
setting.value = value;
|
||||
$.on($('select', div), 'change', function() {
|
||||
editMascot[this.name] = this.value;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on($('select', div), 'change', saveVal);
|
||||
break;
|
||||
case "checkbox":
|
||||
div = $.el("div", {
|
||||
className: "mascotvar",
|
||||
innerHTML: "<label><input type=" + item[2] + " class=field name='" + name + "' " + (value ? 'checked' : void 0) + ">" + item[0] + "</label>"
|
||||
});
|
||||
$.on($('input', div), 'click', function() {
|
||||
editMascot[this.name] = this.checked ? true : false;
|
||||
return MascotTools.change(editMascot);
|
||||
});
|
||||
$.on($('input', div), 'click', saveCheck);
|
||||
}
|
||||
$.add(container, div);
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ MascotTools =
|
||||
dialog: (key) ->
|
||||
Conf['editMode'] = 'mascot'
|
||||
if Mascots[key]
|
||||
editMascot = JSON.parse(JSON.stringify(Mascots[key]))
|
||||
editMascot = JSON.parse JSON.stringify Mascots[key]
|
||||
else
|
||||
editMascot = {}
|
||||
editMascot.name = key or ''
|
||||
@ -147,6 +147,35 @@ MascotTools =
|
||||
innerHTML: """<%= grunt.file.read('src/General/html/Features/MascotDialog.html').replace(/>\s+</g, '><').trim() %>"""
|
||||
|
||||
container = $ "#mascotcontent", dialog
|
||||
|
||||
fileRice = (e) ->
|
||||
if e.shiftKey
|
||||
@nextSibling.click()
|
||||
|
||||
updateMascot = ->
|
||||
MascotTools.change editMascot
|
||||
|
||||
saveVal = ->
|
||||
editMascot[@name] = @value
|
||||
updateMascot()
|
||||
|
||||
imageFn = ->
|
||||
if MascotTools.URL is @value
|
||||
return MascotTools.change editMascot
|
||||
else if MascotTools.URL
|
||||
URL.revokeObjectURL MascotTools.URL
|
||||
delete MascotTools.URL
|
||||
saveVal.call @
|
||||
|
||||
nameFn = ->
|
||||
@value = @value.replace /[^a-z-_0-9]/ig, "_"
|
||||
if (@value isnt "") and !/^[a-z]/i.test @value
|
||||
return alert "Mascot names must start with a letter."
|
||||
saveVal.call @
|
||||
|
||||
saveCheck = ->
|
||||
editMascot[@name] = if @checked then true else false
|
||||
updateMascot()
|
||||
|
||||
for name, item of layout
|
||||
value = editMascot[name] or= item[1]
|
||||
@ -159,14 +188,7 @@ MascotTools =
|
||||
|
||||
switch name
|
||||
when 'image'
|
||||
$.on input, 'blur', ->
|
||||
if MascotTools.URL is @value
|
||||
return MascotTools.change editMascot
|
||||
else if MascotTools.URL
|
||||
URL.revokeObjectURL MascotTools.URL
|
||||
delete MascotTools.URL
|
||||
editMascot[@name] = @value
|
||||
MascotTools.change editMascot
|
||||
$.on input, 'blur', imageFn
|
||||
|
||||
fileInput = $.el 'input',
|
||||
type: "file"
|
||||
@ -174,32 +196,21 @@ MascotTools =
|
||||
title: "imagefile"
|
||||
hidden: "hidden"
|
||||
|
||||
$.on input, 'click', (e) ->
|
||||
if e.shiftKey
|
||||
@nextSibling.click()
|
||||
$.on input, 'click', FileRice
|
||||
|
||||
$.on fileInput, 'change', MascotTools.uploadImage
|
||||
|
||||
$.after input, fileInput
|
||||
|
||||
when 'name'
|
||||
$.on input, 'blur', ->
|
||||
@value = @value.replace /[^a-z-_0-9]/ig, "_"
|
||||
if (@value isnt "") and !/^[a-z]/i.test @value
|
||||
return alert "Mascot names must start with a letter."
|
||||
editMascot[@name] = @value
|
||||
MascotTools.change editMascot
|
||||
$.on input, 'blur', nameFn
|
||||
|
||||
else
|
||||
$.on input, 'blur', ->
|
||||
editMascot[@name] = @value
|
||||
MascotTools.change editMascot
|
||||
$.on input, 'blur', saveVal
|
||||
|
||||
when "number"
|
||||
div = @input item, name
|
||||
$.on $('input', div), 'blur', ->
|
||||
editMascot[@name] = parseInt @value
|
||||
MascotTools.change editMascot
|
||||
$.on $('input', div), 'blur', saveVal
|
||||
|
||||
when "select"
|
||||
optionHTML = "<div class=optionlabel>#{item[0]}</div><div class=option><select name='#{name}' value='#{value}'><br>"
|
||||
@ -212,17 +223,13 @@ MascotTools =
|
||||
setting = $ "select", div
|
||||
setting.value = value
|
||||
|
||||
$.on $('select', div), 'change', ->
|
||||
editMascot[@name] = @value
|
||||
MascotTools.change editMascot
|
||||
$.on $('select', div), 'change', saveVal
|
||||
|
||||
when "checkbox"
|
||||
div = $.el "div",
|
||||
className: "mascotvar"
|
||||
innerHTML: "<label><input type=#{item[2]} class=field name='#{name}' #{if value then 'checked'}>#{item[0]}</label>"
|
||||
$.on $('input', div), 'click', ->
|
||||
editMascot[@name] = if @checked then true else false
|
||||
MascotTools.change editMascot
|
||||
$.on $('input', div), 'click', saveCheck
|
||||
|
||||
$.add container, div
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user