Adapt skin editor to the new skin module and fix some bugs.
Fix internal blocks being detached from literal blocks after sorting. Fix internal blocks not auto-sized. Fix sorting pointer offset. Code cleanup.
This commit is contained in:
@@ -11,447 +11,445 @@ var cel;
|
|||||||
var clist;
|
var clist;
|
||||||
|
|
||||||
var blocklists = {
|
var blocklists = {
|
||||||
"block.element": ["statement.obj", "statement.comp", "statement.filter", "statement.prop"],
|
"block.element": ["statement.obj", "statement.select"],
|
||||||
"block.filter": ["statement.filter.type", "statement.filter.flag", "statement.filter.flag.n", "statement.filter.prop", "statement.filter.prop.n"],
|
"block.filter": ["statement.filter.type", "statement.filter.exp"],
|
||||||
"block.root": ["statement.select", "statement.define"],
|
"block.object": ["statement.comp", "statement.prop", "statement.filter"],
|
||||||
"block.select": ["statement.select.type", "statement.select.flag", "statement.select.flag.n", "statement.select.prop", "statement.select.prop.n"],
|
"block.root": ["statement.select", "statement.define"],
|
||||||
|
"block.select": ["statement.select.type", "statement.select.exp"],
|
||||||
};
|
};
|
||||||
|
|
||||||
var ilid = 0;
|
var ilid = 0;
|
||||||
var inputlists = {
|
var inputlists = {
|
||||||
"input.comp": ["image", "scale3", "rect", "polysec"],
|
"input.comp": ["image", "polysec", "rect", "scale3", "text"],
|
||||||
"input.type": ["chart", "group", "track", "note"],
|
"input.prop": [
|
||||||
|
"pos", "rot", "scale",
|
||||||
|
"image.fit", "image.frame", "image.transparent",
|
||||||
|
"polysec.body", "polysec.head", "polysec.shape", "polysec.tail",
|
||||||
|
"rect.color",
|
||||||
|
"scale3.border",
|
||||||
|
"sprite.bound", "sprite.opacity", "sprite.pivot", "sprite.scale", "sprite.ui", "sprite.zindex",
|
||||||
|
"text.frames", "text.size", "text.spacing", "text.value",
|
||||||
|
],
|
||||||
|
"input.type": ["chart", "group", "track", "note"],
|
||||||
};
|
};
|
||||||
|
|
||||||
var statementlists = {
|
var statementlists = {
|
||||||
"statement.comp": ["input.comp"],
|
"statement.comp": ["input.comp"],
|
||||||
"statement.define": ["input.ident", "exp"],
|
"statement.define": ["input.ident", "exp"],
|
||||||
"statement.filter": ["block.filter", "block.element"],
|
"statement.filter": ["block.filter", "block.object"],
|
||||||
"statement.filter.flag": ["input.flag"],
|
"statement.filter.exp": ["exp"],
|
||||||
"statement.filter.flag.n": ["input.flag"],
|
"statement.filter.type": ["input.type"],
|
||||||
"statement.filter.prop": ["input.prop", "exp"],
|
"statement.obj": ["block.object"],
|
||||||
"statement.filter.prop.n": ["input.prop", "exp"],
|
"statement.prop": ["input.prop", "exp"],
|
||||||
"statement.filter.type": ["input.type"],
|
"statement.select": ["block.select", "block.element"],
|
||||||
"statement.obj": ["block.element"],
|
"statement.select.exp": ["exp"],
|
||||||
"statement.prop": ["input.prop", "exp"],
|
"statement.select.type": ["input.type"],
|
||||||
"statement.select": ["block.select", "block.element"],
|
|
||||||
"statement.select.flag": ["input.flag"],
|
|
||||||
"statement.select.flag.n": ["input.flag"],
|
|
||||||
"statement.select.prop": ["input.prop", "exp"],
|
|
||||||
"statement.select.prop.n": ["input.prop", "exp"],
|
|
||||||
"statement.select.type": ["input.type"],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function () {
|
||||||
lang = navigator.language.replace("-", "_");
|
lang = navigator.language.replace("-", "_");
|
||||||
if (!messages[lang])
|
if (!messages[lang]) lang = "en_US";
|
||||||
lang = "en_US";
|
|
||||||
|
|
||||||
app = $("#app");
|
app = $("#app");
|
||||||
tv = $("#treeview");
|
tv = $("#treeview");
|
||||||
tree = $("#tree");
|
tree = $("#tree");
|
||||||
app.find("tbr").replaceWith(function() {
|
app.find("tbr").replaceWith(function () {
|
||||||
return msg($(this).text());
|
return msg($(this).text());
|
||||||
});
|
});
|
||||||
addAddButton(tree).on("click", function(event) {
|
addAddButton(tree).on("click", function (event) {
|
||||||
if (clist)
|
if (clist) clist.remove();
|
||||||
clist.remove();
|
});
|
||||||
});
|
tv.on("mousemove", null, null, onMouseMove);
|
||||||
tv.on("mousemove", null, null, onMouseMove);
|
|
||||||
|
|
||||||
$(".tgbtn").on("click", function(event) {
|
$(".tgbtn").on("click", function (event) {
|
||||||
var btn = $(this);
|
var btn = $(this);
|
||||||
btn.toggleClass("tgbtn-active");
|
btn.toggleClass("tgbtn-active");
|
||||||
onToggleButtonClick(btn.attr("id"), btn.hasClass("tgbtn-active"));
|
onToggleButtonClick(btn.attr("id"), btn.hasClass("tgbtn-active"));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
;
|
|
||||||
|
|
||||||
function addAddButton(el) {
|
function addAddButton(el) {
|
||||||
return el.append($("<span></span>").addClass("btn btn-add").text("+").on("click", null, el, onAddButtonClick));
|
return el.append($("<span></span>").addClass("btn btn-add").text("+").on("click", null, el, onAddButtonClick));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAddExpButton(el) {
|
function addAddExpButton(el) {
|
||||||
return el.append($("<span></span>").addClass("btn btn-add").text("+").on("click", null, el, onAddExpButtonClick));
|
return el.append($("<span></span>").addClass("btn btn-add").text("+").on("click", null, el, onAddExpButtonClick));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAddButtonLiteral(el) {
|
function addAddButtonLiteral(el) {
|
||||||
return el.append($("<span></span>").addClass("btn btn-add t-inline").text("+").on("click", null, el, onAddButtonLiteralClick));
|
return el.append($("<span></span>").addClass("btn btn-add t-inline").text("+").on("click", null, el, onAddButtonLiteralClick));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDeleteButton(el) {
|
function addDeleteButton(el) {
|
||||||
return el.append($("<span></span>").addClass("btn btn-delete").text("x").on("click", null, el, onDeleteButtonClick));
|
return el.append($("<span></span>").addClass("btn btn-delete").text("x").on("click", null, el, onDeleteButtonClick));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDeleteButtonLiteral(el) {
|
function addDeleteButtonLiteral(el) {
|
||||||
return el.append($("<span></span>").addClass("btn btn-delete t-inline").text("x").on("click", null, el, onDeleteButtonLiteralClick));
|
return el.append($("<span></span>").addClass("btn btn-delete t-inline").text("x").on("click", null, el, onDeleteButtonLiteralClick));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAddButtonClick(event) {
|
function onAddButtonClick(event) {
|
||||||
cel = el = event.data;
|
cel = el = event.data;
|
||||||
generateAddList(event, blocklists[el.attr("key")]);
|
generateAddList(event, blocklists[el.attr("key")]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAddExpButtonClick(event) {
|
function onAddExpButtonClick(event) {
|
||||||
cel = el = event.data;
|
cel = el = event.data;
|
||||||
generateAddExpList(event);
|
generateAddExpList(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAddButtonLiteralClick(event) {
|
function onAddButtonLiteralClick(event) {
|
||||||
var el = event.data.children(".t-internal");
|
var el = event.data.children(".t-internal");
|
||||||
if (!el.hasClass("t-node"))
|
if (!el.hasClass("t-node"))
|
||||||
el = el.children(".t-node");
|
el = el.children(".t-node");
|
||||||
event.data = el;
|
event.data = el;
|
||||||
onAddButtonClick(event);
|
onAddButtonClick(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDeleteButtonClick(event) {
|
function onDeleteButtonClick(event) {
|
||||||
event.data.remove();
|
var el = event.data.parents(".t-literal").first();
|
||||||
|
event.data.remove();
|
||||||
|
if (el) updateLiteral(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDeleteButtonLiteralClick(event) {
|
function onDeleteButtonLiteralClick(event) {
|
||||||
var el = event.data.parents(".t-literal").first();
|
var el = event.data.parents(".t-literal").first();
|
||||||
fetchInternalStatements(el).eq(parseInt(event.data.attr("target"))).remove();
|
fetchInternalStatements(el).eq(parseInt(event.data.attr("target"))).remove();
|
||||||
updateLiteral(el);
|
updateLiteral(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
var tblist = {
|
var tblist = {
|
||||||
"tb-debug": "mode-debug",
|
"tb-debug": "mode-debug",
|
||||||
"tb-hide-add": "mode-hide-add",
|
"tb-hide-add": "mode-hide-add",
|
||||||
"tb-hide-delete": "mode-hide-delete",
|
"tb-hide-delete": "mode-hide-delete",
|
||||||
"tb-sort": "mode-sort",
|
"tb-sort": "mode-sort",
|
||||||
}
|
}
|
||||||
function onToggleButtonClick(id, state) {
|
function onToggleButtonClick(id, state) {
|
||||||
var cls = tblist[id];
|
var cls = tblist[id];
|
||||||
if (state)
|
if (state) tv.addClass(cls);
|
||||||
tv.addClass(cls);
|
else tv.removeClass(cls);
|
||||||
else
|
if (cls == "mode-sort") {
|
||||||
tv.removeClass(cls);
|
var il = tv.find(".t-input");
|
||||||
if (cls == "mode-sort") {
|
var sl = tv.find(".t-statement").not(".t-inline");
|
||||||
var il = tv.find(".t-input");
|
if (state) {
|
||||||
var sl = tv.find(".t-statement").not(".t-inline");
|
il.each(function (i) {
|
||||||
if (state) {
|
$(il[i]).children("input").attr("disabled", "");
|
||||||
il.each(function(i) {
|
});
|
||||||
$(il[i]).children("input").attr("disabled", "");
|
sl.each(function (i) {
|
||||||
});
|
$(sl[i]).on("click", null, $(sl[i]), onStatementSort);
|
||||||
sl.each(function(i) {
|
});
|
||||||
$(sl[i]).on("click", null, $(sl[i]), onStatementSort);
|
}
|
||||||
});
|
else {
|
||||||
} else {
|
il.each(function (i) {
|
||||||
il.each(function(i) {
|
var el = $(il[i]);
|
||||||
var el = $(il[i]);
|
if (!el.parents(".t-internal").length)
|
||||||
if (!el.parents(".t-internal").length)
|
el.children("input").attr("disabled", null);
|
||||||
el.children("input").attr("disabled", null);
|
});
|
||||||
});
|
sl.each(function (i) {
|
||||||
sl.each(function(i) {
|
$(sl[i]).off("click", null, onStatementSort);
|
||||||
$(sl[i]).off("click", null, onStatementSort);
|
});
|
||||||
});
|
tv.removeClass("state-grabbing");
|
||||||
tv.removeClass("state-grabbing");
|
if (grabbing) {
|
||||||
if (grabbing) {
|
grabbing.removeClass("t-grabbing");
|
||||||
grabbing.removeClass("t-grabbing");
|
grabbing = null;
|
||||||
grabbing = null;
|
grabPointer.remove();
|
||||||
grabPointer.remove();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var grabbing;
|
var grabbing;
|
||||||
var grabPointer;
|
var grabPointer;
|
||||||
function onStatementSort(event) {
|
function onStatementSort(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (grabbing) {
|
if (grabbing) {
|
||||||
var l = grabbing.parent().children(".t-statement");
|
var l = grabbing.parent().children(".t-statement");
|
||||||
var i = getGrabPtrIndex(event.pageY);
|
var i = getGrabPtrIndex(event.pageY + tv.scrollTop() - tv[0].offsetTop);
|
||||||
if (i == l.length)
|
if (i == l.length)
|
||||||
grabbing.insertAfter(l.last());
|
grabbing.insertAfter(l.last());
|
||||||
else
|
else
|
||||||
grabbing.insertBefore(l.eq(i));
|
grabbing.insertBefore(l.eq(i));
|
||||||
tv.removeClass("state-grabbing");
|
tv.removeClass("state-grabbing");
|
||||||
grabbing.removeClass("t-grabbing");
|
grabbing.removeClass("t-grabbing");
|
||||||
updateLiteral(grabbing.parents(".t-literal").first());
|
grabPointer.remove();
|
||||||
grabbing = null;
|
updateLiteral(grabbing.parents(".t-literal").first());
|
||||||
grabPointer.remove();
|
grabbing = null;
|
||||||
} else {
|
}
|
||||||
grabbing = event.data;
|
else {
|
||||||
grabbing.addClass("t-grabbing");
|
grabbing = event.data;
|
||||||
tv.addClass("state-grabbing");
|
grabbing.addClass("t-grabbing");
|
||||||
grabPointer = $("<hr />").addClass("grab-ptr");
|
tv.addClass("state-grabbing");
|
||||||
}
|
grabPointer = $("<hr />").addClass("grab-ptr");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseMove(event) {
|
function onMouseMove(event) {
|
||||||
if (grabbing) {
|
if (grabbing) {
|
||||||
var l = grabbing.parent().children(".t-statement");
|
var l = grabbing.parent().children(".t-statement");
|
||||||
var i = getGrabPtrIndex(event.pageY);
|
var i = getGrabPtrIndex(event.pageY + tv.scrollTop() - tv[0].offsetTop);
|
||||||
if (i == l.length)
|
if (i == l.length)
|
||||||
grabPointer.remove().insertAfter(l.last());
|
grabPointer.remove().insertAfter(l.last());
|
||||||
else
|
else
|
||||||
grabPointer.remove().insertBefore(l.eq(i));
|
grabPointer.remove().insertBefore(l.eq(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGrabPtrIndex(y) {
|
function getGrabPtrIndex(y) {
|
||||||
var l = grabbing.parent().children(".t-statement");
|
var l = grabbing.parent().children(".t-statement");
|
||||||
var tl = l.map(function(i) {
|
var tl = l.map(function (i) {
|
||||||
return l[i].offsetTop - tree.scrollTop() - y;
|
return l[i].offsetTop - y;
|
||||||
}).toArray();
|
}).toArray();
|
||||||
tl.push(l.last()[0].offsetTop + l.last().height() - tree.scrollTop() - y);
|
tl.push(l.last()[0].offsetTop + l.last().height() - y);
|
||||||
return ArrayUtil.binarySearch(tl, 0, function(a, b) {
|
return ArrayUtil.binarySearch(tl, 0, function (a, b) {
|
||||||
return a - b;
|
return a - b;
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateAddList(event, items) {
|
function generateAddList(event, items) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (clist)
|
if (clist) clist.remove();
|
||||||
clist.remove();
|
var ul = $("<ul></ul>").addClass("t-list");
|
||||||
var ul = $("<ul></ul>").addClass("t-list");
|
for (var i in items) {
|
||||||
for (var i in items) {
|
var item = items[i];
|
||||||
var item = items[i];
|
ul.append($("<li></li>").addClass("t-li").attr("key", item).text(msg("list." + item)).on("click", null, item, onAddItemClick));
|
||||||
ul.append($("<li></li>").addClass("t-li").attr("key", item).text(msg("list." + item)).on("click", null, item, onAddItemClick));
|
}
|
||||||
}
|
popup(event, ul);
|
||||||
popup(event, ul);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateAddExpList(event, items) {
|
function generateAddExpList(event, items) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (clist)
|
if (clist) clist.remove();
|
||||||
clist.remove();
|
var ul = $("<ul></ul>").addClass("t-list t-exp-list");
|
||||||
var ul = $("<ul></ul>").addClass("t-list t-exp-list");
|
for (var i in items) {
|
||||||
for (var i in items) {
|
var item = items[i];
|
||||||
var item = items[i];
|
ul.append($("<li></li>").addClass("t-li").attr("key", item).text(msg("list." + item)).on("click", null, item, onAddItemClick));
|
||||||
ul.append($("<li></li>").addClass("t-li").attr("key", item).text(msg("list." + item)).on("click", null, item, onAddItemClick));
|
}
|
||||||
}
|
popup(event, ul);
|
||||||
popup(event, ul);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function popup(event, ul) {
|
function popup(event, ul) {
|
||||||
clist = ul;
|
clist = ul;
|
||||||
app.append(ul);
|
app.append(ul);
|
||||||
var left = event.pageX;
|
var left = event.pageX;
|
||||||
if (left + ul.outerWidth() > window.innerWidth)
|
if (left + ul.outerWidth() > window.innerWidth)
|
||||||
left = Math.max(0, left - ul.outerWidth());
|
left = Math.max(0, left - ul.outerWidth());
|
||||||
var top = event.pageY;
|
var top = event.pageY;
|
||||||
if (top + ul.outerHeight() > window.innerHeight)
|
if (top + ul.outerHeight() > window.innerHeight)
|
||||||
top = Math.max(0, top - ul.outerHeight());
|
top = Math.max(0, top - ul.outerHeight());
|
||||||
ul.css({
|
ul.css({
|
||||||
"left": left,
|
"left": left,
|
||||||
"top": top
|
"top": top
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateInputList(el, key) {
|
function generateInputList(el, key) {
|
||||||
var il = inputlists[key];
|
var il = inputlists[key];
|
||||||
if (!il)
|
if (!il) return;
|
||||||
return;
|
var id = "il-" + ilid.toString();
|
||||||
var id = "il-" + ilid.toString();
|
var dl = $("<datalist></datalist>").attr("id", id);
|
||||||
var dl = $("<datalist></datalist>").attr("id", id);
|
for (var i in il) {
|
||||||
for (var i in il) {
|
var li = il[i];
|
||||||
var li = il[i];
|
dl.append($("<option />").attr({
|
||||||
dl.append($("<option />").attr({
|
"label": msg(key + "." + li),
|
||||||
"label": msg(key + "." + li),
|
"value": li,
|
||||||
"value": li,
|
}));
|
||||||
}));
|
}
|
||||||
}
|
dl.insertAfter(el);
|
||||||
dl.insertAfter(el);
|
el.attr("list", id);
|
||||||
el.attr("list", id);
|
ilid++;
|
||||||
ilid++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAddItemClick(event) {
|
function onAddItemClick(event) {
|
||||||
create(event.data).insertBefore(cel.children(":last"));
|
var nel = create(event.data).insertBefore(cel.children(":last"));
|
||||||
if (cel.parents(".t-node").first().hasClass("t-literal"))
|
if (cel.parents(".t-node").first().hasClass("t-literal"))
|
||||||
updateLiteral(cel.parents(".t-node").first());
|
updateLiteral(cel.parents(".t-node").first());
|
||||||
var il = cel.parents(".t-node").first().find(".t-input");
|
var il = nel.find(".t-input");
|
||||||
il.each(function(i) {
|
il.each(function (i) {
|
||||||
var iel = $(il[i]);
|
var iel = $(il[i]);
|
||||||
Stretchy.resize(iel.children("input")[0]);
|
Stretchy.resize(iel.children("input")[0]);
|
||||||
});
|
});
|
||||||
cel = null;
|
cel = null;
|
||||||
clist.remove();
|
clist.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInputLiteralUpdate(event) {
|
function onInputLiteralUpdate(event) {
|
||||||
var ib = event.data.children("input");
|
var ib = event.data.children("input");
|
||||||
var el = event.data.parents(".t-literal").first();
|
var el = event.data.parents(".t-literal").first();
|
||||||
fetchInternalStatements(el).eq(parseInt(event.data.attr("target"))).children("[pid=\"" + event.data.attr("pid") + "\"]").children("input").val(ib.val());
|
var lel = fetchInternalStatements(el).eq(parseInt(event.data.attr("target"))).children("[pid=\"" + event.data.attr("pid") + "\"]").children("input").val(ib.val());
|
||||||
|
Stretchy.resize(lel[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncLiteral(iel) {
|
function syncLiteral(iel) {
|
||||||
if (iel.attr("target") == -1)
|
if (iel.attr("target") == -1) return;
|
||||||
return;
|
var ib = iel.children("input");
|
||||||
var ib = iel.children("input");
|
var el = iel.parents(".t-literal").first();
|
||||||
var el = iel.parents(".t-literal").first();
|
ib.val(fetchInternalStatements(el).eq(parseInt(iel.attr("target"))).children("[pid=\"" + iel.attr("pid") + "\"]").children("input").val());
|
||||||
ib.val(fetchInternalStatements(el).eq(parseInt(iel.attr("target"))).children("[pid=\"" + iel.attr("pid") + "\"]").children("input").val());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchInternalStatements(el, key) {
|
function fetchInternalStatements(el, key) {
|
||||||
var l = el.children(".t-internal");
|
var l = el.children(".t-internal");
|
||||||
if (!l.hasClass("t-node"))
|
if (!l.hasClass("t-node"))
|
||||||
l = l.children(".t-node").first();
|
l = l.children(".t-node").first();
|
||||||
if (key)
|
if (key)
|
||||||
return l.children("[key=\"" + key + "\"]");
|
return l.children("[key=\"" + key + "\"]");
|
||||||
else
|
else
|
||||||
return l.children();
|
return l.children();
|
||||||
}
|
}
|
||||||
|
|
||||||
function create(key, target) {
|
function create(key, target) {
|
||||||
var k0 = key.split(".")[0];
|
var k0 = key.split(".")[0];
|
||||||
var flag = msg("literal." + key);
|
var flag = msg("literal." + key);
|
||||||
if (k0 == "input")
|
if (k0 == "input") flag = true;
|
||||||
flag = true;
|
if (target != null && literal && flag)
|
||||||
if (target != null && literal && flag)
|
switch (k0) {
|
||||||
switch (k0) {
|
case "block":
|
||||||
case "block":
|
return createBlockLiteral(key, target);
|
||||||
return createBlockLiteral(key, target);
|
case "input":
|
||||||
case "input":
|
return createInput(key, target);
|
||||||
return createInput(key, target);
|
case "statement":
|
||||||
case "statement":
|
return createStatementLiteral(key, target);
|
||||||
return createStatementLiteral(key, target);
|
}
|
||||||
}
|
else
|
||||||
else
|
switch (k0) {
|
||||||
switch (k0) {
|
case "block":
|
||||||
case "block":
|
return createBlock(key);
|
||||||
return createBlock(key);
|
case "statement":
|
||||||
case "statement":
|
return createStatement(key);
|
||||||
return createStatement(key);
|
case "exp":
|
||||||
case "exp":
|
return createExp(key);
|
||||||
return createExp(key);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBlock(key) {
|
function createBlock(key) {
|
||||||
var m = msg(key);
|
var m = msg(key);
|
||||||
var b = addAddButton($("<div></div>").attr("key", key).addClass("t-node t-block"));
|
var b = addAddButton($("<div></div>").attr("key", key).addClass("t-node t-block"));
|
||||||
if (!m)
|
if (!m) return b;
|
||||||
return b;
|
else {
|
||||||
else {
|
var n = $("<div></div>").addClass("t-node-sup t-block-sup").html(m);
|
||||||
var n = $("<div></div>").addClass("t-node-sup t-block-sup").html(m);
|
n.children("tbr").replaceWith(b);
|
||||||
n.children("tbr").replaceWith(b);
|
return n;
|
||||||
return n;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBlockLiteral(key, target) {
|
function createBlockLiteral(key, target) {
|
||||||
var o = createBlock(key).addClass("t-internal");
|
var o = createBlock(key).addClass("t-internal");
|
||||||
var el = $("<div></div>").attr({
|
var el = $("<div></div>").attr({
|
||||||
"key": key,
|
"key": key,
|
||||||
"target": target.index()
|
"target": target.index()
|
||||||
}).addClass("t-node t-literal");
|
}).addClass("t-node t-literal");
|
||||||
el.append(o);
|
el.append(o);
|
||||||
updateLiteral(el);
|
updateLiteral(el);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createExp(key) {
|
function createExp(key) {
|
||||||
var m = msg(key);
|
var m = msg(key);
|
||||||
var el = addAddExpButton($("<div></div>").attr("key", key).addClass("t-node t-exp t-inline").html(m));
|
var el = addAddExpButton($("<div></div>").attr("key", key).addClass("t-node t-exp t-inline").html(m));
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createInput(key, target) {
|
function createInput(key, target) {
|
||||||
var el = $("<input />").attr({
|
var el = $("<input />").attr({
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholder": msg(key + ".default")
|
"placeholder": msg(key + ".default")
|
||||||
});
|
});
|
||||||
var r = $("<span></span>").attr({
|
var r = $("<span></span>").attr({
|
||||||
"key": key,
|
"key": key,
|
||||||
"target": target.index()
|
"target": target.index()
|
||||||
}).addClass("t-node t-input t-inline").append(el);
|
}).addClass("t-node t-input t-inline").append(el);
|
||||||
generateInputList(el, key);
|
generateInputList(el, key);
|
||||||
applyResizeHandler(el);
|
applyResizeHandler(el);
|
||||||
el.on("change input", null, r, onInputLiteralUpdate);
|
el.on("change input", null, r, onInputLiteralUpdate);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createStatement(key) {
|
function createStatement(key) {
|
||||||
var r = msg(key);
|
var r = msg(key);
|
||||||
var el = addDeleteButton($("<div></div>").attr("key", key).addClass("t-node t-statement").html(r));
|
var el = addDeleteButton($("<div></div>").attr("key", key).addClass("t-node t-statement").html(r));
|
||||||
el.children("tbr").replaceWith(function() {
|
el.children("tbr").replaceWith(function () {
|
||||||
var m = $(this).text();
|
var m = $(this).text();
|
||||||
var id = parseInt(m);
|
var id = parseInt(m);
|
||||||
if (isNaN(id))
|
if (isNaN(id))
|
||||||
return create(m, $(this).parent());
|
return create(m, $(this).parent());
|
||||||
else
|
else
|
||||||
return create(statementlists[key][id], $(this).parent()).attr("pid", id);
|
return create(statementlists[key][id], $(this).parent()).attr("pid", id);
|
||||||
});
|
});
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createStatementLiteral(key, target) {
|
function createStatementLiteral(key, target) {
|
||||||
var r = msg("literal." + key);
|
var r = msg("literal." + key);
|
||||||
var el = addDeleteButtonLiteral($("<div></div>").attr({
|
var el = addDeleteButtonLiteral($("<div></div>").attr({
|
||||||
"key": key,
|
"key": key,
|
||||||
"target": target.index()
|
"target": target.index()
|
||||||
}).addClass("t-node t-statement t-inline").html(r));
|
}).addClass("t-node t-statement t-inline").html(r));
|
||||||
el.children("tbr").replaceWith(function() {
|
el.children("tbr").replaceWith(function () {
|
||||||
var m = $(this).text();
|
var m = $(this).text();
|
||||||
var id = parseInt(m);
|
var id = parseInt(m);
|
||||||
if (isNaN(id))
|
if (isNaN(id))
|
||||||
return create(m, target);
|
return create(m, target);
|
||||||
else
|
else
|
||||||
return create(statementlists[key][id], target).attr("pid", id);
|
return create(statementlists[key][id], target).attr("pid", id);
|
||||||
});
|
});
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyResizeHandler(el) {
|
function applyResizeHandler(el) {
|
||||||
el.on("change input", function() {
|
el.on("change input", function () {
|
||||||
Stretchy.resize(this);
|
Stretchy.resize(this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLiteral(el) {
|
function updateLiteral(el) {
|
||||||
var key = el.attr("key");
|
var key = el.attr("key");
|
||||||
var m = msg("literal." + key);
|
var m = msg("literal." + key);
|
||||||
var o = el.children(".t-internal");
|
var o = el.children(".t-internal");
|
||||||
tv.append(o); // Stashes the supplement blocks to prevent the event listeners from being detached
|
tv.append(o); // Stashes the supplement blocks to prevent the event listeners from being detached
|
||||||
addAddButtonLiteral(el.html(m));
|
addAddButtonLiteral(el.html(m));
|
||||||
el.append(o); // Restores the blocks
|
el.append(o); // Restores the blocks
|
||||||
el.children("tbr").replaceWith(function() {
|
el.children("tbr").replaceWith(function () {
|
||||||
var m = $(this).text().split("?");
|
var m = $(this).text().split("?");
|
||||||
var def;
|
var def;
|
||||||
if (m.length > 1) {
|
if (m.length > 1) {
|
||||||
def = m[1];
|
def = m[1];
|
||||||
m = m[0];
|
m = m[0];
|
||||||
} else
|
}
|
||||||
m = m[0];
|
else
|
||||||
var l = fetchInternalStatements(el, m);
|
m = m[0];
|
||||||
var s = l.map(function(si) {
|
var l = fetchInternalStatements(el, m);
|
||||||
return create(m, l.eq(si));
|
var s = l.map(function (si) {
|
||||||
});
|
return create(m, l.eq(si));
|
||||||
return conjAnd(s, def);
|
});
|
||||||
});
|
return conjAnd(s, def);
|
||||||
var il = el.find(".t-input");
|
});
|
||||||
il.each(function(i) {
|
var il = el.find(".t-input");
|
||||||
var iel = $(il[i]);
|
il.each(function (i) {
|
||||||
if (iel.parents(".t-internal").length || tv.hasClass("mode-sort"))
|
var iel = $(il[i]);
|
||||||
iel.children("input").attr("disabled", "");
|
if (iel.parents(".t-internal").length || tv.hasClass("mode-sort"))
|
||||||
syncLiteral(iel);
|
iel.children("input").attr("disabled", "");
|
||||||
Stretchy.resize(iel.children("input")[0]);
|
syncLiteral(iel);
|
||||||
});
|
Stretchy.resize(iel.children("input")[0]);
|
||||||
var cl = el.contents();
|
});
|
||||||
for (var t in cl) {
|
var cl = el.contents();
|
||||||
var ci = cl[t];
|
for (var t in cl) {
|
||||||
if (ci.nodeName == "#text" && ci.nodeValue == " ") {
|
var ci = cl[t];
|
||||||
ci.remove();
|
if (ci.nodeName == "#text" && ci.nodeValue == " ") {
|
||||||
}
|
ci.remove();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function conjAnd(list, def) {
|
function conjAnd(list, def) {
|
||||||
var el = $("<div></div>").addClass("t-conj t-inline");
|
var el = $("<div></div>").addClass("t-conj t-inline");
|
||||||
for (var i = 0; i < list.length; i++)
|
for (var i = 0; i < list.length; i++)
|
||||||
el.append(list[i]);
|
el.append(list[i]);
|
||||||
if (list.length == 0)
|
if (list.length == 0)
|
||||||
el.text(def);
|
el.text(def);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function msg(key) {
|
function msg(key) {
|
||||||
var m = messages[lang][key];
|
var m = messages[lang][key];
|
||||||
if (!m)
|
if (!m) return null;
|
||||||
return null;
|
return m.replace(/{(.*?)}/g, "<tbr>$1</tbr>");
|
||||||
return m.replace(/{(.*?)}/g, "<tbr>$1</tbr>");
|
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,31 @@ messages["en_US"] = {
|
|||||||
"input.comp.polysec": "polygon sectional mesh",
|
"input.comp.polysec": "polygon sectional mesh",
|
||||||
"input.comp.rect": "colored rectangle",
|
"input.comp.rect": "colored rectangle",
|
||||||
"input.comp.scale3": "scale3 sprite",
|
"input.comp.scale3": "scale3 sprite",
|
||||||
|
"input.comp.text": "text",
|
||||||
"input.ident.default": "variable",
|
"input.ident.default": "variable",
|
||||||
"input.flag.default": "flag",
|
|
||||||
"input.prop.default": "property",
|
"input.prop.default": "property",
|
||||||
|
"input.prop.image.fit": "image sprite: scale mode",
|
||||||
|
"input.prop.image.frame": "image sprite: image name",
|
||||||
|
"input.prop.image.transparent": "image sprite: transparent mode",
|
||||||
|
"input.prop.polysec.body": "polygon sectional mesh: body image name",
|
||||||
|
"input.prop.polysec.head": "polygon sectional mesh: head image name",
|
||||||
|
"input.prop.polysec.shape": "polygon sectional mesh: section shape",
|
||||||
|
"input.prop.polysec.tail": "polygon sectional mesh: tail image name",
|
||||||
|
"input.prop.pos": "position",
|
||||||
|
"input.prop.rect.color": "colored rectangle: color",
|
||||||
|
"input.prop.rot": "rotation",
|
||||||
|
"input.prop.scale": "scale",
|
||||||
|
"input.prop.scale3.border": "scale3 sprite: unstretched area ratios",
|
||||||
|
"input.prop.sprite.bound": "sprite: secondary anchor position",
|
||||||
|
"input.prop.sprite.opacity": "sprite: opacity",
|
||||||
|
"input.prop.sprite.pivot": "sprite: anchor",
|
||||||
|
"input.prop.sprite.scale": "sprite: scale",
|
||||||
|
"input.prop.sprite.ui": "sprite: ui mode",
|
||||||
|
"input.prop.sprite.zindex": "sprite: layer order",
|
||||||
|
"input.prop.text.frames": "text: image mapping",
|
||||||
|
"input.prop.text.size": "text: font size",
|
||||||
|
"input.prop.text.spacing": "text: character spacing",
|
||||||
|
"input.prop.text.value": "text: content",
|
||||||
"input.type.chart": "chart",
|
"input.type.chart": "chart",
|
||||||
"input.type.default": "element",
|
"input.type.default": "element",
|
||||||
"input.type.group": "track group",
|
"input.type.group": "track group",
|
||||||
@@ -17,46 +39,28 @@ messages["en_US"] = {
|
|||||||
"list.statement.comp": "Attach a component",
|
"list.statement.comp": "Attach a component",
|
||||||
"list.statement.define": "Define a variable",
|
"list.statement.define": "Define a variable",
|
||||||
"list.statement.filter": "Filter element",
|
"list.statement.filter": "Filter element",
|
||||||
"list.statement.filter.flag": "Filter flag",
|
"list.statement.filter.exp": "Filter expression",
|
||||||
"list.statement.filter.flag.n": "Filter flag (negative)",
|
|
||||||
"list.statement.filter.prop": "Filter property",
|
|
||||||
"list.statement.filter.prop.n": "Filter property (negative)",
|
|
||||||
"list.statement.filter.type": "Filter element type",
|
"list.statement.filter.type": "Filter element type",
|
||||||
"list.statement.obj": "Create a container",
|
"list.statement.obj": "Create a container",
|
||||||
"list.statement.prop": "Set property",
|
"list.statement.prop": "Set property",
|
||||||
"list.statement.select": "Select elements",
|
"list.statement.select": "Select elements",
|
||||||
"list.statement.select.flag": "Filter flag",
|
"list.statement.select.exp": "Filter expression",
|
||||||
"list.statement.select.flag.n": "Filter flag (negative)",
|
|
||||||
"list.statement.select.prop": "Filter property",
|
|
||||||
"list.statement.select.prop.n": "Filter property (negative)",
|
|
||||||
"list.statement.select.type": "Filter element type",
|
"list.statement.select.type": "Filter element type",
|
||||||
"literal.block.filter": "If {statement.filter.flag} {statement.filter.flag.n} {statement.filter.type} {statement.filter.prop} {statement.filter.prop.n}",
|
"literal.block.filter": "If {statement.filter.exp} {statement.filter.type}",
|
||||||
"literal.block.select": "For each {statement.select.flag} {statement.select.flag.n} {statement.select.type?element} {statement.select.prop} {statement.select.prop.n}",
|
"literal.block.select": "For each {statement.select.type?element} {statement.select.exp}",
|
||||||
"literal.statement.filter.flag": "it is {0}",
|
"literal.statement.filter.exp": "{0}",
|
||||||
"literal.statement.filter.flag.n": "it is not {0}",
|
|
||||||
"literal.statement.filter.prop": "its {0} is {1}",
|
|
||||||
"literal.statement.filter.prop.n": "its {0} is not {1}",
|
|
||||||
"literal.statement.filter.type": "it is a {0}",
|
"literal.statement.filter.type": "it is a {0}",
|
||||||
"literal.statement.select.flag": "{0}",
|
"literal.statement.select.exp": "that {0}",
|
||||||
"literal.statement.select.flag.n": "non-{0}",
|
|
||||||
"literal.statement.select.prop": "whose {0} is {1}",
|
|
||||||
"literal.statement.select.prop.n": "whose {0} is not {1}",
|
|
||||||
"literal.statement.select.type": "{0}",
|
"literal.statement.select.type": "{0}",
|
||||||
"statement.comp": "with a {0}",
|
"statement.comp": "with a {0}",
|
||||||
"statement.define": "Define {0} = {1}",
|
"statement.define": "Define {0} = {1}",
|
||||||
"statement.filter": "{0} {1}",
|
"statement.filter": "{0} {1}",
|
||||||
"statement.filter.flag": "it is {0}",
|
"statement.filter.exp": "it matches the expression {0}",
|
||||||
"statement.filter.flag.n": "it is not {0}",
|
|
||||||
"statement.filter.prop": "its {0} is {1}",
|
|
||||||
"statement.filter.prop.n": "its {0} is not {1}",
|
|
||||||
"statement.filter.type": "it is a {0}",
|
"statement.filter.type": "it is a {0}",
|
||||||
"statement.obj": "Create a container {0}",
|
"statement.obj": "Create a container {0}",
|
||||||
"statement.prop": "Set its {0} to {1}",
|
"statement.prop": "Set its {0} to {1}",
|
||||||
"statement.select": "{0} {1}",
|
"statement.select": "{0} {1}",
|
||||||
"statement.select.flag": "that is {0}",
|
"statement.select.exp": "it matches the expression {0}",
|
||||||
"statement.select.flag.n": "that is not {0}",
|
|
||||||
"statement.select.prop": "whose {0} is {1}",
|
|
||||||
"statement.select.prop.n": "whose {0} is not {1}",
|
|
||||||
"statement.select.type": "{0}",
|
"statement.select.type": "{0}",
|
||||||
"tool.debug": "Debug",
|
"tool.debug": "Debug",
|
||||||
"tool.hideadd": "Hide Add",
|
"tool.hideadd": "Hide Add",
|
||||||
|
@@ -1,65 +1,69 @@
|
|||||||
messages["zh_CN"] = {
|
messages["zh_CN"] = {
|
||||||
"block.filter": "如果 {}",
|
"block.filter": "如果 {}",
|
||||||
"block.select": "选择 {}",
|
"block.select": "选择 {}",
|
||||||
"input.comp.default": "组件",
|
"input.comp.default": "组件",
|
||||||
"input.comp.image": "图片元件",
|
"input.comp.image": "图片",
|
||||||
"input.comp.polysec": "多边形截面网格",
|
"input.comp.polysec": "多边形截面网格",
|
||||||
"input.comp.rect": "纯色矩形",
|
"input.comp.rect": "纯色矩形",
|
||||||
"input.comp.scale3": "三段拉伸元件",
|
"input.comp.scale3": "三段拉伸图片",
|
||||||
"input.ident.default": "变量",
|
"input.comp.text": "文字",
|
||||||
"input.flag.default": "标记",
|
"input.ident.default": "变量",
|
||||||
"input.prop.default": "属性",
|
"input.prop.default": "属性",
|
||||||
"input.type.chart": "谱面",
|
"input.prop.image.fit": "图片:缩放模式",
|
||||||
"input.type.default": "元素",
|
"input.prop.image.frame": "图片:图片名",
|
||||||
"input.type.group": "轨道组",
|
"input.prop.image.transparent": "图片:透明模式",
|
||||||
"input.type.note": "音符",
|
"input.prop.polysec.body": "多边形截面网格:中部图片名",
|
||||||
"input.type.track": "轨道",
|
"input.prop.polysec.head": "多边形截面网格:头部图片名",
|
||||||
"list.statement.comp": "附加组件",
|
"input.prop.polysec.shape": "多边形截面网格:截面形状",
|
||||||
"list.statement.define": "定义变量",
|
"input.prop.polysec.tail": "多边形截面网格:尾部图片名",
|
||||||
"list.statement.filter": "筛选元素",
|
"input.prop.pos": "位置",
|
||||||
"list.statement.filter.flag": "筛选标记",
|
"input.prop.rect.color": "纯色矩形:颜色",
|
||||||
"list.statement.filter.flag.n": "筛选标记(否定)",
|
"input.prop.rot": "旋转",
|
||||||
"list.statement.filter.prop": "筛选属性",
|
"input.prop.scale": "缩放",
|
||||||
"list.statement.filter.prop.n": "筛选属性(否定)",
|
"input.prop.scale3.border": "三段拉伸图片:非拉伸区域占比",
|
||||||
"list.statement.filter.type": "筛选元素类型",
|
"input.prop.sprite.bound": "图像:副锚点位置",
|
||||||
"list.statement.obj": "创建容器",
|
"input.prop.sprite.opacity": "图像:不透明度",
|
||||||
"list.statement.prop": "设置属性",
|
"input.prop.sprite.pivot": "图像:锚点",
|
||||||
"list.statement.select": "选择元素",
|
"input.prop.sprite.scale": "图像:缩放",
|
||||||
"list.statement.select.flag": "筛选标记",
|
"input.prop.sprite.ui": "图像:界面模式",
|
||||||
"list.statement.select.flag.n": "筛选标记(否定)",
|
"input.prop.sprite.zindex": "图像:叠加次序",
|
||||||
"list.statement.select.prop": "筛选属性",
|
"input.prop.text.frames": "文字:图片映射",
|
||||||
"list.statement.select.prop.n": "筛选属性(否定)",
|
"input.prop.text.size": "文字:字体大小",
|
||||||
"list.statement.select.type": "筛选元素类型",
|
"input.prop.text.spacing": "文字:字符间距",
|
||||||
"literal.block.filter": "如果 {statement.filter.flag} {statement.filter.flag.n} {statement.filter.type} {statement.filter.prop} {statement.filter.prop.n}",
|
"input.prop.text.value": "文字:内容",
|
||||||
"literal.block.select": "对于每个 {statement.select.prop} {statement.select.prop.n} {statement.select.flag} {statement.select.flag.n} {statement.select.type?元素}",
|
"input.type.chart": "谱面",
|
||||||
"literal.statement.filter.flag": "该元素带有标记 {0}",
|
"input.type.default": "元素",
|
||||||
"literal.statement.filter.flag.n": "该元素不带有标记 {0}",
|
"input.type.group": "轨道组",
|
||||||
"literal.statement.filter.prop": "该元素的 {0} {1}",
|
"input.type.note": "按键",
|
||||||
"literal.statement.filter.prop.n": "该元素的 {0} 不 {1}",
|
"input.type.track": "轨道",
|
||||||
"literal.statement.filter.type": "该元素是 {0}",
|
"list.statement.comp": "附加组件",
|
||||||
"literal.statement.select.flag": "{0}",
|
"list.statement.define": "定义变量",
|
||||||
"literal.statement.select.flag.n": "非{0}",
|
"list.statement.filter": "条件分歧",
|
||||||
"literal.statement.select.prop": "{0} {1} 的",
|
"list.statement.filter.exp": "判断表达式",
|
||||||
"literal.statement.select.prop.n": "{0} 不 {1} 的",
|
"list.statement.filter.type": "判断元素类型",
|
||||||
"literal.statement.select.type": "{0}",
|
"list.statement.obj": "创建容器",
|
||||||
"statement.comp": "创建一个 {0} 组件",
|
"list.statement.prop": "设置属性",
|
||||||
"statement.define": "定义变量 {0} = {1}",
|
"list.statement.select": "选择元素",
|
||||||
"statement.filter": "{0} {1}",
|
"list.statement.select.exp": "筛选表达式",
|
||||||
"statement.filter.flag": "该元素带有标记 {0}",
|
"list.statement.select.type": "筛选元素类型",
|
||||||
"statement.filter.flag.n": "该元素不带有标记 {0}",
|
"literal.block.filter": "如果 {statement.filter.exp} {statement.filter.type}",
|
||||||
"statement.filter.prop": "该元素的 {0} {1}",
|
"literal.block.select": "对于每个 {statement.select.exp} {statement.select.type?元素}",
|
||||||
"statement.filter.prop.n": "该元素的 {0} 不 {1}",
|
"literal.statement.filter.exp": "{0}",
|
||||||
"statement.filter.type": "该元素是 {0}",
|
"literal.statement.filter.type": "元素的类型为 {0}",
|
||||||
"statement.obj": "创建一个容器 {0}",
|
"literal.statement.select.exp": "{0} 的",
|
||||||
"statement.prop": "设置属性 {0} 为 {1}",
|
"literal.statement.select.type": "{0}",
|
||||||
"statement.select": "{0} {1}",
|
"statement.comp": "创建一个 {0} 组件",
|
||||||
"statement.select.flag": "{0}",
|
"statement.define": "定义变量 {0} = {1}",
|
||||||
"statement.select.flag.n": "非{0}",
|
"statement.filter": "{0} {1}",
|
||||||
"statement.select.prop": "{0} {1} 的",
|
"statement.filter.exp": "元素符合表达式 {0}",
|
||||||
"statement.select.prop.n": "{0} 不 {1} 的",
|
"statement.filter.type": "元素的类型为 {0}",
|
||||||
"statement.select.type": "{0}",
|
"statement.obj": "创建一个容器 {0}",
|
||||||
"tool.debug": "调试",
|
"statement.prop": "设置属性 {0} 为 {1}",
|
||||||
"tool.hideadd": "隐藏添加按钮",
|
"statement.select": "{0} {1}",
|
||||||
"tool.hidedelete": "隐藏删除按钮",
|
"statement.select.exp": "元素符合表达式 {0}",
|
||||||
"tool.sort": "排序",
|
"statement.select.type": "元素的类型为 {0}",
|
||||||
|
"tool.debug": "调试",
|
||||||
|
"tool.hideadd": "隐藏添加按钮",
|
||||||
|
"tool.hidedelete": "隐藏删除按钮",
|
||||||
|
"tool.sort": "排序",
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user