menus will open only 1 at a time per menu.
This commit is contained in:
parent
4ec0a6e706
commit
52a1dffa9f
3 changed files with 25 additions and 21 deletions
|
|
@ -45,11 +45,6 @@ exports.commands = [{
|
||||||
name: "showSettingsMenu",
|
name: "showSettingsMenu",
|
||||||
bindKey: bindKey("Ctrl-,", "Command-,"),
|
bindKey: bindKey("Ctrl-,", "Command-,"),
|
||||||
exec: function (editor) {
|
exec: function (editor) {
|
||||||
config.loadModule("ace/ext/show_keyboard_shortcuts", function (e) {
|
|
||||||
e(editor);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
}, {
|
||||||
name: "selectall",
|
name: "selectall",
|
||||||
bindKey: bindKey("Ctrl-A", "Command-A"),
|
bindKey: bindKey("Ctrl-A", "Command-A"),
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var overlayPage = require('./overlay_page').overlayPage;
|
|
||||||
var getEditorKeybordShortcuts = require('./get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
|
|
||||||
/**
|
/**
|
||||||
* Generates a menu which displays the keyboard shortcuts.
|
* Generates a menu which displays the keyboard shortcuts.
|
||||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||||
|
|
@ -30,15 +28,22 @@ define(function(require, exports, module) {
|
||||||
* ☭ Hial Atropa!! ☭
|
* ☭ Hial Atropa!! ☭
|
||||||
* @param {ace.Editor} editor An instance of the ace editor.
|
* @param {ace.Editor} editor An instance of the ace editor.
|
||||||
*/
|
*/
|
||||||
module.exports = function showKeyboardShortcuts (editor) {
|
module.exports.showKeyboardShortcuts = function showKeyboardShortcuts (editor) {
|
||||||
var kb = getEditorKeybordShortcuts(editor);
|
// make sure the menu isn't open already.
|
||||||
var el = document.createElement('div');
|
if(!document.getElementById('kbshortcutmenu')) {
|
||||||
var commands = kb.reduce(function (previous, current) {
|
var overlayPage = require('./overlay_page').overlayPage;
|
||||||
return previous + '<div><b>' + current.command + '</b> : ' +
|
var getEditorKeybordShortcuts = require('./get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
|
||||||
current.key + '</div>';
|
var kb = getEditorKeybordShortcuts(editor);
|
||||||
}, '');
|
var el = document.createElement('div');
|
||||||
el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands;
|
var commands = kb.reduce(function (previous, current) {
|
||||||
el.style.cssText = 'margin:0; padding:0;';
|
return previous + '<div><b>' + current.command + '</b> : ' +
|
||||||
overlayPage(el, '0', '0', '0', null);
|
current.key + '</div>';
|
||||||
|
}, '');
|
||||||
|
|
||||||
|
el.id = 'kbshortcutmenu';
|
||||||
|
el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands + '</div>';
|
||||||
|
el.style.cssText = 'margin:0; padding:0;';
|
||||||
|
overlayPage(el, '0', '0', '0', null);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -188,6 +188,7 @@ define(function(require, exports, module) {
|
||||||
*/
|
*/
|
||||||
function wrapElements() {
|
function wrapElements() {
|
||||||
var topmenu = document.createElement('div');
|
var topmenu = document.createElement('div');
|
||||||
|
topmenu.id = 'settingsmenu';
|
||||||
elements.forEach(function (element) {
|
elements.forEach(function (element) {
|
||||||
topmenu.appendChild(element);
|
topmenu.appendChild(element);
|
||||||
});
|
});
|
||||||
|
|
@ -364,9 +365,12 @@ define(function(require, exports, module) {
|
||||||
* ☭ Hial Atropa!! ☭
|
* ☭ Hial Atropa!! ☭
|
||||||
* @param {ace.Editor} editor An instance of the ace editor.
|
* @param {ace.Editor} editor An instance of the ace editor.
|
||||||
*/
|
*/
|
||||||
module.exports = function (editor) {
|
module.exports.showSettingsMenu = function showSettingsMenu (editor) {
|
||||||
addFunctionsForSettingsMenu(editor);
|
// make sure the menu isn't open already.
|
||||||
addEditorMenuOptions(editor);
|
if(!document.getElementById('settingsmenu')) {
|
||||||
generateMenu(editor);
|
addFunctionsForSettingsMenu(editor);
|
||||||
|
addEditorMenuOptions(editor);
|
||||||
|
generateMenu(editor);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue