Projekt

Obecné

Profil

Stáhnout (25.8 KB) Statistiky
| Větev: | Tag: | Revize:
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
transition: all 0.3s\
26
}\
27
.ace_closeButton {\
28
background: rgba(245, 146, 146, 0.5);\
29
border: 1px solid #F48A8A;\
30
border-radius: 50%;\
31
padding: 7px;\
32
position: absolute;\
33
right: -8px;\
34
top: -8px;\
35
z-index: 100000;\
36
}\
37
.ace_closeButton{\
38
background: rgba(245, 146, 146, 0.9);\
39
}\
40
.ace_optionsMenuKey {\
41
color: darkslateblue;\
42
font-weight: bold;\
43
}\
44
.ace_optionsMenuCommand {\
45
color: darkcyan;\
46
font-weight: normal;\
47
}\
48
.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
49
vertical-align: middle;\
50
}\
51
.ace_optionsMenuEntry button[ace_selected_button=true] {\
52
background: #e7e7e7;\
53
box-shadow: 1px 0px 2px 0px #adadad inset;\
54
border-color: #adadad;\
55
}\
56
.ace_optionsMenuEntry button {\
57
background: white;\
58
border: 1px solid lightgray;\
59
margin: 0px;\
60
}\
61
.ace_optionsMenuEntry button:hover{\
62
background: #f0f0f0;\
63
}";
64
dom.importCssString(cssText);
65

    
66
module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
67
    var closer = document.createElement('div');
68
    var ignoreFocusOut = false;
69

    
70
    function documentEscListener(e) {
71
        if (e.keyCode === 27) {
72
            close();
73
        }
74
    }
75

    
76
    function close() {
77
        if (!closer) return;
78
        document.removeEventListener('keydown', documentEscListener);
79
        closer.parentNode.removeChild(closer);
80
        if (editor) {
81
            editor.focus();
82
        }
83
        closer = null;
84
        callback && callback();
85
    }
86
    function setIgnoreFocusOut(ignore) {
87
        ignoreFocusOut = ignore;
88
        if (ignore) {
89
            closer.style.pointerEvents = "none";
90
            contentElement.style.pointerEvents = "auto";
91
        }
92
    }
93

    
94
    closer.style.cssText = 'margin: 0; padding: 0; ' +
95
        'position: fixed; top:0; bottom:0; left:0; right:0;' +
96
        'z-index: 9990; ' +
