fix ticket #239 (Ox.Menu / Ox.MainMenu: setKeyboard / setItemKeyboard options are missing)

This commit is contained in:
rolux 2014-05-13 01:47:09 +02:00
parent 56468a9208
commit 2fbc59e713
3 changed files with 30 additions and 7 deletions

View file

@ -255,6 +255,12 @@ Ox.MainMenu = function(options, self) {
return that;
};
that.setItemKeyboard = function(id, keyboard) {
var item = that.getItem(id);
item && item.options({keyboard: keyboard});
return that;
};
/*@
setItemTitle <f> setItemTitle
(id, title) -> <o> set item title

View file

@ -770,6 +770,12 @@ Ox.Menu = function(options, self) {
return that;
};
that.setItemKeyboard = function(id, keyboard) {
var item = that.getItem(id);
item && item.options({keyboard: keyboard});
return that;
};
/*@
setItemTitle <f> setItemTitle
(id, title) -> <o> set item title

View file

@ -53,6 +53,11 @@ Ox.MenuItem = function(options, self) {
disabled: self.options.disabled
});
},
keyboard: function() {
self.options.keyboard = parseKeyboard(self.options.keyboard);
that.$modifiers.html(formatModifiers());
that.$key.html(formatKey());
},
title: function() {
self.options.title = Ox.makeArray(self.options.title);
that.$title.html(self.options.title[0]);
@ -116,11 +121,7 @@ Ox.MenuItem = function(options, self) {
.append(
that.$modifiers = Ox.$('<td>')
.addClass('OxCell OxModifiers')
.html(
self.options.keyboard.modifiers.map(function(modifier) {
return Ox.UI.symbols[modifier];
}).join('')
)
.html(formatModifiers())
)
.append(
that.$key = Ox.$('<td>')
@ -130,11 +131,21 @@ Ox.MenuItem = function(options, self) {
.html(
self.options.items.length
? Ox.UI.symbols.triangle_right
: Ox.UI.symbols[self.options.keyboard.key]
|| self.options.keyboard.key.toUpperCase()
: formatKey()
)
);
function formatKey() {
return Ox.UI.symbols[self.options.keyboard.key]
|| self.options.keyboard.key.toUpperCase();
}
function formatModifiers() {
return self.options.keyboard.modifiers.map(function(modifier) {
return Ox.UI.symbols[modifier];
}).join('');
}
function parseKeyboard(str) {
var modifiers = str.split(' '),
key = modifiers.pop();