prettifies menu option labels

removes "set" adds space before uppercase letters.

focus handling

focus handling
This commit is contained in:
nightwing 2013-04-13 20:52:50 +04:00
commit fb9bc6d3f4
3 changed files with 13 additions and 4 deletions

View file

@ -68,7 +68,7 @@ define(function(require, exports, module) {
* @param {string|number} bottom absolute position value.
* @param {string|number} left absolute position value.
*/
module.exports.overlayPage = function overlayPage (contentElement, top, right, bottom, left) {
module.exports.overlayPage = function overlayPage (editor, contentElement, top, right, bottom, left) {
top = (top) ? 'top: ' + top + ';' : '';
bottom = (bottom) ? 'bottom: ' + bottom + ';' : '';
right = (right) ? 'right: ' + right + ';' : '';
@ -90,6 +90,7 @@ module.exports.overlayPage = function overlayPage (contentElement, top, right, b
'background-color: rgba(0, 0, 0, 0.2);';
closer.addEventListener('click', function () {
closer.parentNode.removeChild(closer);
editor.focus();
closer = null;
});
// click closer if esc key is pressed
@ -109,6 +110,7 @@ module.exports.overlayPage = function overlayPage (contentElement, top, right, b
contentContainer.appendChild(contentElement);
closer.appendChild(contentContainer);
document.body.appendChild(closer);
editor.blur();
};
});

View file

@ -75,7 +75,7 @@ define(function(require, exports, module) {
el.id = 'kbshortcutmenu';
el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands + '</div>';
el.style.cssText = 'margin:0; padding:0;';
overlayPage(el, '0', '0', '0', null);
overlayPage(editor, el, '0', '0', '0', null);
}
};
});

View file

@ -229,7 +229,14 @@ define(function(require, exports, module) {
div.setAttribute('class', 'menuEntry');
div.setAttribute('style', 'clear: both;');
div.appendChild(egen.createLabel(item, item));
div.appendChild(egen.createLabel(
item.replace(
/^set/, ''
).replace(
/([A-Z])/g, ' $1'
).trim(),
item
));
if(Array.isArray(val)) {
el = egen.createSelection(item, val, clss);
@ -366,7 +373,7 @@ define(function(require, exports, module) {
cleanupElementsList();
// dump the entries from the elements list and wrap them up in a div
// then put the div into the generic menu and show it.
overlayPage(wrapElements(), '0', '0', '0');
overlayPage(editor, wrapElements(), '0', '0', '0');
}
/**
* This builds the settings menu and selects