97
        (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
98
    closer.addEventListener('click', function(e) {
99
        if (!ignoreFocusOut) {
100
            close();
101
        }
102
    });
103
    document.addEventListener('keydown', documentEscListener);
104

    
105
    contentElement.addEventListener('click', function (e) {
106
        e.stopPropagation();
107
    });
108

    
109
    closer.appendChild(contentElement);
110
    document.body.appendChild(closer);
111
    if (editor) {
112
        editor.blur();
113
    }
114
    return {
115
        close: close,
116
        setIgnoreFocusOut: setIgnoreFocusOut
117
    };
118
};
119

    
120
});
121

    
122
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
123
"use strict";
124

    
125
var modes = [];
126
function getModeForPath(path) {
127
    var mode = modesByName.text;
128
    var fileName = path.split(/[\/\\]/).pop();
129
    for (var i = 0; i < modes.length; i++) {
130
        if (modes[i].supportsFile(fileName)) {
131
            mode = modes[i];
132
            break;
133
        }
134
    }
135
    return mode;
136
}
137

    
138
var Mode = function(name, caption, extensions) {
139
    this.name = name;
140
    this.caption = caption;
141
    this.mode = "ace/mode/" + name;
142
    this.extensions = extensions;
143
    var re;
144
    if (/\^/.test(extensions)) {
145
        re = extensions.replace(/\|(\^)?/g, function(a, b){
146
            return "$|" + (b ? "^" : "^.*\\.");
147
        }) + "$";
148
    } else {
149
        re = "^.*\\.(" + extensions + ")$";
150
    }
151

    
152
    this.extRe = new RegExp(re, "gi");
153
};
154

    
155
Mode.prototype.supportsFile = function(filename) {
156
    return filename.match(this.extRe);
157
};
158
var supportedModes = {
159
    ABAP:        ["abap"],
160
    ABC:         ["abc"],
161
    ActionScript:["as"],
162
    ADA:         ["ada|adb"],
163
    Alda:        ["alda"],
164
    Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
165
    Apex:        ["apex|cls|trigger|tgr"],
166
    AQL:         ["aql"],
167
    AsciiDoc:    ["asciidoc|adoc"],
168
    ASL:         ["dsl|asl"],
169
    Assembly_x86:["asm|a"],
170
    AutoHotKey:  ["ahk"],
171
    BatchFile:   ["bat|cmd"],
172
    C_Cpp:       ["cpp|c|cc|cxx|h|hh|hpp|ino"],
173
    C9Search:    ["c9search_results"],
174
    Cirru:       ["cirru|cr"],
175
    Clojure:     ["clj|cljs"],
176
    Cobol:       ["CBL|COB"],
177
    coffee:      ["coffee|cf|cson|^Cakefile"],
178
    ColdFusion:  ["cfm"],
179
    Crystal:     ["cr"],
180
    CSharp:      ["cs"],
181
    Csound_Document: ["csd"],
182
    Csound_Orchestra: ["orc"],
183
    Csound_Score: ["sco"],
184
    CSS:         ["css"],
185
    Curly:       ["curly"],
186
    D:           ["d|di"],
187
    Dart:        ["dart"],
188
    Diff:        ["diff|patch"],
189
    Dockerfile:  ["^Dockerfile"],
190
    Dot:         ["dot"],
191
    Drools:      ["drl"],
192
    Edifact:     ["edi"],
193
    Eiffel:      ["e|ge"],
194
    EJS:         ["ejs"],
195
    Elixir:      ["ex|exs"],
196
    Elm:         ["elm"],
197
    Erlang:      ["erl|hrl"],
198
    Forth:       ["frt|fs|ldr|fth|4th"],
199
    Fortran:     ["f|f90"],
200
    FSharp:      ["fsi|fs|ml|mli|fsx|fsscript"],
201
    FSL:         ["fsl"],
202
    FTL:         ["ftl"],
203
    Gcode:       ["gcode"],
204
    Gherkin:     ["feature"],
205
    Gitignore:   ["^.gitignore"],
206
    Glsl:        ["glsl|frag|vert"],
207
    Gobstones:   ["gbs"],
208
    golang:      ["go"],
209
    GraphQLSchema: ["gql"],
210
    Groovy:      ["groovy"],
211
    HAML:        ["haml"],
212
    Handlebars:  ["hbs|handlebars|tpl|mustache"],
213
    Haskell:     ["hs"],
214
    Haskell_Cabal: ["cabal"],
215
    haXe:        ["hx"],
216
    Hjson:       ["hjson"],
217
    HTML:        ["html|htm|xhtml|vue|we|wpy"],
218
    HTML_Elixir: ["eex|html.eex"],
219
    HTML_Ruby:   ["erb|rhtml|html.erb"],
220
    INI:         ["ini|conf|cfg|prefs"],
221
    Io:          ["io"],
222
    Jack:        ["jack"],
223
    Jade:        ["jade|pug"],
224
    Java:        ["java"],
225
    JavaScript:  ["js|jsm|jsx"],
226
    JSON:        ["json"],
227
    JSON5:       ["json5"],
228
    JSONiq:      ["jq"],
229
    JSP:         ["jsp"],
230
    JSSM:        ["jssm|jssm_state"],
231
    JSX:         ["jsx"],
232
    Julia:       ["jl"],
233
    Kotlin:      ["kt|kts"],
234
    LaTeX:       ["tex|latex|ltx|bib"],
235
    LESS:        ["less"],
236
    Liquid:      ["liquid"],
237
    Lisp:        ["lisp"],
238
    LiveScript:  ["ls"],
239
    LogiQL:      ["logic|lql"],
240
    LSL:         ["lsl"],
241
    Lua:         ["lua"],
242
    LuaPage:     ["lp"],
243
    Lucene:      ["lucene"],
244
    Makefile:    ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
245
    Markdown:    ["md|markdown"],
246
    Mask:        ["mask"],
247
    MATLAB:      ["matlab"],
248
    Maze:        ["mz"],
249
    MediaWiki:   ["wiki|mediawiki"],
250
    MEL:         ["mel"],
251
    MIXAL:       ["mixal"],
252
    MUSHCode:    ["mc|mush"],
253
    MySQL:       ["mysql"],
254
    Nginx:       ["nginx|conf"],
255
    Nim:         ["nim"],
256
    Nix:         ["nix"],
257
    NSIS:        ["nsi|nsh"],
258
    Nunjucks:    ["nunjucks|nunjs|nj|njk"],
259
    ObjectiveC:  ["m|mm"],
260
    OCaml:       ["ml|mli"],
261
    Pascal:      ["pas|p"],
262
    Perl:        ["pl|pm"],
263
    Perl6:       ["p6|pl6|pm6"],
264
    pgSQL:       ["pgsql"],
265
    PHP:         ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
266
    PHP_Laravel_blade: ["blade.php"],
267
    Pig:         ["pig"],
268
    Powershell:  ["ps1"],
269
    Praat:       ["praat|praatscript|psc|proc"],
270
    Prisma:      ["prisma"],
271
    Prolog:      ["plg|prolog"],
272
    Properties:  ["properties"],
273
    Protobuf:    ["proto"],
274
    Puppet:      ["epp|pp"],
275
    Python:      ["py"],
276
    QML:         ["qml"],
277
    R:           ["r"],
278
    Razor:       ["cshtml|asp"],
279
    RDoc:        ["Rd"],
280
    Red:         ["red|reds"],
281
    RHTML:       ["Rhtml"],
282
    RST:         ["rst"],
283
    Ruby:        ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
284
    Rust:        ["rs"],
285
    SASS:        ["sass"],
286
    SCAD:        ["scad"],
287
    Scala:       ["scala|sbt"],
288
    Scheme:      ["scm|sm|rkt|oak|scheme"],
289
    SCSS:        ["scss"],
290
    SH:          ["sh|bash|^.bashrc"],
291
    SJS:         ["sjs"],
292
    Slim:        ["slim|skim"],
293
    Smarty:      ["smarty|tpl"],
294
    snippets:    ["snippets"],
295
    Soy_Template:["soy"],
296
    Space:       ["space"],
297
    SQL:         ["sql"],
298
    SQLServer:   ["sqlserver"],
299
    Stylus:      ["styl|stylus"],
300
    SVG:         ["svg"],
301
    Swift:       ["swift"],
302
    Tcl:         ["tcl"],
303
    Terraform:   ["tf", "tfvars", "terragrunt"],
304
    Tex:         ["tex"],
305
    Text:        ["txt"],
306
    Textile:     ["textile"],
307
    Toml:        ["toml"],
308
    TSX:         ["tsx"],
309
    Twig:        ["latte|twig|swig"],
310
    Typescript:  ["ts|typescript|str"],
311
    Vala:        ["vala"],
312
    VBScript:    ["vbs|vb"],
313
    Velocity:    ["vm"],
314
    Verilog:     ["v|vh|sv|svh"],
315
    VHDL:        ["vhd|vhdl"],
316
    Visualforce: ["vfp|component|page"],
317
    Wollok:      ["wlk|wpgm|wtest"],
318
    XML:         ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
319
    XQuery:      ["xq"],
320
    YAML:        ["yaml|yml"],
321
    Zeek:        ["zeek|bro"],
322
    Django:      ["html"]
323
};
324

    
325
var nameOverrides = {
326
    ObjectiveC: "Objective-C",
327
    CSharp: "C#",
328
    golang: "Go",
329
    C_Cpp: "C and C++",
330
    Csound_Document: "Csound Document",
331
    Csound_Orchestra: "Csound",
332
    Csound_Score: "Csound Score",
333
    coffee: "CoffeeScript",
334
    HTML_Ruby: "HTML (Ruby)",
335
    HTML_Elixir: "HTML (Elixir)",
336
    FTL: "FreeMarker",
337
    PHP_Laravel_blade: "PHP (Blade Template)",
338
    Perl6: "Perl 6",
339
    AutoHotKey: "AutoHotkey / AutoIt"
340
};
341
var modesByName = {};
342
for (var name in supportedModes) {
343
    var data = supportedModes[name];
344
    var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
345
    var filename = name.toLowerCase();
346
    var mode = new Mode(filename, displayName, data[0]);
347
    modesByName[filename] = mode;
348
    modes.push(mode);
349
}
350

    
351
module.exports = {
352
    getModeForPath: getModeForPath,
353
    modes: modes,
354
    modesByName: modesByName
355
};
356

    
357
});
358

    
359
ace.define("ace/ext/themelist",["require","exports","module"], function(require, exports, module) {
360
"use strict";
361

    
362
var themeData = [
363
    ["Chrome"         ],
364
    ["Clouds"         ],
365
    ["Crimson Editor" ],
366
    ["Dawn"           ],
367
    ["Dreamweaver"    ],
368
    ["Eclipse"        ],
369
    ["GitHub"         ],
370
    ["IPlastic"       ],
371
    ["Solarized Light"],
372
    ["TextMate"       ],
373
    ["Tomorrow"       ],
374
    ["Xcode"          ],
375
    ["Kuroir"],
376
    ["KatzenMilch"],
377
    ["SQL Server"           ,"sqlserver"               , "light"],
378
    ["Ambiance"             ,"ambiance"                ,  "dark"],
379
    ["Chaos"                ,"chaos"                   ,  "dark"],
380
    ["Clouds Midnight"      ,"clouds_midnight"         ,  "dark"],
381
    ["Dracula"              ,""                        ,  "dark"],
382
    ["Cobalt"               ,"cobalt"                  ,  "dark"],
383
    ["Gruvbox"              ,"gruvbox"                 ,  "dark"],
384
    ["Green on Black"       ,"gob"                     ,  "dark"],
385
    ["idle Fingers"         ,"idle_fingers"            ,  "dark"],
386
    ["krTheme"              ,"kr_theme"                ,  "dark"],
387
    ["Merbivore"            ,"merbivore"               ,  "dark"],
388
    ["Merbivore Soft"       ,"merbivore_soft"          ,  "dark"],
389
    ["Mono Industrial"      ,"mono_industrial"         ,  "dark"],
390
    ["Monokai"              ,"monokai"                 ,  "dark"],
391
    ["Nord Dark"            ,"nord_dark"               ,  "dark"],
392
    ["Pastel on dark"       ,"pastel_on_dark"          ,  "dark"],
393
    ["Solarized Dark"       ,"solarized_dark"          ,  "dark"],
394
    ["Terminal"             ,"terminal"                ,  "dark"],
395
    ["Tomorrow Night"       ,"tomorrow_night"          ,  "dark"],
396
    ["Tomorrow Night Blue"  ,"tomorrow_night_blue"     ,  "dark"],
397
    ["Tomorrow Night Bright","tomorrow_night_bright"   ,  "dark"],
398
    ["Tomorrow Night 80s"   ,"tomorrow_night_eighties" ,  "dark"],
399
    ["Twilight"             ,"twilight"                ,  "dark"],
400
    ["Vibrant Ink"          ,"vibrant_ink"             ,  "dark"]
401
];
402

    
403

    
404
exports.themesByName = {};
405
exports.themes = themeData.map(function(data) {
406
    var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
407
    var theme = {
408
        caption: data[0],
409
        theme: "ace/theme/" + name,
410
        isDark: data[2] == "dark",
411
        name: name
412
    };
413
    exports.themesByName[name] = theme;
414
    return theme;
415
});
416

    
417
});
418

    
419
ace.define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module) {
420
"use strict";
421

    
422
require("./menu_tools/overlay_page");
423

    
424
var dom = require("../lib/dom");
425
var oop = require("../lib/oop");
426
var config = require("../config");
427
var EventEmitter = require("../lib/event_emitter").EventEmitter;
428
var buildDom = dom.buildDom;
429

    
430
var modelist = require("./modelist");
431
var themelist = require("./themelist");
432

    
433
var themes = { Bright: [], Dark: [] };
434
themelist.themes.forEach(function(x) {
435
    themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
436
});
437

    
438
var modes = modelist.modes.map(function(x){ 
439
    return { caption: x.caption, value: x.mode }; 
440
});
441

    
442

    
443
var optionGroups = {
444
    Main: {
445
        Mode: {
446
            path: "mode",
447
            type: "select",
448
            items: modes
449
        },
450
        Theme: {
451
            path: "theme",
452
            type: "select",
453
            items: themes
454
        },
455
        "Keybinding": {
456
            type: "buttonBar",
457
            path: "keyboardHandler",
458
            items: [
459
                { caption : "Ace", value : null },
460
                { caption : "Vim", value : "ace/keyboard/vim" },
461
                { caption : "Emacs", value : "ace/keyboard/emacs" },
462
                { caption : "Sublime", value : "ace/keyboard/sublime" },
463
                { caption : "VSCode", value : "ace/keyboard/vscode" }
464
            ]
465
        },
466
        "Font Size": {
467
            path: "fontSize",
468
            type: "number",
469
            defaultValue: 12,
470
            defaults: [
471
                {caption: "12px", value: 12},
472
                {caption: "24px", value: 24}
473
            ]
474
        },
475
        "Soft Wrap": {
476
            type: "buttonBar",
477
            path: "wrap",
478
            items: [
479
               { caption : "Off",  value : "off" },
480
               { caption : "View", value : "free" },
481
               { caption : "margin", value : "printMargin" },
482
               { caption : "40",   value : "40" }
483
            ]
484
        },
485
        "Cursor Style": {
486
            path: "cursorStyle",
487
            items: [
488
               { caption : "Ace",    value : "ace" },
489
               { caption : "Slim",   value : "slim" },
490
               { caption : "Smooth", value : "smooth" },
491
               { caption : "Smooth And Slim", value : "smooth slim" },
492
               { caption : "Wide",   value : "wide" }
493
            ]
494
        },
495
        "Folding": {
496
            path: "foldStyle",
497
            items: [
498
                { caption : "Manual", value : "manual" },
499
                { caption : "Mark begin", value : "markbegin" },
500
                { caption : "Mark begin and end", value : "markbeginend" }
501
            ]
502
        },
503
        "Soft Tabs": [{
504
            path: "useSoftTabs"
505
        }, {
506
            ariaLabel: "Tab Size",
507
            path: "tabSize",
508
            type: "number",
509
            values: [2, 3, 4, 8, 16]
510
        }],
511
        "Overscroll": {
512
            type: "buttonBar",
513
            path: "scrollPastEnd",
514
            items: [
515
               { caption : "None",  value : 0 },
516
               { caption : "Half",   value : 0.5 },
517
               { caption : "Full",   value : 1 }
518
            ]
519
        }
520
    },
521
    More: {
522
        "Atomic soft tabs": {
523
            path: "navigateWithinSoftTabs"
524
        },
525
        "Enable Behaviours": {
526
            path: "behavioursEnabled"
527
        },
528
        "Wrap with quotes": {
529
            path: "wrapBehavioursEnabled"
530
        },
531
        "Enable Auto Indent": {
532
            path: "enableAutoIndent"
533
        },
534
        "Full Line Selection": {
535
            type: "checkbox",
536
            values: "text|line",
537
            path: "selectionStyle"
538
        },
539
        "Highlight Active Line": {
540
            path: "highlightActiveLine"
541
        },
542
        "Show Invisibles": {
543
            path: "showInvisibles"
544
        },
545
        "Show Indent Guides": {
546
            path: "displayIndentGuides"
547
        },
548
        "Persistent HScrollbar": {
549
            path: "hScrollBarAlwaysVisible"
550
        },
551
        "Persistent VScrollbar": {
552
            path: "vScrollBarAlwaysVisible"
553
        },
554
        "Animate scrolling": {
555
            path: "animatedScroll"
556
        },
557
        "Show Gutter": {
558
            path: "showGutter"
559
        },
560
        "Show Line Numbers": {
561
            path: "showLineNumbers"
562
        },
563
        "Relative Line Numbers": {
564
            path: "relativeLineNumbers"
565
        },
566
        "Fixed Gutter Width": {
567
            path: "fixedWidthGutter"
568
        },
569
        "Show Print Margin": [{
570
            path: "showPrintMargin"
571
        }, {
572
            ariaLabel: "Print Margin",
573
            type: "number",
574
            path: "printMarginColumn"
575
        }],
576
        "Indented Soft Wrap": {
577
            path: "indentedSoftWrap"
578
        },
579
        "Highlight selected word": {
580
            path: "highlightSelectedWord"
581
        },
582
        "Fade Fold Widgets": {
583
            path: "fadeFoldWidgets"
584
        },
585
        "Use textarea for IME": {
586
            path: "useTextareaForIME"
587
        },
588
        "Merge Undo Deltas": {
589
            path: "mergeUndoDeltas",
590
            items: [
591
               { caption : "Always",  value : "always" },
592
               { caption : "Never",   value : "false" },
593
               { caption : "Timed",   value : "true" }
594
            ]
595
        },
596
        "Elastic Tabstops": {
597
            path: "useElasticTabstops"
598
        },
599
        "Incremental Search": {
600
            path: "useIncrementalSearch"
601
        },
602
        "Read-only": {
603
            path: "readOnly"
604
        },
605
        "Copy without selection": {
606
            path: "copyWithEmptySelection"
607
        },
608
        "Live Autocompletion": {
609
            path: "enableLiveAutocompletion"
610
        }
611
    }
612
};
613

    
614

    
615
var OptionPanel = function(editor, element) {
616
    this.editor = editor;
617
    this.container = element || document.createElement("div");
618
    this.groups = [];
619
    this.options = {};
620
};
621

    
622
(function() {
623
    
624
    oop.implement(this, EventEmitter);
625
    
626
    this.add = function(config) {
627
        if (config.Main)
628
            oop.mixin(optionGroups.Main, config.Main);
629
        if (config.More)
630
            oop.mixin(optionGroups.More, config.More);
631
    };
632
    
633
    this.render = function() {
634
        this.container.innerHTML = "";
635
        buildDom(["table", {role: "presentation", id: "controls"}, 
636
            this.renderOptionGroup(optionGroups.Main),
637
            ["tr", null, ["td", {colspan: 2},
638
                ["table", {role: "presentation", id: "more-controls"}, 
639
                    this.renderOptionGroup(optionGroups.More)
640
                ]
641
            ]],
642
            ["tr", null, ["td", {colspan: 2}, "version " + config.version]]
643
        ], this.container);
644
    };
645
    
646
    this.renderOptionGroup = function(group) {
647
        return Object.keys(group).map(function(key, i) {
648
            var item = group[key];
649
            if (!item.position)
650
                item.position = i / 10000;
651
            if (!item.label)
652
                item.label = key;
653
            return item;
654
        }).sort(function(a, b) {
655
            return a.position - b.position;
656
        }).map(function(item) {
657
            return this.renderOption(item.label, item);
658
        }, this);
659
    };
660
    
661
    this.renderOptionControl = function(key, option) {
662
        var self = this;
663
        if (Array.isArray(option)) {
664
            return option.map(function(x) {
665
                return self.renderOptionControl(key, x);
666
            });
667
        }
668
        var control;
669
        
670
        var value = self.getOption(option);
671
        
672
        if (option.values && option.type != "checkbox") {
673
            if (typeof option.values == "string")
674
                option.values = option.values.split("|");
675
            option.items = option.values.map(function(v) {
676
                return { value: v, name: v };
677
            });
678
        }
679
        
680
        if (option.type == "buttonBar") {
681
            control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) {
682
                return ["button", { 
683
                    value: item.value, 
684
                    ace_selected_button: value == item.value, 
685
                    'aria-pressed': value == item.value, 
686
                    onclick: function() {
687
                        self.setOption(option, item.value);
688
                        var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
689
                        for (var i = 0; i < nodes.length; i++) {
690
                            nodes[i].removeAttribute("ace_selected_button");
691
                            nodes[i].setAttribute("aria-pressed", false);
692
                        }
693
                        this.setAttribute("ace_selected_button", true);
694
                        this.setAttribute("aria-pressed", true);
695
                    } 
696
                }, item.desc || item.caption || item.name];
697
            })];
698
        } else if (option.type == "number") {
699
            control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() {
700
                self.setOption(option, parseInt(this.value));
701
            }}];
