settings_menu.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
  5. * All rights reserved.
  6. *
  7. * Contributed to Ajax.org under the BSD license.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. * * Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * * Neither the name of Ajax.org B.V. nor the
  17. * names of its contributors may be used to endorse or promote products
  18. * derived from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  21. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  24. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * ***** END LICENSE BLOCK ***** */
  32. /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
  33. /*global define, require */
  34. /**
  35. * Show Settings Menu
  36. * @fileOverview Show Settings Menu <br />
  37. * Displays an interactive settings menu mostly generated on the fly based on
  38. * the current state of the editor.
  39. * @author <a href="mailto:matthewkastor@gmail.com">
  40. * Matthew Christopher Kastor-Inare III </a><br />
  41. * ☭ Hial Atropa!! ☭
  42. */
  43. define(function(require, exports, module) {
  44. "use strict";
  45. var generateSettingsMenu = require('./menu_tools/generate_settings_menu').generateSettingsMenu;
  46. var overlayPage = require('./menu_tools/overlay_page').overlayPage;
  47. /**
  48. * This displays the settings menu if it is not already being shown.
  49. * @author <a href="mailto:matthewkastor@gmail.com">
  50. * Matthew Christopher Kastor-Inare III </a><br />
  51. * ☭ Hial Atropa!! ☭
  52. * @param {ace.Editor} editor An instance of the ace editor.
  53. */
  54. function showSettingsMenu(editor) {
  55. // make sure the menu isn't open already.
  56. var sm = document.getElementById('ace_settingsmenu');
  57. if (!sm)
  58. overlayPage(editor, generateSettingsMenu(editor), '0', '0', '0');
  59. }
  60. /**
  61. * Initializes the settings menu extension. It adds the showSettingsMenu
  62. * method to the given editor object and adds the showSettingsMenu command
  63. * to the editor with appropriate keyboard shortcuts.
  64. * @param {ace.Editor} editor An instance of the Editor.
  65. */
  66. module.exports.init = function(editor) {
  67. var Editor = require("ace/editor").Editor;
  68. Editor.prototype.showSettingsMenu = function() {
  69. showSettingsMenu(this);
  70. };
  71. };
  72. });