From 52a1dffa9f43ce10b750d2404210961d8866aa73 Mon Sep 17 00:00:00 2001 From: Matthew Kastor Date: Sun, 31 Mar 2013 21:47:12 -0400 Subject: [PATCH] menus will open only 1 at a time per menu. --- lib/ace/commands/default_commands.js | 5 ----- lib/ace/ext/show_keyboard_shortcuts.js | 29 +++++++++++++++----------- lib/ace/ext/show_settings_menu.js | 12 +++++++---- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 909aa843..658deb87 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -45,11 +45,6 @@ exports.commands = [{ name: "showSettingsMenu", bindKey: bindKey("Ctrl-,", "Command-,"), exec: function (editor) { - config.loadModule("ace/ext/show_keyboard_shortcuts", function (e) { - e(editor); - }); - }, - readOnly: true }, { name: "selectall", bindKey: bindKey("Ctrl-A", "Command-A"), diff --git a/lib/ace/ext/show_keyboard_shortcuts.js b/lib/ace/ext/show_keyboard_shortcuts.js index a88a6e55..f4db2aa8 100644 --- a/lib/ace/ext/show_keyboard_shortcuts.js +++ b/lib/ace/ext/show_keyboard_shortcuts.js @@ -21,8 +21,6 @@ define(function(require, exports, module) { "use strict"; - var overlayPage = require('./overlay_page').overlayPage; - var getEditorKeybordShortcuts = require('./get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; /** * Generates a menu which displays the keyboard shortcuts. * @author @@ -30,15 +28,22 @@ define(function(require, exports, module) { * ☭ Hial Atropa!! ☭ * @param {ace.Editor} editor An instance of the ace editor. */ - module.exports = function showKeyboardShortcuts (editor) { - var kb = getEditorKeybordShortcuts(editor); - var el = document.createElement('div'); - var commands = kb.reduce(function (previous, current) { - return previous + '
' + current.command + ' : ' + - current.key + '
'; - }, ''); - el.innerHTML = '

Keyboard Shortcuts

' + commands; - el.style.cssText = 'margin:0; padding:0;'; - overlayPage(el, '0', '0', '0', null); + module.exports.showKeyboardShortcuts = function showKeyboardShortcuts (editor) { + // make sure the menu isn't open already. + if(!document.getElementById('kbshortcutmenu')) { + var overlayPage = require('./overlay_page').overlayPage; + var getEditorKeybordShortcuts = require('./get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; + var kb = getEditorKeybordShortcuts(editor); + var el = document.createElement('div'); + var commands = kb.reduce(function (previous, current) { + return previous + '
' + current.command + ' : ' + + current.key + '
'; + }, ''); + + el.id = 'kbshortcutmenu'; + el.innerHTML = '

Keyboard Shortcuts

' + commands + ''; + el.style.cssText = 'margin:0; padding:0;'; + overlayPage(el, '0', '0', '0', null); + } }; }); \ No newline at end of file diff --git a/lib/ace/ext/show_settings_menu.js b/lib/ace/ext/show_settings_menu.js index 5e14c62c..01661105 100644 --- a/lib/ace/ext/show_settings_menu.js +++ b/lib/ace/ext/show_settings_menu.js @@ -188,6 +188,7 @@ define(function(require, exports, module) { */ function wrapElements() { var topmenu = document.createElement('div'); + topmenu.id = 'settingsmenu'; elements.forEach(function (element) { topmenu.appendChild(element); }); @@ -364,9 +365,12 @@ define(function(require, exports, module) { * ☭ Hial Atropa!! ☭ * @param {ace.Editor} editor An instance of the ace editor. */ - module.exports = function (editor) { - addFunctionsForSettingsMenu(editor); - addEditorMenuOptions(editor); - generateMenu(editor); + module.exports.showSettingsMenu = function showSettingsMenu (editor) { + // make sure the menu isn't open already. + if(!document.getElementById('settingsmenu')) { + addFunctionsForSettingsMenu(editor); + addEditorMenuOptions(editor); + generateMenu(editor); + } }; }); \ No newline at end of file