702
            if (option.ariaLabel) {
703
                control[1]["aria-label"] = option.ariaLabel;
704
            } else {
705
                control[1].id = key;
706
            }
707
            if (option.defaults) {
708
                control = [control, option.defaults.map(function(item) {
709
                    return ["button", {onclick: function() {
710
                        var input = this.parentNode.firstChild;
711
                        input.value = item.value;
712
                        input.oninput();
713
                    }}, item.caption];
714
                })];
715
            }
716
        } else if (option.items) {
717
            var buildItems = function(items) {
718
                return items.map(function(item) {
719
                    return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
720
                });
721
            };
722
            
723
            var items = Array.isArray(option.items) 
724
                ? buildItems(option.items)
725
                : Object.keys(option.items).map(function(key) {
726
                    return ["optgroup", {"label": key}, buildItems(option.items[key])];
727
                });
728
            control = ["select", { id: key, value: value, onchange: function() {
729
                self.setOption(option, this.value);
730
            } }, items];
731
        } else {
732
            if (typeof option.values == "string")
733
                option.values = option.values.split("|");
734
            if (option.values) value = value == option.values[1];
735
            control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
736
                var value = this.checked;
737
                if (option.values) value = option.values[value ? 1 : 0];
738
                self.setOption(option, value);
739
            }}];
