corrade-nucleus-nucleons – Blame information for rev 20
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) { |
2 | 'use strict'; |
||
3 | var dom = require("../../lib/dom"); |
||
4 | var cssText = "#ace_settingsmenu, #kbshortcutmenu {\ |
||
5 | background-color: #F7F7F7;\ |
||
6 | color: black;\ |
||
7 | box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\ |
||
8 | padding: 1em 0.5em 2em 1em;\ |
||
9 | overflow: auto;\ |
||
10 | position: absolute;\ |
||
11 | margin: 0;\ |
||
12 | bottom: 0;\ |
||
13 | right: 0;\ |
||
14 | top: 0;\ |
||
15 | z-index: 9991;\ |
||
16 | cursor: default;\ |
||
17 | }\ |
||
18 | .ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\ |
||
19 | box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\ |
||
20 | background-color: rgba(255, 255, 255, 0.6);\ |
||
21 | color: black;\ |
||
22 | }\ |
||
23 | .ace_optionsMenuEntry:hover {\ |
||
24 | background-color: rgba(100, 100, 100, 0.1);\ |
||
25 | -webkit-transition: all 0.5s;\ |
||
26 | transition: all 0.3s\ |
||
27 | }\ |
||
28 | .ace_closeButton {\ |
||
29 | background: rgba(245, 146, 146, 0.5);\ |
||
30 | border: 1px solid #F48A8A;\ |
||
31 | border-radius: 50%;\ |
||
32 | padding: 7px;\ |
||
33 | position: absolute;\ |
||
34 | right: -8px;\ |
||
35 | top: -8px;\ |
||
36 | z-index: 1000;\ |
||
37 | }\ |
||
38 | .ace_closeButton{\ |
||
39 | background: rgba(245, 146, 146, 0.9);\ |
||
40 | }\ |
||
41 | .ace_optionsMenuKey {\ |
||
42 | color: darkslateblue;\ |
||
43 | font-weight: bold;\ |
||
44 | }\ |
||
45 | .ace_optionsMenuCommand {\ |
||
46 | color: darkcyan;\ |
||
47 | font-weight: normal;\ |
||
48 | }"; |
||
49 | dom.importCssString(cssText); |
||
50 | module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) { |
||
51 | top = top ? 'top: ' + top + ';' : ''; |
||
52 | bottom = bottom ? 'bottom: ' + bottom + ';' : ''; |
||
53 | right = right ? 'right: ' + right + ';' : ''; |
||
54 | left = left ? 'left: ' + left + ';' : ''; |
||
55 | |||
56 | var closer = document.createElement('div'); |
||
57 | var contentContainer = document.createElement('div'); |
||
58 | |||
59 | function documentEscListener(e) { |
||
60 | if (e.keyCode === 27) { |
||
61 | closer.click(); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | closer.style.cssText = 'margin: 0; padding: 0; ' + |
||
66 | 'position: fixed; top:0; bottom:0; left:0; right:0;' + |
||
67 | 'z-index: 9990; ' + |
||
68 | 'background-color: rgba(0, 0, 0, 0.3);'; |
||
69 | closer.addEventListener('click', function() { |
||
70 | document.removeEventListener('keydown', documentEscListener); |
||
71 | closer.parentNode.removeChild(closer); |
||
72 | editor.focus(); |
||
73 | closer = null; |
||
74 | }); |
||
75 | document.addEventListener('keydown', documentEscListener); |
||
76 | |||
77 | contentContainer.style.cssText = top + right + bottom + left; |
||
78 | contentContainer.addEventListener('click', function(e) { |
||
79 | e.stopPropagation(); |
||
80 | }); |
||
81 | |||
82 | var wrapper = dom.createElement("div"); |
||
83 | wrapper.style.position = "relative"; |
||
84 | |||
85 | var closeButton = dom.createElement("div"); |
||
86 | closeButton.className = "ace_closeButton"; |
||
87 | closeButton.addEventListener('click', function() { |
||
88 | closer.click(); |
||
89 | }); |
||
90 | |||
91 | wrapper.appendChild(closeButton); |
||
92 | contentContainer.appendChild(wrapper); |
||
93 | |||
94 | contentContainer.appendChild(contentElement); |
||
95 | closer.appendChild(contentContainer); |
||
96 | document.body.appendChild(closer); |
||
97 | editor.blur(); |
||
98 | }; |
||
99 | |||
100 | }); |
||
101 | |||
102 | ace.define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module) { |
||
103 | "use strict"; |
||
104 | var keys = require("../../lib/keys"); |
||
105 | module.exports.getEditorKeybordShortcuts = function(editor) { |
||
106 | var KEY_MODS = keys.KEY_MODS; |
||
107 | var keybindings = []; |
||
108 | var commandMap = {}; |
||
109 | editor.keyBinding.$handlers.forEach(function(handler) { |
||
110 | var ckb = handler.commandKeyBinding; |
||
111 | for (var i in ckb) { |
||
112 | var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); }); |
||
113 | var commands = ckb[i]; |
||
114 | if (!Array.isArray(commands)) |
||
115 | commands = [commands]; |
||
116 | commands.forEach(function(command) { |
||
117 | if (typeof command != "string") |
||
118 | command = command.name |
||
119 | if (commandMap[command]) { |
||
120 | commandMap[command].key += "|" + key; |
||
121 | } else { |
||
122 | commandMap[command] = {key: key, command: command}; |
||
123 | keybindings.push(commandMap[command]); |
||
124 | } |
||
125 | }); |
||
126 | } |
||
127 | }); |
||
128 | return keybindings; |
||
129 | }; |
||
130 | |||
131 | }); |
||
132 | |||
133 | ace.define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"], function(require, exports, module) { |
||
134 | "use strict"; |
||
135 | var Editor = require("ace/editor").Editor; |
||
136 | function showKeyboardShortcuts (editor) { |
||
137 | if(!document.getElementById('kbshortcutmenu')) { |
||
138 | var overlayPage = require('./menu_tools/overlay_page').overlayPage; |
||
139 | var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; |
||
140 | var kb = getEditorKeybordShortcuts(editor); |
||
141 | var el = document.createElement('div'); |
||
142 | var commands = kb.reduce(function(previous, current) { |
||
143 | return previous + '<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">' |
||
144 | + current.command + '</span> : ' |
||
145 | + '<span class="ace_optionsMenuKey">' + current.key + '</span></div>'; |
||
146 | }, ''); |
||
147 | |||
148 | el.id = 'kbshortcutmenu'; |
||
149 | el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands + '</div>'; |
||
150 | overlayPage(editor, el, '0', '0', '0', null); |
||
151 | } |
||
152 | } |
||
153 | module.exports.init = function(editor) { |
||
154 | Editor.prototype.showKeyboardShortcuts = function() { |
||
155 | showKeyboardShortcuts(this); |
||
156 | }; |
||
157 | editor.commands.addCommands([{ |
||
158 | name: "showKeyboardShortcuts", |
||
159 | bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"}, |
||
160 | exec: function(editor, line) { |
||
161 | editor.showKeyboardShortcuts(); |
||
162 | } |
||
163 | }]); |
||
164 | }; |
||
165 | |||
166 | }); |
||
167 | (function() { |
||
168 | ace.require(["ace/ext/keybinding_menu"], function() {}); |
||
169 | })(); |
||
170 |