formagic 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/CONTRIBUTING.md +24 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.md +21 -0
  6. data/README.md +29 -0
  7. data/Rakefile +1 -0
  8. data/app/assets/images/datedropper/done.png +0 -0
  9. data/app/assets/images/datedropper/done.svg +1 -0
  10. data/app/assets/images/datedropper/next.png +0 -0
  11. data/app/assets/images/datedropper/next.svg +1 -0
  12. data/app/assets/images/datedropper/prev.png +0 -0
  13. data/app/assets/images/datedropper/prev.svg +1 -0
  14. data/app/assets/javascripts/formagic/form.coffee +229 -0
  15. data/app/assets/javascripts/formagic/group.coffee +28 -0
  16. data/app/assets/javascripts/formagic/inputs/checkbox.coffee +83 -0
  17. data/app/assets/javascripts/formagic/inputs/color.coffee +55 -0
  18. data/app/assets/javascripts/formagic/inputs/date.coffee +69 -0
  19. data/app/assets/javascripts/formagic/inputs/datetime.coffee +130 -0
  20. data/app/assets/javascripts/formagic/inputs/document.coffee +0 -0
  21. data/app/assets/javascripts/formagic/inputs/documents.coffee +173 -0
  22. data/app/assets/javascripts/formagic/inputs/documents_reorder.coffee +67 -0
  23. data/app/assets/javascripts/formagic/inputs/file.coffee +114 -0
  24. data/app/assets/javascripts/formagic/inputs/hidden.coffee +57 -0
  25. data/app/assets/javascripts/formagic/inputs/html.coffee +81 -0
  26. data/app/assets/javascripts/formagic/inputs/image.coffee +28 -0
  27. data/app/assets/javascripts/formagic/inputs/list.coffee +154 -0
  28. data/app/assets/javascripts/formagic/inputs/list_reorder.coffee +39 -0
  29. data/app/assets/javascripts/formagic/inputs/list_typeahead.coffee +55 -0
  30. data/app/assets/javascripts/formagic/inputs/markdown.coffee +93 -0
  31. data/app/assets/javascripts/formagic/inputs/password.coffee +32 -0
  32. data/app/assets/javascripts/formagic/inputs/redactor.coffee +53 -0
  33. data/app/assets/javascripts/formagic/inputs/redactor_character.coffee +75 -0
  34. data/app/assets/javascripts/formagic/inputs/redactor_images.coffee +166 -0
  35. data/app/assets/javascripts/formagic/inputs/select.coffee +84 -0
  36. data/app/assets/javascripts/formagic/inputs/select2.coffee +33 -0
  37. data/app/assets/javascripts/formagic/inputs/string.coffee +160 -0
  38. data/app/assets/javascripts/formagic/inputs/text.coffee +43 -0
  39. data/app/assets/javascripts/formagic/inputs/time.coffee +0 -0
  40. data/app/assets/javascripts/formagic.coffee +22 -0
  41. data/app/assets/javascripts/vendor/ace.js +18280 -0
  42. data/app/assets/javascripts/vendor/datedropper.js +1005 -0
  43. data/app/assets/javascripts/vendor/jquery.scrollparent.js +14 -0
  44. data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +55 -0
  45. data/app/assets/javascripts/vendor/jquery.typeahead.js +1782 -0
  46. data/app/assets/javascripts/vendor/marked.js +1272 -0
  47. data/app/assets/javascripts/vendor/mode-html.js +2436 -0
  48. data/app/assets/javascripts/vendor/mode-markdown.js +2820 -0
  49. data/app/assets/javascripts/vendor/moment.js +3083 -0
  50. data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +107 -0
  51. data/app/assets/javascripts/vendor/select2.js +5274 -0
  52. data/app/assets/stylesheets/formagic/checkbox.scss +8 -0
  53. data/app/assets/stylesheets/formagic/color.scss +12 -0
  54. data/app/assets/stylesheets/formagic/date.scss +37 -0
  55. data/app/assets/stylesheets/formagic/file.scss +29 -0
  56. data/app/assets/stylesheets/formagic/form.scss +36 -0
  57. data/app/assets/stylesheets/formagic/group.scss +22 -0
  58. data/app/assets/stylesheets/formagic/image.scss +19 -0
  59. data/app/assets/stylesheets/formagic/list.scss +39 -0
  60. data/app/assets/stylesheets/formagic/nested-form.scss +23 -0
  61. data/app/assets/stylesheets/formagic/redactor.scss +41 -0
  62. data/app/assets/stylesheets/formagic/select.scss +5 -0
  63. data/app/assets/stylesheets/formagic/select2.scss +95 -0
  64. data/app/assets/stylesheets/formagic/string.scss +14 -0
  65. data/app/assets/stylesheets/formagic/switch.scss +86 -0
  66. data/app/assets/stylesheets/formagic/text.scss +9 -0
  67. data/app/assets/stylesheets/formagic.scss +15 -0
  68. data/app/assets/stylesheets/vendor/datedropper.scss +523 -0
  69. data/app/assets/stylesheets/vendor/select2.scss +258 -0
  70. data/formagic.gemspec +30 -0
  71. data/lib/formagic/engine.rb +5 -0
  72. data/lib/formagic/version.rb +3 -0
  73. data/lib/formagic.rb +5 -0
  74. metadata +146 -0
