moved utilities to subdirectory
This commit is contained in:
parent
ccae5bd8d5
commit
b0e496de88
6 changed files with 5 additions and 5 deletions
392
lib/ace/ext/menu_tools/add_editor_menu_options.js
Normal file
392
lib/ace/ext/menu_tools/add_editor_menu_options.js
Normal file
|
|
@ -0,0 +1,392 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributed to Ajax.org under the BSD license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*jslint
|
||||
indent: 4,
|
||||
maxerr: 50,
|
||||
white: true,
|
||||
browser: true,
|
||||
vars: true
|
||||
*/
|
||||
/*global
|
||||
define,
|
||||
require
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add Editor Menu Options
|
||||
* @fileOverview Add Editor Menu Options <br />
|
||||
* The menu options property needs to be added to the editor
|
||||
* so that the settings menu can know about options for
|
||||
* selection elements and track which option is selected.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* The menu options property needs to be added to the editor
|
||||
* so that the settings menu can know about options for
|
||||
* selection elements and track which option is selected.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {ace.Editor} editor An instance of the ace editor.
|
||||
*/
|
||||
module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
|
||||
editor.menuOptions = {
|
||||
"setNewLineMode" : [{
|
||||
"textContent" : "unix",
|
||||
"value" : "unix"
|
||||
}, {
|
||||
"textContent" : "windows",
|
||||
"value" : "windows"
|
||||
}, {
|
||||
"textContent" : "auto",
|
||||
"value" : "auto"
|
||||
}
|
||||
],
|
||||
"setTheme" : [{
|
||||
"textContent" : "ambiance",
|
||||
"value" : "ace/theme/ambiance"
|
||||
}, {
|
||||
"textContent" : "chaos",
|
||||
"value" : "ace/theme/chaos"
|
||||
}, {
|
||||
"textContent" : "chrome",
|
||||
"value" : "ace/theme/chrome"
|
||||
}, {
|
||||
"textContent" : "clouds",
|
||||
"value" : "ace/theme/clouds"
|
||||
}, {
|
||||
"textContent" : "clouds_midnight",
|
||||
"value" : "ace/theme/clouds_midnight"
|
||||
}, {
|
||||
"textContent" : "cobalt",
|
||||
"value" : "ace/theme/cobalt"
|
||||
}, {
|
||||
"textContent" : "crimson_editor",
|
||||
"value" : "ace/theme/crimson_editor"
|
||||
}, {
|
||||
"textContent" : "dawn",
|
||||
"value" : "ace/theme/dawn"
|
||||
}, {
|
||||
"textContent" : "dreamweaver",
|
||||
"value" : "ace/theme/dreamweaver"
|
||||
}, {
|
||||
"textContent" : "eclipse",
|
||||
"value" : "ace/theme/eclipse"
|
||||
}, {
|
||||
"textContent" : "github",
|
||||
"value" : "ace/theme/github"
|
||||
}, {
|
||||
"textContent" : "idle_fingers",
|
||||
"value" : "ace/theme/idle_fingers"
|
||||
}, {
|
||||
"textContent" : "kr",
|
||||
"value" : "ace/theme/kr"
|
||||
}, {
|
||||
"textContent" : "merbivore",
|
||||
"value" : "ace/theme/merbivore"
|
||||
}, {
|
||||
"textContent" : "merbivore_soft",
|
||||
"value" : "ace/theme/merbivore_soft"
|
||||
}, {
|
||||
"textContent" : "monokai",
|
||||
"value" : "ace/theme/monokai"
|
||||
}, {
|
||||
"textContent" : "mono_industrial",
|
||||
"value" : "ace/theme/mono_industrial"
|
||||
}, {
|
||||
"textContent" : "pastel_on_dark",
|
||||
"value" : "ace/theme/pastel_on_dark"
|
||||
}, {
|
||||
"textContent" : "solarized_dark",
|
||||
"value" : "ace/theme/solarized_dark"
|
||||
}, {
|
||||
"textContent" : "solarized_light",
|
||||
"value" : "ace/theme/solarized_light"
|
||||
}, {
|
||||
"textContent" : "textmate",
|
||||
"value" : "ace/theme/textmate"
|
||||
}, {
|
||||
"textContent" : "tomorrow",
|
||||
"value" : "ace/theme/tomorrow"
|
||||
}, {
|
||||
"textContent" : "tomorrow_night",
|
||||
"value" : "ace/theme/tomorrow_night"
|
||||
}, {
|
||||
"textContent" : "tomorrow_night_blue",
|
||||
"value" : "ace/theme/tomorrow_night_blue"
|
||||
}, {
|
||||
"textContent" : "tomorrow_night_bright",
|
||||
"value" : "ace/theme/tomorrow_night_bright"
|
||||
}, {
|
||||
"textContent" : "tomorrow_night_eighties",
|
||||
"value" : "ace/theme/tomorrow_night_eighties"
|
||||
}, {
|
||||
"textContent" : "twilight",
|
||||
"value" : "ace/theme/twilight"
|
||||
}, {
|
||||
"textContent" : "vibrant_ink",
|
||||
"value" : "ace/theme/vibrant_ink"
|
||||
}, {
|
||||
"textContent" : "xcode",
|
||||
"value" : "ace/theme/xcode"
|
||||
}
|
||||
],
|
||||
"setMode" : [{
|
||||
"textContent" : "abap",
|
||||
"value" : "ace/mode/abap"
|
||||
}, {
|
||||
"textContent" : "asciidoc",
|
||||
"value" : "ace/mode/asciidoc"
|
||||
}, {
|
||||
"textContent" : "c9search",
|
||||
"value" : "ace/mode/c9search"
|
||||
}, {
|
||||
"textContent" : "clojure",
|
||||
"value" : "ace/mode/clojure"
|
||||
}, {
|
||||
"textContent" : "coffee",
|
||||
"value" : "ace/mode/coffee"
|
||||
}, {
|
||||
"textContent" : "coldfusion",
|
||||
"value" : "ace/mode/coldfusion"
|
||||
}, {
|
||||
"textContent" : "csharp",
|
||||
"value" : "ace/mode/csharp"
|
||||
}, {
|
||||
"textContent" : "css",
|
||||
"value" : "ace/mode/css"
|
||||
}, {
|
||||
"textContent" : "curly",
|
||||
"value" : "ace/mode/curly"
|
||||
}, {
|
||||
"textContent" : "c_cpp",
|
||||
"value" : "ace/mode/c_cpp"
|
||||
}, {
|
||||
"textContent" : "dart",
|
||||
"value" : "ace/mode/dart"
|
||||
}, {
|
||||
"textContent" : "diff",
|
||||
"value" : "ace/mode/diff"
|
||||
}, {
|
||||
"textContent" : "django",
|
||||
"value" : "ace/mode/django"
|
||||
}, {
|
||||
"textContent" : "dot",
|
||||
"value" : "ace/mode/dot"
|
||||
}, {
|
||||
"textContent" : "ftl",
|
||||
"value" : "ace/mode/ftl"
|
||||
}, {
|
||||
"textContent" : "glsl",
|
||||
"value" : "ace/mode/glsl"
|
||||
}, {
|
||||
"textContent" : "golang",
|
||||
"value" : "ace/mode/golang"
|
||||
}, {
|
||||
"textContent" : "groovy",
|
||||
"value" : "ace/mode/groovy"
|
||||
}, {
|
||||
"textContent" : "haml",
|
||||
"value" : "ace/mode/haml"
|
||||
}, {
|
||||
"textContent" : "haxe",
|
||||
"value" : "ace/mode/haxe"
|
||||
}, {
|
||||
"textContent" : "html",
|
||||
"value" : "ace/mode/html"
|
||||
}, {
|
||||
"textContent" : "jade",
|
||||
"value" : "ace/mode/jade"
|
||||
}, {
|
||||
"textContent" : "java",
|
||||
"value" : "ace/mode/java"
|
||||
}, {
|
||||
"textContent" : "javascript",
|
||||
"value" : "ace/mode/javascript"
|
||||
}, {
|
||||
"textContent" : "json",
|
||||
"value" : "ace/mode/json"
|
||||
}, {
|
||||
"textContent" : "jsp",
|
||||
"value" : "ace/mode/jsp"
|
||||
}, {
|
||||
"textContent" : "jsx",
|
||||
"value" : "ace/mode/jsx"
|
||||
}, {
|
||||
"textContent" : "latex",
|
||||
"value" : "ace/mode/latex"
|
||||
}, {
|
||||
"textContent" : "less",
|
||||
"value" : "ace/mode/less"
|
||||
}, {
|
||||
"textContent" : "liquid",
|
||||
"value" : "ace/mode/liquid"
|
||||
}, {
|
||||
"textContent" : "lisp",
|
||||
"value" : "ace/mode/lisp"
|
||||
}, {
|
||||
"textContent" : "livescript",
|
||||
"value" : "ace/mode/livescript"
|
||||
}, {
|
||||
"textContent" : "logiql",
|
||||
"value" : "ace/mode/logiql"
|
||||
}, {
|
||||
"textContent" : "lsl",
|
||||
"value" : "ace/mode/lsl"
|
||||
}, {
|
||||
"textContent" : "lua",
|
||||
"value" : "ace/mode/lua"
|
||||
}, {
|
||||
"textContent" : "luapage",
|
||||
"value" : "ace/mode/luapage"
|
||||
}, {
|
||||
"textContent" : "lucene",
|
||||
"value" : "ace/mode/lucene"
|
||||
}, {
|
||||
"textContent" : "makefile",
|
||||
"value" : "ace/mode/makefile"
|
||||
}, {
|
||||
"textContent" : "markdown",
|
||||
"value" : "ace/mode/markdown"
|
||||
}, {
|
||||
"textContent" : "objectivec",
|
||||
"value" : "ace/mode/objectivec"
|
||||
}, {
|
||||
"textContent" : "ocaml",
|
||||
"value" : "ace/mode/ocaml"
|
||||
}, {
|
||||
"textContent" : "pascal",
|
||||
"value" : "ace/mode/pascal"
|
||||
}, {
|
||||
"textContent" : "perl",
|
||||
"value" : "ace/mode/perl"
|
||||
}, {
|
||||
"textContent" : "pgsql",
|
||||
"value" : "ace/mode/pgsql"
|
||||
}, {
|
||||
"textContent" : "php",
|
||||
"value" : "ace/mode/php"
|
||||
}, {
|
||||
"textContent" : "powershell",
|
||||
"value" : "ace/mode/powershell"
|
||||
}, {
|
||||
"textContent" : "python",
|
||||
"value" : "ace/mode/python"
|
||||
}, {
|
||||
"textContent" : "r",
|
||||
"value" : "ace/mode/r"
|
||||
}, {
|
||||
"textContent" : "rdoc",
|
||||
"value" : "ace/mode/rdoc"
|
||||
}, {
|
||||
"textContent" : "rhtml",
|
||||
"value" : "ace/mode/rhtml"
|
||||
}, {
|
||||
"textContent" : "ruby",
|
||||
"value" : "ace/mode/ruby"
|
||||
}, {
|
||||
"textContent" : "sass",
|
||||
"value" : "ace/mode/sass"
|
||||
}, {
|
||||
"textContent" : "scad",
|
||||
"value" : "ace/mode/scad"
|
||||
}, {
|
||||
"textContent" : "scala",
|
||||
"value" : "ace/mode/scala"
|
||||
}, {
|
||||
"textContent" : "scheme",
|
||||
"value" : "ace/mode/scheme"
|
||||
}, {
|
||||
"textContent" : "scss",
|
||||
"value" : "ace/mode/scss"
|
||||
}, {
|
||||
"textContent" : "sh",
|
||||
"value" : "ace/mode/sh"
|
||||
}, {
|
||||
"textContent" : "sql",
|
||||
"value" : "ace/mode/sql"
|
||||
}, {
|
||||
"textContent" : "stylus",
|
||||
"value" : "ace/mode/stylus"
|
||||
}, {
|
||||
"textContent" : "svg",
|
||||
"value" : "ace/mode/svg"
|
||||
}, {
|
||||
"textContent" : "tcl",
|
||||
"value" : "ace/mode/tcl"
|
||||
}, {
|
||||
"textContent" : "tex",
|
||||
"value" : "ace/mode/tex"
|
||||
}, {
|
||||
"textContent" : "text",
|
||||
"value" : "ace/mode/text"
|
||||
}, {
|
||||
"textContent" : "textile",
|
||||
"value" : "ace/mode/textile"
|
||||
}, {
|
||||
"textContent" : "tmsnippet",
|
||||
"value" : "ace/mode/tmsnippet"
|
||||
}, {
|
||||
"textContent" : "tm_snippet",
|
||||
"value" : "ace/mode/tm_snippet"
|
||||
}, {
|
||||
"textContent" : "toml",
|
||||
"value" : "ace/mode/toml"
|
||||
}, {
|
||||
"textContent" : "typescript",
|
||||
"value" : "ace/mode/typescript"
|
||||
}, {
|
||||
"textContent" : "vbscript",
|
||||
"value" : "ace/mode/vbscript"
|
||||
}, {
|
||||
"textContent" : "xml",
|
||||
"value" : "ace/mode/xml"
|
||||
}, {
|
||||
"textContent" : "xquery",
|
||||
"value" : "ace/mode/xquery"
|
||||
}, {
|
||||
"textContent" : "yaml",
|
||||
"value" : "ace/mode/yaml"
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
157
lib/ace/ext/menu_tools/element_generator.js
Normal file
157
lib/ace/ext/menu_tools/element_generator.js
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributed to Ajax.org under the BSD license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*jslint
|
||||
indent: 4,
|
||||
maxerr: 50,
|
||||
white: true,
|
||||
browser: true,
|
||||
vars: true
|
||||
*/
|
||||
/*global
|
||||
define,
|
||||
require
|
||||
*/
|
||||
|
||||
/**
|
||||
* Element Generator
|
||||
* @fileOverview Element Generator <br />
|
||||
* Contains methods for generating elements.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
'use strict';
|
||||
/**
|
||||
* Creates a DOM option element
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {object} obj An object containing properties to add to the dom
|
||||
* element. If one of those properties is named `selected` then it will be
|
||||
* added as an attribute on the element instead.
|
||||
*/
|
||||
module.exports.createOption = function createOption (obj) {
|
||||
var attribute;
|
||||
var el = document.createElement('option');
|
||||
for(attribute in obj) {
|
||||
if(obj.hasOwnProperty(attribute)) {
|
||||
if(attribute === 'selected') {
|
||||
el.setAttribute(attribute, obj[attribute]);
|
||||
} else {
|
||||
el[attribute] = obj[attribute];
|
||||
}
|
||||
}
|
||||
}
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Creates a DOM checkbox element.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {string} id The id of the element.
|
||||
* @param {boolean} checked Whether or not the element is checked.
|
||||
* @param {string} clss The class of the element.
|
||||
* @returns {DOMElement} Returns a checkbox element reference.
|
||||
*/
|
||||
module.exports.createCheckbox = function createCheckbox (id, checked, clss) {
|
||||
var el = document.createElement('input');
|
||||
el.setAttribute('type', 'checkbox');
|
||||
el.setAttribute('id', id);
|
||||
el.setAttribute('name', id);
|
||||
el.setAttribute('value', checked);
|
||||
el.setAttribute('class', clss);
|
||||
if(checked) {
|
||||
el.setAttribute('checked', 'checked');
|
||||
}
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Creates a DOM text input element.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {string} id The id of the element.
|
||||
* @param {string} value The default value of the input element.
|
||||
* @param {string} clss The class of the element.
|
||||
* @returns {DOMElement} Returns an input element reference.
|
||||
*/
|
||||
module.exports.createInput = function createInput (id, value, clss) {
|
||||
var el = document.createElement('input');
|
||||
el.setAttribute('type', 'text');
|
||||
el.setAttribute('id', id);
|
||||
el.setAttribute('name', id);
|
||||
el.setAttribute('value', value);
|
||||
el.setAttribute('class', clss);
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Creates a DOM label element.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {string} text The label text.
|
||||
* @param {string} labelFor The id of the element being labeled.
|
||||
* @returns {DOMElement} Returns a label element reference.
|
||||
*/
|
||||
module.exports.createLabel = function createLabel (text, labelFor) {
|
||||
var el = document.createElement('label');
|
||||
el.setAttribute('for', labelFor);
|
||||
el.textContent = text;
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Creates a DOM selection element.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {string} id The id of the element.
|
||||
* @param {string} values An array of objects suitable for `createOption`
|
||||
* @param {string} clss The class of the element.
|
||||
* @returns {DOMElement} Returns a selection element reference.
|
||||
* @see ace/ext/element_generator.createOption
|
||||
*/
|
||||
module.exports.createSelection = function createSelection (id, values, clss) {
|
||||
var el = document.createElement('select');
|
||||
el.setAttribute('id', id);
|
||||
el.setAttribute('name', id);
|
||||
el.setAttribute('class', clss);
|
||||
values.forEach(function (item) {
|
||||
el.appendChild(module.exports.createOption(item));
|
||||
});
|
||||
return el;
|
||||
};
|
||||
|
||||
});
|
||||
95
lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js
Normal file
95
lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributed to Ajax.org under the BSD license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*jslint
|
||||
indent: 4,
|
||||
maxerr: 50,
|
||||
white: true,
|
||||
browser: true,
|
||||
vars: true
|
||||
*/
|
||||
/*global
|
||||
define,
|
||||
require
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get Editor Keyboard Shortcuts
|
||||
* @fileOverview Get Editor Keyboard Shortcuts <br />
|
||||
* Gets a map of keyboard shortcuts to command names for the current platform.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
/**
|
||||
* Gets a map of keyboard shortcuts to command names for the current platform.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {ace.Editor} editor An editor instance.
|
||||
* @returns {Array} Returns an array of objects representing the keyboard
|
||||
* shortcuts for the given editor.
|
||||
* @example
|
||||
* var getKbShortcuts = require('./get_keyboard_shortcuts');
|
||||
* console.log(getKbShortcuts(editor));
|
||||
* // [
|
||||
* // {'command' : aCommand, 'key' : 'Control-d'},
|
||||
* // {'command' : aCommand, 'key' : 'Control-d'}
|
||||
* // ]
|
||||
*/
|
||||
module.exports.getEditorKeybordShortcuts = function getEditorKeybordShortcuts (editor) {
|
||||
var commands = editor.commands.byName;
|
||||
var commandName;
|
||||
var key;
|
||||
var platform = editor.commands.platform;
|
||||
var kb = [];
|
||||
for (commandName in commands) {
|
||||
try {
|
||||
key = commands[commandName].bindKey[platform];
|
||||
if (key) {
|
||||
kb.push({
|
||||
'command' : commandName,
|
||||
'key' : key
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// errors on properties without bindKey we don't want them
|
||||
// so the errors don't need handling.
|
||||
}
|
||||
}
|
||||
return kb;
|
||||
};
|
||||
|
||||
});
|
||||
114
lib/ace/ext/menu_tools/overlay_page.js
Normal file
114
lib/ace/ext/menu_tools/overlay_page.js
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributed to Ajax.org under the BSD license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*jslint
|
||||
indent: 4,
|
||||
maxerr: 50,
|
||||
white: true,
|
||||
browser: true,
|
||||
vars: true
|
||||
*/
|
||||
/*global
|
||||
define,
|
||||
require
|
||||
*/
|
||||
|
||||
/**
|
||||
* Overlay Page
|
||||
* @fileOverview Overlay Page <br />
|
||||
* Generates an overlay for displaying menus. The overlay is an absolutely
|
||||
* positioned div.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Generates an overlay for displaying menus. The overlay is an absolutely
|
||||
* positioned div.
|
||||
* @author <a href="mailto:matthewkastor@gmail.com">
|
||||
* Matthew Christopher Kastor-Inare III </a><br />
|
||||
* ☭ Hial Atropa!! ☭
|
||||
* @param {DOMElement} contentElement Any element which may be presented inside
|
||||
* a div.
|
||||
* @param {string|number} top absolute position value.
|
||||
* @param {string|number} right absolute position value.
|
||||
* @param {string|number} bottom absolute position value.
|
||||
* @param {string|number} left absolute position value.
|
||||
*/
|
||||
module.exports.overlayPage = function overlayPage (contentElement, top, right, bottom, left) {
|
||||
top = (top) ? 'top: ' + top + ';' : '';
|
||||
bottom = (bottom) ? 'bottom: ' + bottom + ';' : '';
|
||||
right = (right) ? 'right: ' + right + ';' : '';
|
||||
left = (left) ? 'left: ' + left + ';' : '';
|
||||
|
||||
var closer = document.createElement('div');
|
||||
var contentContainer = document.createElement('div');
|
||||
|
||||
function documentEscListener (e) {
|
||||
if (e.keyCode === 27) {
|
||||
closer.click();
|
||||
document.removeEventListener('keydown', documentEscListener);
|
||||
}
|
||||
}
|
||||
|
||||
closer.style.cssText = 'margin: 0; padding: 0; ' +
|
||||
'position: fixed; top:0; bottom:0; left:0; right:0;' +
|
||||
'z-index: 9990; ' +
|
||||
'background-color: rgba(0, 0, 0, 0.2);';
|
||||
closer.addEventListener('click', function () {
|
||||
closer.parentNode.removeChild(closer);
|
||||
closer = null;
|
||||
});
|
||||
// click closer if esc key is pressed
|
||||
document.addEventListener('keydown', documentEscListener);
|
||||
|
||||
contentContainer.style.cssText = 'margin: 0; padding: 0; ' +
|
||||
'position: absolute;' +
|
||||
top + right + bottom + left +
|
||||
'z-index: 9991; ' +
|
||||
'box-shadow: rgba(126, 126, 126, 0.25) -20px 10px 25px; ' +
|
||||
'background-color: rgba(255, 255, 255, 0.6);' +
|
||||
'color: black; overflow: auto;';
|
||||
contentContainer.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
contentContainer.appendChild(contentElement);
|
||||
closer.appendChild(contentContainer);
|
||||
document.body.appendChild(closer);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -63,8 +63,8 @@ define(function(require, exports, module) {
|
|||
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 overlayPage = require('./menu_tools/overlay_page').overlayPage;
|
||||
var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
|
||||
var kb = getEditorKeybordShortcuts(editor);
|
||||
var el = document.createElement('div');
|
||||
var commands = kb.reduce(function (previous, current) {
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
var overlayPage = require('./overlay_page').overlayPage;
|
||||
var addEditorMenuOptions = require('./add_editor_menu_options').addEditorMenuOptions;
|
||||
var overlayPage = require('./menu_tools/overlay_page').overlayPage;
|
||||
var addEditorMenuOptions = require('./menu_tools/add_editor_menu_options').addEditorMenuOptions;
|
||||
|
||||
/**
|
||||
* Generates a list of set functions for the settings menu.
|
||||
|
|
@ -222,7 +222,7 @@ define(function(require, exports, module) {
|
|||
* the dom element's value, checked, or selected option accordingly.
|
||||
*/
|
||||
function createNewEntry(obj, clss, item, val) {
|
||||
var egen = require('./element_generator');
|
||||
var egen = require('./menu_tools/element_generator');
|
||||
var el;
|
||||
var div = document.createElement('div');
|
||||
div.setAttribute('contains', item);
|
||||
|
|
|
|||
Loading…
Reference in a new issue