740
            if (option.type == "checkedNumber") {
741
                control = [control, []];
742
            }
743
        }
744
        return control;
745
    };
746
    
747
    this.renderOption = function(key, option) {
748
        if (option.path && !option.onchange && !this.editor.$options[option.path])
749
            return;
750
        var path = Array.isArray(option) ? option[0].path : option.path;
751
        this.options[path] = option;
752
        var safeKey = "-" + path;
753
        var safeId = path + "-label";
754
        var control = this.renderOptionControl(safeKey, option);
755
        return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
756
            ["label", {for: safeKey, id: safeId}, key]
757
        ], ["td", control]];
758
    };
759
    
760
    this.setOption = function(option, value) {
761
        if (typeof option == "string")
762
            option = this.options[option];
763
        if (value == "false") value = false;
764
        if (value == "true") value = true;
765
        if (value == "null") value = null;
766
        if (value == "undefined") value = undefined;
767
        if (typeof value == "string" && parseFloat(value).toString() == value)
768
            value = parseFloat(value);
769
        if (option.onchange)
770
            option.onchange(value);
771
        else if (option.path)
772
            this.editor.setOption(option.path, value);
773
        this._signal("setOption", {name: option.path, value: value});
774
    };
775
    
776
    this.getOption = function(option) {
777
        if (option.getValue)
778
            return option.getValue();
779
        return this.editor.getOption(option.path);
780
    };
