small fixes to keymaps

pull/85/head
Ruben Daniels 2015-04-13 21:13:13 +00:00 zatwierdzone przez Ruben Daniels
rodzic 82a31c8150
commit 56656a9c2c
2 zmienionych plików z 24 dodań i 10 usunięć

Wyświetl plik

@ -350,9 +350,12 @@ define(function(require, exports, module) {
// Add key // Add key
commands.bindKey(lastKey, commands.commands[name]); commands.bindKey(lastKey, commands.commands[name]);
var keys = {};
keys[commands.platform] = (node.actualKeys || node.keys).split("|");
var n = { var n = {
command: node.name, command: node.name,
keys: (node.actualKeys || node.keys).split("|") keys: keys
}; };
var cmds = settings.getJson("user/key-bindings") || []; var cmds = settings.getJson("user/key-bindings") || [];
@ -389,6 +392,8 @@ define(function(require, exports, module) {
if (!cmd || !cmd.command) if (!cmd || !cmd.command)
return; return;
var keys = cmd.keys; var keys = cmd.keys;
if (typeof keys == "object" && keys[commands.platform])
keys = keys[commands.platform];
if (Array.isArray(keys)) if (Array.isArray(keys))
keys = keys.join("|"); keys = keys.join("|");
if (typeof keys == "string") if (typeof keys == "string")
@ -484,7 +489,7 @@ define(function(require, exports, module) {
}).join(",\n"); }).join(",\n");
if (!keys.length) if (!keys.length)
value += ' // { "command": "nexttab", "keys": ["Ctrl-Tab"] }'; value += ' // { "command": "nexttab", "keys": { win: "Ctrl-Tab", mac: "Cmd-Tab" } }';
value += "\n]"; value += "\n]";
@ -542,8 +547,7 @@ define(function(require, exports, module) {
} }
plugin.form.update([{ plugin.form.update([{
type: "dropdown", id: "kbmode",
name: "kbmode",
items: items items: items
}]) }])
} }

Wyświetl plik

@ -21,6 +21,7 @@ define(function(require, exports, module) {
var maxwidth = options.colmaxwidth || 300; var maxwidth = options.colmaxwidth || 300;
var widths = options.widths || {}; var widths = options.widths || {};
var skins = options.skins || {}; var skins = options.skins || {};
var elements = {};
var container, meta = {}; var container, meta = {};
var debug = location.href.indexOf('menus=1') > -1; var debug = location.href.indexOf('menus=1') > -1;
@ -388,8 +389,10 @@ define(function(require, exports, module) {
}); });
} }
if (options.name) if (options.name) {
node.setAttribute("id", options.name); node.setAttribute("id", options.name);
elements[node.name] = node;
}
ui.insertByIndex(heading.container, node, position, foreign); ui.insertByIndex(heading.container, node, position, foreign);
@ -400,7 +403,7 @@ define(function(require, exports, module) {
function update(items) { function update(items) {
items.forEach(function(item) { items.forEach(function(item) {
var el = plugin.getElement(item.id); var el = elements[item.id];
switch (el.type) { switch (el.type) {
case "dropdown": case "dropdown":
var dropdown = el.lastChild; var dropdown = el.lastChild;
@ -409,10 +412,17 @@ define(function(require, exports, module) {
return "<item value='" + item.value return "<item value='" + item.value
+ "'><![CDATA[" + item.caption + "]]></item>"; + "'><![CDATA[" + item.caption + "]]></item>";
}).join(""); }).join("");
if (data) if (data) {
dropdown.$model.load("<items>" + data + "</items>"); setTimeout(function(){
if (item.value) dropdown.$model.load("<items>" + data + "</items>");
dropdown.setAttribute("value", item.value);
setTimeout(function(){
var value = item.value || dropdown.value;
dropdown.value = -999;
dropdown.setAttribute("value", value);
});
});
}
break; break;
default: default:
if ("value" in item) if ("value" in item)