@@ -0,0 +1,2436 @@
1
+ define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
2
+ "use strict";
3
+
4
+ var oop = require("../lib/oop");
5
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6
+
7
+ var DocCommentHighlightRules = function() {
8
+ this.$rules = {
9
+ "start" : [ {
10
+ token : "comment.doc.tag",
11
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
12
+ },
13
+ DocCommentHighlightRules.getTagRule(),
14
+ {
15
+ defaultToken : "comment.doc",
16
+ caseInsensitive: true
17
+ }]
18
+ };
19
+ };
20
+
21
+ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
22
+
23
+ DocCommentHighlightRules.getTagRule = function(start) {
24
+ return {
25
+ token : "comment.doc.tag.storage.type",
26
+ regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
27
+ };
28
+ }
29
+
30
+ DocCommentHighlightRules.getStartRule = function(start) {
31
+ return {
32
+ token : "comment.doc", // doc comment
33
+ regex : "\\/\\*(?=\\*)",
34
+ next : start
35
+ };
36
+ };
37
+
38
+ DocCommentHighlightRules.getEndRule = function (start) {
39
+ return {
40
+ token : "comment.doc", // closing comment
41
+ regex : "\\*\\/",
42
+ next : start
43
+ };
44
+ };
45
+
46
+
47
+ exports.DocCommentHighlightRules = DocCommentHighlightRules;
48
+
49
+ });
50
+
51
+ define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
52
+ "use strict";
53
+
54
+ var oop = require("../lib/oop");
55
+ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
56
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
57
+
58
+ var JavaScriptHighlightRules = function(options) {
59
+ var keywordMapper = this.createKeywordMapper({
60
+ "variable.language":
61
+ "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
62
+ "Namespace|QName|XML|XMLList|" + // E4X
63
+ "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
64
+ "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
65
+ "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
66
+ "SyntaxError|TypeError|URIError|" +
67
+ "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
68
+ "isNaN|parseFloat|parseInt|" +
69
+ "JSON|Math|" + // Other
70
+ "this|arguments|prototype|window|document" , // Pseudo
71
+ "keyword":
72
+ "const|yield|import|get|set|" +
73
+ "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
74
+ "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
75
+ "__parent__|__count__|escape|unescape|with|__proto__|" +
76
+ "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
77
+ "storage.type":
78
+ "const|let|var|function",
79
+ "constant.language":
80
+ "null|Infinity|NaN|undefined",
81
+ "support.function":
82
+ "alert",
83
+ "constant.language.boolean": "true|false"
84
+ }, "identifier");
85
+ var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
86
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
87
+
88
+ var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
89
+ "u[0-9a-fA-F]{4}|" + // unicode
90
+ "[0-2][0-7]{0,2}|" + // oct
91
+ "3[0-6][0-7]?|" + // oct
92
+ "37[0-7]?|" + // oct
93
+ "[4-7][0-7]?|" + //oct
94
+ ".)";
95
+
96
+ this.$rules = {
97
+ "no_regex" : [
98
+ {
99
+ token : "comment",
100
+ regex : "\\/\\/",
101
+ next : "line_comment"
102
+ },
103
+ DocCommentHighlightRules.getStartRule("doc-start"),
104
+ {
105
+ token : "comment", // multi line comment
106
+ regex : /\/\*/,
107
+ next : "comment"
108
+ }, {
109
+ token : "string",
110
+ regex : "'(?=.)",
111
+ next : "qstring"
112
+ }, {
113
+ token : "string",
114
+ regex : '"(?=.)',
115
+ next : "qqstring"
116
+ }, {
117
+ token : "constant.numeric", // hex
118
+ regex : /0[xX][0-9a-fA-F]+\b/
119
+ }, {
120
+ token : "constant.numeric", // float
121
+ regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
122
+ }, {
123
+ token : [
124
+ "storage.type", "punctuation.operator", "support.function",
125
+ "punctuation.operator", "entity.name.function", "text","keyword.operator"
126
+ ],
127
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
128
+ next: "function_arguments"
129
+ }, {
130
+ token : [
131
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
132
+ "keyword.operator", "text", "storage.type", "text", "paren.lparen"
133
+ ],
134
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
135
+ next: "function_arguments"
136
+ }, {
137
+ token : [
138
+ "entity.name.function", "text", "keyword.operator", "text", "storage.type",
139
+ "text", "paren.lparen"
140
+ ],
141
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
142
+ next: "function_arguments"
143
+ }, {
144
+ token : [
145
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
146
+ "keyword.operator", "text",
147
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
148
+ ],
149
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
150
+ next: "function_arguments"
151
+ }, {
152
+ token : [
153
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
154
+ ],
155
+ regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
156
+ next: "function_arguments"
157
+ }, {
158
+ token : [
159
+ "entity.name.function", "text", "punctuation.operator",
160
+ "text", "storage.type", "text", "paren.lparen"
161
+ ],
162
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
163
+ next: "function_arguments"
164
+ }, {
165
+ token : [
166
+ "text", "text", "storage.type", "text", "paren.lparen"
167
+ ],
168
+ regex : "(:)(\\s*)(function)(\\s*)(\\()",
169
+ next: "function_arguments"
170
+ }, {
171
+ token : "keyword",
172
+ regex : "(?:" + kwBeforeRe + ")\\b",
173
+ next : "start"
174
+ }, {
175
+ token : ["punctuation.operator", "support.function"],
176
+ regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
177
+ }, {
178
+ token : ["punctuation.operator", "support.function.dom"],
179
+ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
180
+ }, {
181
+ token : ["punctuation.operator", "support.constant"],
182
+ regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
183
+ }, {
184
+ token : ["support.constant"],
185
+ regex : /that\b/
186
+ }, {
187
+ token : ["storage.type", "punctuation.operator", "support.function.firebug"],
188
+ regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
189
+ }, {
190
+ token : keywordMapper,
191
+ regex : identifierRe
192
+ }, {
193
+ token : "keyword.operator",
194
+ regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
195
+ next : "start"
196
+ }, {
197
+ token : "punctuation.operator",
198
+ regex : /[?:,;.]/,
199
+ next : "start"
200
+ }, {
201
+ token : "paren.lparen",
202
+ regex : /[\[({]/,
203
+ next : "start"
204
+ }, {
205
+ token : "paren.rparen",
206
+ regex : /[\])}]/
207
+ }, {
208
+ token: "comment",
209
+ regex: /^#!.*$/
210
+ }
211
+ ],
212
+ "start": [
213
+ DocCommentHighlightRules.getStartRule("doc-start"),
214
+ {
215
+ token : "comment", // multi line comment
216
+ regex : "\\/\\*",
217
+ next : "comment_regex_allowed"
218
+ }, {
219
+ token : "comment",
220
+ regex : "\\/\\/",
221
+ next : "line_comment_regex_allowed"
222
+ }, {
223
+ token: "string.regexp",
224
+ regex: "\\/",
225
+ next: "regex"
226
+ }, {
227
+ token : "text",
228
+ regex : "\\s+|^$",
229
+ next : "start"
230
+ }, {
231
+ token: "empty",
232
+ regex: "",
233
+ next: "no_regex"
234
+ }
235
+ ],
236
+ "regex": [
237
+ {
238
+ token: "regexp.keyword.operator",
239
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
240
+ }, {
241
+ token: "string.regexp",
242
+ regex: "/[sxngimy]*",
243
+ next: "no_regex"
244
+ }, {
245
+ token : "invalid",
246
+ regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
247
+ }, {
248
+ token : "constant.language.escape",
249
+ regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
250
+ }, {
251
+ token : "constant.language.delimiter",
252
+ regex: /\|/
253
+ }, {
254
+ token: "constant.language.escape",
255
+ regex: /\[\^?/,
256
+ next: "regex_character_class"
257
+ }, {
258
+ token: "empty",
259
+ regex: "$",
260
+ next: "no_regex"
261
+ }, {
262
+ defaultToken: "string.regexp"
263
+ }
264
+ ],
265
+ "regex_character_class": [
266
+ {
267
+ token: "regexp.charclass.keyword.operator",
268
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
269
+ }, {
270
+ token: "constant.language.escape",
271
+ regex: "]",
272
+ next: "regex"
273
+ }, {
274
+ token: "constant.language.escape",
275
+ regex: "-"
276
+ }, {
277
+ token: "empty",
278
+ regex: "$",
279
+ next: "no_regex"
280
+ }, {
281
+ defaultToken: "string.regexp.charachterclass"
282
+ }
283
+ ],
284
+ "function_arguments": [
285
+ {
286
+ token: "variable.parameter",
287
+ regex: identifierRe
288
+ }, {
289
+ token: "punctuation.operator",
290
+ regex: "[, ]+"
291
+ }, {
292
+ token: "punctuation.operator",
293
+ regex: "$"
294
+ }, {
295
+ token: "empty",
296
+ regex: "",
297
+ next: "no_regex"
298
+ }
299
+ ],
300
+ "comment_regex_allowed" : [
301
+ DocCommentHighlightRules.getTagRule(),
302
+ {token : "comment", regex : "\\*\\/", next : "start"},
303
+ {defaultToken : "comment", caseInsensitive: true}
304
+ ],
305
+ "comment" : [
306
+ DocCommentHighlightRules.getTagRule(),
307
+ {token : "comment", regex : "\\*\\/", next : "no_regex"},
308
+ {defaultToken : "comment", caseInsensitive: true}
309
+ ],
310
+ "line_comment_regex_allowed" : [
311
+ DocCommentHighlightRules.getTagRule(),
312
+ {token : "comment", regex : "$|^", next : "start"},
313
+ {defaultToken : "comment", caseInsensitive: true}
314
+ ],
315
+ "line_comment" : [
316
+ DocCommentHighlightRules.getTagRule(),
317
+ {token : "comment", regex : "$|^", next : "no_regex"},
318
+ {defaultToken : "comment", caseInsensitive: true}
319
+ ],
320
+ "qqstring" : [
321
+ {
322
+ token : "constant.language.escape",
323
+ regex : escapedRe
324
+ }, {
325
+ token : "string",
326
+ regex : "\\\\$",
327
+ next : "qqstring"
328
+ }, {
329
+ token : "string",
330
+ regex : '"|$',
331
+ next : "no_regex"
332
+ }, {
333
+ defaultToken: "string"
334
+ }
335
+ ],
336
+ "qstring" : [
337
+ {
338
+ token : "constant.language.escape",
339
+ regex : escapedRe
340
+ }, {
341
+ token : "string",
342
+ regex : "\\\\$",
343
+ next : "qstring"
344
+ }, {
345
+ token : "string",
346
+ regex : "'|$",
347
+ next : "no_regex"
348
+ }, {
349
+ defaultToken: "string"
350
+ }
351
+ ]
352
+ };
353
+
354
+
355
+ if (!options || !options.noES6) {
356
+ this.$rules.no_regex.unshift({
357
+ regex: "[{}]", onMatch: function(val, state, stack) {
358
+ this.next = val == "{" ? this.nextState : "";
359
+ if (val == "{" && stack.length) {
360
+ stack.unshift("start", state);
361
+ return "paren";
362
+ }
363
+ if (val == "}" && stack.length) {
364
+ stack.shift();
365
+ this.next = stack.shift();
366
+ if (this.next.indexOf("string") != -1)
367
+ return "paren.quasi.end";
368
+ }
369
+ return val == "{" ? "paren.lparen" : "paren.rparen";
370
+ },
371
+ nextState: "start"
372
+ }, {
373
+ token : "string.quasi.start",
374
+ regex : /`/,
375
+ push : [{
376
+ token : "constant.language.escape",
377
+ regex : escapedRe
378
+ }, {
379
+ token : "paren.quasi.start",
380
+ regex : /\${/,
381
+ push : "start"
382
+ }, {
383
+ token : "string.quasi.end",
384
+ regex : /`/,
385
+ next : "pop"
386
+ }, {
387
+ defaultToken: "string.quasi"
388
+ }]
389
+ });
390
+ }
391
+
392
+ this.embedRules(DocCommentHighlightRules, "doc-",
393
+ [ DocCommentHighlightRules.getEndRule("no_regex") ]);
394
+
395
+ this.normalizeRules();
396
+ };
397
+
398
+ oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
399
+
400
+ exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
401
+ });
402
+
403
+ define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
404
+ "use strict";
405
+
406
+ var Range = require("../range").Range;
407
+
408
+ var MatchingBraceOutdent = function() {};
409
+
410
+ (function() {
411
+
412
+ this.checkOutdent = function(line, input) {
413
+ if (! /^\s+$/.test(line))
414
+ return false;
415
+
416
+ return /^\s*\}/.test(input);
417
+ };
418
+
419
+ this.autoOutdent = function(doc, row) {
420
+ var line = doc.getLine(row);
421
+ var match = line.match(/^(\s*\})/);
422
+
423
+ if (!match) return 0;
424
+
425
+ var column = match[1].length;
426
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
427
+
428
+ if (!openBracePos || openBracePos.row == row) return 0;
429
+
430
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
431
+ doc.replace(new Range(row, 0, row, column-1), indent);
432
+ };
433
+
434
+ this.$getIndent = function(line) {
435
+ return line.match(/^\s*/)[0];
436
+ };
437
+
438
+ }).call(MatchingBraceOutdent.prototype);
439
+
440
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
441
+ });
442
+
443
+ define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
444
+ "use strict";
445
+
446
+ var oop = require("../../lib/oop");
447
+ var Behaviour = require("../behaviour").Behaviour;
448
+ var TokenIterator = require("../../token_iterator").TokenIterator;
449
+ var lang = require("../../lib/lang");
450
+
451
+ var SAFE_INSERT_IN_TOKENS =
452
+ ["text", "paren.rparen", "punctuation.operator"];
453
+ var SAFE_INSERT_BEFORE_TOKENS =
454
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
455
+
456
+ var context;
457
+ var contextCache = {};
458
+ var initContext = function(editor) {
459
+ var id = -1;
460
+ if (editor.multiSelect) {
461
+ id = editor.selection.index;
462
+ if (contextCache.rangeCount != editor.multiSelect.rangeCount)
463
+ contextCache = {rangeCount: editor.multiSelect.rangeCount};
464
+ }
465
+ if (contextCache[id])
466
+ return context = contextCache[id];
467
+ context = contextCache[id] = {
468
+ autoInsertedBrackets: 0,
469
+ autoInsertedRow: -1,
470
+ autoInsertedLineEnd: "",
471
+ maybeInsertedBrackets: 0,
472
+ maybeInsertedRow: -1,
473
+ maybeInsertedLineStart: "",
474
+ maybeInsertedLineEnd: ""
475
+ };
476
+ };
477
+
478
+ var CstyleBehaviour = function() {
479
+ this.add("braces", "insertion", function(state, action, editor, session, text) {
480
+ var cursor = editor.getCursorPosition();
481
+ var line = session.doc.getLine(cursor.row);
482
+ if (text == '{') {
483
+ initContext(editor);
484
+ var selection = editor.getSelectionRange();
485
+ var selected = session.doc.getTextRange(selection);
486
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
487
+ return {
488
+ text: '{' + selected + '}',
489
+ selection: false
490
+ };
491
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
492
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
493
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
494
+ return {
495
+ text: '{}',
496
+ selection: [1, 1]
497
+ };
498
+ } else {
499
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
500
+ return {
501
+ text: '{',
502
+ selection: [1, 1]
503
+ };
504
+ }
505
+ }
506
+ } else if (text == '}') {
507
+ initContext(editor);
508
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
509
+ if (rightChar == '}') {
510
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
511
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
512
+ CstyleBehaviour.popAutoInsertedClosing();
513
+ return {
514
+ text: '',
515
+ selection: [1, 1]
516
+ };
517
+ }
518
+ }
519
+ } else if (text == "\n" || text == "\r\n") {
520
+ initContext(editor);
521
+ var closing = "";
522
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
523
+ closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
524
+ CstyleBehaviour.clearMaybeInsertedClosing();
525
+ }
526
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
527
+ if (rightChar === '}') {
528
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
529
+ if (!openBracePos)
530
+ return null;
531
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
532
+ } else if (closing) {
533
+ var next_indent = this.$getIndent(line);
534
+ } else {
535
+ CstyleBehaviour.clearMaybeInsertedClosing();
536
+ return;
537
+ }
538
+ var indent = next_indent + session.getTabString();
539
+
540
+ return {
541
+ text: '\n' + indent + '\n' + next_indent + closing,
542
+ selection: [1, indent.length, 1, indent.length]
543
+ };
544
+ } else {
545
+ CstyleBehaviour.clearMaybeInsertedClosing();
546
+ }
547
+ });
548
+
549
+ this.add("braces", "deletion", function(state, action, editor, session, range) {
550
+ var selected = session.doc.getTextRange(range);
551
+ if (!range.isMultiLine() && selected == '{') {
552
+ initContext(editor);
553
+ var line = session.doc.getLine(range.start.row);
554
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
555
+ if (rightChar == '}') {
556
+ range.end.column++;
557
+ return range;
558
+ } else {
559
+ context.maybeInsertedBrackets--;
560
+ }
561
+ }
562
+ });
563
+
564
+ this.add("parens", "insertion", function(state, action, editor, session, text) {
565
+ if (text == '(') {
566
+ initContext(editor);
567
+ var selection = editor.getSelectionRange();
568
+ var selected = session.doc.getTextRange(selection);
569
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
570
+ return {
571
+ text: '(' + selected + ')',
572
+ selection: false
573
+ };
574
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
575
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
576
+ return {
577
+ text: '()',
578
+ selection: [1, 1]
579
+ };
580
+ }
581
+ } else if (text == ')') {
582
+ initContext(editor);
583
+ var cursor = editor.getCursorPosition();
584
+ var line = session.doc.getLine(cursor.row);
585
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
586
+ if (rightChar == ')') {
587
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
588
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
589
+ CstyleBehaviour.popAutoInsertedClosing();
590
+ return {
591
+ text: '',
592
+ selection: [1, 1]
593
+ };
594
+ }
595
+ }
596
+ }
597
+ });
598
+
599
+ this.add("parens", "deletion", function(state, action, editor, session, range) {
600
+ var selected = session.doc.getTextRange(range);
601
+ if (!range.isMultiLine() && selected == '(') {
602
+ initContext(editor);
603
+ var line = session.doc.getLine(range.start.row);
604
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
605
+ if (rightChar == ')') {
606
+ range.end.column++;
607
+ return range;
608
+ }
609
+ }
610
+ });
611
+
612
+ this.add("brackets", "insertion", function(state, action, editor, session, text) {
613
+ if (text == '[') {
614
+ initContext(editor);
615
+ var selection = editor.getSelectionRange();
616
+ var selected = session.doc.getTextRange(selection);
617
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
618
+ return {
619
+ text: '[' + selected + ']',
620
+ selection: false
621
+ };
622
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
623
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
624
+ return {
625
+ text: '[]',
626
+ selection: [1, 1]
627
+ };
628
+ }
629
+ } else if (text == ']') {
630
+ initContext(editor);
631
+ var cursor = editor.getCursorPosition();
632
+ var line = session.doc.getLine(cursor.row);
633
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
634
+ if (rightChar == ']') {
635
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
636
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
637
+ CstyleBehaviour.popAutoInsertedClosing();
638
+ return {
639
+ text: '',
640
+ selection: [1, 1]
641
+ };
642
+ }
643
+ }
644
+ }
645
+ });
646
+
647
+ this.add("brackets", "deletion", function(state, action, editor, session, range) {
648
+ var selected = session.doc.getTextRange(range);
649
+ if (!range.isMultiLine() && selected == '[') {
650
+ initContext(editor);
651
+ var line = session.doc.getLine(range.start.row);
652
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
653
+ if (rightChar == ']') {
654
+ range.end.column++;
655
+ return range;
656
+ }
657
+ }
658
+ });
659
+
660
+ this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
661
+ if (text == '"' || text == "'") {
662
+ initContext(editor);
663
+ var quote = text;
664
+ var selection = editor.getSelectionRange();
665
+ var selected = session.doc.getTextRange(selection);
666
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
667
+ return {
668
+ text: quote + selected + quote,
669
+ selection: false
670
+ };
671
+ } else if (!selected) {
672
+ var cursor = editor.getCursorPosition();
673
+ var line = session.doc.getLine(cursor.row);
674
+ var leftChar = line.substring(cursor.column-1, cursor.column);
675
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
676
+
677
+ var token = session.getTokenAt(cursor.row, cursor.column);
678
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
679
+ if (leftChar == "\\" && token && /escape/.test(token.type))
680
+ return null;
681
+
682
+ var stringBefore = token && /string/.test(token.type);
683
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
684
+
685
+ var pair;
686
+ if (rightChar == quote) {
687
+ pair = stringBefore !== stringAfter;
688
+ } else {
689
+ if (stringBefore && !stringAfter)
690
+ return null; // wrap string with different quote
691
+ if (stringBefore && stringAfter)
692
+ return null; // do not pair quotes inside strings
693
+ var wordRe = session.$mode.tokenRe;
694
+ wordRe.lastIndex = 0;
695
+ var isWordBefore = wordRe.test(leftChar);
696
+ wordRe.lastIndex = 0;
697
+ var isWordAfter = wordRe.test(leftChar);
698
+ if (isWordBefore || isWordAfter)
699
+ return null; // before or after alphanumeric
700
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
701
+ return null; // there is rightChar and it isn't closing
702
+ pair = true;
703
+ }
704
+ return {
705
+ text: pair ? quote + quote : "",
706
+ selection: [1,1]
707
+ };
708
+ }
709
+ }
710
+ });
711
+
712
+ this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
713
+ var selected = session.doc.getTextRange(range);
714
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
715
+ initContext(editor);
716
+ var line = session.doc.getLine(range.start.row);
717
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
718
+ if (rightChar == selected) {
719
+ range.end.column++;
720
+ return range;
721
+ }
722
+ }
723
+ });
724
+
725
+ };
726
+
727
+
728
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
729
+ var cursor = editor.getCursorPosition();
730
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
731
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
732
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
733
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
734
+ return false;
735
+ }
736
+ iterator.stepForward();
737
+ return iterator.getCurrentTokenRow() !== cursor.row ||
738
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
739
+ };
740
+
741
+ CstyleBehaviour.$matchTokenType = function(token, types) {
742
+ return types.indexOf(token.type || token) > -1;
743
+ };
744
+
745
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
746
+ var cursor = editor.getCursorPosition();
747
+ var line = session.doc.getLine(cursor.row);
748
+ if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
749
+ context.autoInsertedBrackets = 0;
750
+ context.autoInsertedRow = cursor.row;
751
+ context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
752
+ context.autoInsertedBrackets++;
753
+ };
754
+
755
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
756
+ var cursor = editor.getCursorPosition();
757
+ var line = session.doc.getLine(cursor.row);
758
+ if (!this.isMaybeInsertedClosing(cursor, line))
759
+ context.maybeInsertedBrackets = 0;
760
+ context.maybeInsertedRow = cursor.row;
761
+ context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
762
+ context.maybeInsertedLineEnd = line.substr(cursor.column);
763
+ context.maybeInsertedBrackets++;
764
+ };
765
+
766
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
767
+ return context.autoInsertedBrackets > 0 &&
768
+ cursor.row === context.autoInsertedRow &&
769
+ bracket === context.autoInsertedLineEnd[0] &&
770
+ line.substr(cursor.column) === context.autoInsertedLineEnd;
771
+ };
772
+
773
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
774
+ return context.maybeInsertedBrackets > 0 &&
775
+ cursor.row === context.maybeInsertedRow &&
776
+ line.substr(cursor.column) === context.maybeInsertedLineEnd &&
777
+ line.substr(0, cursor.column) == context.maybeInsertedLineStart;
778
+ };
779
+
780
+ CstyleBehaviour.popAutoInsertedClosing = function() {
781
+ context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
782
+ context.autoInsertedBrackets--;
783
+ };
784
+
785
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
786
+ if (context) {
787
+ context.maybeInsertedBrackets = 0;
788
+ context.maybeInsertedRow = -1;
789
+ }
790
+ };
791
+
792
+
793
+
794
+ oop.inherits(CstyleBehaviour, Behaviour);
795
+
796
+ exports.CstyleBehaviour = CstyleBehaviour;
797
+ });
798
+
799
+ define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
800
+ "use strict";
801
+
802
+ var oop = require("../../lib/oop");
803
+ var Range = require("../../range").Range;
804
+ var BaseFoldMode = require("./fold_mode").FoldMode;
805
+
806
+ var FoldMode = exports.FoldMode = function(commentRegex) {
807
+ if (commentRegex) {
808
+ this.foldingStartMarker = new RegExp(
809
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
810
+ );
811
+ this.foldingStopMarker = new RegExp(
812
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
813
+ );
814
+ }
815
+ };
816
+ oop.inherits(FoldMode, BaseFoldMode);
817
+
818
+ (function() {
819
+
820
+ this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
821
+ this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
822
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
823
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
824
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
825
+ this._getFoldWidgetBase = this.getFoldWidget;
826
+ this.getFoldWidget = function(session, foldStyle, row) {
827
+ var line = session.getLine(row);
828
+
829
+ if (this.singleLineBlockCommentRe.test(line)) {
830
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
831
+ return "";
832
+ }
833
+
834
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
835
+
836
+ if (!fw && this.startRegionRe.test(line))
837
+ return "start"; // lineCommentRegionStart
838
+
839
+ return fw;
840
+ };
841
+
842
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
843
+ var line = session.getLine(row);
844
+
845
+ if (this.startRegionRe.test(line))
846
+ return this.getCommentRegionBlock(session, line, row);
847
+
848
+ var match = line.match(this.foldingStartMarker);
849
+ if (match) {
850
+ var i = match.index;
851
+
852
+ if (match[1])
853
+ return this.openingBracketBlock(session, match[1], row, i);
854
+
855
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
856
+
857
+ if (range && !range.isMultiLine()) {
858
+ if (forceMultiline) {
859
+ range = this.getSectionRange(session, row);
860
+ } else if (foldStyle != "all")
861
+ range = null;
862
+ }
863
+
864
+ return range;
865
+ }
866
+
867
+ if (foldStyle === "markbegin")
868
+ return;
869
+
870
+ var match = line.match(this.foldingStopMarker);
871
+ if (match) {
872
+ var i = match.index + match[0].length;
873
+
874
+ if (match[1])
875
+ return this.closingBracketBlock(session, match[1], row, i);
876
+
877
+ return session.getCommentFoldRange(row, i, -1);
878
+ }
879
+ };
880
+
881
+ this.getSectionRange = function(session, row) {
882
+ var line = session.getLine(row);
883
+ var startIndent = line.search(/\S/);
884
+ var startRow = row;
885
+ var startColumn = line.length;
886
+ row = row + 1;
887
+ var endRow = row;
888
+ var maxRow = session.getLength();
889
+ while (++row < maxRow) {
890
+ line = session.getLine(row);
891
+ var indent = line.search(/\S/);
892
+ if (indent === -1)
893
+ continue;
894
+ if (startIndent > indent)
895
+ break;
896
+ var subRange = this.getFoldWidgetRange(session, "all", row);
897
+
898
+ if (subRange) {
899
+ if (subRange.start.row <= startRow) {
900
+ break;
901
+ } else if (subRange.isMultiLine()) {
902
+ row = subRange.end.row;
903
+ } else if (startIndent == indent) {
904
+ break;
905
+ }
906
+ }
907
+ endRow = row;
908
+ }
909
+
910
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
911
+ };
912
+
913
+ this.getCommentRegionBlock = function(session, line, row) {
914
+ var startColumn = line.search(/\s*$/);
915
+ var maxRow = session.getLength();
916
+ var startRow = row;
917
+
918
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
919
+ var depth = 1;
920
+ while (++row < maxRow) {
921
+ line = session.getLine(row);
922
+ var m = re.exec(line);
923
+ if (!m) continue;
924
+ if (m[1]) depth--;
925
+ else depth++;
926
+
927
+ if (!depth) break;
928
+ }
929
+
930
+ var endRow = row;
931
+ if (endRow > startRow) {
932
+ return new Range(startRow, startColumn, endRow, line.length);
933
+ }
934
+ };
935
+
936
+ }).call(FoldMode.prototype);
937
+
938
+ });
939
+
940
+ define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
941
+ "use strict";
942
+
943
+ var oop = require("../lib/oop");
944
+ var TextMode = require("./text").Mode;
945
+ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
946
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
947
+ var Range = require("../range").Range;
948
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
949
+ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
950
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
951
+
952
+ var Mode = function() {
953
+ this.HighlightRules = JavaScriptHighlightRules;
954
+
955
+ this.$outdent = new MatchingBraceOutdent();
956
+ this.$behaviour = new CstyleBehaviour();
957
+ this.foldingRules = new CStyleFoldMode();
958
+ };
959
+ oop.inherits(Mode, TextMode);
960
+
961
+ (function() {
962
+
963
+ this.lineCommentStart = "//";
964
+ this.blockComment = {start: "/*", end: "*/"};
965
+
966
+ this.getNextLineIndent = function(state, line, tab) {
967
+ var indent = this.$getIndent(line);
968
+
969
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
970
+ var tokens = tokenizedLine.tokens;
971
+ var endState = tokenizedLine.state;
972
+
973
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
974
+ return indent;
975
+ }
976
+
977
+ if (state == "start" || state == "no_regex") {
978
+ var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
979
+ if (match) {
980
+ indent += tab;
981
+ }
982
+ } else if (state == "doc-start") {
983
+ if (endState == "start" || endState == "no_regex") {
984
+ return "";
985
+ }
986
+ var match = line.match(/^\s*(\/?)\*/);
987
+ if (match) {
988
+ if (match[1]) {
989
+ indent += " ";
990
+ }
991
+ indent += "* ";
992
+ }
993
+ }
994
+
995
+ return indent;
996
+ };
997
+
998
+ this.checkOutdent = function(state, line, input) {
999
+ return this.$outdent.checkOutdent(line, input);
1000
+ };
1001
+
1002
+ this.autoOutdent = function(state, doc, row) {
1003
+ this.$outdent.autoOutdent(doc, row);
1004
+ };
1005
+
1006
+ this.createWorker = function(session) {
1007
+ var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
1008
+ worker.attachToDocument(session.getDocument());
1009
+
1010
+ worker.on("annotate", function(results) {
1011
+ session.setAnnotations(results.data);
1012
+ });
1013
+
1014
+ worker.on("terminate", function() {
1015
+ session.clearAnnotations();
1016
+ });
1017
+
1018
+ return worker;
1019
+ };
1020
+
1021
+ this.$id = "ace/mode/javascript";
1022
+ }).call(Mode.prototype);
1023
+
1024
+ exports.Mode = Mode;
1025
+ });
1026
+
1027
+ define("ace/mode/css_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
1028
+ "use strict";
1029
+
1030
+ var oop = require("../lib/oop");
1031
+ var lang = require("../lib/lang");
1032
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1033
+ var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|pointer-events|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
1034
+ var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
1035
+ var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
1036
+ var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
1037
+ var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
1038
+
1039
+ var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1040
+ var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1041
+ var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
1042
+
1043
+ var CssHighlightRules = function() {
1044
+
1045
+ var keywordMapper = this.createKeywordMapper({
1046
+ "support.function": supportFunction,
1047
+ "support.constant": supportConstant,
1048
+ "support.type": supportType,
1049
+ "support.constant.color": supportConstantColor,
1050
+ "support.constant.fonts": supportConstantFonts
1051
+ }, "text", true);
1052
+
1053
+ this.$rules = {
1054
+ "start" : [{
1055
+ token : "comment", // multi line comment
1056
+ regex : "\\/\\*",
1057
+ push : "comment"
1058
+ }, {
1059
+ token: "paren.lparen",
1060
+ regex: "\\{",
1061
+ push: "ruleset"
1062
+ }, {
1063
+ token: "string",
1064
+ regex: "@.*?{",
1065
+ push: "media"
1066
+ }, {
1067
+ token: "keyword",
1068
+ regex: "#[a-z0-9-_]+"
1069
+ }, {
1070
+ token: "variable",
1071
+ regex: "\\.[a-z0-9-_]+"
1072
+ }, {
1073
+ token: "string",
1074
+ regex: ":[a-z0-9-_]+"
1075
+ }, {
1076
+ token: "constant",
1077
+ regex: "[a-z0-9-_]+"
1078
+ }, {
1079
+ caseInsensitive: true
1080
+ }],
1081
+
1082
+ "media" : [{
1083
+ token : "comment", // multi line comment
1084
+ regex : "\\/\\*",
1085
+ push : "comment"
1086
+ }, {
1087
+ token: "paren.lparen",
1088
+ regex: "\\{",
1089
+ push: "ruleset"
1090
+ }, {
1091
+ token: "string",
1092
+ regex: "\\}",
1093
+ next: "pop"
1094
+ }, {
1095
+ token: "keyword",
1096
+ regex: "#[a-z0-9-_]+"
1097
+ }, {
1098
+ token: "variable",
1099
+ regex: "\\.[a-z0-9-_]+"
1100
+ }, {
1101
+ token: "string",
1102
+ regex: ":[a-z0-9-_]+"
1103
+ }, {
1104
+ token: "constant",
1105
+ regex: "[a-z0-9-_]+"
1106
+ }, {
1107
+ caseInsensitive: true
1108
+ }],
1109
+
1110
+ "comment" : [{
1111
+ token : "comment",
1112
+ regex : "\\*\\/",
1113
+ next : "pop"
1114
+ }, {
1115
+ defaultToken : "comment"
1116
+ }],
1117
+
1118
+ "ruleset" : [
1119
+ {
1120
+ token : "paren.rparen",
1121
+ regex : "\\}",
1122
+ next: "pop"
1123
+ }, {
1124
+ token : "comment", // multi line comment
1125
+ regex : "\\/\\*",
1126
+ push : "comment"
1127
+ }, {
1128
+ token : "string", // single line
1129
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1130
+ }, {
1131
+ token : "string", // single line
1132
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1133
+ }, {
1134
+ token : ["constant.numeric", "keyword"],
1135
+ regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
1136
+ }, {
1137
+ token : "constant.numeric",
1138
+ regex : numRe
1139
+ }, {
1140
+ token : "constant.numeric", // hex6 color
1141
+ regex : "#[a-f0-9]{6}"
1142
+ }, {
1143
+ token : "constant.numeric", // hex3 color
1144
+ regex : "#[a-f0-9]{3}"
1145
+ }, {
1146
+ token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1147
+ regex : pseudoElements
1148
+ }, {
1149
+ token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1150
+ regex : pseudoClasses
1151
+ }, {
1152
+ token : ["support.function", "string", "support.function"],
1153
+ regex : "(url\\()(.*)(\\))"
1154
+ }, {
1155
+ token : keywordMapper,
1156
+ regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1157
+ }, {
1158
+ caseInsensitive: true
1159
+ }]
1160
+ };
1161
+
1162
+ this.normalizeRules();
1163
+ };
1164
+
1165
+ oop.inherits(CssHighlightRules, TextHighlightRules);
1166
+
1167
+ exports.CssHighlightRules = CssHighlightRules;
1168
+
1169
+ });
1170
+
1171
+ define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(require, exports, module) {
1172
+ "use strict";
1173
+
1174
+ var oop = require("../../lib/oop");
1175
+ var Behaviour = require("../behaviour").Behaviour;
1176
+ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1177
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1178
+
1179
+ var CssBehaviour = function () {
1180
+
1181
+ this.inherit(CstyleBehaviour);
1182
+
1183
+ this.add("colon", "insertion", function (state, action, editor, session, text) {
1184
+ if (text === ':') {
1185
+ var cursor = editor.getCursorPosition();
1186
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1187
+ var token = iterator.getCurrentToken();
1188
+ if (token && token.value.match(/\s+/)) {
1189
+ token = iterator.stepBackward();
1190
+ }
1191
+ if (token && token.type === 'support.type') {
1192
+ var line = session.doc.getLine(cursor.row);
1193
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1194
+ if (rightChar === ':') {
1195
+ return {
1196
+ text: '',
1197
+ selection: [1, 1]
1198
+ }
1199
+ }
1200
+ if (!line.substring(cursor.column).match(/^\s*;/)) {
1201
+ return {
1202
+ text: ':;',
1203
+ selection: [1, 1]
1204
+ }
1205
+ }
1206
+ }
1207
+ }
1208
+ });
1209
+
1210
+ this.add("colon", "deletion", function (state, action, editor, session, range) {
1211
+ var selected = session.doc.getTextRange(range);
1212
+ if (!range.isMultiLine() && selected === ':') {
1213
+ var cursor = editor.getCursorPosition();
1214
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1215
+ var token = iterator.getCurrentToken();
1216
+ if (token && token.value.match(/\s+/)) {
1217
+ token = iterator.stepBackward();
1218
+ }
1219
+ if (token && token.type === 'support.type') {
1220
+ var line = session.doc.getLine(range.start.row);
1221
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
1222
+ if (rightChar === ';') {
1223
+ range.end.column ++;
1224
+ return range;
1225
+ }
1226
+ }
1227
+ }
1228
+ });
1229
+
1230
+ this.add("semicolon", "insertion", function (state, action, editor, session, text) {
1231
+ if (text === ';') {
1232
+ var cursor = editor.getCursorPosition();
1233
+ var line = session.doc.getLine(cursor.row);
1234
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1235
+ if (rightChar === ';') {
1236
+ return {
1237
+ text: '',
1238
+ selection: [1, 1]
1239
+ }
1240
+ }
1241
+ }
1242
+ });
1243
+
1244
+ }
1245
+ oop.inherits(CssBehaviour, CstyleBehaviour);
1246
+
1247
+ exports.CssBehaviour = CssBehaviour;
1248
+ });
1249
+
1250
+ define("ace/mode/css",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/css_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(require, exports, module) {
1251
+ "use strict";
1252
+
1253
+ var oop = require("../lib/oop");
1254
+ var TextMode = require("./text").Mode;
1255
+ var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1256
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1257
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
1258
+ var CssBehaviour = require("./behaviour/css").CssBehaviour;
1259
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1260
+
1261
+ var Mode = function() {
1262
+ this.HighlightRules = CssHighlightRules;
1263
+ this.$outdent = new MatchingBraceOutdent();
1264
+ this.$behaviour = new CssBehaviour();
1265
+ this.foldingRules = new CStyleFoldMode();
1266
+ };
1267
+ oop.inherits(Mode, TextMode);
1268
+
1269
+ (function() {
1270
+
1271
+ this.foldingRules = "cStyle";
1272
+ this.blockComment = {start: "/*", end: "*/"};
1273
+
1274
+ this.getNextLineIndent = function(state, line, tab) {
1275
+ var indent = this.$getIndent(line);
1276
+ var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
1277
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
1278
+ return indent;
1279
+ }
1280
+
1281
+ var match = line.match(/^.*\{\s*$/);
1282
+ if (match) {
1283
+ indent += tab;
1284
+ }
1285
+
1286
+ return indent;
1287
+ };
1288
+
1289
+ this.checkOutdent = function(state, line, input) {
1290
+ return this.$outdent.checkOutdent(line, input);
1291
+ };
1292
+
1293
+ this.autoOutdent = function(state, doc, row) {
1294
+ this.$outdent.autoOutdent(doc, row);
1295
+ };
1296
+
1297
+ this.createWorker = function(session) {
1298
+ var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1299
+ worker.attachToDocument(session.getDocument());
1300
+
1301
+ worker.on("annotate", function(e) {
1302
+ session.setAnnotations(e.data);
1303
+ });
1304
+
1305
+ worker.on("terminate", function() {
1306
+ session.clearAnnotations();
1307
+ });
1308
+
1309
+ return worker;
1310
+ };
1311
+
1312
+ this.$id = "ace/mode/css";
1313
+ }).call(Mode.prototype);
1314
+
1315
+ exports.Mode = Mode;
1316
+
1317
+ });
1318
+
1319
+ define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
1320
+ "use strict";
1321
+
1322
+ var oop = require("../lib/oop");
1323
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1324
+
1325
+ var XmlHighlightRules = function(normalize) {
1326
+
1327
+ var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
1328
+
1329
+ this.$rules = {
1330
+ start : [
1331
+ {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
1332
+ {
1333
+ token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
1334
+ regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
1335
+ },
1336
+ {
1337
+ token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
1338
+ regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
1339
+ },
1340
+ {token : "comment.xml", regex : "<\\!--", next : "comment"},
1341
+ {
1342
+ token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
1343
+ regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
1344
+ },
1345
+ {include : "tag"},
1346
+ {token : "text.end-tag-open.xml", regex: "</"},
1347
+ {token : "text.tag-open.xml", regex: "<"},
1348
+ {include : "reference"},
1349
+ {defaultToken : "text.xml"}
1350
+ ],
1351
+
1352
+ xml_decl : [{
1353
+ token : "entity.other.attribute-name.decl-attribute-name.xml",
1354
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
1355
+ }, {
1356
+ token : "keyword.operator.decl-attribute-equals.xml",
1357
+ regex : "="
1358
+ }, {
1359
+ include: "whitespace"
1360
+ }, {
1361
+ include: "string"
1362
+ }, {
1363
+ token : "punctuation.xml-decl.xml",
1364
+ regex : "\\?>",
1365
+ next : "start"
1366
+ }],
1367
+
1368
+ processing_instruction : [
1369
+ {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
1370
+ {defaultToken : "instruction.xml"}
1371
+ ],
1372
+
1373
+ doctype : [
1374
+ {include : "whitespace"},
1375
+ {include : "string"},
1376
+ {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
1377
+ {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
1378
+ {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
1379
+ ],
1380
+
1381
+ int_subset : [{
1382
+ token : "text.xml",
1383
+ regex : "\\s+"
1384
+ }, {
1385
+ token: "punctuation.int-subset.xml",
1386
+ regex: "]",
1387
+ next: "pop"
1388
+ }, {
1389
+ token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
1390
+ regex : "(<\\!)(" + tagRegex + ")",
1391
+ push : [{
1392
+ token : "text",
1393
+ regex : "\\s+"
1394
+ },
1395
+ {
1396
+ token : "punctuation.markup-decl.xml",
1397
+ regex : ">",
1398
+ next : "pop"
1399
+ },
1400
+ {include : "string"}]
1401
+ }],
1402
+
1403
+ cdata : [
1404
+ {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
1405
+ {token : "text.xml", regex : "\\s+"},
1406
+ {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
1407
+ ],
1408
+
1409
+ comment : [
1410
+ {token : "comment.xml", regex : "-->", next : "start"},
1411
+ {defaultToken : "comment.xml"}
1412
+ ],
1413
+
1414
+ reference : [{
1415
+ token : "constant.language.escape.reference.xml",
1416
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1417
+ }],
1418
+
1419
+ attr_reference : [{
1420
+ token : "constant.language.escape.reference.attribute-value.xml",
1421
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1422
+ }],
1423
+
1424
+ tag : [{
1425
+ token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
1426
+ regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
1427
+ next: [
1428
+ {include : "attributes"},
1429
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
1430
+ ]
1431
+ }],
1432
+
1433
+ tag_whitespace : [
1434
+ {token : "text.tag-whitespace.xml", regex : "\\s+"}
1435
+ ],
1436
+ whitespace : [
1437
+ {token : "text.whitespace.xml", regex : "\\s+"}
1438
+ ],
1439
+ string: [{
1440
+ token : "string.xml",
1441
+ regex : "'",
1442
+ push : [
1443
+ {token : "string.xml", regex: "'", next: "pop"},
1444
+ {defaultToken : "string.xml"}
1445
+ ]
1446
+ }, {
1447
+ token : "string.xml",
1448
+ regex : '"',
1449
+ push : [
1450
+ {token : "string.xml", regex: '"', next: "pop"},
1451
+ {defaultToken : "string.xml"}
1452
+ ]
1453
+ }],
1454
+
1455
+ attributes: [{
1456
+ token : "entity.other.attribute-name.xml",
1457
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
1458
+ }, {
1459
+ token : "keyword.operator.attribute-equals.xml",
1460
+ regex : "="
1461
+ }, {
1462
+ include: "tag_whitespace"
1463
+ }, {
1464
+ include: "attribute_value"
1465
+ }],
1466
+
1467
+ attribute_value: [{
1468
+ token : "string.attribute-value.xml",
1469
+ regex : "'",
1470
+ push : [
1471
+ {token : "string.attribute-value.xml", regex: "'", next: "pop"},
1472
+ {include : "attr_reference"},
1473
+ {defaultToken : "string.attribute-value.xml"}
1474
+ ]
1475
+ }, {
1476
+ token : "string.attribute-value.xml",
1477
+ regex : '"',
1478
+ push : [
1479
+ {token : "string.attribute-value.xml", regex: '"', next: "pop"},
1480
+ {include : "attr_reference"},
1481
+ {defaultToken : "string.attribute-value.xml"}
1482
+ ]
1483
+ }]
1484
+ };
1485
+
1486
+ if (this.constructor === XmlHighlightRules)
1487
+ this.normalizeRules();
1488
+ };
1489
+
1490
+
1491
+ (function() {
1492
+
1493
+ this.embedTagRules = function(HighlightRules, prefix, tag){
1494
+ this.$rules.tag.unshift({
1495
+ token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
1496
+ regex : "(<)(" + tag + "(?=\\s|>|$))",
1497
+ next: [
1498
+ {include : "attributes"},
1499
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
1500
+ ]
1501
+ });
1502
+
1503
+ this.$rules[tag + "-end"] = [
1504
+ {include : "attributes"},
1505
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
1506
+ onMatch : function(value, currentState, stack) {
1507
+ stack.splice(0);
1508
+ return this.token;
1509
+ }}
1510
+ ]
1511
+
1512
+ this.embedRules(HighlightRules, prefix, [{
1513
+ token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
1514
+ regex : "(</)(" + tag + "(?=\\s|>|$))",
1515
+ next: tag + "-end"
1516
+ }, {
1517
+ token: "string.cdata.xml",
1518
+ regex : "<\\!\\[CDATA\\["
1519
+ }, {
1520
+ token: "string.cdata.xml",
1521
+ regex : "\\]\\]>"
1522
+ }]);
1523
+ };
1524
+
1525
+ }).call(TextHighlightRules.prototype);
1526
+
1527
+ oop.inherits(XmlHighlightRules, TextHighlightRules);
1528
+
1529
+ exports.XmlHighlightRules = XmlHighlightRules;
1530
+ });
1531
+
1532
+ define("ace/mode/html_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/css_highlight_rules","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module) {
1533
+ "use strict";
1534
+
1535
+ var oop = require("../lib/oop");
1536
+ var lang = require("../lib/lang");
1537
+ var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1538
+ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1539
+ var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
1540
+
1541
+ var tagMap = lang.createMap({
1542
+ a : 'anchor',
1543
+ button : 'form',
1544
+ form : 'form',
1545
+ img : 'image',
1546
+ input : 'form',
1547
+ label : 'form',
1548
+ option : 'form',
1549
+ script : 'script',
1550
+ select : 'form',
1551
+ textarea : 'form',
1552
+ style : 'style',
1553
+ table : 'table',
1554
+ tbody : 'table',
1555
+ td : 'table',
1556
+ tfoot : 'table',
1557
+ th : 'table',
1558
+ tr : 'table'
1559
+ });
1560
+
1561
+ var HtmlHighlightRules = function() {
1562
+ XmlHighlightRules.call(this);
1563
+
1564
+ this.addRules({
1565
+ attributes: [{
1566
+ include : "tag_whitespace"
1567
+ }, {
1568
+ token : "entity.other.attribute-name.xml",
1569
+ regex : "[-_a-zA-Z0-9:]+"
1570
+ }, {
1571
+ token : "keyword.operator.attribute-equals.xml",
1572
+ regex : "=",
1573
+ push : [{
1574
+ include: "tag_whitespace"
1575
+ }, {
1576
+ token : "string.unquoted.attribute-value.html",
1577
+ regex : "[^<>='\"`\\s]+",
1578
+ next : "pop"
1579
+ }, {
1580
+ token : "empty",
1581
+ regex : "",
1582
+ next : "pop"
1583
+ }]
1584
+ }, {
1585
+ include : "attribute_value"
1586
+ }],
1587
+ tag: [{
1588
+ token : function(start, tag) {
1589
+ var group = tagMap[tag];
1590
+ return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
1591
+ "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
1592
+ },
1593
+ regex : "(</?)([-_a-zA-Z0-9:]+)",
1594
+ next: "tag_stuff"
1595
+ }],
1596
+ tag_stuff: [
1597
+ {include : "attributes"},
1598
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
1599
+ ],
1600
+ });
1601
+
1602
+ this.embedTagRules(CssHighlightRules, "css-", "style");
1603
+ this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
1604
+
1605
+ if (this.constructor === HtmlHighlightRules)
1606
+ this.normalizeRules();
1607
+ };
1608
+
1609
+ oop.inherits(HtmlHighlightRules, XmlHighlightRules);
1610
+
1611
+ exports.HtmlHighlightRules = HtmlHighlightRules;
1612
+ });
1613
+
1614
+ define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
1615
+ "use strict";
1616
+
1617
+ var oop = require("../../lib/oop");
1618
+ var Behaviour = require("../behaviour").Behaviour;
1619
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1620
+ var lang = require("../../lib/lang");
1621
+
1622
+ function is(token, type) {
1623
+ return token.type.lastIndexOf(type + ".xml") > -1;
1624
+ }
1625
+
1626
+ var XmlBehaviour = function () {
1627
+
1628
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
1629
+ if (text == '"' || text == "'") {
1630
+ var quote = text;
1631
+ var selected = session.doc.getTextRange(editor.getSelectionRange());
1632
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
1633
+ return {
1634
+ text: quote + selected + quote,
1635
+ selection: false
1636
+ };
1637
+ }
1638
+
1639
+ var cursor = editor.getCursorPosition();
1640
+ var line = session.doc.getLine(cursor.row);
1641
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1642
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1643
+ var token = iterator.getCurrentToken();
1644
+
1645
+ if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
1646
+ return {
1647
+ text: "",
1648
+ selection: [1, 1]
1649
+ };
1650
+ }
1651
+
1652
+ if (!token)
1653
+ token = iterator.stepBackward();
1654
+
1655
+ if (!token)
1656
+ return;
1657
+
1658
+ while (is(token, "tag-whitespace") || is(token, "whitespace")) {
1659
+ token = iterator.stepBackward();
1660
+ }
1661
+ var rightSpace = !rightChar || rightChar.match(/\s/);
1662
+ if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
1663
+ return {
1664
+ text: quote + quote,
1665
+ selection: [1, 1]
1666
+ };
1667
+ }
1668
+ }
1669
+ });
1670
+
1671
+ this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
1672
+ var selected = session.doc.getTextRange(range);
1673
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
1674
+ var line = session.doc.getLine(range.start.row);
1675
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
1676
+ if (rightChar == selected) {
1677
+ range.end.column++;
1678
+ return range;
1679
+ }
1680
+ }
1681
+ });
1682
+
1683
+ this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1684
+ if (text == '>') {
1685
+ var position = editor.getCursorPosition();
1686
+ var iterator = new TokenIterator(session, position.row, position.column);
1687
+ var token = iterator.getCurrentToken() || iterator.stepBackward();
1688
+ if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
1689
+ return;
1690
+ if (is(token, "reference.attribute-value"))
1691
+ return;
1692
+ if (is(token, "attribute-value")) {
1693
+ var firstChar = token.value.charAt(0);
1694
+ if (firstChar == '"' || firstChar == "'") {
1695
+ var lastChar = token.value.charAt(token.value.length - 1);
1696
+ var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
1697
+ if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
1698
+ return;
1699
+ }
1700
+ }
1701
+ while (!is(token, "tag-name")) {
1702
+ token = iterator.stepBackward();
1703
+ }
1704
+
1705
+ var tokenRow = iterator.getCurrentTokenRow();
1706
+ var tokenColumn = iterator.getCurrentTokenColumn();
1707
+ if (is(iterator.stepBackward(), "end-tag-open"))
1708
+ return;
1709
+
1710
+ var element = token.value;
1711
+ if (tokenRow == position.row)
1712
+ element = element.substring(0, position.column - tokenColumn);
1713
+
1714
+ if (this.voidElements.hasOwnProperty(element.toLowerCase()))
1715
+ return;
1716
+
1717
+ return {
1718
+ text: ">" + "</" + element + ">",
1719
+ selection: [1, 1]
1720
+ };
1721
+ }
1722
+ });
1723
+
1724
+ this.add("autoindent", "insertion", function (state, action, editor, session, text) {
1725
+ if (text == "\n") {
1726
+ var cursor = editor.getCursorPosition();
1727
+ var line = session.getLine(cursor.row);
1728
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1729
+ var token = iterator.getCurrentToken();
1730
+
1731
+ if (token && token.type.indexOf("tag-close") !== -1) {
1732
+ if (token.value == "/>")
1733
+ return;
1734
+ while (token && token.type.indexOf("tag-name") === -1) {
1735
+ token = iterator.stepBackward();
1736
+ }
1737
+
1738
+ if (!token) {
1739
+ return;
1740
+ }
1741
+
1742
+ var tag = token.value;
1743
+ var row = iterator.getCurrentTokenRow();
1744
+ token = iterator.stepBackward();
1745
+ if (!token || token.type.indexOf("end-tag") !== -1) {
1746
+ return;
1747
+ }
1748
+
1749
+ if (this.voidElements && !this.voidElements[tag]) {
1750
+ var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
1751
+ var line = session.getLine(row);
1752
+ var nextIndent = this.$getIndent(line);
1753
+ var indent = nextIndent + session.getTabString();
1754
+
1755
+ if (nextToken && nextToken.value === "</") {
1756
+ return {
1757
+ text: "\n" + indent + "\n" + nextIndent,
1758
+ selection: [1, indent.length, 1, indent.length]
1759
+ };
1760
+ } else {
1761
+ return {
1762
+ text: "\n" + indent
1763
+ };
1764
+ }
1765
+ }
1766
+ }
1767
+ }
1768
+ });
1769
+
1770
+ };
1771
+
1772
+ oop.inherits(XmlBehaviour, Behaviour);
1773
+
1774
+ exports.XmlBehaviour = XmlBehaviour;
1775
+ });
1776
+
1777
+ define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
1778
+ "use strict";
1779
+
1780
+ var oop = require("../../lib/oop");
1781
+ var BaseFoldMode = require("./fold_mode").FoldMode;
1782
+
1783
+ var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1784
+ this.defaultMode = defaultMode;
1785
+ this.subModes = subModes;
1786
+ };
1787
+ oop.inherits(FoldMode, BaseFoldMode);
1788
+
1789
+ (function() {
1790
+
1791
+
1792
+ this.$getMode = function(state) {
1793
+ if (typeof state != "string")
1794
+ state = state[0];
1795
+ for (var key in this.subModes) {
1796
+ if (state.indexOf(key) === 0)
1797
+ return this.subModes[key];
1798
+ }
1799
+ return null;
1800
+ };
1801
+
1802
+ this.$tryMode = function(state, session, foldStyle, row) {
1803
+ var mode = this.$getMode(state);
1804
+ return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1805
+ };
1806
+
1807
+ this.getFoldWidget = function(session, foldStyle, row) {
1808
+ return (
1809
+ this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1810
+ this.$tryMode(session.getState(row), session, foldStyle, row) ||
1811
+ this.defaultMode.getFoldWidget(session, foldStyle, row)
1812
+ );
1813
+ };
1814
+
1815
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
1816
+ var mode = this.$getMode(session.getState(row-1));
1817
+
1818
+ if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1819
+ mode = this.$getMode(session.getState(row));
1820
+
1821
+ if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1822
+ mode = this.defaultMode;
1823
+
1824
+ return mode.getFoldWidgetRange(session, foldStyle, row);
1825
+ };
1826
+
1827
+ }).call(FoldMode.prototype);
1828
+
1829
+ });
1830
+
1831
+ define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], function(require, exports, module) {
1832
+ "use strict";
1833
+
1834
+ var oop = require("../../lib/oop");
1835
+ var lang = require("../../lib/lang");
1836
+ var Range = require("../../range").Range;
1837
+ var BaseFoldMode = require("./fold_mode").FoldMode;
1838
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1839
+
1840
+ var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
1841
+ BaseFoldMode.call(this);
1842
+ this.voidElements = voidElements || {};
1843
+ this.optionalEndTags = oop.mixin({}, this.voidElements);
1844
+ if (optionalEndTags)
1845
+ oop.mixin(this.optionalEndTags, optionalEndTags);
1846
+
1847
+ };
1848
+ oop.inherits(FoldMode, BaseFoldMode);
1849
+
1850
+ var Tag = function() {
1851
+ this.tagName = "";
1852
+ this.closing = false;
1853
+ this.selfClosing = false;
1854
+ this.start = {row: 0, column: 0};
1855
+ this.end = {row: 0, column: 0};
1856
+ };
1857
+
1858
+ function is(token, type) {
1859
+ return token.type.lastIndexOf(type + ".xml") > -1;
1860
+ }
1861
+
1862
+ (function() {
1863
+
1864
+ this.getFoldWidget = function(session, foldStyle, row) {
1865
+ var tag = this._getFirstTagInLine(session, row);
1866
+
1867
+ if (!tag)
1868
+ return "";
1869
+
1870
+ if (tag.closing || (!tag.tagName && tag.selfClosing))
1871
+ return foldStyle == "markbeginend" ? "end" : "";
1872
+
1873
+ if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
1874
+ return "";
1875
+
1876
+ if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
1877
+ return "";
1878
+
1879
+ return "start";
1880
+ };
1881
+ this._getFirstTagInLine = function(session, row) {
1882
+ var tokens = session.getTokens(row);
1883
+ var tag = new Tag();
1884
+
1885
+ for (var i = 0; i < tokens.length; i++) {
1886
+ var token = tokens[i];
1887
+ if (is(token, "tag-open")) {
1888
+ tag.end.column = tag.start.column + token.value.length;
1889
+ tag.closing = is(token, "end-tag-open");
1890
+ token = tokens[++i];
1891
+ if (!token)
1892
+ return null;
1893
+ tag.tagName = token.value;
1894
+ tag.end.column += token.value.length;
1895
+ for (i++; i < tokens.length; i++) {
1896
+ token = tokens[i];
1897
+ tag.end.column += token.value.length;
1898
+ if (is(token, "tag-close")) {
1899
+ tag.selfClosing = token.value == '/>';
1900
+ break;
1901
+ }
1902
+ }
1903
+ return tag;
1904
+ } else if (is(token, "tag-close")) {
1905
+ tag.selfClosing = token.value == '/>';
1906
+ return tag;
1907
+ }
1908
+ tag.start.column += token.value.length;
1909
+ }
1910
+
1911
+ return null;
1912
+ };
1913
+
1914
+ this._findEndTagInLine = function(session, row, tagName, startColumn) {
1915
+ var tokens = session.getTokens(row);
1916
+ var column = 0;
1917
+ for (var i = 0; i < tokens.length; i++) {
1918
+ var token = tokens[i];
1919
+ column += token.value.length;
1920
+ if (column < startColumn)
1921
+ continue;
1922
+ if (is(token, "end-tag-open")) {
1923
+ token = tokens[i + 1];
1924
+ if (token && token.value == tagName)
1925
+ return true;
1926
+ }
1927
+ }
1928
+ return false;
1929
+ };
1930
+ this._readTagForward = function(iterator) {
1931
+ var token = iterator.getCurrentToken();
1932
+ if (!token)
1933
+ return null;
1934
+
1935
+ var tag = new Tag();
1936
+ do {
1937
+ if (is(token, "tag-open")) {
1938
+ tag.closing = is(token, "end-tag-open");
1939
+ tag.start.row = iterator.getCurrentTokenRow();
1940
+ tag.start.column = iterator.getCurrentTokenColumn();
1941
+ } else if (is(token, "tag-name")) {
1942
+ tag.tagName = token.value;
1943
+ } else if (is(token, "tag-close")) {
1944
+ tag.selfClosing = token.value == "/>";
1945
+ tag.end.row = iterator.getCurrentTokenRow();
1946
+ tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
1947
+ iterator.stepForward();
1948
+ return tag;
1949
+ }
1950
+ } while(token = iterator.stepForward());
1951
+
1952
+ return null;
1953
+ };
1954
+
1955
+ this._readTagBackward = function(iterator) {
1956
+ var token = iterator.getCurrentToken();
1957
+ if (!token)
1958
+ return null;
1959
+
1960
+ var tag = new Tag();
1961
+ do {
1962
+ if (is(token, "tag-open")) {
1963
+ tag.closing = is(token, "end-tag-open");
1964
+ tag.start.row = iterator.getCurrentTokenRow();
1965
+ tag.start.column = iterator.getCurrentTokenColumn();
1966
+ iterator.stepBackward();
1967
+ return tag;
1968
+ } else if (is(token, "tag-name")) {
1969
+ tag.tagName = token.value;
1970
+ } else if (is(token, "tag-close")) {
1971
+ tag.selfClosing = token.value == "/>";
1972
+ tag.end.row = iterator.getCurrentTokenRow();
1973
+ tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
1974
+ }
1975
+ } while(token = iterator.stepBackward());
1976
+
1977
+ return null;
1978
+ };
1979
+
1980
+ this._pop = function(stack, tag) {
1981
+ while (stack.length) {
1982
+
1983
+ var top = stack[stack.length-1];
1984
+ if (!tag || top.tagName == tag.tagName) {
1985
+ return stack.pop();
1986
+ }
1987
+ else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
1988
+ stack.pop();
1989
+ continue;
1990
+ } else {
1991
+ return null;
1992
+ }
1993
+ }
1994
+ };
1995
+
1996
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
1997
+ var firstTag = this._getFirstTagInLine(session, row);
1998
+
1999
+ if (!firstTag)
2000
+ return null;
2001
+
2002
+ var isBackward = firstTag.closing || firstTag.selfClosing;
2003
+ var stack = [];
2004
+ var tag;
2005
+
2006
+ if (!isBackward) {
2007
+ var iterator = new TokenIterator(session, row, firstTag.start.column);
2008
+ var start = {
2009
+ row: row,
2010
+ column: firstTag.start.column + firstTag.tagName.length + 2
2011
+ };
2012
+ if (firstTag.start.row == firstTag.end.row)
2013
+ start.column = firstTag.end.column;
2014
+ while (tag = this._readTagForward(iterator)) {
2015
+ if (tag.selfClosing) {
2016
+ if (!stack.length) {
2017
+ tag.start.column += tag.tagName.length + 2;
2018
+ tag.end.column -= 2;
2019
+ return Range.fromPoints(tag.start, tag.end);
2020
+ } else
2021
+ continue;
2022
+ }
2023
+
2024
+ if (tag.closing) {
2025
+ this._pop(stack, tag);
2026
+ if (stack.length == 0)
2027
+ return Range.fromPoints(start, tag.start);
2028
+ }
2029
+ else {
2030
+ stack.push(tag);
2031
+ }
2032
+ }
2033
+ }
2034
+ else {
2035
+ var iterator = new TokenIterator(session, row, firstTag.end.column);
2036
+ var end = {
2037
+ row: row,
2038
+ column: firstTag.start.column
2039
+ };
2040
+
2041
+ while (tag = this._readTagBackward(iterator)) {
2042
+ if (tag.selfClosing) {
2043
+ if (!stack.length) {
2044
+ tag.start.column += tag.tagName.length + 2;
2045
+ tag.end.column -= 2;
2046
+ return Range.fromPoints(tag.start, tag.end);
2047
+ } else
2048
+ continue;
2049
+ }
2050
+
2051
+ if (!tag.closing) {
2052
+ this._pop(stack, tag);
2053
+ if (stack.length == 0) {
2054
+ tag.start.column += tag.tagName.length + 2;
2055
+ if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
2056
+ tag.start.column = tag.end.column;
2057
+ return Range.fromPoints(tag.start, end);
2058
+ }
2059
+ }
2060
+ else {
2061
+ stack.push(tag);
2062
+ }
2063
+ }
2064
+ }
2065
+
2066
+ };
2067
+
2068
+ }).call(FoldMode.prototype);
2069
+
2070
+ });
2071
+
2072
+ define("ace/mode/folding/html",["require","exports","module","ace/lib/oop","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module) {
2073
+ "use strict";
2074
+
2075
+ var oop = require("../../lib/oop");
2076
+ var MixedFoldMode = require("./mixed").FoldMode;
2077
+ var XmlFoldMode = require("./xml").FoldMode;
2078
+ var CStyleFoldMode = require("./cstyle").FoldMode;
2079
+
2080
+ var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
2081
+ MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
2082
+ "js-": new CStyleFoldMode(),
2083
+ "css-": new CStyleFoldMode()
2084
+ });
2085
+ };
2086
+
2087
+ oop.inherits(FoldMode, MixedFoldMode);
2088
+
2089
+ });
2090
+
2091
+ define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) {
2092
+ "use strict";
2093
+
2094
+ var TokenIterator = require("../token_iterator").TokenIterator;
2095
+
2096
+ var commonAttributes = [
2097
+ "accesskey",
2098
+ "class",
2099
+ "contenteditable",
2100
+ "contextmenu",
2101
+ "dir",
2102
+ "draggable",
2103
+ "dropzone",
2104
+ "hidden",
2105
+ "id",
2106
+ "inert",
2107
+ "itemid",
2108
+ "itemprop",
2109
+ "itemref",
2110
+ "itemscope",
2111
+ "itemtype",
2112
+ "lang",
2113
+ "spellcheck",
2114
+ "style",
2115
+ "tabindex",
2116
+ "title",
2117
+ "translate"
2118
+ ];
2119
+
2120
+ var eventAttributes = [
2121
+ "onabort",
2122
+ "onblur",
2123
+ "oncancel",
2124
+ "oncanplay",
2125
+ "oncanplaythrough",
2126
+ "onchange",
2127
+ "onclick",
2128
+ "onclose",
2129
+ "oncontextmenu",
2130
+ "oncuechange",
2131
+ "ondblclick",
2132
+ "ondrag",
2133
+ "ondragend",
2134
+ "ondragenter",
2135
+ "ondragleave",
2136
+ "ondragover",
2137
+ "ondragstart",
2138
+ "ondrop",
2139
+ "ondurationchange",
2140
+ "onemptied",
2141
+ "onended",
2142
+ "onerror",
2143
+ "onfocus",
2144
+ "oninput",
2145
+ "oninvalid",
2146
+ "onkeydown",
2147
+ "onkeypress",
2148
+ "onkeyup",
2149
+ "onload",
2150
+ "onloadeddata",
2151
+ "onloadedmetadata",
2152
+ "onloadstart",
2153
+ "onmousedown",
2154
+ "onmousemove",
2155
+ "onmouseout",
2156
+ "onmouseover",
2157
+ "onmouseup",
2158
+ "onmousewheel",
2159
+ "onpause",
2160
+ "onplay",
2161
+ "onplaying",
2162
+ "onprogress",
2163
+ "onratechange",
2164
+ "onreset",
2165
+ "onscroll",
2166
+ "onseeked",
2167
+ "onseeking",
2168
+ "onselect",
2169
+ "onshow",
2170
+ "onstalled",
2171
+ "onsubmit",
2172
+ "onsuspend",
2173
+ "ontimeupdate",
2174
+ "onvolumechange",
2175
+ "onwaiting"
2176
+ ];
2177
+
2178
+ var globalAttributes = commonAttributes.concat(eventAttributes);
2179
+
2180
+ var attributeMap = {
2181
+ "html": ["manifest"],
2182
+ "head": [],
2183
+ "title": [],
2184
+ "base": ["href", "target"],
2185
+ "link": ["href", "hreflang", "rel", "media", "type", "sizes"],
2186
+ "meta": ["http-equiv", "name", "content", "charset"],
2187
+ "style": ["type", "media", "scoped"],
2188
+ "script": ["charset", "type", "src", "defer", "async"],
2189
+ "noscript": ["href"],
2190
+ "body": ["onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onmessage", "onoffline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload"],
2191
+ "section": [],
2192
+ "nav": [],
2193
+ "article": ["pubdate"],
2194
+ "aside": [],
2195
+ "h1": [],
2196
+ "h2": [],
2197
+ "h3": [],
2198
+ "h4": [],
2199
+ "h5": [],
2200
+ "h6": [],
2201
+ "header": [],
2202
+ "footer": [],
2203
+ "address": [],
2204
+ "main": [],
2205
+ "p": [],
2206
+ "hr": [],
2207
+ "pre": [],
2208
+ "blockquote": ["cite"],
2209
+ "ol": ["start", "reversed"],
2210
+ "ul": [],
2211
+ "li": ["value"],
2212
+ "dl": [],
2213
+ "dt": [],
2214
+ "dd": [],
2215
+ "figure": [],
2216
+ "figcaption": [],
2217
+ "div": [],
2218
+ "a": ["href", "target", "ping", "rel", "media", "hreflang", "type"],
2219
+ "em": [],
2220
+ "strong": [],
2221
+ "small": [],
2222
+ "s": [],
2223
+ "cite": [],
2224
+ "q": ["cite"],
2225
+ "dfn": [],
2226
+ "abbr": [],
2227
+ "data": [],
2228
+ "time": ["datetime"],
2229
+ "code": [],
2230
+ "var": [],
2231
+ "samp": [],
2232
+ "kbd": [],
2233
+ "sub": [],
2234
+ "sup": [],
2235
+ "i": [],
2236
+ "b": [],
2237
+ "u": [],
2238
+ "mark": [],
2239
+ "ruby": [],
2240
+ "rt": [],
2241
+ "rp": [],
2242
+ "bdi": [],
2243
+ "bdo": [],
2244
+ "span": [],
2245
+ "br": [],
2246
+ "wbr": [],
2247
+ "ins": ["cite", "datetime"],
2248
+ "del": ["cite", "datetime"],
2249
+ "img": ["alt", "src", "height", "width", "usemap", "ismap"],
2250
+ "iframe": ["name", "src", "height", "width", "sandbox", "seamless"],
2251
+ "embed": ["src", "height", "width", "type"],
2252
+ "object": ["param", "data", "type", "height" , "width", "usemap", "name", "form", "classid"],
2253
+ "param": ["name", "value"],
2254
+ "video": ["src", "autobuffer", "autoplay", "loop", "controls", "width", "height", "poster"],
2255
+ "audio": ["src", "autobuffer", "autoplay", "loop", "controls"],
2256
+ "source": ["src", "type", "media"],
2257
+ "track": ["kind", "src", "srclang", "label", "default"],
2258
+ "canvas": ["width", "height"],
2259
+ "map": ["name"],
2260
+ "area": ["shape", "coords", "href", "hreflang", "alt", "target", "media", "rel", "ping", "type"],
2261
+ "svg": [],
2262
+ "math": [],
2263
+ "table": ["summary"],
2264
+ "caption": [],
2265
+ "colgroup": ["span"],
2266
+ "col": ["span"],
2267
+ "tbody": [],
2268
+ "thead": [],
2269
+ "tfoot": [],
2270
+ "tr": [],
2271
+ "td": ["headers", "rowspan", "colspan"],
2272
+ "th": ["headers", "rowspan", "colspan", "scope"],
2273
+ "form": ["accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"],
2274
+ "fieldset": ["disabled", "form", "name"],
2275
+ "legend": [],
2276
+ "label": ["form", "for"],
2277
+ "input": ["type", "accept", "alt", "autocomplete", "checked", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "list", "max", "maxlength", "min", "multiple", "pattern", "placeholder", "readonly", "required", "size", "src", "step", "width", "files", "value"],
2278
+ "button": ["autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "value", "type"],
2279
+ "select": ["autofocus", "disabled", "form", "multiple", "name", "size"],
2280
+ "datalist": [],
2281
+ "optgroup": ["disabled", "label"],
2282
+ "option": ["disabled", "selected", "label", "value"],
2283
+ "textarea": ["autofocus", "disabled", "form", "maxlength", "name", "placeholder", "readonly", "required", "rows", "cols", "wrap"],
2284
+ "keygen": ["autofocus", "challenge", "disabled", "form", "keytype", "name"],
2285
+ "output": ["for", "form", "name"],
2286
+ "progress": ["value", "max"],
2287
+ "meter": ["value", "min", "max", "low", "high", "optimum"],
2288
+ "details": ["open"],
2289
+ "summary": [],
2290
+ "command": ["type", "label", "icon", "disabled", "checked", "radiogroup", "command"],
2291
+ "menu": ["type", "label"],
2292
+ "dialog": ["open"]
2293
+ };
2294
+
2295
+ var elements = Object.keys(attributeMap);
2296
+
2297
+ function is(token, type) {
2298
+ return token.type.lastIndexOf(type + ".xml") > -1;
2299
+ }
2300
+
2301
+ function findTagName(session, pos) {
2302
+ var iterator = new TokenIterator(session, pos.row, pos.column);
2303
+ var token = iterator.getCurrentToken();
2304
+ while (token && !is(token, "tag-name")){
2305
+ token = iterator.stepBackward();
2306
+ }
2307
+ if (token)
2308
+ return token.value;
2309
+ }
2310
+
2311
+ var HtmlCompletions = function() {
2312
+
2313
+ };
2314
+
2315
+ (function() {
2316
+
2317
+ this.getCompletions = function(state, session, pos, prefix) {
2318
+ var token = session.getTokenAt(pos.row, pos.column);
2319
+
2320
+ if (!token)
2321
+ return [];
2322
+ if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
2323
+ return this.getTagCompletions(state, session, pos, prefix);
2324
+ if (is(token, "tag-whitespace") || is(token, "attribute-name"))
2325
+ return this.getAttributeCompetions(state, session, pos, prefix);
2326
+
2327
+ return [];
2328
+ };
2329
+
2330
+ this.getTagCompletions = function(state, session, pos, prefix) {
2331
+ return elements.map(function(element){
2332
+ return {
2333
+ value: element,
2334
+ meta: "tag",
2335
+ score: Number.MAX_VALUE
2336
+ };
2337
+ });
2338
+ };
2339
+
2340
+ this.getAttributeCompetions = function(state, session, pos, prefix) {
2341
+ var tagName = findTagName(session, pos);
2342
+ if (!tagName)
2343
+ return [];
2344
+ var attributes = globalAttributes;
2345
+ if (tagName in attributeMap) {
2346
+ attributes = attributes.concat(attributeMap[tagName]);
2347
+ }
2348
+ return attributes.map(function(attribute){
2349
+ return {
2350
+ caption: attribute,
2351
+ snippet: attribute + '="$0"',
2352
+ meta: "attribute",
2353
+ score: Number.MAX_VALUE
2354
+ };
2355
+ });
2356
+ };
2357
+
2358
+ }).call(HtmlCompletions.prototype);
2359
+
2360
+ exports.HtmlCompletions = HtmlCompletions;
2361
+ });
2362
+
2363
+ define("ace/mode/html",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/javascript","ace/mode/css","ace/mode/html_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/html","ace/mode/html_completions","ace/worker/worker_client"], function(require, exports, module) {
2364
+ "use strict";
2365
+
2366
+ var oop = require("../lib/oop");
2367
+ var lang = require("../lib/lang");
2368
+ var TextMode = require("./text").Mode;
2369
+ var JavaScriptMode = require("./javascript").Mode;
2370
+ var CssMode = require("./css").Mode;
2371
+ var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
2372
+ var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
2373
+ var HtmlFoldMode = require("./folding/html").FoldMode;
2374
+ var HtmlCompletions = require("./html_completions").HtmlCompletions;
2375
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
2376
+ var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
2377
+ var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
2378
+
2379
+ var Mode = function(options) {
2380
+ this.fragmentContext = options && options.fragmentContext;
2381
+ this.HighlightRules = HtmlHighlightRules;
2382
+ this.$behaviour = new XmlBehaviour();
2383
+ this.$completer = new HtmlCompletions();
2384
+
2385
+ this.createModeDelegates({
2386
+ "js-": JavaScriptMode,
2387
+ "css-": CssMode
2388
+ });
2389
+
2390
+ this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
2391
+ };
2392
+ oop.inherits(Mode, TextMode);
2393
+
2394
+ (function() {
2395
+
2396
+ this.blockComment = {start: "<!--", end: "-->"};
2397
+
2398
+ this.voidElements = lang.arrayToMap(voidElements);
2399
+
2400
+ this.getNextLineIndent = function(state, line, tab) {
2401
+ return this.$getIndent(line);
2402
+ };
2403
+
2404
+ this.checkOutdent = function(state, line, input) {
2405
+ return false;
2406
+ };
2407
+
2408
+ this.getCompletions = function(state, session, pos, prefix) {
2409
+ return this.$completer.getCompletions(state, session, pos, prefix);
2410
+ };
2411
+
2412
+ this.createWorker = function(session) {
2413
+ if (this.constructor != Mode)
2414
+ return;
2415
+ var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
2416
+ worker.attachToDocument(session.getDocument());
2417
+
2418
+ if (this.fragmentContext)
2419
+ worker.call("setOptions", [{context: this.fragmentContext}]);
2420
+
2421
+ worker.on("error", function(e) {
2422
+ session.setAnnotations(e.data);
2423
+ });
2424
+
2425
+ worker.on("terminate", function() {
2426
+ session.clearAnnotations();
2427
+ });
2428
+
2429
+ return worker;
2430
+ };
2431
+
2432
+ this.$id = "ace/mode/html";
2433
+ }).call(Mode.prototype);
2434
+
2435
+ exports.Mode = Mode;
2436
+ });