781
    
782
}).call(OptionPanel.prototype);
783

    
784
exports.OptionPanel = OptionPanel;
785

    
786
});
787

    
788
ace.define("ace/ext/settings_menu",["require","exports","module","ace/ext/options","ace/ext/menu_tools/overlay_page","ace/editor"], function(require, exports, module) {
789
"use strict";
790
var OptionPanel = require("./options").OptionPanel;
791
var overlayPage = require('./menu_tools/overlay_page').overlayPage;
792
function showSettingsMenu(editor) {
793
    if (!document.getElementById('ace_settingsmenu')) {
794
        var options = new OptionPanel(editor);
795
        options.render();
796
        options.container.id = "ace_settingsmenu";
797
        overlayPage(editor, options.container);
798
        options.container.querySelector("select,input,button,checkbox").focus();
799
    }
800
}
801
module.exports.init = function() {
802
    var Editor = require("../editor").Editor;
803
    Editor.prototype.showSettingsMenu = function() {
804
        showSettingsMenu(this);
805
    };
806
};
807
});                (function() {
808
                    ace.require(["ace/ext/settings_menu"], function(m) {
809
                        if (typeof module == "object" && typeof exports == "object" && module) {
810
                            module.exports = m;
811
                        }
812
                    });
813
                })();
814
            
(15-15/244)