corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
2 "use strict";
3  
4 exports.isDark = false;
5 exports.cssClass = "ace-tm";
6 exports.cssText = ".ace-tm .ace_gutter {\
7 background: #f0f0f0;\
8 color: #333;\
9 }\
10 .ace-tm .ace_print-margin {\
11 width: 1px;\
12 background: #e8e8e8;\
13 }\
14 .ace-tm .ace_fold {\
15 background-color: #6B72E6;\
16 }\
17 .ace-tm {\
18 background-color: #FFFFFF;\
19 color: black;\
20 }\
21 .ace-tm .ace_cursor {\
22 color: black;\
23 }\
24 .ace-tm .ace_invisible {\
25 color: rgb(191, 191, 191);\
26 }\
27 .ace-tm .ace_storage,\
28 .ace-tm .ace_keyword {\
29 color: blue;\
30 }\
31 .ace-tm .ace_constant {\
32 color: rgb(197, 6, 11);\
33 }\
34 .ace-tm .ace_constant.ace_buildin {\
35 color: rgb(88, 72, 246);\
36 }\
37 .ace-tm .ace_constant.ace_language {\
38 color: rgb(88, 92, 246);\
39 }\
40 .ace-tm .ace_constant.ace_library {\
41 color: rgb(6, 150, 14);\
42 }\
43 .ace-tm .ace_invalid {\
44 background-color: rgba(255, 0, 0, 0.1);\
45 color: red;\
46 }\
47 .ace-tm .ace_support.ace_function {\
48 color: rgb(60, 76, 114);\
49 }\
50 .ace-tm .ace_support.ace_constant {\
51 color: rgb(6, 150, 14);\
52 }\
53 .ace-tm .ace_support.ace_type,\
54 .ace-tm .ace_support.ace_class {\
55 color: rgb(109, 121, 222);\
56 }\
57 .ace-tm .ace_keyword.ace_operator {\
58 color: rgb(104, 118, 135);\
59 }\
60 .ace-tm .ace_string {\
61 color: rgb(3, 106, 7);\
62 }\
63 .ace-tm .ace_comment {\
64 color: rgb(76, 136, 107);\
65 }\
66 .ace-tm .ace_comment.ace_doc {\
67 color: rgb(0, 102, 255);\
68 }\
69 .ace-tm .ace_comment.ace_doc.ace_tag {\
70 color: rgb(128, 159, 191);\
71 }\
72 .ace-tm .ace_constant.ace_numeric {\
73 color: rgb(0, 0, 205);\
74 }\
75 .ace-tm .ace_variable {\
76 color: rgb(49, 132, 149);\
77 }\
78 .ace-tm .ace_xml-pe {\
79 color: rgb(104, 104, 91);\
80 }\
81 .ace-tm .ace_entity.ace_name.ace_function {\
82 color: #0000A2;\
83 }\
84 .ace-tm .ace_heading {\
85 color: rgb(12, 7, 255);\
86 }\
87 .ace-tm .ace_list {\
88 color:rgb(185, 6, 144);\
89 }\
90 .ace-tm .ace_meta.ace_tag {\
91 color:rgb(0, 22, 142);\
92 }\
93 .ace-tm .ace_string.ace_regex {\
94 color: rgb(255, 0, 0)\
95 }\
96 .ace-tm .ace_marker-layer .ace_selection {\
97 background: rgb(181, 213, 255);\
98 }\
99 .ace-tm.ace_multiselect .ace_selection.ace_start {\
100 box-shadow: 0 0 3px 0px white;\
101 }\
102 .ace-tm .ace_marker-layer .ace_step {\
103 background: rgb(252, 255, 0);\
104 }\
105 .ace-tm .ace_marker-layer .ace_stack {\
106 background: rgb(164, 229, 101);\
107 }\
108 .ace-tm .ace_marker-layer .ace_bracket {\
109 margin: -1px 0 0 -1px;\
110 border: 1px solid rgb(192, 192, 192);\
111 }\
112 .ace-tm .ace_marker-layer .ace_active-line {\
113 background: rgba(0, 0, 0, 0.07);\
114 }\
115 .ace-tm .ace_gutter-active-line {\
116 background-color : #dcdcdc;\
117 }\
118 .ace-tm .ace_marker-layer .ace_selected-word {\
119 background: rgb(250, 250, 255);\
120 border: 1px solid rgb(200, 200, 250);\
121 }\
122 .ace-tm .ace_indent-guide {\
123 background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
124 }\
125 ";
126  
127 var dom = require("../lib/dom");
128 dom.importCssString(exports.cssText, exports.cssClass);
129 });
130  
131 ace.define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace","ace/theme/textmate"], function(require, exports, module) {
132 "use strict";
133  
134 var event = require("../lib/event");
135 var UA = require("../lib/useragent");
136 var net = require("../lib/net");
137 var ace = require("../ace");
138  
139 require("../theme/textmate");
140  
141 module.exports = exports = ace;
142 var getCSSProperty = function(element, container, property) {
143 var ret = element.style[property];
144  
145 if (!ret) {
146 if (window.getComputedStyle) {
147 ret = window.getComputedStyle(element, '').getPropertyValue(property);
148 } else {
149 ret = element.currentStyle[property];
150 }
151 }
152  
153 if (!ret || ret == 'auto' || ret == 'intrinsic') {
154 ret = container.style[property];
155 }
156 return ret;
157 };
158  
159 function applyStyles(elm, styles) {
160 for (var style in styles) {
161 elm.style[style] = styles[style];
162 }
163 }
164  
165 function setupContainer(element, getValue) {
166 if (element.type != 'textarea') {
167 throw new Error("Textarea required!");
168 }
169  
170 var parentNode = element.parentNode;
171 var container = document.createElement('div');
172 var resizeEvent = function() {
173 var style = 'position:relative;';
174 [
175 'margin-top', 'margin-left', 'margin-right', 'margin-bottom'
176 ].forEach(function(item) {
177 style += item + ':' +
178 getCSSProperty(element, container, item) + ';';
179 });
180 var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px");
181 var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px");
182 style += 'height:' + height + ';width:' + width + ';';
183 style += 'display:inline-block;';
184 container.setAttribute('style', style);
185 };
186 event.addListener(window, 'resize', resizeEvent);
187 resizeEvent();
188 parentNode.insertBefore(container, element.nextSibling);
189 while (parentNode !== document) {
190 if (parentNode.tagName.toUpperCase() === 'FORM') {
191 var oldSumit = parentNode.onsubmit;
192 parentNode.onsubmit = function(evt) {
193 element.value = getValue();
194 if (oldSumit) {
195 oldSumit.call(this, evt);
196 }
197 };
198 break;
199 }
200 parentNode = parentNode.parentNode;
201 }
202 return container;
203 }
204  
205 exports.transformTextarea = function(element, options) {
206 var session;
207 var container = setupContainer(element, function() {
208 return session.getValue();
209 });
210 element.style.display = 'none';
211 container.style.background = 'white';
212 var editorDiv = document.createElement("div");
213 applyStyles(editorDiv, {
214 top: "0px",
215 left: "0px",
216 right: "0px",
217 bottom: "0px",
218 border: "1px solid gray",
219 position: "absolute"
220 });
221 container.appendChild(editorDiv);
222  
223 var settingOpener = document.createElement("div");
224 applyStyles(settingOpener, {
225 position: "absolute",
226 right: "0px",
227 bottom: "0px",
228 background: "red",
229 cursor: "nw-resize",
230 borderStyle: "solid",
231 borderWidth: "9px 8px 10px 9px",
232 width: "2px",
233 borderColor: "lightblue gray gray lightblue",
234 zIndex: 101
235 });
236  
237 var settingDiv = document.createElement("div");
238 var settingDivStyles = {
239 top: "0px",
240 left: "20%",
241 right: "0px",
242 bottom: "0px",
243 position: "absolute",
244 padding: "5px",
245 zIndex: 100,
246 color: "white",
247 display: "none",
248 overflow: "auto",
249 fontSize: "14px",
250 boxShadow: "-5px 2px 3px gray"
251 };
252 if (!UA.isOldIE) {
253 settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)";
254 } else {
255 settingDivStyles.backgroundColor = "#333";
256 }
257  
258 applyStyles(settingDiv, settingDivStyles);
259 container.appendChild(settingDiv);
260  
261 options = options || exports.defaultOptions;
262 var editor = ace.edit(editorDiv);
263 session = editor.getSession();
264  
265 session.setValue(element.value || element.innerHTML);
266 editor.focus();
267 container.appendChild(settingOpener);
268 setupApi(editor, editorDiv, settingDiv, ace, options, load);
269 setupSettingPanel(settingDiv, settingOpener, editor);
270  
271 var state = "";
272 event.addListener(settingOpener, "mousemove", function(e) {
273 var rect = this.getBoundingClientRect();
274 var x = e.clientX - rect.left, y = e.clientY - rect.top;
275 if (x + y < (rect.width + rect.height)/2) {
276 this.style.cursor = "pointer";
277 state = "toggle";
278 } else {
279 state = "resize";
280 this.style.cursor = "nw-resize";
281 }
282 });
283  
284 event.addListener(settingOpener, "mousedown", function(e) {
285 if (state == "toggle") {
286 editor.setDisplaySettings();
287 return;
288 }
289 container.style.zIndex = 100000;
290 var rect = container.getBoundingClientRect();
291 var startX = rect.width + rect.left - e.clientX;
292 var startY = rect.height + rect.top - e.clientY;
293 event.capture(settingOpener, function(e) {
294 container.style.width = e.clientX - rect.left + startX + "px";
295 container.style.height = e.clientY - rect.top + startY + "px";
296 editor.resize();
297 }, function() {});
298 });
299  
300 return editor;
301 };
302  
303 function load(url, module, callback) {
304 net.loadScript(url, function() {
305 require([module], callback);
306 });
307 }
308  
309 function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
310 var session = editor.getSession();
311 var renderer = editor.renderer;
312 loader = loader || load;
313  
314 function toBool(value) {
315 return value === "true" || value == true;
316 }
317  
318 editor.setDisplaySettings = function(display) {
319 if (display == null)
320 display = settingDiv.style.display == "none";
321 if (display) {
322 settingDiv.style.display = "block";
323 settingDiv.hideButton.focus();
324 editor.on("focus", function onFocus() {
325 editor.removeListener("focus", onFocus);
326 settingDiv.style.display = "none";
327 });
328 } else {
329 editor.focus();
330 }
331 };
332  
333 editor.$setOption = editor.setOption;
334 editor.$getOption = editor.getOption;
335 editor.setOption = function(key, value) {
336 switch (key) {
337 case "mode":
338 editor.$setOption("mode", "ace/mode/" + value)
339 break;
340 case "theme":
341 editor.$setOption("theme", "ace/theme/" + value)
342 break;
343 case "keybindings":
344 switch (value) {
345 case "vim":
346 editor.setKeyboardHandler("ace/keyboard/vim");
347 break;
348 case "emacs":
349 editor.setKeyboardHandler("ace/keyboard/emacs");
350 break;
351 default:
352 editor.setKeyboardHandler(null);
353 }
354 break;
355  
356 case "softWrap":
357 case "fontSize":
358 editor.$setOption(key, value);
359 break;
360  
361 default:
362 editor.$setOption(key, toBool(value));
363 }
364 };
365  
366 editor.getOption = function(key) {
367 switch (key) {
368 case "mode":
369 return editor.$getOption("mode").substr("ace/mode/".length)
370 break;
371  
372 case "theme":
373 return editor.$getOption("theme").substr("ace/theme/".length)
374 break;
375  
376 case "keybindings":
377 var value = editor.getKeyboardHandler()
378 switch (value && value.$id) {
379 case "ace/keyboard/vim":
380 return "vim";
381 case "ace/keyboard/emacs":
382 return "emacs";
383 default:
384 return "ace";
385 }
386 break;
387  
388 default:
389 return editor.$getOption(key);
390 }
391 };
392  
393 editor.setOptions(options);
394 return editor;
395 }
396  
397 function setupSettingPanel(settingDiv, settingOpener, editor) {
398 var BOOL = null;
399  
400 var desc = {
401 mode: "Mode:",
402 wrap: "Soft Wrap:",
403 theme: "Theme:",
404 fontSize: "Font Size:",
405 showGutter: "Display Gutter:",
406 keybindings: "Keyboard",
407 showPrintMargin: "Show Print Margin:",
408 useSoftTabs: "Use Soft Tabs:",
409 showInvisibles: "Show Invisibles"
410 };
411  
412 var optionValues = {
413 mode: {
414 text: "Plain",
415 javascript: "JavaScript",
416 xml: "XML",
417 html: "HTML",
418 css: "CSS",
419 scss: "SCSS",
420 python: "Python",
421 php: "PHP",
422 java: "Java",
423 ruby: "Ruby",
424 c_cpp: "C/C++",
425 coffee: "CoffeeScript",
426 json: "json",
427 perl: "Perl",
428 clojure: "Clojure",
429 ocaml: "OCaml",
430 csharp: "C#",
431 haxe: "haXe",
432 svg: "SVG",
433 textile: "Textile",
434 groovy: "Groovy",
435 liquid: "Liquid",
436 Scala: "Scala"
437 },
438 theme: {
439 clouds: "Clouds",
440 clouds_midnight: "Clouds Midnight",
441 cobalt: "Cobalt",
442 crimson_editor: "Crimson Editor",
443 dawn: "Dawn",
444 eclipse: "Eclipse",
445 idle_fingers: "Idle Fingers",
446 kr_theme: "Kr Theme",
447 merbivore: "Merbivore",
448 merbivore_soft: "Merbivore Soft",
449 mono_industrial: "Mono Industrial",
450 monokai: "Monokai",
451 pastel_on_dark: "Pastel On Dark",
452 solarized_dark: "Solarized Dark",
453 solarized_light: "Solarized Light",
454 textmate: "Textmate",
455 twilight: "Twilight",
456 vibrant_ink: "Vibrant Ink"
457 },
458 showGutter: BOOL,
459 fontSize: {
460 "10px": "10px",
461 "11px": "11px",
462 "12px": "12px",
463 "14px": "14px",
464 "16px": "16px"
465 },
466 wrap: {
467 off: "Off",
468 40: "40",
469 80: "80",
470 free: "Free"
471 },
472 keybindings: {
473 ace: "ace",
474 vim: "vim",
475 emacs: "emacs"
476 },
477 showPrintMargin: BOOL,
478 useSoftTabs: BOOL,
479 showInvisibles: BOOL
480 };
481  
482 var table = [];
483 table.push("<table><tr><th>Setting</th>Valueth></tr>");
484  
485 function renderOption(builder, option, obj, cValue) {
486 if (!obj) {
487 builder.push(
488 "
489
490 input>"
491 );
492 return;
493 }
494 builder.push("<select title='" + option + "'>");
495 for (var value in obj) {
496 builder.push("<option value='" + value + "' ");
497  
498 if (cValue == value) {
499 builder.push(" selected ");
500 }
501  
502 builder.push(">",
503 obj[value],
504 "</option>");
505 }
506 builder.push("select>");
507 }
508  
509 for (var option in exports.defaultOptions) {
510 table.push("<tr><td>", desc[option], "</td>");
511 table.push("");
512 renderOption(table, option, optionValues[option], editor.getOption(option));
513 table.push("td></tr>");
514 }
515 table.push("table>");
516 settingDiv.innerHTML = table.join("");
517  
518 var onChange = function(e) {
519 var select = e.currentTarget;
520 editor.setOption(select.title, select.value);
521 };
522 var onClick = function(e) {
523 var cb = e.currentTarget;
524 editor.setOption(cb.title, cb.checked);
525 };
526 var selects = settingDiv.getElementsByTagName("select");
527 for (var i = 0; i < selects.length; i++)
528 selects[i].onchange = onChange;
529 var cbs = settingDiv.getElementsByTagName("input");
530 for (var i = 0; i < cbs.length; i++)
531 cbs[i].onclick = onClick;
532  
533  
534 var button = document.createElement("input");
535 button.type = "button";
536 button.value = "Hide";
537 event.addListener(button, "click", function() {
538 editor.setDisplaySettings(false);
539 });
540 settingDiv.appendChild(button);
541 settingDiv.hideButton = button;
542 }
543 exports.defaultOptions = {
544 mode: "javascript",
545 theme: "textmate",
546 wrap: "off",
547 fontSize: "12px",
548 showGutter: "false",
549 keybindings: "ace",
550 showPrintMargin: "false",
551 useSoftTabs: "true",
552 showInvisibles: "false"
553 };
554  
555 });
556 (function() {
557 ace.require(["ace/ext/textarea"], function() {});
558 })();
559