WordPress Infinite Scroll – Ajax Load More - Version 5.1.7.1

Version Description

  • December 9, 2019 =
  • FIX - Hotfix to remove JavaSscript error/warning message for Single Posts and Next Page add-on users.
Download this release

Release Info

Developer dcooney
Plugin Icon 128x128 WordPress Infinite Scroll – Ajax Load More
Version 5.1.7.1
Comparing to
See all releases

Code changes from version 5.1.6.1 to 5.1.7.1

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://connekthq.com/donate/
4
  Tags: infinite scroll, infinite scrolling, scroll, infinite, lazy load, lazy loading, endless scroll, pagination, ajax pagination, ajax, ajax posts, woocommerce, ajax load more, masonry
5
  Requires at least: 4.0
6
  Tested up to: 5.3
7
- Stable tag: 5.1.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -382,6 +382,22 @@ How to install Ajax Load More.
382
 
383
  == Changelog ==
384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  = 5.1.6.1 - November 19, 2019 =
386
  * NEW - Added new `placeholder` parameter that allows users to display a placeholder image while Ajax content is being loaded. [View Example](https://connekthq.com/plugins/ajax-load-more/examples/placeholder/).
387
  * FIX - Fixed issue with deep linking URLs in the filters add-on not sending user to correct location on the page.
4
  Tags: infinite scroll, infinite scrolling, scroll, infinite, lazy load, lazy loading, endless scroll, pagination, ajax pagination, ajax, ajax posts, woocommerce, ajax load more, masonry
5
  Requires at least: 4.0
6
  Tested up to: 5.3
7
+ Stable tag: 5.1.7.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
382
 
383
  == Changelog ==
384
 
385
+ = 5.1.7.1 - December 9, 2019 =
386
+ * FIX - Hotfix to remove JavaSscript error/warning message for Single Posts and Next Page add-on users.
387
+
388
+
389
+ = 5.1.7 - December 6, 2019 =
390
+ * NEW - Added support for multiple instances on ALM Masonry on the same page.
391
+ * NEW - Added `CTRL+S` and `CMD+S` support for saving Repeater Templates in the Ajax Load More admin :)
392
+ * NEW - Added built-in support for Elementor using the `elementor="true"` shortcode parameter. [View Blog Post](https://connekthq.com/elementor-infinite-scrolling/)
393
+ * FIX - Fixed issue where loading `placeholder` would remain on screen if no results were found.
394
+ * FIX - Added fix for Safari desktop moving browser window when an instance of ALM is filtered.
395
+ * FIX - Fixed error in PHP 7.2.2 in the `plugin_action_links_` filter related to a string array.
396
+ * UPDATE - Added functionality to get the current post ID is not specified in the shortcode for Single Posts and Next page add-ons.
397
+ * UPDATE - Updated Code Mirror code editor for Repeater Templates.
398
+ * UPDATE - Improved admin UI and UX.
399
+
400
+
401
  = 5.1.6.1 - November 19, 2019 =
402
  * NEW - Added new `placeholder` parameter that allows users to display a placeholder image while Ajax content is being loaded. [View Example](https://connekthq.com/plugins/ajax-load-more/examples/placeholder/).
403
  * FIX - Fixed issue with deep linking URLs in the filters add-on not sending user to correct location on the page.
admin/codemirror/lib/codemirror.css CHANGED
@@ -4,10 +4,8 @@
4
  /* Set height, width, borders, and global font properties here */
5
  font-family: monospace;
6
  height: 300px;
7
- }
8
- .CodeMirror-scroll {
9
- /* Set scrolling behaviour here */
10
- overflow: auto;
11
  }
12
 
13
  /* PADDING */
@@ -15,7 +13,8 @@
15
  .CodeMirror-lines {
16
  padding: 4px 0; /* Vertical padding around content */
17
  }
18
- .CodeMirror pre {
 
19
  padding: 0 4px; /* Horizontal padding of content */
20
  }
21
 
@@ -36,8 +35,7 @@
36
  min-width: 20px;
37
  text-align: right;
38
  color: #999;
39
- -moz-box-sizing: content-box;
40
- box-sizing: content-box;
41
  }
42
 
43
  .CodeMirror-guttermarker { color: black; }
@@ -45,53 +43,80 @@
45
 
46
  /* CURSOR */
47
 
48
- .CodeMirror div.CodeMirror-cursor {
49
  border-left: 1px solid black;
 
 
50
  }
51
  /* Shown when moving in bi-directional text */
52
  .CodeMirror div.CodeMirror-secondarycursor {
53
  border-left: 1px solid silver;
54
  }
55
- .CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
56
  width: auto;
57
- border: 0;
58
  background: #7e7;
59
  }
 
 
 
 
 
 
 
 
 
60
  .cm-animate-fat-cursor {
61
  width: auto;
62
  border: 0;
63
  -webkit-animation: blink 1.06s steps(1) infinite;
64
  -moz-animation: blink 1.06s steps(1) infinite;
65
  animation: blink 1.06s steps(1) infinite;
 
66
  }
67
  @-moz-keyframes blink {
68
- 0% { background: #7e7; }
69
- 50% { background: none; }
70
- 100% { background: #7e7; }
71
  }
72
  @-webkit-keyframes blink {
73
- 0% { background: #7e7; }
74
- 50% { background: none; }
75
- 100% { background: #7e7; }
76
  }
77
  @keyframes blink {
78
- 0% { background: #7e7; }
79
- 50% { background: none; }
80
- 100% { background: #7e7; }
81
  }
82
 
83
  /* Can style cursor different in overwrite (non-insert) mode */
84
- div.CodeMirror-overwrite div.CodeMirror-cursor {}
85
 
86
- .cm-tab { display: inline-block; }
87
 
 
 
 
 
 
88
  .CodeMirror-ruler {
89
  border-left: 1px solid #ccc;
 
90
  position: absolute;
91
  }
92
 
93
  /* DEFAULT THEME */
94
 
 
 
 
 
 
 
 
 
 
95
  .cm-s-default .cm-keyword {color: #708;}
96
  .cm-s-default .cm-atom {color: #219;}
97
  .cm-s-default .cm-number {color: #164;}
@@ -101,7 +126,7 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
101
  .cm-s-default .cm-property,
102
  .cm-s-default .cm-operator {}
103
  .cm-s-default .cm-variable-2 {color: #05a;}
104
- .cm-s-default .cm-variable-3 {color: #085;}
105
  .cm-s-default .cm-comment {color: #a50;}
106
  .cm-s-default .cm-string {color: #a11;}
107
  .cm-s-default .cm-string-2 {color: #f50;}
@@ -111,24 +136,18 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
111
  .cm-s-default .cm-bracket {color: #997;}
112
  .cm-s-default .cm-tag {color: #170;}
113
  .cm-s-default .cm-attribute {color: #00c;}
114
- .cm-s-default .cm-header {color: blue;}
115
- .cm-s-default .cm-quote {color: #090;}
116
  .cm-s-default .cm-hr {color: #999;}
117
  .cm-s-default .cm-link {color: #00c;}
118
 
119
- .cm-negative {color: #d44;}
120
- .cm-positive {color: #292;}
121
- .cm-header, .cm-strong {font-weight: bold;}
122
- .cm-em {font-style: italic;}
123
- .cm-link {text-decoration: underline;}
124
-
125
  .cm-s-default .cm-error {color: #f00;}
126
  .cm-invalidchar {color: #f00;}
127
 
 
 
128
  /* Default styles for common addons */
129
 
130
- div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
131
- div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
132
  .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
133
  .CodeMirror-activeline-background {background: #e8f2ff;}
134
 
@@ -138,14 +157,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
138
  the editor. You probably shouldn't touch them. */
139
 
140
  .CodeMirror {
141
- line-height: 1;
142
  position: relative;
143
  overflow: hidden;
144
  background: white;
145
- color: black;
146
  }
147
 
148
  .CodeMirror-scroll {
 
149
  /* 30px is the magic margin used to hide the element's real scrollbars */
150
  /* See overflow: hidden in .CodeMirror */
151
  margin-bottom: -30px; margin-right: -30px;
@@ -153,18 +171,14 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
153
  height: 100%;
154
  outline: none; /* Prevent dragging from highlighting the element */
155
  position: relative;
156
- -moz-box-sizing: content-box;
157
- box-sizing: content-box;
158
  }
159
  .CodeMirror-sizer {
160
  position: relative;
161
  border-right: 30px solid transparent;
162
- -moz-box-sizing: content-box;
163
- box-sizing: content-box;
164
  }
165
 
166
  /* The fake, visible scrollbars. Used to force redraw during scrolling
167
- before actuall scrolling happens, thus preventing shaking and
168
  flickering artifacts. */
169
  .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
170
  position: absolute;
@@ -190,31 +204,41 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
190
 
191
  .CodeMirror-gutters {
192
  position: absolute; left: 0; top: 0;
193
- padding-bottom: 30px;
194
  z-index: 3;
195
  }
196
  .CodeMirror-gutter {
197
  white-space: normal;
198
  height: 100%;
199
- -moz-box-sizing: content-box;
200
- box-sizing: content-box;
201
- padding-bottom: 30px;
202
- margin-bottom: -32px;
203
  display: inline-block;
204
- /* Hack to make IE7 behave */
205
- *zoom:1;
206
- *display:inline;
 
 
 
 
 
 
 
 
 
 
207
  }
208
  .CodeMirror-gutter-elt {
209
  position: absolute;
210
  cursor: default;
211
  z-index: 4;
212
  }
 
 
213
 
214
  .CodeMirror-lines {
215
  cursor: text;
 
216
  }
217
- .CodeMirror pre {
 
218
  /* Reset some styles that the rest of the page might have set */
219
  -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
220
  border-width: 0;
@@ -229,8 +253,12 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
229
  z-index: 2;
230
  position: relative;
231
  overflow: visible;
 
 
 
232
  }
233
- .CodeMirror-wrap pre {
 
234
  word-wrap: break-word;
235
  white-space: pre-wrap;
236
  word-break: normal;
@@ -245,13 +273,25 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
245
  .CodeMirror-linewidget {
246
  position: relative;
247
  z-index: 2;
248
- overflow: auto;
249
  }
250
 
251
  .CodeMirror-widget {}
252
 
253
- .CodeMirror-wrap .CodeMirror-scroll {
254
- overflow-x: hidden;
 
 
 
 
 
 
 
 
 
 
 
 
255
  }
256
 
257
  .CodeMirror-measure {
@@ -261,19 +301,22 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
261
  overflow: hidden;
262
  visibility: hidden;
263
  }
264
- .CodeMirror-measure pre { position: static; }
265
 
266
- .CodeMirror div.CodeMirror-cursor {
267
  position: absolute;
268
- border-right: none;
269
- width: 0;
270
  }
 
271
 
272
  div.CodeMirror-cursors {
273
  visibility: hidden;
274
  position: relative;
275
- z-index: 1;
 
 
 
276
  }
 
277
  .CodeMirror-focused div.CodeMirror-cursors {
278
  visibility: visible;
279
  }
@@ -281,15 +324,14 @@ div.CodeMirror-cursors {
281
  .CodeMirror-selected { background: #d9d9d9; }
282
  .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
283
  .CodeMirror-crosshair { cursor: crosshair; }
 
 
284
 
285
  .cm-searching {
286
- background: #ffa;
287
- background: rgba(255, 255, 0, .4);
288
  }
289
 
290
- /* IE7 hack to prevent it from returning funny offsetTops on the spans */
291
- .CodeMirror span { *vertical-align: text-bottom; }
292
-
293
  /* Used to force a border model for a node */
294
  .cm-force-border { padding-right: .1px; }
295
 
@@ -299,3 +341,9 @@ div.CodeMirror-cursors {
299
  visibility: hidden;
300
  }
301
  }
 
 
 
 
 
 
4
  /* Set height, width, borders, and global font properties here */
5
  font-family: monospace;
6
  height: 300px;
7
+ color: black;
8
+ direction: ltr;
 
 
9
  }
10
 
11
  /* PADDING */
13
  .CodeMirror-lines {
14
  padding: 4px 0; /* Vertical padding around content */
15
  }
16
+ .CodeMirror pre.CodeMirror-line,
17
+ .CodeMirror pre.CodeMirror-line-like {
18
  padding: 0 4px; /* Horizontal padding of content */
19
  }
20
 
35
  min-width: 20px;
36
  text-align: right;
37
  color: #999;
38
+ white-space: nowrap;
 
39
  }
40
 
41
  .CodeMirror-guttermarker { color: black; }
43
 
44
  /* CURSOR */
45
 
46
+ .CodeMirror-cursor {
47
  border-left: 1px solid black;
48
+ border-right: none;
49
+ width: 0;
50
  }
51
  /* Shown when moving in bi-directional text */
52
  .CodeMirror div.CodeMirror-secondarycursor {
53
  border-left: 1px solid silver;
54
  }
55
+ .cm-fat-cursor .CodeMirror-cursor {
56
  width: auto;
57
+ border: 0 !important;
58
  background: #7e7;
59
  }
60
+ .cm-fat-cursor div.CodeMirror-cursors {
61
+ z-index: 1;
62
+ }
63
+ .cm-fat-cursor-mark {
64
+ background-color: rgba(20, 255, 20, 0.5);
65
+ -webkit-animation: blink 1.06s steps(1) infinite;
66
+ -moz-animation: blink 1.06s steps(1) infinite;
67
+ animation: blink 1.06s steps(1) infinite;
68
+ }
69
  .cm-animate-fat-cursor {
70
  width: auto;
71
  border: 0;
72
  -webkit-animation: blink 1.06s steps(1) infinite;
73
  -moz-animation: blink 1.06s steps(1) infinite;
74
  animation: blink 1.06s steps(1) infinite;
75
+ background-color: #7e7;
76
  }
77
  @-moz-keyframes blink {
78
+ 0% {}
79
+ 50% { background-color: transparent; }
80
+ 100% {}
81
  }
82
  @-webkit-keyframes blink {
83
+ 0% {}
84
+ 50% { background-color: transparent; }
85
+ 100% {}
86
  }
87
  @keyframes blink {
88
+ 0% {}
89
+ 50% { background-color: transparent; }
90
+ 100% {}
91
  }
92
 
93
  /* Can style cursor different in overwrite (non-insert) mode */
94
+ .CodeMirror-overwrite .CodeMirror-cursor {}
95
 
96
+ .cm-tab { display: inline-block; text-decoration: inherit; }
97
 
98
+ .CodeMirror-rulers {
99
+ position: absolute;
100
+ left: 0; right: 0; top: -50px; bottom: 0;
101
+ overflow: hidden;
102
+ }
103
  .CodeMirror-ruler {
104
  border-left: 1px solid #ccc;
105
+ top: 0; bottom: 0;
106
  position: absolute;
107
  }
108
 
109
  /* DEFAULT THEME */
110
 
111
+ .cm-s-default .cm-header {color: blue;}
112
+ .cm-s-default .cm-quote {color: #090;}
113
+ .cm-negative {color: #d44;}
114
+ .cm-positive {color: #292;}
115
+ .cm-header, .cm-strong {font-weight: bold;}
116
+ .cm-em {font-style: italic;}
117
+ .cm-link {text-decoration: underline;}
118
+ .cm-strikethrough {text-decoration: line-through;}
119
+
120
  .cm-s-default .cm-keyword {color: #708;}
121
  .cm-s-default .cm-atom {color: #219;}
122
  .cm-s-default .cm-number {color: #164;}
126
  .cm-s-default .cm-property,
127
  .cm-s-default .cm-operator {}
128
  .cm-s-default .cm-variable-2 {color: #05a;}
129
+ .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
130
  .cm-s-default .cm-comment {color: #a50;}
131
  .cm-s-default .cm-string {color: #a11;}
132
  .cm-s-default .cm-string-2 {color: #f50;}
136
  .cm-s-default .cm-bracket {color: #997;}
137
  .cm-s-default .cm-tag {color: #170;}
138
  .cm-s-default .cm-attribute {color: #00c;}
 
 
139
  .cm-s-default .cm-hr {color: #999;}
140
  .cm-s-default .cm-link {color: #00c;}
141
 
 
 
 
 
 
 
142
  .cm-s-default .cm-error {color: #f00;}
143
  .cm-invalidchar {color: #f00;}
144
 
145
+ .CodeMirror-composing { border-bottom: 2px solid; }
146
+
147
  /* Default styles for common addons */
148
 
149
+ div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
150
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
151
  .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
152
  .CodeMirror-activeline-background {background: #e8f2ff;}
153
 
157
  the editor. You probably shouldn't touch them. */
158
 
159
  .CodeMirror {
 
160
  position: relative;
161
  overflow: hidden;
162
  background: white;
 
163
  }
164
 
165
  .CodeMirror-scroll {
166
+ overflow: scroll !important; /* Things will break if this is overridden */
167
  /* 30px is the magic margin used to hide the element's real scrollbars */
168
  /* See overflow: hidden in .CodeMirror */
169
  margin-bottom: -30px; margin-right: -30px;
171
  height: 100%;
172
  outline: none; /* Prevent dragging from highlighting the element */
173
  position: relative;
 
 
174
  }
175
  .CodeMirror-sizer {
176
  position: relative;
177
  border-right: 30px solid transparent;
 
 
178
  }
179
 
180
  /* The fake, visible scrollbars. Used to force redraw during scrolling
181
+ before actual scrolling happens, thus preventing shaking and
182
  flickering artifacts. */
183
  .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
184
  position: absolute;
204
 
205
  .CodeMirror-gutters {
206
  position: absolute; left: 0; top: 0;
207
+ min-height: 100%;
208
  z-index: 3;
209
  }
210
  .CodeMirror-gutter {
211
  white-space: normal;
212
  height: 100%;
 
 
 
 
213
  display: inline-block;
214
+ vertical-align: top;
215
+ margin-bottom: -30px;
216
+ }
217
+ .CodeMirror-gutter-wrapper {
218
+ position: absolute;
219
+ z-index: 4;
220
+ background: none !important;
221
+ border: none !important;
222
+ }
223
+ .CodeMirror-gutter-background {
224
+ position: absolute;
225
+ top: 0; bottom: 0;
226
+ z-index: 4;
227
  }
228
  .CodeMirror-gutter-elt {
229
  position: absolute;
230
  cursor: default;
231
  z-index: 4;
232
  }
233
+ .CodeMirror-gutter-wrapper ::selection { background-color: transparent }
234
+ .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
235
 
236
  .CodeMirror-lines {
237
  cursor: text;
238
+ min-height: 1px; /* prevents collapsing before first draw */
239
  }
240
+ .CodeMirror pre.CodeMirror-line,
241
+ .CodeMirror pre.CodeMirror-line-like {
242
  /* Reset some styles that the rest of the page might have set */
243
  -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
244
  border-width: 0;
253
  z-index: 2;
254
  position: relative;
255
  overflow: visible;
256
+ -webkit-tap-highlight-color: transparent;
257
+ -webkit-font-variant-ligatures: contextual;
258
+ font-variant-ligatures: contextual;
259
  }
260
+ .CodeMirror-wrap pre.CodeMirror-line,
261
+ .CodeMirror-wrap pre.CodeMirror-line-like {
262
  word-wrap: break-word;
263
  white-space: pre-wrap;
264
  word-break: normal;
273
  .CodeMirror-linewidget {
274
  position: relative;
275
  z-index: 2;
276
+ padding: 0.1px; /* Force widget margins to stay inside of the container */
277
  }
278
 
279
  .CodeMirror-widget {}
280
 
281
+ .CodeMirror-rtl pre { direction: rtl; }
282
+
283
+ .CodeMirror-code {
284
+ outline: none;
285
+ }
286
+
287
+ /* Force content-box sizing for the elements where we expect it */
288
+ .CodeMirror-scroll,
289
+ .CodeMirror-sizer,
290
+ .CodeMirror-gutter,
291
+ .CodeMirror-gutters,
292
+ .CodeMirror-linenumber {
293
+ -moz-box-sizing: content-box;
294
+ box-sizing: content-box;
295
  }
296
 
297
  .CodeMirror-measure {
301
  overflow: hidden;
302
  visibility: hidden;
303
  }
 
304
 
305
+ .CodeMirror-cursor {
306
  position: absolute;
307
+ pointer-events: none;
 
308
  }
309
+ .CodeMirror-measure pre { position: static; }
310
 
311
  div.CodeMirror-cursors {
312
  visibility: hidden;
313
  position: relative;
314
+ z-index: 3;
315
+ }
316
+ div.CodeMirror-dragcursors {
317
+ visibility: visible;
318
  }
319
+
320
  .CodeMirror-focused div.CodeMirror-cursors {
321
  visibility: visible;
322
  }
324
  .CodeMirror-selected { background: #d9d9d9; }
325
  .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
326
  .CodeMirror-crosshair { cursor: crosshair; }
327
+ .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
328
+ .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
329
 
330
  .cm-searching {
331
+ background-color: #ffa;
332
+ background-color: rgba(255, 255, 0, .4);
333
  }
334
 
 
 
 
335
  /* Used to force a border model for a node */
336
  .cm-force-border { padding-right: .1px; }
337
 
341
  visibility: hidden;
342
  }
343
  }
344
+
345
+ /* See issue #2901 */
346
+ .cm-tab-wrap-hack:after { content: ''; }
347
+
348
+ /* Help users use markselection to safely style text background */
349
+ span.CodeMirror-selectedtext { background: none; }
admin/codemirror/lib/codemirror.js CHANGED
@@ -1,1445 +1,1253 @@
1
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
 
4
- // This is CodeMirror (http://codemirror.net), a code editor
5
  // implemented in JavaScript on top of the browser's DOM.
6
  //
7
  // You can find some technical background for some of the code below
8
  // at http://marijnhaverbeke.nl/blog/#cm-internals .
9
 
10
- (function(mod) {
11
- if (typeof exports == "object" && typeof module == "object") // CommonJS
12
- module.exports = mod();
13
- else if (typeof define == "function" && define.amd) // AMD
14
- return define([], mod);
15
- else // Plain browser env
16
- this.CodeMirror = mod();
17
- })(function() {
18
- "use strict";
19
-
20
- // BROWSER SNIFFING
21
 
22
  // Kludges for bugs and behavior differences that can't be feature
23
  // detected are enabled based on userAgent etc sniffing.
24
-
25
- var gecko = /gecko\/\d/i.test(navigator.userAgent);
26
- // ie_uptoN means Internet Explorer version N or lower
27
- var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
28
- var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
29
- var ie = ie_upto10 || ie_11up;
30
- var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
31
- var webkit = /WebKit\//.test(navigator.userAgent);
32
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
33
- var chrome = /Chrome\//.test(navigator.userAgent);
34
- var presto = /Opera\//.test(navigator.userAgent);
 
 
35
  var safari = /Apple Computer/.test(navigator.vendor);
36
- var khtml = /KHTML\//.test(navigator.userAgent);
37
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
38
- var phantom = /PhantomJS/.test(navigator.userAgent);
39
 
40
- var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
 
41
  // This is woefully incomplete. Suggestions for alternative methods welcome.
42
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
43
- var mac = ios || /Mac/.test(navigator.platform);
44
- var windows = /win/i.test(navigator.platform);
 
45
 
46
- var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
47
- if (presto_version) presto_version = Number(presto_version[1]);
48
  if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
49
  // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
50
  var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
51
  var captureRightClick = gecko || (ie && ie_version >= 9);
52
 
53
- // Optimize some code when these features are not used.
54
- var sawReadOnlySpans = false, sawCollapsedSpans = false;
55
-
56
- // EDITOR CONSTRUCTOR
57
-
58
- // A CodeMirror instance represents an editor. This is the object
59
- // that user code is usually dealing with.
60
-
61
- function CodeMirror(place, options) {
62
- if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
63
-
64
- this.options = options = options || {};
65
- // Determine effective options based on given values and defaults.
66
- copyObj(defaults, options, false);
67
- setGuttersForLineNumbers(options);
68
-
69
- var doc = options.value;
70
- if (typeof doc == "string") doc = new Doc(doc, options.mode);
71
- this.doc = doc;
72
-
73
- var display = this.display = new Display(place, doc);
74
- display.wrapper.CodeMirror = this;
75
- updateGutters(this);
76
- themeChanged(this);
77
- if (options.lineWrapping)
78
- this.display.wrapper.className += " CodeMirror-wrap";
79
- if (options.autofocus && !mobile) focusInput(this);
80
-
81
- this.state = {
82
- keyMaps: [], // stores maps added by addKeyMap
83
- overlays: [], // highlighting overlays, as added by addOverlay
84
- modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
85
- overwrite: false, focused: false,
86
- suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
87
- pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput
88
- draggingText: false,
89
- highlight: new Delayed() // stores highlight worker timeout
90
- };
91
-
92
- // Override magic textarea content restore that IE sometimes does
93
- // on our hidden textarea on reload
94
- if (ie && ie_version < 11) setTimeout(bind(resetInput, this, true), 20);
95
-
96
- registerEventHandlers(this);
97
- ensureGlobalHandlers();
98
 
99
- var cm = this;
100
- runInOp(this, function() {
101
- cm.curOp.forceUpdate = true;
102
- attachDoc(cm, doc);
 
 
 
 
103
 
104
- if ((options.autofocus && !mobile) || activeElt() == display.input)
105
- setTimeout(bind(onFocus, cm), 20);
106
- else
107
- onBlur(cm);
 
108
 
109
- for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
110
- optionHandlers[opt](cm, options[opt], Init);
111
- maybeUpdateLineNumberWidth(cm);
112
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm);
113
- });
114
  }
115
 
116
- // DISPLAY CONSTRUCTOR
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
- // The display handles the DOM integration, both for input reading
119
- // and content drawing. It holds references to DOM nodes and
120
- // display-related state.
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
- function Display(place, doc) {
123
- var d = this;
 
 
 
 
 
 
 
 
124
 
125
- // The semihidden textarea that is focused when the editor is
126
- // focused, and receives input.
127
- var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
128
- // The textarea is kept positioned near the cursor to prevent the
129
- // fact that it'll be scrolled into view on input from scrolling
130
- // our fake cursor out of view. On webkit, when wrap=off, paste is
131
- // very slow. So make the area wide instead.
132
- if (webkit) input.style.width = "1000px";
133
- else input.setAttribute("wrap", "off");
134
- // If border: 0; -- iOS fails to open keyboard (issue #1287)
135
- if (ios) input.style.border = "1px solid black";
136
- input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
 
 
137
 
138
- // Wraps and hides input textarea
139
- d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
140
- // The fake scrollbar elements.
141
- d.scrollbarH = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
142
- d.scrollbarV = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
143
- // Covers bottom-right square when both scrollbars are present.
144
- d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
145
- // Covers bottom of gutter when coverGutterNextToScrollbar is on
146
- // and h scrollbar is present.
147
- d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
148
- // Will contain the actual code, positioned to cover the viewport.
149
- d.lineDiv = elt("div", null, "CodeMirror-code");
150
- // Elements are added to these to represent selection and cursors.
151
- d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
152
- d.cursorDiv = elt("div", null, "CodeMirror-cursors");
153
- // A visibility: hidden element used to find the size of things.
154
- d.measure = elt("div", null, "CodeMirror-measure");
155
- // When lines outside of the viewport are measured, they are drawn in this.
156
- d.lineMeasure = elt("div", null, "CodeMirror-measure");
157
- // Wraps everything that needs to exist inside the vertically-padded coordinate system
158
- d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
159
- null, "position: relative; outline: none");
160
- // Moved around its parent to cover visible view.
161
- d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
162
- // Set to the height of the document, allowing scrolling.
163
- d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
164
- // Behavior of elts with overflow: auto and padding is
165
- // inconsistent across browsers. This is used to ensure the
166
- // scrollable area is big enough.
167
- d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;");
168
- // Will contain the gutters, if any.
169
- d.gutters = elt("div", null, "CodeMirror-gutters");
170
- d.lineGutter = null;
171
- // Actual scrollable element.
172
- d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
173
- d.scroller.setAttribute("tabIndex", "-1");
174
- // The element in which the editor lives.
175
- d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
176
- d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
177
 
178
- // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
179
- if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
180
- // Needed to hide big blue blinking cursor on Mobile Safari
181
- if (ios) input.style.width = "0px";
182
- if (!webkit) d.scroller.draggable = true;
183
- // Needed to handle Tab key in KHTML
184
- if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; }
185
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
186
- if (ie && ie_version < 8) d.scrollbarH.style.minHeight = d.scrollbarV.style.minWidth = "18px";
187
 
188
- if (place.appendChild) place.appendChild(d.wrapper);
189
- else place(d.wrapper);
 
 
190
 
191
- // Current rendered range (may be bigger than the view window).
192
- d.viewFrom = d.viewTo = doc.first;
193
- // Information about the rendered lines.
194
- d.view = [];
195
- // Holds info about a single rendered line when it was rendered
196
- // for measurement, while not in view.
197
- d.externalMeasured = null;
198
- // Empty space (in pixels) above the view
199
- d.viewOffset = 0;
200
- d.lastSizeC = 0;
201
- d.updateLineNumbers = null;
202
 
203
- // Used to only resize the line number gutter when necessary (when
204
- // the amount of lines crosses a boundary that makes its width change)
205
- d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
206
- // See readInput and resetInput
207
- d.prevInput = "";
208
- // Set to true when a non-horizontal-scrolling line widget is
209
- // added. As an optimization, line widget aligning is skipped when
210
- // this is false.
211
- d.alignWidgets = false;
212
- // Flag that indicates whether we expect input to appear real soon
213
- // now (after some event like 'keypress' or 'input') and are
214
- // polling intensively.
215
- d.pollingFast = false;
216
- // Self-resetting timeout for the poller
217
- d.poll = new Delayed();
 
218
 
219
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
- // Tracks when resetInput has punted to just putting a short
222
- // string into the textarea instead of the full selection.
223
- d.inaccurateSelection = false;
 
 
224
 
225
- // Tracks the maximum line length so that the horizontal scrollbar
226
- // can be kept static when scrolling.
227
- d.maxLine = null;
228
- d.maxLineLength = 0;
229
- d.maxLineChanged = false;
230
 
231
- // Used for measuring wheel scrolling granularity
232
- d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
 
233
 
234
- // True when shift is held down.
235
- d.shift = false;
236
 
237
- // Used to track whether anything happened since the context menu
238
- // was opened.
239
- d.selForContextMenu = null;
 
 
 
 
 
 
 
 
 
 
 
240
  }
241
 
242
- // STATE UPDATES
 
 
 
 
 
243
 
244
- // Used to get the editor into a consistent state again when options change.
245
 
246
- function loadMode(cm) {
247
- cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
248
- resetModeState(cm);
 
249
  }
250
 
251
- function resetModeState(cm) {
252
- cm.doc.iter(function(line) {
253
- if (line.stateAfter) line.stateAfter = null;
254
- if (line.styles) line.styles = null;
255
- });
256
- cm.doc.frontier = cm.doc.first;
257
- startWorker(cm, 100);
258
- cm.state.modeGen++;
259
- if (cm.curOp) regChange(cm);
260
  }
261
 
262
- function wrappingChanged(cm) {
263
- if (cm.options.lineWrapping) {
264
- addClass(cm.display.wrapper, "CodeMirror-wrap");
265
- cm.display.sizer.style.minWidth = "";
 
 
266
  } else {
267
- rmClass(cm.display.wrapper, "CodeMirror-wrap");
268
- findMaxLine(cm);
269
  }
270
- estimateLineHeights(cm);
271
- regChange(cm);
272
- clearCaches(cm);
273
- setTimeout(function(){updateScrollbars(cm);}, 100);
274
  }
275
 
276
- // Returns a function that estimates the height of a line, to use as
277
- // first approximation until the line becomes visible (and is thus
278
- // properly measurable).
279
- function estimateHeight(cm) {
280
- var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
281
- var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
282
- return function(line) {
283
- if (lineIsHidden(cm.doc, line)) return 0;
284
-
285
- var widgetsHeight = 0;
286
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
287
- if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
288
- }
289
-
290
- if (wrapping)
291
- return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
292
- else
293
- return widgetsHeight + th;
294
- };
295
  }
296
-
297
- function estimateLineHeights(cm) {
298
- var doc = cm.doc, est = estimateHeight(cm);
299
- doc.iter(function(line) {
300
- var estHeight = est(line);
301
- if (estHeight != line.height) updateLineHeight(line, estHeight);
302
- });
303
  }
304
 
305
- function keyMapChanged(cm) {
306
- var map = keyMap[cm.options.keyMap], style = map.style;
307
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
308
- (style ? " cm-keymap-" + style : "");
309
  }
310
 
311
- function themeChanged(cm) {
312
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
313
- cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
314
- clearCaches(cm);
 
 
 
 
 
 
 
 
315
  }
316
 
317
- function guttersChanged(cm) {
318
- updateGutters(cm);
319
- regChange(cm);
320
- setTimeout(function(){alignHorizontally(cm);}, 20);
 
 
 
 
 
 
 
 
 
 
321
  }
322
 
323
- // Rebuild the gutter elements, ensure the margin to the left of the
324
- // code matches their width.
325
- function updateGutters(cm) {
326
- var gutters = cm.display.gutters, specs = cm.options.gutters;
327
- removeChildren(gutters);
328
- for (var i = 0; i < specs.length; ++i) {
329
- var gutterClass = specs[i];
330
- var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
331
- if (gutterClass == "CodeMirror-linenumbers") {
332
- cm.display.lineGutter = gElt;
333
- gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
334
  }
335
  }
336
- gutters.style.display = i ? "" : "none";
337
- updateGutterSpace(cm);
338
  }
339
 
340
- function updateGutterSpace(cm) {
341
- var width = cm.display.gutters.offsetWidth;
342
- cm.display.sizer.style.marginLeft = width + "px";
343
- cm.display.scrollbarH.style.left = cm.options.fixedGutter ? width + "px" : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  }
345
 
346
- // Compute the character length of a line, taking into account
347
- // collapsed ranges (see markText) that might hide parts, and join
348
- // other lines onto it.
349
- function lineLength(line) {
350
- if (line.height == 0) return 0;
351
- var len = line.text.length, merged, cur = line;
352
- while (merged = collapsedSpanAtStart(cur)) {
353
- var found = merged.find(0, true);
354
- cur = found.from.line;
355
- len += found.from.ch - found.to.ch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  }
357
- cur = line;
358
- while (merged = collapsedSpanAtEnd(cur)) {
359
- var found = merged.find(0, true);
360
- len -= cur.text.length - found.from.ch;
361
- cur = found.to.line;
362
- len += cur.text.length - found.to.ch;
 
363
  }
364
- return len;
365
- }
366
 
367
- // Find the longest line in the document.
368
- function findMaxLine(cm) {
369
- var d = cm.display, doc = cm.doc;
370
- d.maxLine = getLine(doc, doc.first);
371
- d.maxLineLength = lineLength(d.maxLine);
372
- d.maxLineChanged = true;
373
- doc.iter(function(line) {
374
- var len = lineLength(line);
375
- if (len > d.maxLineLength) {
376
- d.maxLineLength = len;
377
- d.maxLine = line;
 
 
 
 
 
378
  }
379
- });
380
- }
381
 
382
- // Make sure the gutters options contains the element
383
- // "CodeMirror-linenumbers" when the lineNumbers option is true.
384
- function setGuttersForLineNumbers(options) {
385
- var found = indexOf(options.gutters, "CodeMirror-linenumbers");
386
- if (found == -1 && options.lineNumbers) {
387
- options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
388
- } else if (found > -1 && !options.lineNumbers) {
389
- options.gutters = options.gutters.slice(0);
390
- options.gutters.splice(found, 1);
391
- }
392
- }
393
 
394
- // SCROLLBARS
 
 
 
 
 
 
 
 
 
395
 
396
- function hScrollbarTakesSpace(cm) {
397
- return cm.display.scroller.clientHeight - cm.display.wrapper.clientHeight < scrollerCutOff - 3;
398
- }
 
 
 
 
 
 
 
 
 
 
 
 
399
 
400
- // Prepare DOM reads needed to update the scrollbars. Done in one
401
- // shot to minimize update/measure roundtrips.
402
- function measureForScrollbars(cm) {
403
- var scroll = cm.display.scroller;
404
- return {
405
- clientHeight: scroll.clientHeight,
406
- barHeight: cm.display.scrollbarV.clientHeight,
407
- scrollWidth: scroll.scrollWidth, clientWidth: scroll.clientWidth,
408
- hScrollbarTakesSpace: hScrollbarTakesSpace(cm),
409
- barWidth: cm.display.scrollbarH.clientWidth,
410
- docHeight: Math.round(cm.doc.height + paddingVert(cm.display))
411
- };
412
- }
413
 
414
- // Re-synchronize the fake scrollbars with the actual size of the
415
- // content.
416
- function updateScrollbars(cm, measure) {
417
- if (!measure) measure = measureForScrollbars(cm);
418
- var d = cm.display, sWidth = scrollbarWidth(d.measure);
419
- var scrollHeight = measure.docHeight + scrollerCutOff;
420
- var needsH = measure.scrollWidth > measure.clientWidth;
421
- if (needsH && measure.scrollWidth <= measure.clientWidth + 1 &&
422
- sWidth > 0 && !measure.hScrollbarTakesSpace)
423
- needsH = false; // (Issue #2562)
424
- var needsV = scrollHeight > measure.clientHeight;
 
 
 
 
 
 
425
 
426
- if (needsV) {
427
- d.scrollbarV.style.display = "block";
428
- d.scrollbarV.style.bottom = needsH ? sWidth + "px" : "0";
429
- // A bug in IE8 can cause this value to be negative, so guard it.
430
- d.scrollbarV.firstChild.style.height =
431
- Math.max(0, scrollHeight - measure.clientHeight + (measure.barHeight || d.scrollbarV.clientHeight)) + "px";
432
- } else {
433
- d.scrollbarV.style.display = "";
434
- d.scrollbarV.firstChild.style.height = "0";
435
- }
436
- if (needsH) {
437
- d.scrollbarH.style.display = "block";
438
- d.scrollbarH.style.right = needsV ? sWidth + "px" : "0";
439
- d.scrollbarH.firstChild.style.width =
440
- (measure.scrollWidth - measure.clientWidth + (measure.barWidth || d.scrollbarH.clientWidth)) + "px";
441
- } else {
442
- d.scrollbarH.style.display = "";
443
- d.scrollbarH.firstChild.style.width = "0";
444
- }
445
- if (needsH && needsV) {
446
- d.scrollbarFiller.style.display = "block";
447
- d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = sWidth + "px";
448
- } else d.scrollbarFiller.style.display = "";
449
- if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
450
- d.gutterFiller.style.display = "block";
451
- d.gutterFiller.style.height = sWidth + "px";
452
- d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
453
- } else d.gutterFiller.style.display = "";
454
-
455
- if (!cm.state.checkedOverlayScrollbar && measure.clientHeight > 0) {
456
- if (sWidth === 0) {
457
- var w = mac && !mac_geMountainLion ? "12px" : "18px";
458
- d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = w;
459
- var barMouseDown = function(e) {
460
- if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH)
461
- operation(cm, onMouseDown)(e);
462
- };
463
- on(d.scrollbarV, "mousedown", barMouseDown);
464
- on(d.scrollbarH, "mousedown", barMouseDown);
465
  }
466
- cm.state.checkedOverlayScrollbar = true;
 
467
  }
 
 
 
 
 
 
 
 
 
468
  }
469
 
470
- // Compute the lines that are visible in a given viewport (defaults
471
- // the the current scroll position). viewport may contain top,
472
- // height, and ensure (see op.scrollToPos) properties.
473
- function visibleLines(display, doc, viewport) {
474
- var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
475
- top = Math.floor(top - paddingTop(display));
476
- var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
477
 
478
- var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
479
- // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
480
- // forces those lines into the viewport (if possible).
481
- if (viewport && viewport.ensure) {
482
- var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
483
- if (ensureFrom < from)
484
- return {from: ensureFrom,
485
- to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)};
486
- if (Math.min(ensureTo, doc.lastLine()) >= to)
487
- return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight),
488
- to: ensureTo};
489
- }
490
- return {from: from, to: Math.max(to, from + 1)};
491
- }
492
 
493
- // LINE NUMBERS
494
 
495
- // Re-align line numbers and gutter marks to compensate for
496
- // horizontal scrolling.
497
- function alignHorizontally(cm) {
498
- var display = cm.display, view = display.view;
499
- if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
500
- var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
501
- var gutterW = display.gutters.offsetWidth, left = comp + "px";
502
- for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
503
- if (cm.options.fixedGutter && view[i].gutter)
504
- view[i].gutter.style.left = left;
505
- var align = view[i].alignable;
506
- if (align) for (var j = 0; j < align.length; j++)
507
- align[j].style.left = left;
508
  }
509
- if (cm.options.fixedGutter)
510
- display.gutters.style.left = (comp + gutterW) + "px";
 
 
511
  }
512
 
513
- // Used to ensure that the line number gutter is still the right
514
- // size for the current document size. Returns true when an update
515
- // is needed.
516
- function maybeUpdateLineNumberWidth(cm) {
517
- if (!cm.options.lineNumbers) return false;
518
- var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
519
- if (last.length != display.lineNumChars) {
520
- var test = display.measure.appendChild(elt("div", [elt("div", last)],
521
- "CodeMirror-linenumber CodeMirror-gutter-elt"));
522
- var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
523
- display.lineGutter.style.width = "";
524
- display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
525
- display.lineNumWidth = display.lineNumInnerWidth + padding;
526
- display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
527
- display.lineGutter.style.width = display.lineNumWidth + "px";
528
- updateGutterSpace(cm);
529
- return true;
530
  }
531
- return false;
532
  }
533
 
534
- function lineNumberFor(options, i) {
535
- return String(options.lineNumberFormatter(i + options.firstLineNumber));
 
 
 
536
  }
537
 
538
- // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
539
- // but using getBoundingClientRect to get a sub-pixel-accurate
540
- // result.
541
- function compensateForHScroll(display) {
542
- return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
 
 
 
543
  }
544
 
545
- // DISPLAY DRAWING
546
-
547
- function DisplayUpdate(cm, viewport, force) {
548
- var display = cm.display;
 
 
 
549
 
550
- this.viewport = viewport;
551
- // Store some values that we'll need later (but don't want to force a relayout for)
552
- this.visible = visibleLines(display, cm.doc, viewport);
553
- this.editorIsHidden = !display.wrapper.offsetWidth;
554
- this.wrapperHeight = display.wrapper.clientHeight;
555
- this.oldViewFrom = display.viewFrom; this.oldViewTo = display.viewTo;
556
- this.oldScrollerWidth = display.scroller.clientWidth;
557
- this.force = force;
558
- this.dims = getDimensions(cm);
559
  }
560
 
561
- // Does the actual updating of the line display. Bails out
562
- // (returning false) when there is nothing to be done and forced is
563
- // false.
564
- function updateDisplayIfNeeded(cm, update) {
565
- var display = cm.display, doc = cm.doc;
566
- if (update.editorIsHidden) {
567
- resetView(cm);
568
- return false;
569
- }
570
 
571
- // Bail out if the visible area is already rendered and nothing changed.
572
- if (!update.force &&
573
- update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
574
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
575
- countDirtyView(cm) == 0)
576
- return false;
577
 
578
- if (maybeUpdateLineNumberWidth(cm)) {
579
- resetView(cm);
580
- update.dims = getDimensions(cm);
581
- }
 
 
 
 
 
 
 
 
582
 
583
- // Compute a suitable new viewport (from & to)
584
- var end = doc.first + doc.size;
585
- var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
586
- var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
587
- if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
588
- if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
589
- if (sawCollapsedSpans) {
590
- from = visualLineNo(cm.doc, from);
591
- to = visualLineEndNo(cm.doc, to);
592
  }
 
 
 
593
 
594
- var different = from != display.viewFrom || to != display.viewTo ||
595
- display.lastSizeC != update.wrapperHeight;
596
- adjustView(cm, from, to);
597
-
598
- display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
599
- // Position the mover div to align with the current scroll position
600
- cm.display.mover.style.top = display.viewOffset + "px";
601
-
602
- var toUpdate = countDirtyView(cm);
603
- if (!different && toUpdate == 0 && !update.force &&
604
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
605
- return false;
606
-
607
- // For big changes, we hide the enclosing element during the
608
- // update, since that speeds up the operations on most browsers.
609
- var focused = activeElt();
610
- if (toUpdate > 4) display.lineDiv.style.display = "none";
611
- patchDisplay(cm, display.updateLineNumbers, update.dims);
612
- if (toUpdate > 4) display.lineDiv.style.display = "";
613
- // There might have been a widget with a focused element that got
614
- // hidden or updated, if so re-focus it.
615
- if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
616
-
617
- // Prevent selection and cursors from interfering with the scroll
618
- // width.
619
- removeChildren(display.cursorDiv);
620
- removeChildren(display.selectionDiv);
621
 
622
- if (different) {
623
- display.lastSizeC = update.wrapperHeight;
624
- startWorker(cm, 400);
 
 
 
 
625
  }
 
 
 
 
 
626
 
627
- display.updateLineNumbers = null;
628
-
629
- return true;
 
 
 
 
 
 
 
630
  }
631
 
632
- function postUpdateDisplay(cm, update) {
633
- var force = update.force, viewport = update.viewport;
634
- for (var first = true;; first = false) {
635
- if (first && cm.options.lineWrapping && update.oldScrollerWidth != cm.display.scroller.clientWidth) {
636
- force = true;
 
 
 
 
 
 
 
637
  } else {
638
- force = false;
639
- // Clip forced viewport to actual scrollable area.
640
- if (viewport && viewport.top != null)
641
- viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - scrollerCutOff -
642
- cm.display.scroller.clientHeight, viewport.top)};
643
- // Updated line heights might result in the drawn area not
644
- // actually covering the viewport. Keep looping until it does.
645
- update.visible = visibleLines(cm.display, cm.doc, viewport);
646
- if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
647
- break;
648
  }
649
- if (!updateDisplayIfNeeded(cm, update)) break;
650
- updateHeightsInViewport(cm);
651
- var barMeasure = measureForScrollbars(cm);
652
- updateSelection(cm);
653
- setDocumentHeight(cm, barMeasure);
654
- updateScrollbars(cm, barMeasure);
655
  }
 
 
656
 
657
- signalLater(cm, "update", cm);
658
- if (cm.display.viewFrom != update.oldViewFrom || cm.display.viewTo != update.oldViewTo)
659
- signalLater(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
660
- }
 
 
 
 
 
 
661
 
662
- function updateDisplaySimple(cm, viewport) {
663
- var update = new DisplayUpdate(cm, viewport);
664
- if (updateDisplayIfNeeded(cm, update)) {
665
- postUpdateDisplay(cm, update);
666
- var barMeasure = measureForScrollbars(cm);
667
- updateSelection(cm);
668
- setDocumentHeight(cm, barMeasure);
669
- updateScrollbars(cm, barMeasure);
670
- }
671
- }
672
 
673
- function setDocumentHeight(cm, measure) {
674
- cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = measure.docHeight + "px";
675
- cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px";
 
 
 
 
676
  }
677
 
678
- function checkForWebkitWidthBug(cm, measure) {
679
- // Work around Webkit bug where it sometimes reserves space for a
680
- // non-existing phantom scrollbar in the scroller (Issue #2420)
681
- if (cm.display.sizer.offsetWidth + cm.display.gutters.offsetWidth < cm.display.scroller.clientWidth - 1) {
682
- cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = "0px";
683
- cm.display.gutters.style.height = measure.docHeight + "px";
684
- }
685
- }
686
 
687
- // Read the actual heights of the rendered lines, and update their
688
- // stored heights to match.
689
- function updateHeightsInViewport(cm) {
690
- var display = cm.display;
691
- var prevBottom = display.lineDiv.offsetTop;
692
- for (var i = 0; i < display.view.length; i++) {
693
- var cur = display.view[i], height;
694
- if (cur.hidden) continue;
695
- if (ie && ie_version < 8) {
696
- var bot = cur.node.offsetTop + cur.node.offsetHeight;
697
- height = bot - prevBottom;
698
- prevBottom = bot;
699
- } else {
700
- var box = cur.node.getBoundingClientRect();
701
- height = box.bottom - box.top;
702
- }
703
- var diff = cur.line.height - height;
704
- if (height < 2) height = textHeight(display);
705
- if (diff > .001 || diff < -.001) {
706
- updateLineHeight(cur.line, height);
707
- updateWidgetHeight(cur.line);
708
- if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
709
- updateWidgetHeight(cur.rest[j]);
710
- }
711
- }
712
  }
713
 
714
- // Read and store the height of line widgets associated with the
715
- // given line.
716
- function updateWidgetHeight(line) {
717
- if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
718
- line.widgets[i].height = line.widgets[i].node.offsetHeight;
719
  }
720
 
721
- // Do a bulk-read of the DOM positions and sizes needed to draw the
722
- // view, so that we don't interleave reading and writing to the DOM.
723
- function getDimensions(cm) {
724
- var d = cm.display, left = {}, width = {};
725
- for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
726
- left[cm.options.gutters[i]] = n.offsetLeft;
727
- width[cm.options.gutters[i]] = n.offsetWidth;
 
 
 
 
 
 
 
728
  }
729
- return {fixedPos: compensateForHScroll(d),
730
- gutterTotalWidth: d.gutters.offsetWidth,
731
- gutterLeft: left,
732
- gutterWidth: width,
733
- wrapperWidth: d.wrapper.clientWidth};
734
  }
735
 
736
- // Sync the actual display DOM structure with display.view, removing
737
- // nodes for lines that are no longer in view, and creating the ones
738
- // that are not there yet, and updating the ones that are out of
739
- // date.
740
- function patchDisplay(cm, updateNumbersFrom, dims) {
741
- var display = cm.display, lineNumbers = cm.options.lineNumbers;
742
- var container = display.lineDiv, cur = container.firstChild;
743
-
744
- function rm(node) {
745
- var next = node.nextSibling;
746
- // Works around a throw-scroll bug in OS X Webkit
747
- if (webkit && mac && cm.display.currentWheelTarget == node)
748
- node.style.display = "none";
749
- else
750
- node.parentNode.removeChild(node);
751
- return next;
752
- }
753
-
754
- var view = display.view, lineN = display.viewFrom;
755
- // Loop over the elements in the view, syncing cur (the DOM nodes
756
- // in display.lineDiv) with the view as we go.
757
- for (var i = 0; i < view.length; i++) {
758
- var lineView = view[i];
759
- if (lineView.hidden) {
760
- } else if (!lineView.node) { // Not drawn yet
761
- var node = buildLineElement(cm, lineView, lineN, dims);
762
- container.insertBefore(node, cur);
763
- } else { // Already drawn
764
- while (cur != lineView.node) cur = rm(cur);
765
- var updateNumber = lineNumbers && updateNumbersFrom != null &&
766
- updateNumbersFrom <= lineN && lineView.lineNumber;
767
- if (lineView.changes) {
768
- if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
769
- updateLineForChanges(cm, lineView, lineN, dims);
770
- }
771
- if (updateNumber) {
772
- removeChildren(lineView.lineNumber);
773
- lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
774
- }
775
- cur = lineView.node.nextSibling;
776
  }
777
- lineN += lineView.size;
778
  }
779
- while (cur) cur = rm(cur);
780
- }
 
 
781
 
782
- // When an aspect of a line changes, a string is added to
783
- // lineView.changes. This updates the relevant part of the line's
784
- // DOM structure.
785
- function updateLineForChanges(cm, lineView, lineN, dims) {
786
- for (var j = 0; j < lineView.changes.length; j++) {
787
- var type = lineView.changes[j];
788
- if (type == "text") updateLineText(cm, lineView);
789
- else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
790
- else if (type == "class") updateLineClasses(lineView);
791
- else if (type == "widget") updateLineWidgets(lineView, dims);
792
- }
793
- lineView.changes = null;
794
  }
795
 
796
- // Lines with gutter elements, widgets or a background class need to
797
- // be wrapped, and have the extra elements added to the wrapper div
798
- function ensureLineWrapped(lineView) {
799
- if (lineView.node == lineView.text) {
800
- lineView.node = elt("div", null, null, "position: relative");
801
- if (lineView.text.parentNode)
802
- lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
803
- lineView.node.appendChild(lineView.text);
804
- if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
805
- }
806
- return lineView.node;
807
  }
808
 
809
- function updateLineBackground(lineView) {
810
- var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
811
- if (cls) cls += " CodeMirror-linebackground";
812
- if (lineView.background) {
813
- if (cls) lineView.background.className = cls;
814
- else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
815
- } else if (cls) {
816
- var wrap = ensureLineWrapped(lineView);
817
- lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
818
  }
 
819
  }
820
 
821
- // Wrapper around buildLineContent which will reuse the structure
822
- // in display.externalMeasured when possible.
823
- function getLineContent(cm, lineView) {
824
- var ext = cm.display.externalMeasured;
825
- if (ext && ext.line == lineView.line) {
826
- cm.display.externalMeasured = null;
827
- lineView.measure = ext.measure;
828
- return ext.built;
 
829
  }
830
- return buildLineContent(cm, lineView);
831
  }
832
 
833
- // Redraw the line's text. Interacts with the background and text
834
- // classes because the mode may output tokens that influence these
835
- // classes.
836
- function updateLineText(cm, lineView) {
837
- var cls = lineView.text.className;
838
- var built = getLineContent(cm, lineView);
839
- if (lineView.text == lineView.node) lineView.node = built.pre;
840
- lineView.text.parentNode.replaceChild(built.pre, lineView.text);
841
- lineView.text = built.pre;
842
- if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
843
- lineView.bgClass = built.bgClass;
844
- lineView.textClass = built.textClass;
845
- updateLineClasses(lineView);
846
- } else if (cls) {
847
- lineView.text.className = cls;
848
- }
849
  }
850
 
851
- function updateLineClasses(lineView) {
852
- updateLineBackground(lineView);
853
- if (lineView.line.wrapClass)
854
- ensureLineWrapped(lineView).className = lineView.line.wrapClass;
855
- else if (lineView.node != lineView.text)
856
- lineView.node.className = "";
857
- var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
858
- lineView.text.className = textClass || "";
859
- }
860
 
861
- function updateLineGutter(cm, lineView, lineN, dims) {
862
- if (lineView.gutter) {
863
- lineView.node.removeChild(lineView.gutter);
864
- lineView.gutter = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
  }
866
- var markers = lineView.line.gutterMarkers;
867
- if (cm.options.lineNumbers || markers) {
868
- var wrap = ensureLineWrapped(lineView);
869
- var gutterWrap = lineView.gutter =
870
- wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " +
871
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
872
- lineView.text);
873
- if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
874
- lineView.lineNumber = gutterWrap.appendChild(
875
- elt("div", lineNumberFor(cm.options, lineN),
876
- "CodeMirror-linenumber CodeMirror-gutter-elt",
877
- "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
878
- + cm.display.lineNumInnerWidth + "px"));
879
- if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
880
- var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
881
- if (found)
882
- gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
883
- dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
884
  }
 
 
 
 
 
885
  }
886
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
887
 
888
- function updateLineWidgets(lineView, dims) {
889
- if (lineView.alignable) lineView.alignable = null;
890
- for (var node = lineView.node.firstChild, next; node; node = next) {
891
- var next = node.nextSibling;
892
- if (node.className == "CodeMirror-linewidget")
893
- lineView.node.removeChild(node);
 
 
 
 
 
894
  }
895
- insertLineWidgets(lineView, dims);
896
  }
897
 
898
- // Build a line's DOM representation from scratch
899
- function buildLineElement(cm, lineView, lineN, dims) {
900
- var built = getLineContent(cm, lineView);
901
- lineView.text = lineView.node = built.pre;
902
- if (built.bgClass) lineView.bgClass = built.bgClass;
903
- if (built.textClass) lineView.textClass = built.textClass;
904
-
905
- updateLineClasses(lineView);
906
- updateLineGutter(cm, lineView, lineN, dims);
907
- insertLineWidgets(lineView, dims);
908
- return lineView.node;
 
 
 
 
 
 
 
909
  }
910
 
911
- // A lineView may contain multiple logical lines (when merged by
912
- // collapsed spans). The widgets for all of them need to be drawn.
913
- function insertLineWidgets(lineView, dims) {
914
- insertLineWidgetsFor(lineView.line, lineView, dims, true);
915
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
916
- insertLineWidgetsFor(lineView.rest[i], lineView, dims, false);
917
  }
918
 
919
- function insertLineWidgetsFor(line, lineView, dims, allowAbove) {
920
- if (!line.widgets) return;
921
- var wrap = ensureLineWrapped(lineView);
922
- for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
923
- var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
924
- if (!widget.handleMouseEvents) node.ignoreEvents = true;
925
- positionLineWidget(widget, node, lineView, dims);
926
- if (allowAbove && widget.above)
927
- wrap.insertBefore(node, lineView.gutter || lineView.text);
928
- else
929
- wrap.appendChild(node);
930
- signalLater(widget, "redraw");
931
  }
 
932
  }
933
 
934
- function positionLineWidget(widget, node, lineView, dims) {
935
- if (widget.noHScroll) {
936
- (lineView.alignable || (lineView.alignable = [])).push(node);
937
- var width = dims.wrapperWidth;
938
- node.style.left = dims.fixedPos + "px";
939
- if (!widget.coverGutter) {
940
- width -= dims.gutterTotalWidth;
941
- node.style.paddingLeft = dims.gutterTotalWidth + "px";
 
 
942
  }
943
- node.style.width = width + "px";
944
- }
945
- if (widget.coverGutter) {
946
- node.style.zIndex = 5;
947
- node.style.position = "relative";
948
- if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
 
949
  }
 
950
  }
951
 
952
- // POSITION OBJECT
953
-
954
- // A Pos instance represents a position within the text.
955
- var Pos = CodeMirror.Pos = function(line, ch) {
956
- if (!(this instanceof Pos)) return new Pos(line, ch);
957
- this.line = line; this.ch = ch;
958
- };
959
-
960
- // Compare two positions, return 0 if they are the same, a negative
961
- // number when a is less, and a positive number otherwise.
962
- var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
963
-
964
- function copyPos(x) {return Pos(x.line, x.ch);}
965
- function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
966
- function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
967
-
968
- // SELECTION / CURSOR
969
 
970
- // Selection objects are immutable. A new one is created every time
971
- // the selection changes. A selection is one or more non-overlapping
972
- // (and non-touching) ranges, sorted, and an integer that indicates
973
- // which one is the primary selection (the one that's scrolled into
974
- // view, that getCursor returns, etc).
975
- function Selection(ranges, primIndex) {
976
- this.ranges = ranges;
977
- this.primIndex = primIndex;
978
  }
979
 
980
- Selection.prototype = {
981
- primary: function() { return this.ranges[this.primIndex]; },
982
- equals: function(other) {
983
- if (other == this) return true;
984
- if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
985
- for (var i = 0; i < this.ranges.length; i++) {
986
- var here = this.ranges[i], there = other.ranges[i];
987
- if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
988
- }
989
- return true;
990
- },
991
- deepCopy: function() {
992
- for (var out = [], i = 0; i < this.ranges.length; i++)
993
- out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
994
- return new Selection(out, this.primIndex);
995
- },
996
- somethingSelected: function() {
997
- for (var i = 0; i < this.ranges.length; i++)
998
- if (!this.ranges[i].empty()) return true;
999
- return false;
1000
- },
1001
- contains: function(pos, end) {
1002
- if (!end) end = pos;
1003
- for (var i = 0; i < this.ranges.length; i++) {
1004
- var range = this.ranges[i];
1005
- if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
1006
- return i;
1007
- }
1008
- return -1;
1009
- }
1010
- };
1011
 
1012
- function Range(anchor, head) {
1013
- this.anchor = anchor; this.head = head;
 
 
1014
  }
1015
 
1016
- Range.prototype = {
1017
- from: function() { return minPos(this.anchor, this.head); },
1018
- to: function() { return maxPos(this.anchor, this.head); },
1019
- empty: function() {
1020
- return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
1021
- }
1022
- };
1023
 
1024
- // Take an unsorted, potentially overlapping set of ranges, and
1025
- // build a selection out of it. 'Consumes' ranges array (modifying
1026
- // it).
1027
- function normalizeSelection(ranges, primIndex) {
1028
- var prim = ranges[primIndex];
1029
- ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
1030
- primIndex = indexOf(ranges, prim);
1031
- for (var i = 1; i < ranges.length; i++) {
1032
- var cur = ranges[i], prev = ranges[i - 1];
1033
- if (cmp(prev.to(), cur.from()) >= 0) {
1034
- var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
1035
- var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
1036
- if (i <= primIndex) --primIndex;
1037
- ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
1038
- }
1039
- }
1040
- return new Selection(ranges, primIndex);
1041
- }
1042
 
1043
- function simpleSelection(anchor, head) {
1044
- return new Selection([new Range(anchor, head || anchor)], 0);
1045
- }
1046
 
1047
  // Most of the external API clips given positions to make sure they
1048
  // actually exist within the document.
1049
- function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
1050
  function clipPos(doc, pos) {
1051
- if (pos.line < doc.first) return Pos(doc.first, 0);
1052
  var last = doc.first + doc.size - 1;
1053
- if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
1054
- return clipToLen(pos, getLine(doc, pos.line).text.length);
1055
  }
1056
  function clipToLen(pos, linelen) {
1057
  var ch = pos.ch;
1058
- if (ch == null || ch > linelen) return Pos(pos.line, linelen);
1059
- else if (ch < 0) return Pos(pos.line, 0);
1060
- else return pos;
1061
  }
1062
- function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
1063
  function clipPosArray(doc, array) {
1064
- for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
1065
- return out;
 
1066
  }
1067
 
1068
- // SELECTION UPDATES
 
 
 
1069
 
1070
- // The 'scroll' parameter given to many of these indicated whether
1071
- // the new cursor position should be scrolled into view after
1072
- // modifying the selection.
 
 
 
 
 
1073
 
1074
- // If shift is held or the extend flag is set, extends a range to
1075
- // include a given position (and optionally a second position).
1076
- // Otherwise, simply returns the range between the given positions.
1077
- // Used for cursor motion and such.
1078
- function extendRange(doc, range, head, other) {
1079
- if (doc.cm && doc.cm.display.shift || doc.extend) {
1080
- var anchor = range.anchor;
1081
- if (other) {
1082
- var posBefore = cmp(head, anchor) < 0;
1083
- if (posBefore != (cmp(other, anchor) < 0)) {
1084
- anchor = head;
1085
- head = other;
1086
- } else if (posBefore != (cmp(head, other) < 0)) {
1087
- head = other;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1088
  }
1089
- }
1090
- return new Range(anchor, head);
1091
- } else {
1092
- return new Range(other || head, head);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1093
  }
 
1094
  }
1095
 
1096
- // Extend the primary selection range, discard the rest.
1097
- function extendSelection(doc, head, other, options) {
1098
- setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
 
 
 
 
 
 
 
 
 
 
 
 
1099
  }
1100
 
1101
- // Extend all selections (pos is an array of selections with length
1102
- // equal the number of selections)
1103
- function extendSelections(doc, heads, options) {
1104
- for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
1105
- out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
1106
- var newSel = normalizeSelection(out, doc.sel.primIndex);
1107
- setSelection(doc, newSel, options);
 
 
 
 
 
1108
  }
1109
 
1110
- // Updates a single range in the selection.
1111
- function replaceOneSelection(doc, i, range, options) {
1112
- var ranges = doc.sel.ranges.slice(0);
1113
- ranges[i] = range;
1114
- setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
1115
  }
1116
 
1117
- // Reset the selection to a single range.
1118
- function setSimpleSelection(doc, anchor, head, options) {
1119
- setSelection(doc, simpleSelection(anchor, head), options);
 
 
 
 
1120
  }
1121
 
1122
- // Give beforeSelectionChange handlers a change to influence a
1123
- // selection update.
1124
- function filterSelectionChange(doc, sel) {
1125
- var obj = {
1126
- ranges: sel.ranges,
1127
- update: function(ranges) {
1128
- this.ranges = [];
1129
- for (var i = 0; i < ranges.length; i++)
1130
- this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
1131
- clipPos(doc, ranges[i].head));
1132
- }
1133
- };
1134
- signal(doc, "beforeSelectionChange", doc, obj);
1135
- if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
1136
- if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
1137
- else return sel;
 
 
 
 
1138
  }
1139
 
1140
- function setSelectionReplaceHistory(doc, sel, options) {
1141
- var done = doc.history.done, last = lst(done);
1142
- if (last && last.ranges) {
1143
- done[done.length - 1] = sel;
1144
- setSelectionNoUndo(doc, sel, options);
1145
- } else {
1146
- setSelection(doc, sel, options);
1147
- }
1148
- }
1149
-
1150
- // Set a new selection.
1151
- function setSelection(doc, sel, options) {
1152
- setSelectionNoUndo(doc, sel, options);
1153
- addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
1154
- }
1155
-
1156
- function setSelectionNoUndo(doc, sel, options) {
1157
- if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
1158
- sel = filterSelectionChange(doc, sel);
1159
-
1160
- var bias = options && options.bias ||
1161
- (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
1162
- setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
1163
-
1164
- if (!(options && options.scroll === false) && doc.cm)
1165
- ensureCursorVisible(doc.cm);
1166
- }
1167
-
1168
- function setSelectionInner(doc, sel) {
1169
- if (sel.equals(doc.sel)) return;
1170
-
1171
- doc.sel = sel;
1172
-
1173
- if (doc.cm) {
1174
- doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
1175
- signalCursorActivity(doc.cm);
1176
- }
1177
- signalLater(doc, "cursorActivity", doc);
1178
- }
1179
-
1180
- // Verify that the selection does not partially select any atomic
1181
- // marked ranges.
1182
- function reCheckSelection(doc) {
1183
- setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
1184
- }
1185
-
1186
- // Return a selection that does not partially select any atomic
1187
- // ranges.
1188
- function skipAtomicInSelection(doc, sel, bias, mayClear) {
1189
- var out;
1190
- for (var i = 0; i < sel.ranges.length; i++) {
1191
- var range = sel.ranges[i];
1192
- var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
1193
- var newHead = skipAtomic(doc, range.head, bias, mayClear);
1194
- if (out || newAnchor != range.anchor || newHead != range.head) {
1195
- if (!out) out = sel.ranges.slice(0, i);
1196
- out[i] = new Range(newAnchor, newHead);
1197
- }
1198
- }
1199
- return out ? normalizeSelection(out, sel.primIndex) : sel;
1200
  }
1201
 
1202
- // Ensure a given position is not inside an atomic range.
1203
- function skipAtomic(doc, pos, bias, mayClear) {
1204
- var flipped = false, curPos = pos;
1205
- var dir = bias || 1;
1206
- doc.cantEdit = false;
1207
- search: for (;;) {
1208
- var line = getLine(doc, curPos.line);
1209
- if (line.markedSpans) {
1210
- for (var i = 0; i < line.markedSpans.length; ++i) {
1211
- var sp = line.markedSpans[i], m = sp.marker;
1212
- if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
1213
- (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
1214
- if (mayClear) {
1215
- signal(m, "beforeCursorEnter");
1216
- if (m.explicitlyCleared) {
1217
- if (!line.markedSpans) break;
1218
- else {--i; continue;}
1219
- }
1220
- }
1221
- if (!m.atomic) continue;
1222
- var newPos = m.find(dir < 0 ? -1 : 1);
1223
- if (cmp(newPos, curPos) == 0) {
1224
- newPos.ch += dir;
1225
- if (newPos.ch < 0) {
1226
- if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
1227
- else newPos = null;
1228
- } else if (newPos.ch > line.text.length) {
1229
- if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
1230
- else newPos = null;
1231
- }
1232
- if (!newPos) {
1233
- if (flipped) {
1234
- // Driven in a corner -- no valid cursor position found at all
1235
- // -- try again *with* clearing, if we didn't already
1236
- if (!mayClear) return skipAtomic(doc, pos, bias, true);
1237
- // Otherwise, turn off editing until further notice, and return the start of the doc
1238
- doc.cantEdit = true;
1239
- return Pos(doc.first, 0);
1240
- }
1241
- flipped = true; newPos = pos; dir = -dir;
1242
- }
1243
- }
1244
- curPos = newPos;
1245
- continue search;
1246
- }
1247
- }
1248
  }
1249
- return curPos;
1250
- }
1251
- }
1252
-
1253
- // SELECTION DRAWING
1254
-
1255
- // Redraw the selection and/or cursor
1256
- function drawSelection(cm) {
1257
- var display = cm.display, doc = cm.doc, result = {};
1258
- var curFragment = result.cursors = document.createDocumentFragment();
1259
- var selFragment = result.selection = document.createDocumentFragment();
1260
-
1261
- for (var i = 0; i < doc.sel.ranges.length; i++) {
1262
- var range = doc.sel.ranges[i];
1263
- var collapsed = range.empty();
1264
- if (collapsed || cm.options.showCursorWhenSelecting)
1265
- drawSelectionCursor(cm, range, curFragment);
1266
- if (!collapsed)
1267
- drawSelectionRange(cm, range, selFragment);
1268
- }
1269
-
1270
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
1271
- if (cm.options.moveInputWithCursor) {
1272
- var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
1273
- var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
1274
- result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
1275
- headPos.top + lineOff.top - wrapOff.top));
1276
- result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
1277
- headPos.left + lineOff.left - wrapOff.left));
1278
- }
1279
-
1280
- return result;
1281
- }
1282
-
1283
- function updateSelection(cm, drawn) {
1284
- if (!drawn) drawn = drawSelection(cm);
1285
- removeChildrenAndAdd(cm.display.cursorDiv, drawn.cursors);
1286
- removeChildrenAndAdd(cm.display.selectionDiv, drawn.selection);
1287
- if (drawn.teTop != null) {
1288
- cm.display.inputDiv.style.top = drawn.teTop + "px";
1289
- cm.display.inputDiv.style.left = drawn.teLeft + "px";
1290
- }
1291
- }
1292
-
1293
- // Draws a cursor for the given range
1294
- function drawSelectionCursor(cm, range, output) {
1295
- var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
1296
-
1297
- var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
1298
- cursor.style.left = pos.left + "px";
1299
- cursor.style.top = pos.top + "px";
1300
- cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
1301
-
1302
- if (pos.other) {
1303
- // Secondary cursor, shown when on a 'jump' in bi-directional text
1304
- var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
1305
- otherCursor.style.display = "";
1306
- otherCursor.style.left = pos.other.left + "px";
1307
- otherCursor.style.top = pos.other.top + "px";
1308
- otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
1309
- }
1310
- }
1311
-
1312
- // Draws the given range as a highlighted selection
1313
- function drawSelectionRange(cm, range, output) {
1314
- var display = cm.display, doc = cm.doc;
1315
- var fragment = document.createDocumentFragment();
1316
- var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - padding.right;
1317
-
1318
- function add(left, top, width, bottom) {
1319
- if (top < 0) top = 0;
1320
- top = Math.round(top);
1321
- bottom = Math.round(bottom);
1322
- fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
1323
- "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
1324
- "px; height: " + (bottom - top) + "px"));
1325
- }
1326
-
1327
- function drawForLine(line, fromArg, toArg) {
1328
- var lineObj = getLine(doc, line);
1329
- var lineLen = lineObj.text.length;
1330
- var start, end;
1331
- function coords(ch, bias) {
1332
- return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
1333
  }
1334
-
1335
- iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
1336
- var leftPos = coords(from, "left"), rightPos, left, right;
1337
- if (from == to) {
1338
- rightPos = leftPos;
1339
- left = right = leftPos.left;
1340
- } else {
1341
- rightPos = coords(to - 1, "right");
1342
- if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
1343
- left = leftPos.left;
1344
- right = rightPos.right;
1345
- }
1346
- if (fromArg == null && from == 0) left = leftSide;
1347
- if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
1348
- add(left, leftPos.top, null, leftPos.bottom);
1349
- left = leftSide;
1350
- if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
1351
- }
1352
- if (toArg == null && to == lineLen) right = rightSide;
1353
- if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
1354
- start = leftPos;
1355
- if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
1356
- end = rightPos;
1357
- if (left < leftSide + 1) left = leftSide;
1358
- add(left, rightPos.top, right - left, rightPos.bottom);
1359
- });
1360
- return {start: start, end: end};
1361
- }
1362
-
1363
- var sFrom = range.from(), sTo = range.to();
1364
- if (sFrom.line == sTo.line) {
1365
- drawForLine(sFrom.line, sFrom.ch, sTo.ch);
1366
- } else {
1367
- var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
1368
- var singleVLine = visualLine(fromLine) == visualLine(toLine);
1369
- var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
1370
- var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
1371
- if (singleVLine) {
1372
- if (leftEnd.top < rightStart.top - 2) {
1373
- add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
1374
- add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
1375
- } else {
1376
- add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
1377
  }
 
1378
  }
1379
- if (leftEnd.bottom < rightStart.top)
1380
- add(leftSide, leftEnd.bottom, null, rightStart.top);
 
 
 
 
 
 
 
1381
  }
1382
-
1383
- output.appendChild(fragment);
1384
- }
1385
-
1386
- // Cursor-blinking
1387
- function restartBlink(cm) {
1388
- if (!cm.state.focused) return;
1389
- var display = cm.display;
1390
- clearInterval(display.blinker);
1391
- var on = true;
1392
- display.cursorDiv.style.visibility = "";
1393
- if (cm.options.cursorBlinkRate > 0)
1394
- display.blinker = setInterval(function() {
1395
- display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
1396
- }, cm.options.cursorBlinkRate);
1397
- else if (cm.options.cursorBlinkRate < 0)
1398
- display.cursorDiv.style.visibility = "hidden";
1399
- }
1400
-
1401
- // HIGHLIGHT WORKER
1402
-
1403
- function startWorker(cm, time) {
1404
- if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
1405
- cm.state.highlight.set(time, bind(highlightWorker, cm));
1406
- }
1407
-
1408
- function highlightWorker(cm) {
1409
- var doc = cm.doc;
1410
- if (doc.frontier < doc.first) doc.frontier = doc.first;
1411
- if (doc.frontier >= cm.display.viewTo) return;
1412
- var end = +new Date + cm.options.workTime;
1413
- var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
1414
- var changedLines = [];
1415
-
1416
- doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
1417
- if (doc.frontier >= cm.display.viewFrom) { // Visible
1418
- var oldStyles = line.styles;
1419
- var highlighted = highlightLine(cm, line, state, true);
1420
- line.styles = highlighted.styles;
1421
- var oldCls = line.styleClasses, newCls = highlighted.classes;
1422
- if (newCls) line.styleClasses = newCls;
1423
- else if (oldCls) line.styleClasses = null;
1424
- var ischange = !oldStyles || oldStyles.length != line.styles.length ||
1425
- oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
1426
- for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
1427
- if (ischange) changedLines.push(doc.frontier);
1428
- line.stateAfter = copyState(doc.mode, state);
1429
- } else {
1430
- processLine(cm, line.text, state);
1431
- line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
1432
- }
1433
- ++doc.frontier;
1434
- if (+new Date > end) {
1435
- startWorker(cm, cm.options.workDelay);
1436
- return true;
1437
- }
1438
- });
1439
- if (changedLines.length) runInOp(cm, function() {
1440
- for (var i = 0; i < changedLines.length; i++)
1441
- regLineChange(cm, changedLines[i], "text");
1442
- });
1443
  }
1444
 
1445
  // Finds the line to start with when starting a parse. Tries to
@@ -1451,709 +1259,735 @@
1451
  var minindent, minline, doc = cm.doc;
1452
  var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
1453
  for (var search = n; search > lim; --search) {
1454
- if (search <= doc.first) return doc.first;
1455
- var line = getLine(doc, search - 1);
1456
- if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
 
1457
  var indented = countColumn(line.text, null, cm.options.tabSize);
1458
  if (minline == null || minindent > indented) {
1459
  minline = search - 1;
1460
  minindent = indented;
1461
  }
1462
  }
1463
- return minline;
1464
- }
1465
-
1466
- function getStateBefore(cm, n, precise) {
1467
- var doc = cm.doc, display = cm.display;
1468
- if (!doc.mode.startState) return true;
1469
- var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
1470
- if (!state) state = startState(doc.mode);
1471
- else state = copyState(doc.mode, state);
1472
- doc.iter(pos, n, function(line) {
1473
- processLine(cm, line.text, state);
1474
- var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
1475
- line.stateAfter = save ? copyState(doc.mode, state) : null;
1476
- ++pos;
1477
- });
1478
- if (precise) doc.frontier = pos;
1479
- return state;
1480
- }
1481
-
1482
- // POSITION MEASUREMENT
1483
-
1484
- function paddingTop(display) {return display.lineSpace.offsetTop;}
1485
- function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
1486
- function paddingH(display) {
1487
- if (display.cachedPaddingH) return display.cachedPaddingH;
1488
- var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
1489
- var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
1490
- var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
1491
- if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
1492
- return data;
1493
  }
1494
 
1495
- // Ensure the lineView.wrapping.heights array is populated. This is
1496
- // an array of bottom offsets for the lines that make up a drawn
1497
- // line. When lineWrapping is on, there might be more than one
1498
- // height.
1499
- function ensureLineHeights(cm, lineView, rect) {
1500
- var wrapping = cm.options.lineWrapping;
1501
- var curWidth = wrapping && cm.display.scroller.clientWidth;
1502
- if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
1503
- var heights = lineView.measure.heights = [];
1504
- if (wrapping) {
1505
- lineView.measure.width = curWidth;
1506
- var rects = lineView.text.firstChild.getClientRects();
1507
- for (var i = 0; i < rects.length - 1; i++) {
1508
- var cur = rects[i], next = rects[i + 1];
1509
- if (Math.abs(cur.bottom - next.bottom) > 2)
1510
- heights.push((cur.bottom + next.top) / 2 - rect.top);
1511
- }
1512
  }
1513
- heights.push(rect.bottom - rect.top);
1514
  }
 
1515
  }
1516
 
1517
- // Find a line map (mapping character offsets to text nodes) and a
1518
- // measurement cache for the given line number. (A line view might
1519
- // contain multiple lines when collapsed ranges are present.)
1520
- function mapFromLineView(lineView, line, lineN) {
1521
- if (lineView.line == line)
1522
- return {map: lineView.measure.map, cache: lineView.measure.cache};
1523
- for (var i = 0; i < lineView.rest.length; i++)
1524
- if (lineView.rest[i] == line)
1525
- return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
1526
- for (var i = 0; i < lineView.rest.length; i++)
1527
- if (lineNo(lineView.rest[i]) > lineN)
1528
- return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
1529
- }
1530
 
1531
- // Render a line into the hidden node display.externalMeasured. Used
1532
- // when measurement is needed for a line that's not in the viewport.
1533
- function updateExternalMeasurement(cm, line) {
1534
- line = visualLine(line);
1535
- var lineN = lineNo(line);
1536
- var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
1537
- view.lineN = lineN;
1538
- var built = view.built = buildLineContent(cm, view);
1539
- view.text = built.pre;
1540
- removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
1541
- return view;
1542
  }
1543
 
1544
- // Get a {top, bottom, left, right} box (in line-local coordinates)
1545
- // for a given character.
1546
- function measureChar(cm, line, ch, bias) {
1547
- return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
1548
  }
1549
 
1550
- // Find a line view that corresponds to the given line number.
1551
- function findViewForLine(cm, lineN) {
1552
- if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
1553
- return cm.display.view[findViewIndex(cm, lineN)];
1554
- var ext = cm.display.externalMeasured;
1555
- if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
1556
- return ext;
1557
  }
1558
 
1559
- // Measurement can be split in two steps, the set-up work that
1560
- // applies to the whole line, and the measurement of the actual
1561
- // character. Functions like coordsChar, that need to do a lot of
1562
- // measurements in a row, can thus ensure that the set-up work is
1563
- // only done once.
1564
- function prepareMeasureForLine(cm, line) {
1565
- var lineN = lineNo(line);
1566
- var view = findViewForLine(cm, lineN);
1567
- if (view && !view.text)
1568
- view = null;
1569
- else if (view && view.changes)
1570
- updateLineForChanges(cm, view, lineN, getDimensions(cm));
1571
- if (!view)
1572
- view = updateExternalMeasurement(cm, line);
1573
-
1574
- var info = mapFromLineView(view, line, lineN);
1575
- return {
1576
- line: line, view: view, rect: null,
1577
- map: info.map, cache: info.cache, before: info.before,
1578
- hasHeights: false
1579
- };
1580
  }
1581
 
1582
- // Given a prepared measurement object, measures the position of an
1583
- // actual character (or fetches it from the cache).
1584
- function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
1585
- if (prepared.before) ch = -1;
1586
- var key = ch + (bias || ""), found;
1587
- if (prepared.cache.hasOwnProperty(key)) {
1588
- found = prepared.cache[key];
1589
- } else {
1590
- if (!prepared.rect)
1591
- prepared.rect = prepared.view.text.getBoundingClientRect();
1592
- if (!prepared.hasHeights) {
1593
- ensureLineHeights(cm, prepared.view, prepared.rect);
1594
- prepared.hasHeights = true;
1595
  }
1596
- found = measureCharInner(cm, prepared, ch, bias);
1597
- if (!found.bogus) prepared.cache[key] = found;
1598
- }
1599
- return {left: found.left, right: found.right,
1600
- top: varHeight ? found.rtop : found.top,
1601
- bottom: varHeight ? found.rbottom : found.bottom};
 
 
 
 
 
 
 
 
 
1602
  }
1603
 
1604
- var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
 
 
 
 
 
 
 
 
 
 
1605
 
1606
- function measureCharInner(cm, prepared, ch, bias) {
1607
- var map = prepared.map;
 
 
1608
 
1609
- var node, start, end, collapse;
1610
- // First, search the line map for the text node corresponding to,
1611
- // or closest to, the target character.
1612
- for (var i = 0; i < map.length; i += 3) {
1613
- var mStart = map[i], mEnd = map[i + 1];
1614
- if (ch < mStart) {
1615
- start = 0; end = 1;
1616
- collapse = "left";
1617
- } else if (ch < mEnd) {
1618
- start = ch - mStart;
1619
- end = start + 1;
1620
- } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
1621
- end = mEnd - mStart;
1622
- start = end - 1;
1623
- if (ch >= mEnd) collapse = "right";
1624
  }
1625
- if (start != null) {
1626
- node = map[i + 2];
1627
- if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
1628
- collapse = bias;
1629
- if (bias == "left" && start == 0)
1630
- while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
1631
- node = map[(i -= 3) + 2];
1632
- collapse = "left";
1633
- }
1634
- if (bias == "right" && start == mEnd - mStart)
1635
- while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
1636
- node = map[(i += 3) + 2];
1637
- collapse = "right";
1638
  }
1639
- break;
 
 
 
1640
  }
1641
  }
 
 
 
1642
 
1643
- var rect;
1644
- if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
1645
- while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) --start;
1646
- while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) ++end;
1647
- if (ie && ie_version < 9 && start == 0 && end == mEnd - mStart) {
1648
- rect = node.parentNode.getBoundingClientRect();
1649
- } else if (ie && cm.options.lineWrapping) {
1650
- var rects = range(node, start, end).getClientRects();
1651
- if (rects.length)
1652
- rect = rects[bias == "right" ? rects.length - 1 : 0];
1653
- else
1654
- rect = nullRect;
1655
- } else {
1656
- rect = range(node, start, end).getBoundingClientRect() || nullRect;
1657
- }
1658
- } else { // If it is a widget, simply get the box for the whole widget.
1659
- if (start > 0) collapse = bias = "right";
1660
- var rects;
1661
- if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
1662
- rect = rects[bias == "right" ? rects.length - 1 : 0];
1663
- else
1664
- rect = node.getBoundingClientRect();
1665
- }
1666
- if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
1667
- var rSpan = node.parentNode.getClientRects()[0];
1668
- if (rSpan)
1669
- rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
1670
- else
1671
- rect = nullRect;
1672
  }
1673
-
1674
- if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
1675
-
1676
- var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
1677
- var mid = (rtop + rbot) / 2;
1678
- var heights = prepared.view.measure.heights;
1679
- for (var i = 0; i < heights.length - 1; i++)
1680
- if (mid < heights[i]) break;
1681
- var top = i ? heights[i - 1] : 0, bot = heights[i];
1682
- var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
1683
- right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
1684
- top: top, bottom: bot};
1685
- if (!rect.left && !rect.right) result.bogus = true;
1686
- if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
1687
-
1688
- return result;
1689
  }
1690
 
1691
- // Work around problem with bounding client rects on ranges being
1692
- // returned incorrectly when zoomed on IE10 and below.
1693
- function maybeUpdateRectForZooming(measure, rect) {
1694
- if (!window.screen || screen.logicalXDPI == null ||
1695
- screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
1696
- return rect;
1697
- var scaleX = screen.logicalXDPI / screen.deviceXDPI;
1698
- var scaleY = screen.logicalYDPI / screen.deviceYDPI;
1699
- return {left: rect.left * scaleX, right: rect.right * scaleX,
1700
- top: rect.top * scaleY, bottom: rect.bottom * scaleY};
1701
  }
1702
 
1703
- function clearLineMeasurementCacheFor(lineView) {
1704
- if (lineView.measure) {
1705
- lineView.measure.cache = {};
1706
- lineView.measure.heights = null;
1707
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
1708
- lineView.measure.caches[i] = {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1709
  }
 
1710
  }
1711
 
1712
- function clearLineMeasurementCache(cm) {
1713
- cm.display.externalMeasure = null;
1714
- removeChildren(cm.display.lineMeasure);
1715
- for (var i = 0; i < cm.display.view.length; i++)
1716
- clearLineMeasurementCacheFor(cm.display.view[i]);
 
 
1717
  }
1718
-
1719
- function clearCaches(cm) {
1720
- clearLineMeasurementCache(cm);
1721
- cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
1722
- if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
1723
- cm.display.lineNumChars = null;
1724
  }
1725
 
1726
- function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
1727
- function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
 
 
1728
 
1729
- // Converts a {top, bottom, left, right} box from line-local
1730
- // coordinates into another coordinate system. Context may be one of
1731
- // "line", "div" (display.lineDiv), "local"/null (editor), or "page".
1732
- function intoCoordSystem(cm, lineObj, rect, context) {
1733
- if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
1734
- var size = widgetHeight(lineObj.widgets[i]);
1735
- rect.top += size; rect.bottom += size;
1736
- }
1737
- if (context == "line") return rect;
1738
- if (!context) context = "local";
1739
- var yOff = heightAtLine(lineObj);
1740
- if (context == "local") yOff += paddingTop(cm.display);
1741
- else yOff -= cm.display.viewOffset;
1742
- if (context == "page" || context == "window") {
1743
- var lOff = cm.display.lineSpace.getBoundingClientRect();
1744
- yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
1745
- var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
1746
- rect.left += xOff; rect.right += xOff;
1747
- }
1748
- rect.top += yOff; rect.bottom += yOff;
1749
- return rect;
1750
  }
1751
 
1752
- // Coverts a box from "div" coords to another coordinate system.
1753
- // Context may be "window", "page", "div", or "local"/null.
1754
- function fromCoordSystem(cm, coords, context) {
1755
- if (context == "div") return coords;
1756
- var left = coords.left, top = coords.top;
1757
- // First move into "page" coordinate system
1758
- if (context == "page") {
1759
- left -= pageScrollX();
1760
- top -= pageScrollY();
1761
- } else if (context == "local" || !context) {
1762
- var localBox = cm.display.sizer.getBoundingClientRect();
1763
- left += localBox.left;
1764
- top += localBox.top;
1765
- }
1766
 
1767
- var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
1768
- return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
 
 
 
 
 
 
1769
  }
1770
 
1771
- function charCoords(cm, pos, context, lineObj, bias) {
1772
- if (!lineObj) lineObj = getLine(cm.doc, pos.line);
1773
- return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1774
  }
1775
 
1776
- // Returns a box for a given cursor position, which may have an
1777
- // 'other' property containing the position of the secondary cursor
1778
- // on a bidi boundary.
1779
- function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
1780
- lineObj = lineObj || getLine(cm.doc, pos.line);
1781
- if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
1782
- function get(ch, right) {
1783
- var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
1784
- if (right) m.left = m.right; else m.right = m.left;
1785
- return intoCoordSystem(cm, lineObj, m, context);
1786
- }
1787
- function getBidi(ch, partPos) {
1788
- var part = order[partPos], right = part.level % 2;
1789
- if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
1790
- part = order[--partPos];
1791
- ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
1792
- right = true;
1793
- } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
1794
- part = order[++partPos];
1795
- ch = bidiLeft(part) - part.level % 2;
1796
- right = false;
1797
- }
1798
- if (right && ch == part.to && ch > part.from) return get(ch - 1);
1799
- return get(ch, right);
1800
- }
1801
- var order = getOrder(lineObj), ch = pos.ch;
1802
- if (!order) return get(ch);
1803
- var partPos = getBidiPartAt(order, ch);
1804
- var val = getBidi(ch, partPos);
1805
- if (bidiOther != null) val.other = getBidi(ch, bidiOther);
1806
- return val;
1807
  }
1808
 
1809
- // Used to cheaply estimate the coordinates for a position. Used for
1810
- // intermediate scroll updates.
1811
- function estimateCoords(cm, pos) {
1812
- var left = 0, pos = clipPos(cm.doc, pos);
1813
- if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
1814
- var lineObj = getLine(cm.doc, pos.line);
1815
- var top = heightAtLine(lineObj) + paddingTop(cm.display);
1816
- return {left: left, right: left, top: top, bottom: top + lineObj.height};
1817
  }
1818
 
1819
- // Positions returned by coordsChar contain some extra information.
1820
- // xRel is the relative x position of the input coordinates compared
1821
- // to the found position (so xRel > 0 means the coordinates are to
1822
- // the right of the character position, for example). When outside
1823
- // is true, that means the coordinates lie outside the line's
1824
- // vertical range.
1825
- function PosWithInfo(line, ch, outside, xRel) {
1826
- var pos = Pos(line, ch);
1827
- pos.xRel = xRel;
1828
- if (outside) pos.outside = true;
1829
- return pos;
1830
  }
1831
 
1832
- // Compute the character position closest to the given coordinates.
1833
- // Input must be lineSpace-local ("div" coordinate system).
1834
- function coordsChar(cm, x, y) {
1835
- var doc = cm.doc;
1836
- y += cm.display.viewOffset;
1837
- if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
1838
- var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
1839
- if (lineN > last)
1840
- return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
1841
- if (x < 0) x = 0;
1842
-
1843
- var lineObj = getLine(doc, lineN);
1844
- for (;;) {
1845
- var found = coordsCharInner(cm, lineObj, lineN, x, y);
1846
- var merged = collapsedSpanAtEnd(lineObj);
1847
- var mergedPos = merged && merged.find(0, true);
1848
- if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
1849
- lineN = lineNo(lineObj = mergedPos.to.line);
1850
- else
1851
- return found;
1852
- }
1853
  }
1854
 
1855
- function coordsCharInner(cm, lineObj, lineNo, x, y) {
1856
- var innerOff = y - heightAtLine(lineObj);
1857
- var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
1858
- var preparedMeasure = prepareMeasureForLine(cm, lineObj);
 
 
 
 
 
 
1859
 
1860
- function getX(ch) {
1861
- var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
1862
- wrongLine = true;
1863
- if (innerOff > sp.bottom) return sp.left - adjust;
1864
- else if (innerOff < sp.top) return sp.left + adjust;
1865
- else wrongLine = false;
1866
- return sp.left;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1867
  }
 
1868
 
1869
- var bidi = getOrder(lineObj), dist = lineObj.text.length;
1870
- var from = lineLeft(lineObj), to = lineRight(lineObj);
1871
- var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
1872
 
1873
- if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
1874
- // Do a binary search between these bounds.
1875
- for (;;) {
1876
- if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
1877
- var ch = x < fromX || x - fromX <= toX - x ? from : to;
1878
- var xDiff = x - (ch == from ? fromX : toX);
1879
- while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
1880
- var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
1881
- xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
1882
- return pos;
1883
- }
1884
- var step = Math.ceil(dist / 2), middle = from + step;
1885
- if (bidi) {
1886
- middle = from;
1887
- for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
1888
  }
1889
- var middleX = getX(middle);
1890
- if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
1891
- else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
1892
  }
 
1893
  }
1894
 
1895
- var measureText;
1896
- // Compute the default text height.
1897
- function textHeight(display) {
1898
- if (display.cachedTextHeight != null) return display.cachedTextHeight;
1899
- if (measureText == null) {
1900
- measureText = elt("pre");
1901
- // Measure a bunch of lines, for browsers that compute
1902
- // fractional heights.
1903
- for (var i = 0; i < 49; ++i) {
1904
- measureText.appendChild(document.createTextNode("x"));
1905
- measureText.appendChild(elt("br"));
1906
- }
1907
- measureText.appendChild(document.createTextNode("x"));
1908
  }
1909
- removeChildrenAndAdd(display.measure, measureText);
1910
- var height = measureText.offsetHeight / 50;
1911
- if (height > 3) display.cachedTextHeight = height;
1912
- removeChildren(display.measure);
1913
- return height || 1;
 
 
 
1914
  }
1915
 
1916
- // Compute the default character width.
1917
- function charWidth(display) {
1918
- if (display.cachedCharWidth != null) return display.cachedCharWidth;
1919
- var anchor = elt("span", "xxxxxxxxxx");
1920
- var pre = elt("pre", [anchor]);
1921
- removeChildrenAndAdd(display.measure, pre);
1922
- var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
1923
- if (width > 2) display.cachedCharWidth = width;
1924
- return width || 10;
 
 
 
 
1925
  }
1926
 
1927
- // OPERATIONS
1928
-
1929
- // Operations are used to wrap a series of changes to the editor
1930
- // state in such a way that each change won't have to update the
1931
- // cursor and display (which would be awkward, slow, and
1932
- // error-prone). Instead, display updates are batched and then all
1933
- // combined and executed at once.
1934
 
1935
- var operationGroup = null;
 
 
 
 
 
 
1936
 
1937
- var nextOpId = 0;
1938
- // Start a new operation.
1939
- function startOperation(cm) {
1940
- cm.curOp = {
1941
- cm: cm,
1942
- viewChanged: false, // Flag that indicates that lines might need to be redrawn
1943
- startHeight: cm.doc.height, // Used to detect need to update scrollbar
1944
- forceUpdate: false, // Used to force a redraw
1945
- updateInput: null, // Whether to reset the input textarea
1946
- typing: false, // Whether this reset should be careful to leave existing text (for compositing)
1947
- changeObjs: null, // Accumulated changes, for firing change events
1948
- cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
1949
- cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
1950
- selectionChanged: false, // Whether the selection needs to be redrawn
1951
- updateMaxLine: false, // Set when the widest line needs to be determined anew
1952
- scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
1953
- scrollToPos: null, // Used to scroll to a specific position
1954
- id: ++nextOpId // Unique ID
1955
- };
1956
- if (operationGroup) {
1957
- operationGroup.ops.push(cm.curOp);
1958
- } else {
1959
- cm.curOp.ownsGroup = operationGroup = {
1960
- ops: [cm.curOp],
1961
- delayedCallbacks: []
1962
- };
1963
- }
1964
- }
1965
 
1966
- function fireCallbacksForOps(group) {
1967
- // Calls delayed callbacks and cursorActivity handlers until no
1968
- // new ones appear
1969
- var callbacks = group.delayedCallbacks, i = 0;
1970
- do {
1971
- for (; i < callbacks.length; i++)
1972
- callbacks[i]();
1973
- for (var j = 0; j < group.ops.length; j++) {
1974
- var op = group.ops[j];
1975
- if (op.cursorActivityHandlers)
1976
- while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
1977
- op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
1978
- }
1979
- } while (i < callbacks.length);
1980
  }
1981
 
1982
- // Finish an operation, updating the display and signalling delayed events
1983
- function endOperation(cm) {
1984
- var op = cm.curOp, group = op.ownsGroup;
1985
- if (!group) return;
1986
-
1987
- try { fireCallbacksForOps(group); }
1988
- finally {
1989
- operationGroup = null;
1990
- for (var i = 0; i < group.ops.length; i++)
1991
- group.ops[i].cm.curOp = null;
1992
- endOperations(group);
1993
- }
1994
  }
1995
 
1996
- // The DOM updates done when an operation finishes are batched so
1997
- // that the minimum number of relayouts are required.
1998
- function endOperations(group) {
1999
- var ops = group.ops;
2000
- for (var i = 0; i < ops.length; i++) // Read DOM
2001
- endOperation_R1(ops[i]);
2002
- for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
2003
- endOperation_W1(ops[i]);
2004
- for (var i = 0; i < ops.length; i++) // Read DOM
2005
- endOperation_R2(ops[i]);
2006
- for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
2007
- endOperation_W2(ops[i]);
2008
- for (var i = 0; i < ops.length; i++) // Read DOM
2009
- endOperation_finish(ops[i]);
2010
  }
2011
 
2012
- function endOperation_R1(op) {
2013
- var cm = op.cm, display = cm.display;
2014
- if (op.updateMaxLine) findMaxLine(cm);
 
 
 
 
 
 
 
 
 
 
 
 
2015
 
2016
- op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
2017
- op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
2018
- op.scrollToPos.to.line >= display.viewTo) ||
2019
- display.maxLineChanged && cm.options.lineWrapping;
2020
- op.update = op.mustUpdate &&
2021
- new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
2022
- }
 
 
 
 
 
 
 
 
 
 
 
2023
 
2024
- function endOperation_W1(op) {
2025
- op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
2026
- }
2027
 
2028
- function endOperation_R2(op) {
2029
- var cm = op.cm, display = cm.display;
2030
- if (op.updatedDisplay) updateHeightsInViewport(cm);
 
 
 
 
 
 
2031
 
2032
- // If the max line changed since it was last measured, measure it,
2033
- // and ensure the document's width matches it.
2034
- // updateDisplayIfNeeded will use these properties to do the actual resizing
2035
- if (display.maxLineChanged && !cm.options.lineWrapping) {
2036
- op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left;
2037
- op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo +
2038
- scrollerCutOff - display.scroller.clientWidth);
2039
  }
2040
 
2041
- op.barMeasure = measureForScrollbars(cm);
2042
- if (op.updatedDisplay || op.selectionChanged)
2043
- op.newSelectionNodes = drawSelection(cm);
2044
- }
2045
 
2046
- function endOperation_W2(op) {
2047
- var cm = op.cm;
2048
 
2049
- if (op.adjustWidthTo != null) {
2050
- cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
2051
- if (op.maxScrollLeft < cm.doc.scrollLeft)
2052
- setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
2053
- }
2054
-
2055
- if (op.newSelectionNodes)
2056
- updateSelection(cm, op.newSelectionNodes);
2057
- if (op.updatedDisplay)
2058
- setDocumentHeight(cm, op.barMeasure);
2059
- if (op.updatedDisplay || op.startHeight != cm.doc.height)
2060
- updateScrollbars(cm, op.barMeasure);
2061
-
2062
- if (op.selectionChanged) restartBlink(cm);
2063
-
2064
- if (cm.state.focused && op.updateInput)
2065
- resetInput(cm, op.typing);
2066
  }
2067
 
2068
- function endOperation_finish(op) {
2069
- var cm = op.cm, display = cm.display, doc = cm.doc;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2070
 
2071
- if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
 
 
 
 
 
 
 
 
 
 
 
 
 
2072
 
2073
- // Abort mouse wheel delta measurement, when scrolling explicitly
2074
- if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
2075
- display.wheelStartX = display.wheelStartY = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2076
 
2077
- // Propagate the scroll position to the actual DOM scroller
2078
- if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) {
2079
- var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
2080
- display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top;
 
 
 
2081
  }
2082
- if (op.scrollLeft != null && display.scroller.scrollLeft != op.scrollLeft) {
2083
- var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft));
2084
- display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left;
2085
- alignHorizontally(cm);
2086
  }
2087
- // If we need to scroll a specific position into view, do so.
2088
- if (op.scrollToPos) {
2089
- var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
2090
- clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
2091
- if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
 
 
 
 
 
 
 
2092
  }
2093
 
2094
- // Fire events for markers that are hidden/unidden by editing or
2095
- // undoing
2096
- var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
2097
- if (hidden) for (var i = 0; i < hidden.length; ++i)
2098
- if (!hidden[i].lines.length) signal(hidden[i], "hide");
2099
- if (unhidden) for (var i = 0; i < unhidden.length; ++i)
2100
- if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2101
 
2102
- if (display.wrapper.offsetHeight)
2103
- doc.scrollTop = cm.display.scroller.scrollTop;
 
 
 
 
 
 
 
 
2104
 
2105
- // Apply workaround for two webkit bugs
2106
- if (op.updatedDisplay && webkit) {
2107
- if (cm.options.lineWrapping)
2108
- checkForWebkitWidthBug(cm, op.barMeasure); // (Issue #2420)
2109
- if (op.barMeasure.scrollWidth > op.barMeasure.clientWidth &&
2110
- op.barMeasure.scrollWidth < op.barMeasure.clientWidth + 1 &&
2111
- !hScrollbarTakesSpace(cm))
2112
- updateScrollbars(cm); // (Issue #2562)
 
 
 
 
 
 
 
 
2113
  }
2114
-
2115
- // Fire change events, and delayed event handlers
2116
- if (op.changeObjs)
2117
- signal(cm, "changes", cm, op.changeObjs);
2118
- }
2119
-
2120
- // Run the given function in an operation
2121
- function runInOp(cm, f) {
2122
- if (cm.curOp) return f();
2123
- startOperation(cm);
2124
- try { return f(); }
2125
- finally { endOperation(cm); }
2126
- }
2127
- // Wraps a function in an operation. Returns the wrapped function.
2128
- function operation(cm, f) {
2129
- return function() {
2130
- if (cm.curOp) return f.apply(cm, arguments);
2131
- startOperation(cm);
2132
- try { return f.apply(cm, arguments); }
2133
- finally { endOperation(cm); }
2134
- };
2135
- }
2136
- // Used to add methods to editor and doc instances, wrapping them in
2137
- // operations.
2138
- function methodOp(f) {
2139
- return function() {
2140
- if (this.curOp) return f.apply(this, arguments);
2141
- startOperation(this);
2142
- try { return f.apply(this, arguments); }
2143
- finally { endOperation(this); }
2144
- };
2145
- }
2146
- function docMethodOp(f) {
2147
- return function() {
2148
- var cm = this.cm;
2149
- if (!cm || cm.curOp) return f.apply(this, arguments);
2150
- startOperation(cm);
2151
- try { return f.apply(this, arguments); }
2152
- finally { endOperation(cm); }
2153
- };
2154
  }
2155
 
2156
- // VIEW TRACKING
2157
 
2158
  // These objects are used to represent the visible (currently drawn)
2159
  // part of the document. A LineView may correspond to multiple
@@ -2177,1524 +2011,1407 @@
2177
  nextPos = pos + view.size;
2178
  array.push(view);
2179
  }
2180
- return array;
2181
  }
2182
 
2183
- // Updates the display.view data structure for a given change to the
2184
- // document. From and to are in pre-change coordinates. Lendiff is
2185
- // the amount of lines added or subtracted by the change. This is
2186
- // used for changes that span multiple lines, or change the way
2187
- // lines are divided into visual lines. regLineChange (below)
2188
- // registers single-line changes.
2189
- function regChange(cm, from, to, lendiff) {
2190
- if (from == null) from = cm.doc.first;
2191
- if (to == null) to = cm.doc.first + cm.doc.size;
2192
- if (!lendiff) lendiff = 0;
2193
-
2194
- var display = cm.display;
2195
- if (lendiff && to < display.viewTo &&
2196
- (display.updateLineNumbers == null || display.updateLineNumbers > from))
2197
- display.updateLineNumbers = from;
2198
 
2199
- cm.curOp.viewChanged = true;
 
 
 
 
 
 
 
 
 
2200
 
2201
- if (from >= display.viewTo) { // Change after
2202
- if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
2203
- resetView(cm);
2204
- } else if (to <= display.viewFrom) { // Change before
2205
- if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
2206
- resetView(cm);
2207
- } else {
2208
- display.viewFrom += lendiff;
2209
- display.viewTo += lendiff;
2210
- }
2211
- } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
2212
- resetView(cm);
2213
- } else if (from <= display.viewFrom) { // Top overlap
2214
- var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
2215
- if (cut) {
2216
- display.view = display.view.slice(cut.index);
2217
- display.viewFrom = cut.lineN;
2218
- display.viewTo += lendiff;
2219
- } else {
2220
- resetView(cm);
2221
- }
2222
- } else if (to >= display.viewTo) { // Bottom overlap
2223
- var cut = viewCuttingPoint(cm, from, from, -1);
2224
- if (cut) {
2225
- display.view = display.view.slice(0, cut.index);
2226
- display.viewTo = cut.lineN;
2227
- } else {
2228
- resetView(cm);
2229
- }
2230
- } else { // Gap in the middle
2231
- var cutTop = viewCuttingPoint(cm, from, from, -1);
2232
- var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
2233
- if (cutTop && cutBot) {
2234
- display.view = display.view.slice(0, cutTop.index)
2235
- .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
2236
- .concat(display.view.slice(cutBot.index));
2237
- display.viewTo += lendiff;
2238
- } else {
2239
- resetView(cm);
2240
  }
2241
- }
 
2242
 
2243
- var ext = display.externalMeasured;
2244
- if (ext) {
2245
- if (to < ext.lineN)
2246
- ext.lineN += lendiff;
2247
- else if (from < ext.lineN + ext.size)
2248
- display.externalMeasured = null;
 
 
2249
  }
2250
  }
2251
 
2252
- // Register a change to a single line. Type must be one of "text",
2253
- // "gutter", "class", "widget"
2254
- function regLineChange(cm, line, type) {
2255
- cm.curOp.viewChanged = true;
2256
- var display = cm.display, ext = cm.display.externalMeasured;
2257
- if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
2258
- display.externalMeasured = null;
2259
 
2260
- if (line < display.viewFrom || line >= display.viewTo) return;
2261
- var lineView = display.view[findViewIndex(cm, line)];
2262
- if (lineView.node == null) return;
2263
- var arr = lineView.changes || (lineView.changes = []);
2264
- if (indexOf(arr, type) == -1) arr.push(type);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2265
  }
2266
 
2267
- // Clear the view.
2268
- function resetView(cm) {
2269
- cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
2270
- cm.display.view = [];
2271
- cm.display.viewOffset = 0;
2272
  }
2273
 
2274
- // Find the view element corresponding to a given line. Return null
2275
- // when the line isn't visible.
2276
- function findViewIndex(cm, n) {
2277
- if (n >= cm.display.viewTo) return null;
2278
- n -= cm.display.viewFrom;
2279
- if (n < 0) return null;
2280
- var view = cm.display.view;
2281
- for (var i = 0; i < view.length; i++) {
2282
- n -= view[i].size;
2283
- if (n < 0) return i;
2284
  }
 
2285
  }
2286
 
2287
- function viewCuttingPoint(cm, oldN, newN, dir) {
2288
- var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
2289
- if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
2290
- return {index: index, lineN: newN};
2291
- for (var i = 0, n = cm.display.viewFrom; i < index; i++)
2292
- n += view[i].size;
2293
- if (n != oldN) {
2294
- if (dir > 0) {
2295
- if (index == view.length - 1) return null;
2296
- diff = (n + view[index].size) - oldN;
2297
- index++;
2298
- } else {
2299
- diff = n - oldN;
2300
- }
2301
- oldN += diff; newN += diff;
2302
- }
2303
- while (visualLineNo(cm.doc, newN) != newN) {
2304
- if (index == (dir < 0 ? 0 : view.length - 1)) return null;
2305
- newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
2306
- index += dir;
2307
  }
2308
- return {index: index, lineN: newN};
2309
  }
2310
 
2311
- // Force the view to cover a given range, adding empty view element
2312
- // or clipping off existing ones as needed.
2313
- function adjustView(cm, from, to) {
2314
- var display = cm.display, view = display.view;
2315
- if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
2316
- display.view = buildViewArray(cm, from, to);
2317
- display.viewFrom = from;
2318
- } else {
2319
- if (display.viewFrom > from)
2320
- display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
2321
- else if (display.viewFrom < from)
2322
- display.view = display.view.slice(findViewIndex(cm, from));
2323
- display.viewFrom = from;
2324
- if (display.viewTo < to)
2325
- display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
2326
- else if (display.viewTo > to)
2327
- display.view = display.view.slice(0, findViewIndex(cm, to));
2328
  }
2329
- display.viewTo = to;
2330
  }
2331
 
2332
- // Count the number of lines in the view whose DOM representation is
2333
- // out of date (or nonexistent).
2334
- function countDirtyView(cm) {
2335
- var view = cm.display.view, dirty = 0;
2336
- for (var i = 0; i < view.length; i++) {
2337
- var lineView = view[i];
2338
- if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
 
2339
  }
2340
- return dirty;
2341
- }
2342
-
2343
- // INPUT HANDLING
2344
-
2345
- // Poll for input changes, using the normal rate of polling. This
2346
- // runs as long as the editor is focused.
2347
- function slowPoll(cm) {
2348
- if (cm.display.pollingFast) return;
2349
- cm.display.poll.set(cm.options.pollInterval, function() {
2350
- readInput(cm);
2351
- if (cm.state.focused) slowPoll(cm);
2352
- });
2353
  }
2354
 
2355
- // When an event has just come in that is likely to add or change
2356
- // something in the input textarea, we poll faster, to ensure that
2357
- // the change appears on the screen quickly.
2358
- function fastPoll(cm) {
2359
- var missed = false;
2360
- cm.display.pollingFast = true;
2361
- function p() {
2362
- var changed = readInput(cm);
2363
- if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}
2364
- else {cm.display.pollingFast = false; slowPoll(cm);}
 
 
 
 
 
2365
  }
2366
- cm.display.poll.set(20, p);
2367
  }
2368
 
2369
- // This will be set to an array of strings when copying, so that,
2370
- // when pasting, we know what kind of selections the copied text
2371
- // was made out of.
2372
- var lastCopied = null;
 
 
 
 
 
2373
 
2374
- // Read input from the textarea, and update the document to match.
2375
- // When something is selected, it is present in the textarea, and
2376
- // selected (unless it is huge, in which case a placeholder is
2377
- // used). When nothing is selected, the cursor sits after previously
2378
- // seen text (can be empty), which is stored in prevInput (we must
2379
- // not reset the textarea when typing, because that breaks IME).
2380
- function readInput(cm) {
2381
- var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc;
2382
- // Since this is called a *lot*, try to bail out as cheaply as
2383
- // possible when it is clear that nothing happened. hasSelection
2384
- // will be the case when there is a lot of text in the textarea,
2385
- // in which case reading its value would be expensive.
2386
- if (!cm.state.focused || (hasSelection(input) && !prevInput) || isReadOnly(cm) || cm.options.disableInput)
2387
- return false;
2388
- // See paste handler for more on the fakedLastChar kludge
2389
- if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
2390
- input.value = input.value.substring(0, input.value.length - 1);
2391
- cm.state.fakedLastChar = false;
2392
  }
2393
- var text = input.value;
2394
- // If nothing changed, bail.
2395
- if (text == prevInput && !cm.somethingSelected()) return false;
2396
- // Work around nonsensical selection resetting in IE9/10, and
2397
- // inexplicable appearance of private area unicode characters on
2398
- // some key combos in Mac (#2689).
2399
- if (ie && ie_version >= 9 && cm.display.inputHasSelection === text ||
2400
- mac && /[\uf700-\uf7ff]/.test(text)) {
2401
- resetInput(cm);
2402
- return false;
2403
  }
2404
-
2405
- var withOp = !cm.curOp;
2406
- if (withOp) startOperation(cm);
2407
- cm.display.shift = false;
2408
-
2409
- if (text.charCodeAt(0) == 0x200b && doc.sel == cm.display.selForContextMenu && !prevInput)
2410
- prevInput = "\u200b";
2411
- // Find the part of the input that is actually new
2412
- var same = 0, l = Math.min(prevInput.length, text.length);
2413
- while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
2414
- var inserted = text.slice(same), textLines = splitLines(inserted);
2415
-
2416
- // When pasing N lines into N selections, insert one line per selection
2417
- var multiPaste = null;
2418
- if (cm.state.pasteIncoming && doc.sel.ranges.length > 1) {
2419
- if (lastCopied && lastCopied.join("\n") == inserted)
2420
- multiPaste = doc.sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
2421
- else if (textLines.length == doc.sel.ranges.length)
2422
- multiPaste = map(textLines, function(l) { return [l]; });
2423
  }
2424
-
2425
- // Normal behavior is to insert the new text into every selection
2426
- for (var i = doc.sel.ranges.length - 1; i >= 0; i--) {
2427
- var range = doc.sel.ranges[i];
2428
- var from = range.from(), to = range.to();
2429
- // Handle deletion
2430
- if (same < prevInput.length)
2431
- from = Pos(from.line, from.ch - (prevInput.length - same));
2432
- // Handle overwrite
2433
- else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming)
2434
- to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
2435
- var updateInput = cm.curOp.updateInput;
2436
- var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
2437
- origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
2438
- makeChange(cm.doc, changeEvent);
2439
- signalLater(cm, "inputRead", cm, changeEvent);
2440
- // When an 'electric' character is inserted, immediately trigger a reindent
2441
- if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
2442
- cm.options.smartIndent && range.head.ch < 100 &&
2443
- (!i || doc.sel.ranges[i - 1].head.line != range.head.line)) {
2444
- var mode = cm.getModeAt(range.head);
2445
- if (mode.electricChars) {
2446
- for (var j = 0; j < mode.electricChars.length; j++)
2447
- if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
2448
- indentLine(cm, range.head.line, "smart");
2449
- break;
2450
- }
2451
- } else if (mode.electricInput) {
2452
- var end = changeEnd(changeEvent);
2453
- if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
2454
- indentLine(cm, range.head.line, "smart");
2455
- }
2456
- }
2457
  }
2458
- ensureCursorVisible(cm);
2459
- cm.curOp.updateInput = updateInput;
2460
- cm.curOp.typing = true;
2461
-
2462
- // Don't leave long text in the textarea, since it makes further polling slow
2463
- if (text.length > 1000 || text.indexOf("\n") > -1) input.value = cm.display.prevInput = "";
2464
- else cm.display.prevInput = text;
2465
- if (withOp) endOperation(cm);
2466
- cm.state.pasteIncoming = cm.state.cutIncoming = false;
2467
- return true;
2468
  }
2469
 
2470
- // Reset the input to correspond to the selection (or to be empty,
2471
- // when not typing and nothing is selected)
2472
- function resetInput(cm, typing) {
2473
- var minimal, selected, doc = cm.doc;
2474
- if (cm.somethingSelected()) {
2475
- cm.display.prevInput = "";
2476
- var range = doc.sel.primary();
2477
- minimal = hasCopyEvent &&
2478
- (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
2479
- var content = minimal ? "-" : selected || cm.getSelection();
2480
- cm.display.input.value = content;
2481
- if (cm.state.focused) selectInput(cm.display.input);
2482
- if (ie && ie_version >= 9) cm.display.inputHasSelection = content;
2483
- } else if (!typing) {
2484
- cm.display.prevInput = cm.display.input.value = "";
2485
- if (ie && ie_version >= 9) cm.display.inputHasSelection = null;
2486
  }
2487
- cm.display.inaccurateSelection = minimal;
2488
  }
2489
 
2490
- function focusInput(cm) {
2491
- if (cm.options.readOnly != "nocursor" && (!mobile || activeElt() != cm.display.input))
2492
- cm.display.input.focus();
2493
- }
 
 
2494
 
2495
- function ensureFocus(cm) {
2496
- if (!cm.state.focused) { focusInput(cm); onFocus(cm); }
 
 
2497
  }
2498
 
2499
- function isReadOnly(cm) {
2500
- return cm.options.readOnly || cm.doc.cantEdit;
 
 
 
 
2501
  }
2502
 
2503
- // EVENT HANDLERS
2504
-
2505
- // Attach the necessary event handlers when initializing the editor
2506
- function registerEventHandlers(cm) {
2507
- var d = cm.display;
2508
- on(d.scroller, "mousedown", operation(cm, onMouseDown));
2509
- // Older IE's will not fire a second mousedown for a double click
2510
- if (ie && ie_version < 11)
2511
- on(d.scroller, "dblclick", operation(cm, function(e) {
2512
- if (signalDOMEvent(cm, e)) return;
2513
- var pos = posFromMouse(cm, e);
2514
- if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
2515
- e_preventDefault(e);
2516
- var word = findWordAt(cm, pos);
2517
- extendSelection(cm.doc, word.anchor, word.head);
2518
- }));
2519
- else
2520
- on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
2521
- // Prevent normal selection in the editor (we handle our own)
2522
- on(d.lineSpace, "selectstart", function(e) {
2523
- if (!eventInWidget(d, e)) e_preventDefault(e);
2524
- });
2525
- // Some browsers fire contextmenu *after* opening the menu, at
2526
- // which point we can't mess with it anymore. Context menu is
2527
- // handled in onMouseDown for these browsers.
2528
- if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
2529
-
2530
- // Sync scrolling between fake scrollbars and real scrollable
2531
- // area, ensure viewport is updated when scrolling.
2532
- on(d.scroller, "scroll", function() {
2533
- if (d.scroller.clientHeight) {
2534
- setScrollTop(cm, d.scroller.scrollTop);
2535
- setScrollLeft(cm, d.scroller.scrollLeft, true);
2536
- signal(cm, "scroll", cm);
2537
- }
2538
- });
2539
- on(d.scrollbarV, "scroll", function() {
2540
- if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop);
2541
- });
2542
- on(d.scrollbarH, "scroll", function() {
2543
- if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft);
2544
- });
2545
-
2546
- // Listen to wheel events in order to try and update the viewport on time.
2547
- on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
2548
- on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
2549
-
2550
- // Prevent clicks in the scrollbars from killing focus
2551
- function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }
2552
- on(d.scrollbarH, "mousedown", reFocus);
2553
- on(d.scrollbarV, "mousedown", reFocus);
2554
- // Prevent wrapper from ever scrolling
2555
- on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
2556
-
2557
- on(d.input, "keyup", function(e) { onKeyUp.call(cm, e); });
2558
- on(d.input, "input", function() {
2559
- if (ie && ie_version >= 9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
2560
- fastPoll(cm);
2561
- });
2562
- on(d.input, "keydown", operation(cm, onKeyDown));
2563
- on(d.input, "keypress", operation(cm, onKeyPress));
2564
- on(d.input, "focus", bind(onFocus, cm));
2565
- on(d.input, "blur", bind(onBlur, cm));
2566
-
2567
- function drag_(e) {
2568
- if (!signalDOMEvent(cm, e)) e_stop(e);
2569
- }
2570
- if (cm.options.dragDrop) {
2571
- on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
2572
- on(d.scroller, "dragenter", drag_);
2573
- on(d.scroller, "dragover", drag_);
2574
- on(d.scroller, "drop", operation(cm, onDrop));
2575
- }
2576
- on(d.scroller, "paste", function(e) {
2577
- if (eventInWidget(d, e)) return;
2578
- cm.state.pasteIncoming = true;
2579
- focusInput(cm);
2580
- fastPoll(cm);
2581
- });
2582
- on(d.input, "paste", function() {
2583
- // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
2584
- // Add a char to the end of textarea before paste occur so that
2585
- // selection doesn't span to the end of textarea.
2586
- if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
2587
- var start = d.input.selectionStart, end = d.input.selectionEnd;
2588
- d.input.value += "$";
2589
- // The selection end needs to be set before the start, otherwise there
2590
- // can be an intermediate non-empty selection between the two, which
2591
- // can override the middle-click paste buffer on linux and cause the
2592
- // wrong thing to get pasted.
2593
- d.input.selectionEnd = end;
2594
- d.input.selectionStart = start;
2595
- cm.state.fakedLastChar = true;
2596
- }
2597
- cm.state.pasteIncoming = true;
2598
- fastPoll(cm);
2599
- });
2600
 
2601
- function prepareCopyCut(e) {
2602
- if (cm.somethingSelected()) {
2603
- lastCopied = cm.getSelections();
2604
- if (d.inaccurateSelection) {
2605
- d.prevInput = "";
2606
- d.inaccurateSelection = false;
2607
- d.input.value = lastCopied.join("\n");
2608
- selectInput(d.input);
2609
- }
2610
- } else {
2611
- var text = [], ranges = [];
2612
- for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
2613
- var line = cm.doc.sel.ranges[i].head.line;
2614
- var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
2615
- ranges.push(lineRange);
2616
- text.push(cm.getRange(lineRange.anchor, lineRange.head));
2617
- }
2618
- if (e.type == "cut") {
2619
- cm.setSelections(ranges, null, sel_dontScroll);
2620
- } else {
2621
- d.prevInput = "";
2622
- d.input.value = text.join("\n");
2623
- selectInput(d.input);
2624
- }
2625
- lastCopied = text;
2626
  }
2627
- if (e.type == "cut") cm.state.cutIncoming = true;
 
 
 
 
 
2628
  }
2629
- on(d.input, "cut", prepareCopyCut);
2630
- on(d.input, "copy", prepareCopyCut);
2631
-
2632
- // Needed to handle Tab key in KHTML
2633
- if (khtml) on(d.sizer, "mouseup", function() {
2634
- if (activeElt() == d.input) d.input.blur();
2635
- focusInput(cm);
2636
- });
2637
  }
2638
 
2639
- // Called when the window resizes
2640
- function onResize(cm) {
2641
- // Might be a text scaling operation, clear size caches.
2642
- var d = cm.display;
2643
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
2644
- cm.setSize();
 
 
 
 
 
 
 
2645
  }
2646
 
2647
- // MOUSE EVENTS
2648
-
2649
  // Return true when the given mouse event happened in a widget
2650
  function eventInWidget(display, e) {
2651
  for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
2652
- if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true;
 
 
2653
  }
2654
  }
2655
 
2656
- // Given a mouse event, find the corresponding position. If liberal
2657
- // is false, it checks whether a gutter or scrollbar was clicked,
2658
- // and returns null if it was. forRect is used by rectangular
2659
- // selections, and tries to estimate a character position even for
2660
- // coordinates beyond the right of the text.
2661
- function posFromMouse(cm, e, liberal, forRect) {
2662
- var display = cm.display;
2663
- if (!liberal) {
2664
- var target = e_target(e);
2665
- if (target == display.scrollbarH || target == display.scrollbarV ||
2666
- target == display.scrollbarFiller || target == display.gutterFiller) return null;
2667
- }
2668
- var x, y, space = display.lineSpace.getBoundingClientRect();
2669
- // Fails unpredictably on IE[67] when mouse is dragged around quickly.
2670
- try { x = e.clientX - space.left; y = e.clientY - space.top; }
2671
- catch (e) { return null; }
2672
- var coords = coordsChar(cm, x, y), line;
2673
- if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
2674
- var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
2675
- coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
2676
- }
2677
- return coords;
2678
  }
2679
 
2680
- // A mouse down can be a single click, double click, triple click,
2681
- // start of selection drag, start of text drag, new cursor
2682
- // (ctrl-click), rectangle drag (alt-drag), or xwin
2683
- // middle-click-paste. Or it might be a click on something we should
2684
- // not interfere with, such as a scrollbar or widget.
2685
- function onMouseDown(e) {
2686
- if (signalDOMEvent(this, e)) return;
2687
- var cm = this, display = cm.display;
2688
- display.shift = e.shiftKey;
2689
 
2690
- if (eventInWidget(display, e)) {
2691
- if (!webkit) {
2692
- // Briefly turn off draggability, to allow widgets to do
2693
- // normal dragging things.
2694
- display.scroller.draggable = false;
2695
- setTimeout(function(){display.scroller.draggable = true;}, 100);
 
 
 
 
 
 
 
 
 
 
 
2696
  }
2697
- return;
2698
- }
2699
- if (clickInGutter(cm, e)) return;
2700
- var start = posFromMouse(cm, e);
2701
- window.focus();
2702
-
2703
- switch (e_button(e)) {
2704
- case 1:
2705
- if (start)
2706
- leftButtonDown(cm, e, start);
2707
- else if (e_target(e) == display.scroller)
2708
- e_preventDefault(e);
2709
- break;
2710
- case 2:
2711
- if (webkit) cm.state.lastMiddleDown = +new Date;
2712
- if (start) extendSelection(cm.doc, start);
2713
- setTimeout(bind(focusInput, cm), 20);
2714
- e_preventDefault(e);
2715
- break;
2716
- case 3:
2717
- if (captureRightClick) onContextMenu(cm, e);
2718
- break;
2719
  }
2720
  }
2721
 
2722
- var lastClick, lastDoubleClick;
2723
- function leftButtonDown(cm, e, start) {
2724
- setTimeout(bind(ensureFocus, cm), 0);
2725
-
2726
- var now = +new Date, type;
2727
- if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
2728
- type = "triple";
2729
- } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
2730
- type = "double";
2731
- lastDoubleClick = {time: now, pos: start};
2732
- } else {
2733
- type = "single";
2734
- lastClick = {time: now, pos: start};
2735
- }
2736
 
2737
- var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey;
2738
- if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
2739
- type == "single" && sel.contains(start) > -1 && sel.somethingSelected())
2740
- leftButtonStartDrag(cm, e, start, modifier);
2741
- else
2742
- leftButtonSelect(cm, e, start, type, modifier);
 
 
 
 
 
2743
  }
2744
 
2745
- // Start a text drag. When it ends, see if any dragging actually
2746
- // happen, and treat as a click if it didn't.
2747
- function leftButtonStartDrag(cm, e, start, modifier) {
2748
- var display = cm.display;
2749
- var dragEnd = operation(cm, function(e2) {
2750
- if (webkit) display.scroller.draggable = false;
2751
- cm.state.draggingText = false;
2752
- off(document, "mouseup", dragEnd);
2753
- off(display.scroller, "drop", dragEnd);
2754
- if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
2755
- e_preventDefault(e2);
2756
- if (!modifier)
2757
- extendSelection(cm.doc, start);
2758
- focusInput(cm);
2759
- // Work around unexplainable focus problem in IE9 (#2127)
2760
- if (ie && ie_version == 9)
2761
- setTimeout(function() {document.body.focus(); focusInput(cm);}, 20);
2762
- }
2763
- });
2764
- // Let the drag handler handle this.
2765
- if (webkit) display.scroller.draggable = true;
2766
- cm.state.draggingText = dragEnd;
2767
- // IE's approach to draggable
2768
- if (display.scroller.dragDrop) display.scroller.dragDrop();
2769
- on(document, "mouseup", dragEnd);
2770
- on(display.scroller, "drop", dragEnd);
2771
  }
2772
 
2773
- // Normal selection, as opposed to text dragging.
2774
- function leftButtonSelect(cm, e, start, type, addNew) {
2775
- var display = cm.display, doc = cm.doc;
2776
- e_preventDefault(e);
 
 
 
 
2777
 
2778
- var ourRange, ourIndex, startSel = doc.sel;
2779
- if (addNew && !e.shiftKey) {
2780
- ourIndex = doc.sel.contains(start);
2781
- if (ourIndex > -1)
2782
- ourRange = doc.sel.ranges[ourIndex];
2783
- else
2784
- ourRange = new Range(start, start);
2785
- } else {
2786
- ourRange = doc.sel.primary();
 
 
 
 
2787
  }
 
 
2788
 
2789
- if (e.altKey) {
2790
- type = "rect";
2791
- if (!addNew) ourRange = new Range(start, start);
2792
- start = posFromMouse(cm, e, true, true);
2793
- ourIndex = -1;
2794
- } else if (type == "double") {
2795
- var word = findWordAt(cm, start);
2796
- if (cm.display.shift || doc.extend)
2797
- ourRange = extendRange(doc, ourRange, word.anchor, word.head);
2798
- else
2799
- ourRange = word;
2800
- } else if (type == "triple") {
2801
- var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
2802
- if (cm.display.shift || doc.extend)
2803
- ourRange = extendRange(doc, ourRange, line.anchor, line.head);
2804
- else
2805
- ourRange = line;
2806
- } else {
2807
- ourRange = extendRange(doc, ourRange, start);
2808
  }
 
2809
 
2810
- if (!addNew) {
2811
- ourIndex = 0;
2812
- setSelection(doc, new Selection([ourRange], 0), sel_mouse);
2813
- startSel = doc.sel;
2814
- } else if (ourIndex > -1) {
2815
- replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
 
2816
  } else {
2817
- ourIndex = doc.sel.ranges.length;
2818
- setSelection(doc, normalizeSelection(doc.sel.ranges.concat([ourRange]), ourIndex),
2819
- {scroll: false, origin: "*mouse"});
 
 
 
 
 
2820
  }
 
 
 
 
2821
 
2822
- var lastPos = start;
2823
- function extendTo(pos) {
2824
- if (cmp(lastPos, pos) == 0) return;
2825
- lastPos = pos;
2826
 
2827
- if (type == "rect") {
2828
- var ranges = [], tabSize = cm.options.tabSize;
2829
- var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
2830
- var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
2831
- var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
2832
- for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
2833
- line <= end; line++) {
2834
- var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
2835
- if (left == right)
2836
- ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
2837
- else if (text.length > leftPos)
2838
- ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
2839
- }
2840
- if (!ranges.length) ranges.push(new Range(start, start));
2841
- setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
2842
- {origin: "*mouse", scroll: false});
2843
- cm.scrollIntoView(pos);
2844
- } else {
2845
- var oldRange = ourRange;
2846
- var anchor = oldRange.anchor, head = pos;
2847
- if (type != "single") {
2848
- if (type == "double")
2849
- var range = findWordAt(cm, pos);
2850
- else
2851
- var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
2852
- if (cmp(range.anchor, anchor) > 0) {
2853
- head = range.head;
2854
- anchor = minPos(oldRange.from(), range.anchor);
2855
- } else {
2856
- head = range.anchor;
2857
- anchor = maxPos(oldRange.to(), range.head);
2858
- }
2859
- }
2860
- var ranges = startSel.ranges.slice(0);
2861
- ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
2862
- setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
2863
  }
2864
  }
 
 
2865
 
2866
- var editorSize = display.wrapper.getBoundingClientRect();
2867
- // Used to ensure timeout re-tries don't fire when another extend
2868
- // happened in the meantime (clearTimeout isn't reliable -- at
2869
- // least on Chrome, the timeouts still happen even when cleared,
2870
- // if the clear happens after their scheduled firing time).
2871
- var counter = 0;
 
 
 
2872
 
2873
- function extend(e) {
2874
- var curCount = ++counter;
2875
- var cur = posFromMouse(cm, e, true, type == "rect");
2876
- if (!cur) return;
2877
- if (cmp(cur, lastPos) != 0) {
2878
- ensureFocus(cm);
2879
- extendTo(cur);
2880
- var visible = visibleLines(display, doc);
2881
- if (cur.line >= visible.to || cur.line < visible.from)
2882
- setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
2883
- } else {
2884
- var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
2885
- if (outside) setTimeout(operation(cm, function() {
2886
- if (counter != curCount) return;
2887
- display.scroller.scrollTop += outside;
2888
- extend(e);
2889
- }), 50);
2890
  }
 
 
 
 
 
 
 
 
2891
  }
2892
-
2893
- function done(e) {
2894
- counter = Infinity;
2895
- e_preventDefault(e);
2896
- focusInput(cm);
2897
- off(document, "mousemove", move);
2898
- off(document, "mouseup", up);
2899
- doc.history.lastSelOrigin = null;
2900
  }
2901
 
2902
- var move = operation(cm, function(e) {
2903
- if (!e_button(e)) done(e);
2904
- else extend(e);
2905
- });
2906
- var up = operation(cm, done);
2907
- on(document, "mousemove", move);
2908
- on(document, "mouseup", up);
 
 
 
 
 
 
 
2909
  }
2910
 
2911
- // Determines whether an event happened in the gutter, and fires the
2912
- // handlers for the corresponding event.
2913
- function gutterEvent(cm, e, type, prevent, signalfn) {
2914
- try { var mX = e.clientX, mY = e.clientY; }
2915
- catch(e) { return false; }
2916
- if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
2917
- if (prevent) e_preventDefault(e);
 
 
 
 
2918
 
2919
- var display = cm.display;
2920
- var lineBox = display.lineDiv.getBoundingClientRect();
 
 
 
 
 
 
2921
 
2922
- if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
2923
- mY -= lineBox.top - display.viewOffset;
 
 
 
 
2924
 
2925
- for (var i = 0; i < cm.options.gutters.length; ++i) {
2926
- var g = display.gutters.childNodes[i];
2927
- if (g && g.getBoundingClientRect().right >= mX) {
2928
- var line = lineAtHeight(cm.doc, mY);
2929
- var gutter = cm.options.gutters[i];
2930
- signalfn(cm, type, cm, line, gutter, e);
2931
- return e_defaultPrevented(e);
2932
- }
2933
- }
2934
  }
2935
 
2936
- function clickInGutter(cm, e) {
2937
- return gutterEvent(cm, e, "gutterClick", true, signalLater);
 
 
 
 
 
 
 
 
2938
  }
2939
 
2940
- // Kludge to work around strange IE behavior where it'll sometimes
2941
- // re-fire a series of drag-related events right after the drop (#1551)
2942
- var lastDrop = 0;
 
 
 
2943
 
2944
- function onDrop(e) {
2945
- var cm = this;
2946
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
2947
- return;
2948
- e_preventDefault(e);
2949
- if (ie) lastDrop = +new Date;
2950
- var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
2951
- if (!pos || isReadOnly(cm)) return;
2952
- // Might be a file drop, in which case we simply extract the text
2953
- // and insert it.
2954
- if (files && files.length && window.FileReader && window.File) {
2955
- var n = files.length, text = Array(n), read = 0;
2956
- var loadFile = function(file, i) {
2957
- var reader = new FileReader;
2958
- reader.onload = operation(cm, function() {
2959
- text[i] = reader.result;
2960
- if (++read == n) {
2961
- pos = clipPos(cm.doc, pos);
2962
- var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
2963
- makeChange(cm.doc, change);
2964
- setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
2965
- }
2966
- });
2967
- reader.readAsText(file);
2968
- };
2969
- for (var i = 0; i < n; ++i) loadFile(files[i], i);
2970
- } else { // Normal drop
2971
- // Don't do a replace if the drop happened inside of the selected text.
2972
- if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
2973
- cm.state.draggingText(e);
2974
- // Ensure the editor is re-focused
2975
- setTimeout(bind(focusInput, cm), 20);
2976
- return;
2977
- }
2978
- try {
2979
- var text = e.dataTransfer.getData("Text");
2980
- if (text) {
2981
- if (cm.state.draggingText && !(mac ? e.metaKey : e.ctrlKey))
2982
- var selected = cm.listSelections();
2983
- setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
2984
- if (selected) for (var i = 0; i < selected.length; ++i)
2985
- replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
2986
- cm.replaceSelection(text, "around", "paste");
2987
- focusInput(cm);
2988
- }
2989
- }
2990
- catch(e){}
2991
  }
 
 
2992
  }
2993
 
2994
- function onDragStart(cm, e) {
2995
- if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
2996
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
 
 
 
 
 
 
 
 
 
 
 
2997
 
2998
- e.dataTransfer.setData("Text", cm.getSelection());
 
 
2999
 
3000
- // Use dummy image instead of default browsers image.
3001
- // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
3002
- if (e.dataTransfer.setDragImage && !safari) {
3003
- var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
3004
- img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
3005
- if (presto) {
3006
- img.width = img.height = 1;
3007
- cm.display.wrapper.appendChild(img);
3008
- // Force a relayout, or Opera won't use our image for some obscure reason
3009
- img._top = img.offsetTop;
3010
- }
3011
- e.dataTransfer.setDragImage(img, 0, 0);
3012
- if (presto) img.parentNode.removeChild(img);
3013
- }
3014
  }
3015
 
3016
- // SCROLL EVENTS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3017
 
3018
- // Sync the scrollable area and scrollbars, ensure the viewport
3019
- // covers the visible area.
3020
- function setScrollTop(cm, val) {
3021
- if (Math.abs(cm.doc.scrollTop - val) < 2) return;
3022
- cm.doc.scrollTop = val;
3023
- if (!gecko) updateDisplaySimple(cm, {top: val});
3024
- if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
3025
- if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val;
3026
- if (gecko) updateDisplaySimple(cm);
3027
- startWorker(cm, 100);
3028
  }
3029
- // Sync scroller and scrollbar, ensure the gutter elements are
3030
- // aligned.
3031
- function setScrollLeft(cm, val, isScroller) {
3032
- if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
3033
- val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
3034
- cm.doc.scrollLeft = val;
3035
- alignHorizontally(cm);
3036
- if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
3037
- if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val;
 
3038
  }
3039
 
3040
- // Since the delta values reported on mouse wheel events are
3041
- // unstandardized between browsers and even browser versions, and
3042
- // generally horribly unpredictable, this code starts by measuring
3043
- // the scroll effect that the first few mouse wheel events have,
3044
- // and, from that, detects the way it can convert deltas to pixel
3045
- // offsets afterwards.
3046
- //
3047
- // The reason we want to know the amount a wheel event will scroll
3048
- // is that it gives us a chance to update the display before the
3049
- // actual scrolling happens, reducing flickering.
 
 
3050
 
3051
- var wheelSamples = 0, wheelPixelsPerUnit = null;
3052
- // Fill in a browser-detected starting value on browsers where we
3053
- // know one. These don't have to be accurate -- the result of them
3054
- // being wrong would just be a slight flicker on the first wheel
3055
- // scroll (if it is large enough).
3056
- if (ie) wheelPixelsPerUnit = -.53;
3057
- else if (gecko) wheelPixelsPerUnit = 15;
3058
- else if (chrome) wheelPixelsPerUnit = -.7;
3059
- else if (safari) wheelPixelsPerUnit = -1/3;
 
3060
 
3061
- function onScrollWheel(cm, e) {
3062
- var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
3063
- if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
3064
- if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
3065
- else if (dy == null) dy = e.wheelDelta;
 
 
 
 
 
3066
 
3067
- var display = cm.display, scroll = display.scroller;
3068
- // Quit if there's nothing to scroll here
3069
- if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
3070
- dy && scroll.scrollHeight > scroll.clientHeight)) return;
 
 
 
3071
 
3072
- // Webkit browsers on OS X abort momentum scrolls when the target
3073
- // of the scroll event is removed from the scrollable element.
3074
- // This hack (see related code in patchDisplay) makes sure the
3075
- // element is kept around.
3076
- if (dy && mac && webkit) {
3077
- outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
3078
- for (var i = 0; i < view.length; i++) {
3079
- if (view[i].node == cur) {
3080
- cm.display.currentWheelTarget = cur;
3081
- break outer;
3082
- }
3083
- }
3084
- }
3085
- }
3086
 
3087
- // On some browsers, horizontal scrolling will cause redraws to
3088
- // happen before the gutter has been realigned, causing it to
3089
- // wriggle around in a most unseemly way. When we have an
3090
- // estimated pixels/delta value, we just handle horizontal
3091
- // scrolling entirely here. It'll be slightly off from native, but
3092
- // better than glitching out.
3093
- if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
3094
- if (dy)
3095
- setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
3096
- setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
3097
- e_preventDefault(e);
3098
- display.wheelStartX = null; // Abort measurement, if in progress
3099
- return;
3100
- }
3101
 
3102
- // 'Project' the visible viewport to cover the area that is being
3103
- // scrolled into view (if we know enough to estimate it).
3104
- if (dy && wheelPixelsPerUnit != null) {
3105
- var pixels = dy * wheelPixelsPerUnit;
3106
- var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
3107
- if (pixels < 0) top = Math.max(0, top + pixels - 50);
3108
- else bot = Math.min(cm.doc.height, bot + pixels + 50);
3109
- updateDisplaySimple(cm, {top: top, bottom: bot});
3110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3111
 
3112
- if (wheelSamples < 20) {
3113
- if (display.wheelStartX == null) {
3114
- display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
3115
- display.wheelDX = dx; display.wheelDY = dy;
3116
- setTimeout(function() {
3117
- if (display.wheelStartX == null) return;
3118
- var movedX = scroll.scrollLeft - display.wheelStartX;
3119
- var movedY = scroll.scrollTop - display.wheelStartY;
3120
- var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
3121
- (movedX && display.wheelDX && movedX / display.wheelDX);
3122
- display.wheelStartX = display.wheelStartY = null;
3123
- if (!sample) return;
3124
- wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
3125
- ++wheelSamples;
3126
- }, 200);
3127
- } else {
3128
- display.wheelDX += dx; display.wheelDY += dy;
3129
  }
 
3130
  }
 
 
 
 
 
3131
  }
3132
 
3133
- // KEY EVENTS
 
 
 
 
 
 
 
 
 
3134
 
3135
- // Run a handler that was bound to a key.
3136
- function doHandleBinding(cm, bound, dropShift) {
3137
- if (typeof bound == "string") {
3138
- bound = commands[bound];
3139
- if (!bound) return false;
3140
- }
3141
- // Ensure previous input has been read, so that the handler sees a
3142
- // consistent view of the document
3143
- if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;
3144
- var prevShift = cm.display.shift, done = false;
3145
- try {
3146
- if (isReadOnly(cm)) cm.state.suppressEdits = true;
3147
- if (dropShift) cm.display.shift = false;
3148
- done = bound(cm) != Pass;
3149
- } finally {
3150
- cm.display.shift = prevShift;
3151
- cm.state.suppressEdits = false;
3152
  }
3153
- return done;
 
 
 
 
3154
  }
3155
 
3156
- // Collect the currently active keymaps.
3157
- function allKeyMaps(cm) {
3158
- var maps = cm.state.keyMaps.slice(0);
3159
- if (cm.options.extraKeys) maps.push(cm.options.extraKeys);
3160
- maps.push(cm.options.keyMap);
3161
- return maps;
3162
  }
3163
 
3164
- var maybeTransition;
3165
- // Handle a key from the keydown event.
3166
- function handleKeyBinding(cm, e) {
3167
- // Handle automatic keymap transitions
3168
- var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
3169
- clearTimeout(maybeTransition);
3170
- if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
3171
- if (getKeyMap(cm.options.keyMap) == startMap) {
3172
- cm.options.keyMap = (next.call ? next.call(null, cm) : next);
3173
- keyMapChanged(cm);
3174
- }
3175
- }, 50);
3176
-
3177
- var name = keyName(e, true), handled = false;
3178
- if (!name) return false;
3179
- var keymaps = allKeyMaps(cm);
3180
 
3181
- if (e.shiftKey) {
3182
- // First try to resolve full name (including 'Shift-'). Failing
3183
- // that, see if there is a cursor-motion command (starting with
3184
- // 'go') bound to the keyname without 'Shift-'.
3185
- handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);})
3186
- || lookupKey(name, keymaps, function(b) {
3187
- if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
3188
- return doHandleBinding(cm, b);
3189
- });
3190
- } else {
3191
- handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); });
3192
- }
3193
 
3194
- if (handled) {
3195
- e_preventDefault(e);
3196
- restartBlink(cm);
3197
- signalLater(cm, "keyHandled", cm, name, e);
3198
  }
3199
- return handled;
3200
  }
3201
 
3202
- // Handle a key from the keypress event
3203
- function handleCharBinding(cm, e, ch) {
3204
- var handled = lookupKey("'" + ch + "'", allKeyMaps(cm),
3205
- function(b) { return doHandleBinding(cm, b, true); });
3206
- if (handled) {
3207
- e_preventDefault(e);
3208
- restartBlink(cm);
3209
- signalLater(cm, "keyHandled", cm, "'" + ch + "'", e);
3210
- }
3211
- return handled;
3212
  }
3213
 
3214
- var lastStoppedKey = null;
3215
- function onKeyDown(e) {
3216
- var cm = this;
3217
- ensureFocus(cm);
3218
- if (signalDOMEvent(cm, e)) return;
3219
- // IE does strange things with escape.
3220
- if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
3221
- var code = e.keyCode;
3222
- cm.display.shift = code == 16 || e.shiftKey;
3223
- var handled = handleKeyBinding(cm, e);
3224
- if (presto) {
3225
- lastStoppedKey = handled ? code : null;
3226
- // Opera has no cut event... we try to at least catch the key combo
3227
- if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
3228
- cm.replaceSelection("", null, "cut");
3229
- }
3230
 
3231
- // Turn mouse into crosshair when Alt is held on Mac.
3232
- if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
3233
- showCrossHair(cm);
 
 
 
 
 
 
 
3234
  }
3235
 
3236
- function showCrossHair(cm) {
3237
- var lineDiv = cm.display.lineDiv;
3238
- addClass(lineDiv, "CodeMirror-crosshair");
3239
-
3240
- function up(e) {
3241
- if (e.keyCode == 18 || !e.altKey) {
3242
- rmClass(lineDiv, "CodeMirror-crosshair");
3243
- off(document, "keyup", up);
3244
- off(document, "mouseover", up);
3245
- }
3246
  }
3247
- on(document, "keyup", up);
3248
- on(document, "mouseover", up);
3249
  }
3250
 
3251
- function onKeyUp(e) {
3252
- if (e.keyCode == 16) this.doc.sel.shift = false;
3253
- signalDOMEvent(this, e);
3254
- }
 
 
 
 
 
 
3255
 
3256
- function onKeyPress(e) {
3257
- var cm = this;
3258
- if (signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
3259
- var keyCode = e.keyCode, charCode = e.charCode;
3260
- if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
3261
- if (((presto && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;
3262
- var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
3263
- if (handleCharBinding(cm, e, ch)) return;
3264
- if (ie && ie_version >= 9) cm.display.inputHasSelection = null;
3265
- fastPoll(cm);
3266
- }
3267
 
3268
- // FOCUS/BLUR EVENTS
3269
 
3270
- function onFocus(cm) {
3271
- if (cm.options.readOnly == "nocursor") return;
3272
- if (!cm.state.focused) {
3273
- signal(cm, "focus", cm);
3274
- cm.state.focused = true;
3275
- addClass(cm.display.wrapper, "CodeMirror-focused");
3276
- // The prevInput test prevents this from firing when a context
3277
- // menu is closed (since the resetInput would kill the
3278
- // select-all detection hack)
3279
- if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
3280
- resetInput(cm);
3281
- if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3282
  }
3283
  }
3284
- slowPoll(cm);
3285
- restartBlink(cm);
3286
- }
3287
- function onBlur(cm) {
3288
- if (cm.state.focused) {
3289
- signal(cm, "blur", cm);
3290
- cm.state.focused = false;
3291
- rmClass(cm.display.wrapper, "CodeMirror-focused");
3292
  }
3293
- clearInterval(cm.display.blinker);
3294
- setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
3295
  }
3296
 
3297
- // CONTEXT MENU HANDLING
3298
-
3299
- // To make the context menu work, we need to briefly unhide the
3300
- // textarea (making it as unobtrusive as possible) to let the
3301
- // right-click take effect on it.
3302
- function onContextMenu(cm, e) {
3303
- if (signalDOMEvent(cm, e, "contextmenu")) return;
3304
- var display = cm.display;
3305
- if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;
3306
 
3307
- var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
3308
- if (!pos || presto) return; // Opera is difficult.
 
 
 
 
3309
 
3310
- // Reset the current text selection only if the click is done outside of the selection
3311
- // and 'resetSelectionOnContextMenu' option is true.
3312
- var reset = cm.options.resetSelectionOnContextMenu;
3313
- if (reset && cm.doc.sel.contains(pos) == -1)
3314
- operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
3315
-
3316
- var oldCSS = display.input.style.cssText;
3317
- display.inputDiv.style.position = "absolute";
3318
- display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
3319
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
3320
- (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
3321
- "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
3322
- if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
3323
- focusInput(cm);
3324
- if (webkit) window.scrollTo(null, oldScrollY);
3325
- resetInput(cm);
3326
- // Adds "Select all" to context menu in FF
3327
- if (!cm.somethingSelected()) display.input.value = display.prevInput = " ";
3328
- display.selForContextMenu = cm.doc.sel;
3329
- clearTimeout(display.detectingSelectAll);
3330
 
3331
- // Select-all will be greyed out if there's nothing to select, so
3332
- // this adds a zero-width space so that we can later check whether
3333
- // it got selected.
3334
- function prepareSelectAllHack() {
3335
- if (display.input.selectionStart != null) {
3336
- var selected = cm.somethingSelected();
3337
- var extval = display.input.value = "\u200b" + (selected ? display.input.value : "");
3338
- display.prevInput = selected ? "" : "\u200b";
3339
- display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
3340
- // Re-set this, in case some other handler touched the
3341
- // selection in the meantime.
3342
- display.selForContextMenu = cm.doc.sel;
 
 
3343
  }
 
3344
  }
3345
- function rehide() {
3346
- display.inputDiv.style.position = "relative";
3347
- display.input.style.cssText = oldCSS;
3348
- if (ie && ie_version < 9) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos;
3349
- slowPoll(cm);
3350
-
3351
- // Try to detect the user choosing select-all
3352
- if (display.input.selectionStart != null) {
3353
- if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
3354
- var i = 0, poll = function() {
3355
- if (display.selForContextMenu == cm.doc.sel && display.input.selectionStart == 0)
3356
- operation(cm, commands.selectAll)(cm);
3357
- else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
3358
- else resetInput(cm);
3359
- };
3360
- display.detectingSelectAll = setTimeout(poll, 200);
3361
- }
3362
  }
 
 
3363
 
3364
- if (ie && ie_version >= 9) prepareSelectAllHack();
3365
- if (captureRightClick) {
3366
- e_stop(e);
3367
- var mouseup = function() {
3368
- off(window, "mouseup", mouseup);
3369
- setTimeout(rehide, 20);
3370
- };
3371
- on(window, "mouseup", mouseup);
3372
  } else {
3373
- setTimeout(rehide, 50);
 
 
 
 
 
 
 
 
3374
  }
 
3375
  }
3376
 
3377
- function contextMenuInGutter(cm, e) {
3378
- if (!hasHandler(cm, "gutterContextMenu")) return false;
3379
- return gutterEvent(cm, e, "gutterContextMenu", false, signal);
 
 
 
 
 
 
3380
  }
3381
 
3382
- // UPDATING
3383
-
3384
- // Compute the position of the end of a change (its 'to' property
3385
- // refers to the pre-change end).
3386
- var changeEnd = CodeMirror.changeEnd = function(change) {
3387
- if (!change.text) return change.to;
3388
- return Pos(change.from.line + change.text.length - 1,
3389
- lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
3390
- };
3391
 
3392
- // Adjust a position to refer to the post-change position of the
3393
- // same text, or the end of the change if the change covers it.
3394
- function adjustForChange(pos, change) {
3395
- if (cmp(pos, change.from) < 0) return pos;
3396
- if (cmp(pos, change.to) <= 0) return changeEnd(change);
3397
 
3398
- var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
3399
- if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
3400
- return Pos(line, ch);
3401
- }
3402
 
3403
- function computeSelAfterChange(doc, change) {
3404
- var out = [];
3405
  for (var i = 0; i < doc.sel.ranges.length; i++) {
3406
- var range = doc.sel.ranges[i];
3407
- out.push(new Range(adjustForChange(range.anchor, change),
3408
- adjustForChange(range.head, change)));
 
 
 
 
 
3409
  }
3410
- return normalizeSelection(out, doc.sel.primIndex);
3411
  }
3412
 
3413
- function offsetPos(pos, old, nw) {
3414
- if (pos.line == old.line)
3415
- return Pos(nw.line, pos.ch - old.ch + nw.ch);
3416
- else
3417
- return Pos(nw.line + (pos.line - old.line), pos.ch);
3418
- }
3419
 
3420
- // Used by replaceSelections to allow moving the selection to the
3421
- // start or around the replaced test. Hint may be "start" or "around".
3422
- function computeReplacedSel(doc, changes, hint) {
3423
- var out = [];
3424
- var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
3425
- for (var i = 0; i < changes.length; i++) {
3426
- var change = changes[i];
3427
- var from = offsetPos(change.from, oldPrev, newPrev);
3428
- var to = offsetPos(changeEnd(change), oldPrev, newPrev);
3429
- oldPrev = change.to;
3430
- newPrev = to;
3431
- if (hint == "around") {
3432
- var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
3433
- out[i] = new Range(inv ? to : from, inv ? from : to);
3434
- } else {
3435
- out[i] = new Range(from, from);
3436
- }
3437
  }
3438
- return new Selection(out, doc.sel.primIndex);
3439
  }
3440
 
3441
- // Allow "beforeChange" event handlers to influence a change
3442
- function filterChange(doc, change, update) {
3443
- var obj = {
3444
- canceled: false,
3445
- from: change.from,
3446
- to: change.to,
3447
- text: change.text,
3448
- origin: change.origin,
3449
- cancel: function() { this.canceled = true; }
3450
- };
3451
- if (update) obj.update = function(from, to, text, origin) {
3452
- if (from) this.from = clipPos(doc, from);
3453
- if (to) this.to = clipPos(doc, to);
3454
- if (text) this.text = text;
3455
- if (origin !== undefined) this.origin = origin;
3456
- };
3457
- signal(doc, "beforeChange", doc, obj);
3458
- if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
3459
-
3460
- if (obj.canceled) return null;
3461
- return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
3462
- }
3463
-
3464
- // Apply a change to a document, and add it to the document's
3465
- // history, and propagating it to all linked documents.
3466
- function makeChange(doc, change, ignoreReadOnly) {
3467
- if (doc.cm) {
3468
- if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
3469
- if (doc.cm.state.suppressEdits) return;
3470
- }
3471
 
3472
- if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
3473
- change = filterChange(doc, change, true);
3474
- if (!change) return;
3475
- }
 
 
 
3476
 
3477
- // Possibly split or suppress the update based on the presence
3478
- // of read-only spans in its range.
3479
- var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
3480
- if (split) {
3481
- for (var i = split.length - 1; i >= 0; --i)
3482
- makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
3483
- } else {
3484
- makeChangeInner(doc, change);
3485
  }
3486
- }
3487
-
3488
- function makeChangeInner(doc, change) {
3489
- if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
3490
- var selAfter = computeSelAfterChange(doc, change);
3491
- addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
3492
-
3493
- makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
3494
- var rebased = [];
3495
-
3496
- linkedDocs(doc, function(doc, sharedHist) {
3497
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
3498
- rebaseHist(doc.history, change);
3499
- rebased.push(doc.history);
3500
- }
3501
- makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
3502
- });
3503
- }
3504
-
3505
- // Revert a change stored in a document's history.
3506
- function makeChangeFromHistory(doc, type, allowSelectionOnly) {
3507
- if (doc.cm && doc.cm.state.suppressEdits) return;
3508
 
3509
- var hist = doc.history, event, selAfter = doc.sel;
3510
- var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3511
 
3512
- // Verify that there is a useable event (so that ctrl-z won't
3513
- // needlessly clear selection events)
3514
- for (var i = 0; i < source.length; i++) {
3515
- event = source[i];
3516
- if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
3517
- break;
3518
  }
3519
- if (i == source.length) return;
3520
- hist.lastOrigin = hist.lastSelOrigin = null;
3521
 
3522
- for (;;) {
3523
- event = source.pop();
3524
- if (event.ranges) {
3525
- pushSelectionToHistory(event, dest);
3526
- if (allowSelectionOnly && !event.equals(doc.sel)) {
3527
- setSelection(doc, event, {clearRedo: false});
3528
- return;
 
 
 
 
 
 
 
3529
  }
3530
- selAfter = event;
3531
  }
3532
- else break;
 
3533
  }
3534
 
3535
- // Build up a reverse change object to add to the opposite history
3536
- // stack (redo when undoing, and vice versa).
3537
- var antiChanges = [];
3538
- pushSelectionToHistory(selAfter, dest);
3539
- dest.push({changes: antiChanges, generation: hist.generation});
3540
- hist.generation = event.generation || ++hist.maxGeneration;
3541
-
3542
- var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
3543
-
3544
- for (var i = event.changes.length - 1; i >= 0; --i) {
3545
- var change = event.changes[i];
3546
- change.origin = type;
3547
- if (filter && !filterChange(doc, change, false)) {
3548
- source.length = 0;
3549
- return;
3550
- }
3551
-
3552
- antiChanges.push(historyChangeFromChange(doc, change));
3553
-
3554
- var after = i ? computeSelAfterChange(doc, change) : lst(source);
3555
- makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
3556
- if (!i && doc.cm) doc.cm.scrollIntoView(change);
3557
- var rebased = [];
3558
 
3559
- // Propagate to the linked documents
3560
- linkedDocs(doc, function(doc, sharedHist) {
3561
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
3562
- rebaseHist(doc.history, change);
3563
- rebased.push(doc.history);
3564
- }
3565
- makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
3566
- });
3567
- }
 
 
 
3568
  }
3569
 
3570
- // Sub-views need their line numbers shifted when text is added
3571
- // above or below them in the parent document.
3572
- function shiftDoc(doc, distance) {
3573
- if (distance == 0) return;
3574
- doc.first += distance;
3575
- doc.sel = new Selection(map(doc.sel.ranges, function(range) {
3576
- return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
3577
- Pos(range.head.line + distance, range.head.ch));
3578
- }), doc.sel.primIndex);
3579
- if (doc.cm) {
3580
- regChange(doc.cm, doc.first, doc.first - distance, distance);
3581
- for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
3582
- regLineChange(doc.cm, l, "gutter");
3583
- }
3584
  }
3585
 
3586
- // More lower-level change function, handling only a single document
3587
- // (not linked ones).
3588
- function makeChangeSingleDoc(doc, change, selAfter, spans) {
3589
- if (doc.cm && !doc.cm.curOp)
3590
- return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
 
 
3591
 
3592
- if (change.to.line < doc.first) {
3593
- shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
3594
- return;
3595
- }
3596
- if (change.from.line > doc.lastLine()) return;
3597
 
3598
- // Clip the change to the size of this doc
3599
- if (change.from.line < doc.first) {
3600
- var shift = change.text.length - 1 - (doc.first - change.from.line);
3601
- shiftDoc(doc, shift);
3602
- change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
3603
- text: [lst(change.text)], origin: change.origin};
3604
- }
3605
- var last = doc.lastLine();
3606
- if (change.to.line > last) {
3607
- change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
3608
- text: [change.text[0]], origin: change.origin};
 
 
3609
  }
3610
-
3611
- change.removed = getBetween(doc, change.from, change.to);
3612
-
3613
- if (!selAfter) selAfter = computeSelAfterChange(doc, change);
3614
- if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
3615
- else updateDoc(doc, change, spans);
3616
- setSelectionNoUndo(doc, selAfter, sel_dontScroll);
3617
  }
 
 
3618
 
3619
- // Handle the interaction of a change to a document with the editor
3620
- // that this document is part of.
3621
- function makeChangeSingleDocInEditor(cm, change, spans) {
3622
- var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
3623
-
3624
- var recomputeMaxLength = false, checkWidthStart = from.line;
3625
- if (!cm.options.lineWrapping) {
3626
- checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
3627
- doc.iter(checkWidthStart, to.line + 1, function(line) {
3628
- if (line == display.maxLine) {
3629
- recomputeMaxLength = true;
3630
- return true;
3631
- }
3632
- });
3633
  }
 
 
 
3634
 
3635
- if (doc.sel.contains(change.from, change.to) > -1)
3636
- signalCursorActivity(cm);
3637
-
3638
- updateDoc(doc, change, spans, estimateHeight(cm));
3639
-
3640
- if (!cm.options.lineWrapping) {
3641
- doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
3642
- var len = lineLength(line);
3643
- if (len > display.maxLineLength) {
3644
- display.maxLine = line;
3645
- display.maxLineLength = len;
3646
- display.maxLineChanged = true;
3647
- recomputeMaxLength = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3648
  }
3649
- });
3650
- if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
3651
  }
 
3652
 
3653
- // Adjust frontier, schedule worker
3654
- doc.frontier = Math.min(doc.frontier, from.line);
3655
- startWorker(cm, 400);
 
 
 
 
 
3656
 
3657
- var lendiff = change.text.length - (to.line - from.line) - 1;
3658
- // Remember that these lines changed, for updating the display
3659
- if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
3660
- regLineChange(cm, from.line, "text");
3661
- else
3662
- regChange(cm, from.line, to.line + 1, lendiff);
 
3663
 
3664
- var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
3665
- if (changeHandler || changesHandler) {
3666
- var obj = {
3667
- from: from, to: to,
3668
- text: change.text,
3669
- removed: change.removed,
3670
- origin: change.origin
3671
- };
3672
- if (changeHandler) signalLater(cm, "change", cm, obj);
3673
- if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
 
 
3674
  }
3675
- cm.display.selForContextMenu = null;
3676
- }
3677
-
3678
- function replaceRange(doc, code, from, to, origin) {
3679
- if (!to) to = from;
3680
- if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
3681
- if (typeof code == "string") code = splitLines(code);
3682
- makeChange(doc, {from: from, to: to, text: code, origin: origin});
3683
  }
3684
 
3685
  // SCROLLING THINGS INTO VIEW
3686
 
3687
  // If an editor sits on the top or bottom of the window, partially
3688
  // scrolled out of view, this ensures that the cursor is visible.
3689
- function maybeScrollWindow(cm, coords) {
 
 
3690
  var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
3691
- if (coords.top + box.top < 0) doScroll = true;
3692
- else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
3693
  if (doScroll != null && !phantom) {
3694
- var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
3695
- (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
3696
- (coords.bottom - coords.top + scrollerCutOff) + "px; left: " +
3697
- coords.left + "px; width: 2px;");
3698
  cm.display.lineSpace.appendChild(scrollNode);
3699
  scrollNode.scrollIntoView(doScroll);
3700
  cm.display.lineSpace.removeChild(scrollNode);
@@ -3705,86 +3422,102 @@
3705
  // it actually became visible (as line heights are accurately
3706
  // measured, the position of something may 'drift' during drawing).
3707
  function scrollPosIntoView(cm, pos, end, margin) {
3708
- if (margin == null) margin = 0;
3709
- for (;;) {
3710
- var changed = false, coords = cursorCoords(cm, pos);
 
 
 
 
 
 
 
 
 
3711
  var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
3712
- var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
3713
- Math.min(coords.top, endCoords.top) - margin,
3714
- Math.max(coords.left, endCoords.left),
3715
- Math.max(coords.bottom, endCoords.bottom) + margin);
 
3716
  var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
3717
  if (scrollPos.scrollTop != null) {
3718
- setScrollTop(cm, scrollPos.scrollTop);
3719
- if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
3720
  }
3721
  if (scrollPos.scrollLeft != null) {
3722
  setScrollLeft(cm, scrollPos.scrollLeft);
3723
- if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
3724
  }
3725
- if (!changed) return coords;
3726
  }
 
3727
  }
3728
 
3729
  // Scroll a given set of coordinates into view (immediately).
3730
- function scrollIntoView(cm, x1, y1, x2, y2) {
3731
- var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
3732
- if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
3733
- if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
3734
  }
3735
 
3736
  // Calculate a new scroll position needed to scroll the given
3737
  // rectangle into view. Returns an object with scrollTop and
3738
  // scrollLeft properties. When these are undefined, the
3739
  // vertical/horizontal position does not need to be adjusted.
3740
- function calculateScrollPos(cm, x1, y1, x2, y2) {
3741
  var display = cm.display, snapMargin = textHeight(cm.display);
3742
- if (y1 < 0) y1 = 0;
3743
  var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
3744
- var screen = display.scroller.clientHeight - scrollerCutOff, result = {};
 
3745
  var docBottom = cm.doc.height + paddingVert(display);
3746
- var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
3747
- if (y1 < screentop) {
3748
- result.scrollTop = atTop ? 0 : y1;
3749
- } else if (y2 > screentop + screen) {
3750
- var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
3751
- if (newTop != screentop) result.scrollTop = newTop;
3752
  }
3753
 
3754
  var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
3755
- var screenw = display.scroller.clientWidth - scrollerCutOff;
3756
- x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth;
3757
- var gutterw = display.gutters.offsetWidth;
3758
- var atLeft = x1 < gutterw + 10;
3759
- if (x1 < screenleft + gutterw || atLeft) {
3760
- if (atLeft) x1 = 0;
3761
- result.scrollLeft = Math.max(0, x1 - 10 - gutterw);
3762
- } else if (x2 > screenw + screenleft - 3) {
3763
- result.scrollLeft = x2 + 10 - screenw;
3764
- }
3765
- return result;
3766
  }
3767
 
3768
  // Store a relative adjustment to the scroll position in the current
3769
  // operation (to be applied when the operation finishes).
3770
- function addToScrollPos(cm, left, top) {
3771
- if (left != null || top != null) resolveScrollToPos(cm);
3772
- if (left != null)
3773
- cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
3774
- if (top != null)
3775
- cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
3776
  }
3777
 
3778
  // Make sure that at the end of the operation the current cursor is
3779
  // shown.
3780
  function ensureCursorVisible(cm) {
3781
  resolveScrollToPos(cm);
3782
- var cur = cm.getCursor(), from = cur, to = cur;
3783
- if (!cm.options.lineWrapping) {
3784
- from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
3785
- to = Pos(cur.line, cur.ch + 1);
3786
- }
3787
- cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
 
 
 
 
 
 
 
3788
  }
3789
 
3790
  // When an operation has its scrollToPos property set, and another
@@ -3792,4010 +3525,6259 @@
3792
  // 'simulates' scrolling that position into view in a cheap way, so
3793
  // that the effect of intermediate scroll commands is not ignored.
3794
  function resolveScrollToPos(cm) {
3795
- var range = cm.curOp.scrollToPos;
3796
- if (range) {
3797
  cm.curOp.scrollToPos = null;
3798
- var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
3799
- var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
3800
- Math.min(from.top, to.top) - range.margin,
3801
- Math.max(from.right, to.right),
3802
- Math.max(from.bottom, to.bottom) + range.margin);
3803
- cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
3804
  }
3805
  }
3806
 
3807
- // API UTILITIES
 
 
 
 
 
 
 
 
3808
 
3809
- // Indent the given line. The how parameter can be "smart",
3810
- // "add"/null, "subtract", or "prev". When aggressive is false
3811
- // (typically set to true for forced single-line indents), empty
3812
- // lines are not indented, and places where the mode returns Pass
3813
- // are left alone.
3814
- function indentLine(cm, n, how, aggressive) {
3815
- var doc = cm.doc, state;
3816
- if (how == null) how = "add";
3817
- if (how == "smart") {
3818
- // Fall back to "prev" when the mode doesn't have an indentation
3819
- // method.
3820
- if (!doc.mode.indent) how = "prev";
3821
- else state = getStateBefore(cm, n);
3822
- }
3823
 
3824
- var tabSize = cm.options.tabSize;
3825
- var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
3826
- if (line.stateAfter) line.stateAfter = null;
3827
- var curSpaceString = line.text.match(/^\s*/)[0], indentation;
3828
- if (!aggressive && !/\S/.test(line.text)) {
3829
- indentation = 0;
3830
- how = "not";
3831
- } else if (how == "smart") {
3832
- indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
3833
- if (indentation == Pass || indentation > 150) {
3834
- if (!aggressive) return;
3835
- how = "prev";
3836
- }
3837
- }
3838
- if (how == "prev") {
3839
- if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
3840
- else indentation = 0;
3841
- } else if (how == "add") {
3842
- indentation = curSpace + cm.options.indentUnit;
3843
- } else if (how == "subtract") {
3844
- indentation = curSpace - cm.options.indentUnit;
3845
- } else if (typeof how == "number") {
3846
- indentation = curSpace + how;
3847
- }
3848
- indentation = Math.max(0, indentation);
3849
 
3850
- var indentString = "", pos = 0;
3851
- if (cm.options.indentWithTabs)
3852
- for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
3853
- if (pos < indentation) indentString += spaceStr(indentation - pos);
 
 
 
 
 
 
3854
 
3855
- if (indentString != curSpaceString) {
3856
- replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
3857
- } else {
3858
- // Ensure that, if the cursor was in the whitespace at the start
3859
- // of the line, it is moved to the end of that space.
3860
- for (var i = 0; i < doc.sel.ranges.length; i++) {
3861
- var range = doc.sel.ranges[i];
3862
- if (range.head.line == n && range.head.ch < curSpaceString.length) {
3863
- var pos = Pos(n, curSpaceString.length);
3864
- replaceOneSelection(doc, i, new Range(pos, pos));
3865
- break;
3866
- }
3867
- }
 
 
 
 
3868
  }
3869
- line.stateAfter = null;
3870
  }
3871
 
3872
- // Utility for applying a change to a line by handle or number,
3873
- // returning the number and optionally registering the line as
3874
- // changed.
3875
- function changeLine(doc, handle, changeType, op) {
3876
- var no = handle, line = handle;
3877
- if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
3878
- else no = lineNo(handle);
3879
- if (no == null) return null;
3880
- if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
3881
- return line;
3882
- }
3883
 
3884
- // Helper for deleting text near the selection(s), used to implement
3885
- // backspace, delete, and similar functionality.
3886
- function deleteNearSelection(cm, compute) {
3887
- var ranges = cm.doc.sel.ranges, kill = [];
3888
- // Build up a set of ranges to kill first, merging overlapping
3889
- // ranges.
3890
- for (var i = 0; i < ranges.length; i++) {
3891
- var toKill = compute(ranges[i]);
3892
- while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
3893
- var replaced = kill.pop();
3894
- if (cmp(replaced.from, toKill.from) < 0) {
3895
- toKill.from = replaced.from;
3896
- break;
3897
- }
3898
- }
3899
- kill.push(toKill);
3900
- }
3901
- // Next, remove those actual ranges.
3902
- runInOp(cm, function() {
3903
- for (var i = kill.length - 1; i >= 0; i--)
3904
- replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
3905
- ensureCursorVisible(cm);
3906
  });
3907
- }
3908
 
3909
- // Used for horizontal relative motion. Dir is -1 or 1 (left or
3910
- // right), unit can be "char", "column" (like char, but doesn't
3911
- // cross line boundaries), "word" (across next word), or "group" (to
3912
- // the start of next group of word or non-word-non-whitespace
3913
- // chars). The visually param controls whether, in right-to-left
3914
- // text, direction 1 means to move towards the next index in the
3915
- // string, or towards the character to the right of the current
3916
- // position. The resulting position will have a hitSide=true
3917
- // property if it reached the end of the document.
3918
- function findPosH(doc, pos, dir, unit, visually) {
3919
- var line = pos.line, ch = pos.ch, origDir = dir;
3920
- var lineObj = getLine(doc, line);
3921
- var possible = true;
3922
- function findNextLine() {
3923
- var l = line + dir;
3924
- if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
3925
- line = l;
3926
- return lineObj = getLine(doc, l);
3927
- }
3928
- function moveOnce(boundToLine) {
3929
- var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
3930
- if (next == null) {
3931
- if (!boundToLine && findNextLine()) {
3932
- if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
3933
- else ch = dir < 0 ? lineObj.text.length : 0;
3934
- } else return (possible = false);
3935
- } else ch = next;
3936
- return true;
3937
- }
3938
 
3939
- if (unit == "char") moveOnce();
3940
- else if (unit == "column") moveOnce(true);
3941
- else if (unit == "word" || unit == "group") {
3942
- var sawType = null, group = unit == "group";
3943
- var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
3944
- for (var first = true;; first = false) {
3945
- if (dir < 0 && !moveOnce(!first)) break;
3946
- var cur = lineObj.text.charAt(ch) || "\n";
3947
- var type = isWordChar(cur, helper) ? "w"
3948
- : group && cur == "\n" ? "n"
3949
- : !group || /\s/.test(cur) ? null
3950
- : "p";
3951
- if (group && !first && !type) type = "s";
3952
- if (sawType && sawType != type) {
3953
- if (dir < 0) {dir = 1; moveOnce();}
3954
- break;
3955
- }
3956
 
3957
- if (type) sawType = type;
3958
- if (dir > 0 && !moveOnce(!first)) break;
3959
- }
 
 
 
 
 
 
 
3960
  }
3961
- var result = skipAtomic(doc, Pos(line, ch), origDir, true);
3962
- if (!possible) result.hitSide = true;
3963
- return result;
3964
- }
3965
 
3966
- // For relative vertical movement. Dir may be -1 or 1. Unit can be
3967
- // "page" or "line". The resulting position will have a hitSide=true
3968
- // property if it reached the end of the document.
3969
- function findPosV(cm, pos, dir, unit) {
3970
- var doc = cm.doc, x = pos.left, y;
3971
- if (unit == "page") {
3972
- var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
3973
- y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
3974
- } else if (unit == "line") {
3975
- y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
3976
- }
3977
- for (;;) {
3978
- var target = coordsChar(cm, x, y);
3979
- if (!target.outside) break;
3980
- if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
3981
- y += dir * 5;
3982
  }
3983
- return target;
3984
- }
3985
 
3986
- // Find the word at the given position (as returned by coordsChar).
3987
- function findWordAt(cm, pos) {
3988
- var doc = cm.doc, line = getLine(doc, pos.line).text;
3989
- var start = pos.ch, end = pos.ch;
3990
- if (line) {
3991
- var helper = cm.getHelper(pos, "wordChars");
3992
- if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
3993
- var startChar = line.charAt(start);
3994
- var check = isWordChar(startChar, helper)
3995
- ? function(ch) { return isWordChar(ch, helper); }
3996
- : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
3997
- : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
3998
- while (start > 0 && check(line.charAt(start - 1))) --start;
3999
- while (end < line.length && check(line.charAt(end))) ++end;
4000
  }
4001
- return new Range(Pos(pos.line, start), Pos(pos.line, end));
4002
- }
4003
 
4004
- // EDITOR METHODS
 
4005
 
4006
- // The publicly visible API. Note that methodOp(f) means
4007
- // 'wrap f in an operation, performed on its `this` parameter'.
 
 
4008
 
4009
- // This is not the complete set of editor methods. Most of the
4010
- // methods defined on the Doc type are also injected into
4011
- // CodeMirror.prototype, for backwards compatibility and
4012
- // convenience.
4013
 
4014
- CodeMirror.prototype = {
4015
- constructor: CodeMirror,
4016
- focus: function(){window.focus(); focusInput(this); fastPoll(this);},
 
 
 
 
4017
 
4018
- setOption: function(option, value) {
4019
- var options = this.options, old = options[option];
4020
- if (options[option] == value && option != "mode") return;
4021
- options[option] = value;
4022
- if (optionHandlers.hasOwnProperty(option))
4023
- operation(this, optionHandlers[option])(this, value, old);
4024
- },
 
 
 
 
 
 
 
 
 
 
4025
 
4026
- getOption: function(option) {return this.options[option];},
4027
- getDoc: function() {return this.doc;},
 
 
 
4028
 
4029
- addKeyMap: function(map, bottom) {
4030
- this.state.keyMaps[bottom ? "push" : "unshift"](map);
4031
- },
4032
- removeKeyMap: function(map) {
4033
- var maps = this.state.keyMaps;
4034
- for (var i = 0; i < maps.length; ++i)
4035
- if (maps[i] == map || (typeof maps[i] != "string" && maps[i].name == map)) {
4036
- maps.splice(i, 1);
4037
- return true;
4038
- }
4039
- },
4040
 
4041
- addOverlay: methodOp(function(spec, options) {
4042
- var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
4043
- if (mode.startState) throw new Error("Overlays may not be stateful.");
4044
- this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
4045
- this.state.modeGen++;
4046
- regChange(this);
4047
- }),
4048
- removeOverlay: methodOp(function(spec) {
4049
- var overlays = this.state.overlays;
4050
- for (var i = 0; i < overlays.length; ++i) {
4051
- var cur = overlays[i].modeSpec;
4052
- if (cur == spec || typeof spec == "string" && cur.name == spec) {
4053
- overlays.splice(i, 1);
4054
- this.state.modeGen++;
4055
- regChange(this);
4056
- return;
4057
- }
4058
- }
4059
- }),
4060
 
4061
- indentLine: methodOp(function(n, dir, aggressive) {
4062
- if (typeof dir != "string" && typeof dir != "number") {
4063
- if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
4064
- else dir = dir ? "add" : "subtract";
4065
- }
4066
- if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
4067
- }),
4068
- indentSelection: methodOp(function(how) {
4069
- var ranges = this.doc.sel.ranges, end = -1;
4070
- for (var i = 0; i < ranges.length; i++) {
4071
- var range = ranges[i];
4072
- if (!range.empty()) {
4073
- var start = Math.max(end, range.from().line);
4074
- var to = range.to();
4075
- end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
4076
- for (var j = start; j < end; ++j)
4077
- indentLine(this, j, how);
4078
- } else if (range.head.line > end) {
4079
- indentLine(this, range.head.line, how, true);
4080
- end = range.head.line;
4081
- if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
4082
- }
4083
- }
4084
- }),
4085
 
4086
- // Fetch the parser token for a given character. Useful for hacks
4087
- // that want to inspect the mode state (say, for completion).
4088
- getTokenAt: function(pos, precise) {
4089
- var doc = this.doc;
4090
- pos = clipPos(doc, pos);
4091
- var state = getStateBefore(this, pos.line, precise), mode = this.doc.mode;
4092
- var line = getLine(doc, pos.line);
4093
- var stream = new StringStream(line.text, this.options.tabSize);
4094
- while (stream.pos < pos.ch && !stream.eol()) {
4095
- stream.start = stream.pos;
4096
- var style = readToken(mode, stream, state);
4097
- }
4098
- return {start: stream.start,
4099
- end: stream.pos,
4100
- string: stream.current(),
4101
- type: style || null,
4102
- state: state};
4103
- },
4104
 
4105
- getTokenTypeAt: function(pos) {
4106
- pos = clipPos(this.doc, pos);
4107
- var styles = getLineStyles(this, getLine(this.doc, pos.line));
4108
- var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
4109
- var type;
4110
- if (ch == 0) type = styles[2];
4111
- else for (;;) {
4112
- var mid = (before + after) >> 1;
4113
- if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
4114
- else if (styles[mid * 2 + 1] < ch) before = mid + 1;
4115
- else { type = styles[mid * 2 + 2]; break; }
4116
- }
4117
- var cut = type ? type.indexOf("cm-overlay ") : -1;
4118
- return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
4119
- },
4120
 
4121
- getModeAt: function(pos) {
4122
- var mode = this.doc.mode;
4123
- if (!mode.innerMode) return mode;
4124
- return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
4125
- },
 
 
 
 
 
 
4126
 
4127
- getHelper: function(pos, type) {
4128
- return this.getHelpers(pos, type)[0];
4129
- },
4130
 
4131
- getHelpers: function(pos, type) {
4132
- var found = [];
4133
- if (!helpers.hasOwnProperty(type)) return helpers;
4134
- var help = helpers[type], mode = this.getModeAt(pos);
4135
- if (typeof mode[type] == "string") {
4136
- if (help[mode[type]]) found.push(help[mode[type]]);
4137
- } else if (mode[type]) {
4138
- for (var i = 0; i < mode[type].length; i++) {
4139
- var val = help[mode[type][i]];
4140
- if (val) found.push(val);
4141
- }
4142
- } else if (mode.helperType && help[mode.helperType]) {
4143
- found.push(help[mode.helperType]);
4144
- } else if (help[mode.name]) {
4145
- found.push(help[mode.name]);
4146
- }
4147
- for (var i = 0; i < help._global.length; i++) {
4148
- var cur = help._global[i];
4149
- if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
4150
- found.push(cur.val);
4151
- }
4152
- return found;
4153
- },
4154
 
4155
- getStateAfter: function(line, precise) {
4156
- var doc = this.doc;
4157
- line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
4158
- return getStateBefore(this, line + 1, precise);
4159
- },
 
 
 
 
 
 
 
 
 
4160
 
4161
- cursorCoords: function(start, mode) {
4162
- var pos, range = this.doc.sel.primary();
4163
- if (start == null) pos = range.head;
4164
- else if (typeof start == "object") pos = clipPos(this.doc, start);
4165
- else pos = start ? range.from() : range.to();
4166
- return cursorCoords(this, pos, mode || "page");
4167
- },
4168
 
4169
- charCoords: function(pos, mode) {
4170
- return charCoords(this, clipPos(this.doc, pos), mode || "page");
4171
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4172
 
4173
- coordsChar: function(coords, mode) {
4174
- coords = fromCoordSystem(this, coords, mode || "page");
4175
- return coordsChar(this, coords.left, coords.top);
4176
- },
 
 
 
 
 
4177
 
4178
- lineAtHeight: function(height, mode) {
4179
- height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
4180
- return lineAtHeight(this.doc, height + this.display.viewOffset);
4181
- },
4182
- heightAtLine: function(line, mode) {
4183
- var end = false, last = this.doc.first + this.doc.size - 1;
4184
- if (line < this.doc.first) line = this.doc.first;
4185
- else if (line > last) { line = last; end = true; }
4186
- var lineObj = getLine(this.doc, line);
4187
- return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
4188
- (end ? this.doc.height - heightAtLine(lineObj) : 0);
4189
- },
 
 
 
4190
 
4191
- defaultTextHeight: function() { return textHeight(this.display); },
4192
- defaultCharWidth: function() { return charWidth(this.display); },
 
 
4193
 
4194
- setGutterMarker: methodOp(function(line, gutterID, value) {
4195
- return changeLine(this.doc, line, "gutter", function(line) {
4196
- var markers = line.gutterMarkers || (line.gutterMarkers = {});
4197
- markers[gutterID] = value;
4198
- if (!value && isEmpty(markers)) line.gutterMarkers = null;
4199
- return true;
4200
- });
4201
- }),
4202
 
4203
- clearGutter: methodOp(function(gutterID) {
4204
- var cm = this, doc = cm.doc, i = doc.first;
4205
- doc.iter(function(line) {
4206
- if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
4207
- line.gutterMarkers[gutterID] = null;
4208
- regLineChange(cm, i, "gutter");
4209
- if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
4210
- }
4211
- ++i;
4212
- });
4213
- }),
4214
 
4215
- addLineWidget: methodOp(function(handle, node, options) {
4216
- return addLineWidget(this, handle, node, options);
4217
- }),
4218
 
4219
- removeLineWidget: function(widget) { widget.clear(); },
4220
 
4221
- lineInfo: function(line) {
4222
- if (typeof line == "number") {
4223
- if (!isLine(this.doc, line)) return null;
4224
- var n = line;
4225
- line = getLine(this.doc, line);
4226
- if (!line) return null;
4227
- } else {
4228
- var n = lineNo(line);
4229
- if (n == null) return null;
4230
- }
4231
- return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
4232
- textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
4233
- widgets: line.widgets};
4234
- },
4235
-
4236
- getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
4237
-
4238
- addWidget: function(pos, node, scroll, vert, horiz) {
4239
- var display = this.display;
4240
- pos = cursorCoords(this, clipPos(this.doc, pos));
4241
- var top = pos.bottom, left = pos.left;
4242
- node.style.position = "absolute";
4243
- display.sizer.appendChild(node);
4244
- if (vert == "over") {
4245
- top = pos.top;
4246
- } else if (vert == "above" || vert == "near") {
4247
- var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
4248
- hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
4249
- // Default to positioning above (if specified and possible); otherwise default to positioning below
4250
- if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
4251
- top = pos.top - node.offsetHeight;
4252
- else if (pos.bottom + node.offsetHeight <= vspace)
4253
- top = pos.bottom;
4254
- if (left + node.offsetWidth > hspace)
4255
- left = hspace - node.offsetWidth;
4256
- }
4257
- node.style.top = top + "px";
4258
- node.style.left = node.style.right = "";
4259
- if (horiz == "right") {
4260
- left = display.sizer.clientWidth - node.offsetWidth;
4261
- node.style.right = "0px";
4262
- } else {
4263
- if (horiz == "left") left = 0;
4264
- else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
4265
- node.style.left = left + "px";
4266
- }
4267
- if (scroll)
4268
- scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
4269
- },
4270
-
4271
- triggerOnKeyDown: methodOp(onKeyDown),
4272
- triggerOnKeyPress: methodOp(onKeyPress),
4273
- triggerOnKeyUp: onKeyUp,
4274
 
4275
- execCommand: function(cmd) {
4276
- if (commands.hasOwnProperty(cmd))
4277
- return commands[cmd](this);
4278
- },
4279
 
4280
- findPosH: function(from, amount, unit, visually) {
4281
- var dir = 1;
4282
- if (amount < 0) { dir = -1; amount = -amount; }
4283
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
4284
- cur = findPosH(this.doc, cur, dir, unit, visually);
4285
- if (cur.hitSide) break;
4286
- }
4287
- return cur;
4288
- },
4289
 
4290
- moveH: methodOp(function(dir, unit) {
4291
- var cm = this;
4292
- cm.extendSelectionsBy(function(range) {
4293
- if (cm.display.shift || cm.doc.extend || range.empty())
4294
- return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
4295
- else
4296
- return dir < 0 ? range.from() : range.to();
4297
- }, sel_move);
4298
- }),
4299
 
4300
- deleteH: methodOp(function(dir, unit) {
4301
- var sel = this.doc.sel, doc = this.doc;
4302
- if (sel.somethingSelected())
4303
- doc.replaceSelection("", null, "+delete");
4304
- else
4305
- deleteNearSelection(this, function(range) {
4306
- var other = findPosH(doc, range.head, dir, unit, false);
4307
- return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
4308
- });
4309
- }),
4310
 
4311
- findPosV: function(from, amount, unit, goalColumn) {
4312
- var dir = 1, x = goalColumn;
4313
- if (amount < 0) { dir = -1; amount = -amount; }
4314
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
4315
- var coords = cursorCoords(this, cur, "div");
4316
- if (x == null) x = coords.left;
4317
- else coords.left = x;
4318
- cur = findPosV(this, coords, dir, unit);
4319
- if (cur.hitSide) break;
4320
- }
4321
- return cur;
4322
- },
4323
 
4324
- moveV: methodOp(function(dir, unit) {
4325
- var cm = this, doc = this.doc, goals = [];
4326
- var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
4327
- doc.extendSelectionsBy(function(range) {
4328
- if (collapse)
4329
- return dir < 0 ? range.from() : range.to();
4330
- var headPos = cursorCoords(cm, range.head, "div");
4331
- if (range.goalColumn != null) headPos.left = range.goalColumn;
4332
- goals.push(headPos.left);
4333
- var pos = findPosV(cm, headPos, dir, unit);
4334
- if (unit == "page" && range == doc.sel.primary())
4335
- addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
4336
- return pos;
4337
- }, sel_move);
4338
- if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
4339
- doc.sel.ranges[i].goalColumn = goals[i];
4340
- }),
4341
 
4342
- toggleOverwrite: function(value) {
4343
- if (value != null && value == this.state.overwrite) return;
4344
- if (this.state.overwrite = !this.state.overwrite)
4345
- addClass(this.display.cursorDiv, "CodeMirror-overwrite");
4346
- else
4347
- rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
4348
 
4349
- signal(this, "overwriteToggle", this, this.state.overwrite);
4350
- },
4351
- hasFocus: function() { return activeElt() == this.display.input; },
4352
 
4353
- scrollTo: methodOp(function(x, y) {
4354
- if (x != null || y != null) resolveScrollToPos(this);
4355
- if (x != null) this.curOp.scrollLeft = x;
4356
- if (y != null) this.curOp.scrollTop = y;
4357
- }),
4358
- getScrollInfo: function() {
4359
- var scroller = this.display.scroller, co = scrollerCutOff;
4360
- return {left: scroller.scrollLeft, top: scroller.scrollTop,
4361
- height: scroller.scrollHeight - co, width: scroller.scrollWidth - co,
4362
- clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
4363
- },
4364
 
4365
- scrollIntoView: methodOp(function(range, margin) {
4366
- if (range == null) {
4367
- range = {from: this.doc.sel.primary().head, to: null};
4368
- if (margin == null) margin = this.options.cursorScrollMargin;
4369
- } else if (typeof range == "number") {
4370
- range = {from: Pos(range, 0), to: null};
4371
- } else if (range.from == null) {
4372
- range = {from: range, to: null};
4373
- }
4374
- if (!range.to) range.to = range.from;
4375
- range.margin = margin || 0;
4376
-
4377
- if (range.from.line != null) {
4378
- resolveScrollToPos(this);
4379
- this.curOp.scrollToPos = range;
4380
- } else {
4381
- var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
4382
- Math.min(range.from.top, range.to.top) - range.margin,
4383
- Math.max(range.from.right, range.to.right),
4384
- Math.max(range.from.bottom, range.to.bottom) + range.margin);
4385
- this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
4386
- }
4387
- }),
4388
 
4389
- setSize: methodOp(function(width, height) {
4390
- var cm = this;
4391
- function interpret(val) {
4392
- return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
4393
- }
4394
- if (width != null) cm.display.wrapper.style.width = interpret(width);
4395
- if (height != null) cm.display.wrapper.style.height = interpret(height);
4396
- if (cm.options.lineWrapping) clearLineMeasurementCache(this);
4397
- var lineNo = cm.display.viewFrom;
4398
- cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
4399
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
4400
- if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
4401
- ++lineNo;
4402
- });
4403
- cm.curOp.forceUpdate = true;
4404
- signal(cm, "refresh", this);
4405
- }),
4406
 
4407
- operation: function(f){return runInOp(this, f);},
4408
-
4409
- refresh: methodOp(function() {
4410
- var oldHeight = this.display.cachedTextHeight;
4411
- regChange(this);
4412
- this.curOp.forceUpdate = true;
4413
- clearCaches(this);
4414
- this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
4415
- updateGutterSpace(this);
4416
- if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
4417
- estimateLineHeights(this);
4418
- signal(this, "refresh", this);
4419
- }),
4420
 
4421
- swapDoc: methodOp(function(doc) {
4422
- var old = this.doc;
4423
- old.cm = null;
4424
- attachDoc(this, doc);
4425
- clearCaches(this);
4426
- resetInput(this);
4427
- this.scrollTo(doc.scrollLeft, doc.scrollTop);
4428
- signalLater(this, "swapDoc", this, old);
4429
- return old;
4430
- }),
4431
 
4432
- getInputField: function(){return this.display.input;},
4433
- getWrapperElement: function(){return this.display.wrapper;},
4434
- getScrollerElement: function(){return this.display.scroller;},
4435
- getGutterElement: function(){return this.display.gutters;}
4436
- };
4437
- eventMixin(CodeMirror);
4438
 
4439
- // OPTION DEFAULTS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4440
 
4441
- // The default configuration options.
4442
- var defaults = CodeMirror.defaults = {};
4443
- // Functions to run when options are changed.
4444
- var optionHandlers = CodeMirror.optionHandlers = {};
4445
 
4446
- function option(name, deflt, handle, notOnInit) {
4447
- CodeMirror.defaults[name] = deflt;
4448
- if (handle) optionHandlers[name] =
4449
- notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
4450
  }
4451
 
4452
- // Passed to option handlers when there is no old value.
4453
- var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
4454
-
4455
- // These two are, on init, called from the constructor because they
4456
- // have to be initialized before the editor can start at all.
4457
- option("value", "", function(cm, val) {
4458
- cm.setValue(val);
4459
- }, true);
4460
- option("mode", null, function(cm, val) {
4461
- cm.doc.modeOption = val;
4462
- loadMode(cm);
4463
- }, true);
4464
 
4465
- option("indentUnit", 2, loadMode, true);
4466
- option("indentWithTabs", false);
4467
- option("smartIndent", true);
4468
- option("tabSize", 4, function(cm) {
4469
- resetModeState(cm);
4470
- clearCaches(cm);
4471
- regChange(cm);
4472
- }, true);
4473
- option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function(cm, val) {
4474
- cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
4475
- cm.refresh();
4476
- }, true);
4477
- option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
4478
- option("electricChars", true);
4479
- option("rtlMoveVisually", !windows);
4480
- option("wholeLineUpdateBefore", true);
4481
-
4482
- option("theme", "default", function(cm) {
4483
- themeChanged(cm);
4484
- guttersChanged(cm);
4485
- }, true);
4486
- option("keyMap", "default", keyMapChanged);
4487
- option("extraKeys", null);
4488
-
4489
- option("lineWrapping", false, wrappingChanged, true);
4490
- option("gutters", [], function(cm) {
4491
- setGuttersForLineNumbers(cm.options);
4492
- guttersChanged(cm);
4493
- }, true);
4494
- option("fixedGutter", true, function(cm, val) {
4495
- cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
4496
- cm.refresh();
4497
- }, true);
4498
- option("coverGutterNextToScrollbar", false, updateScrollbars, true);
4499
- option("lineNumbers", false, function(cm) {
4500
- setGuttersForLineNumbers(cm.options);
4501
- guttersChanged(cm);
4502
- }, true);
4503
- option("firstLineNumber", 1, guttersChanged, true);
4504
- option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
4505
- option("showCursorWhenSelecting", false, updateSelection, true);
4506
-
4507
- option("resetSelectionOnContextMenu", true);
4508
-
4509
- option("readOnly", false, function(cm, val) {
4510
- if (val == "nocursor") {
4511
- onBlur(cm);
4512
- cm.display.input.blur();
4513
- cm.display.disabled = true;
4514
- } else {
4515
- cm.display.disabled = false;
4516
- if (!val) resetInput(cm);
4517
- }
4518
- });
4519
- option("disableInput", false, function(cm, val) {if (!val) resetInput(cm);}, true);
4520
- option("dragDrop", true);
4521
-
4522
- option("cursorBlinkRate", 530);
4523
- option("cursorScrollMargin", 0);
4524
- option("cursorHeight", 1, updateSelection, true);
4525
- option("singleCursorHeightPerLine", true, updateSelection, true);
4526
- option("workTime", 100);
4527
- option("workDelay", 100);
4528
- option("flattenSpans", true, resetModeState, true);
4529
- option("addModeClass", false, resetModeState, true);
4530
- option("pollInterval", 100);
4531
- option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
4532
- option("historyEventDelay", 1250);
4533
- option("viewportMargin", 10, function(cm){cm.refresh();}, true);
4534
- option("maxHighlightLength", 10000, resetModeState, true);
4535
- option("moveInputWithCursor", true, function(cm, val) {
4536
- if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;
4537
- });
4538
 
4539
- option("tabindex", null, function(cm, val) {
4540
- cm.display.input.tabIndex = val || "";
4541
- });
4542
- option("autofocus", null);
4543
 
4544
- // MODE DEFINITION AND QUERYING
 
4545
 
4546
- // Known modes, by name and by MIME
4547
- var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
 
 
 
 
 
 
 
 
 
4548
 
4549
- // Extra arguments are stored as the mode's dependencies, which is
4550
- // used by (legacy) mechanisms like loadmode.js to automatically
4551
- // load a mode. (Preferred mechanism is the require/define calls.)
4552
- CodeMirror.defineMode = function(name, mode) {
4553
- if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
4554
- if (arguments.length > 2) {
4555
- mode.dependencies = [];
4556
- for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
4557
- }
4558
- modes[name] = mode;
4559
  };
 
 
4560
 
4561
- CodeMirror.defineMIME = function(mime, spec) {
4562
- mimeModes[mime] = spec;
4563
  };
4564
 
4565
- // Given a MIME type, a {name, ...options} config object, or a name
4566
- // string, return a mode config object.
4567
- CodeMirror.resolveMode = function(spec) {
4568
- if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
4569
- spec = mimeModes[spec];
4570
- } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
4571
- var found = mimeModes[spec.name];
4572
- if (typeof found == "string") found = {name: found};
4573
- spec = createObj(found, spec);
4574
- spec.name = found.name;
4575
- } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
4576
- return CodeMirror.resolveMode("application/xml");
4577
  }
4578
- if (typeof spec == "string") return {name: spec};
4579
- else return spec || {name: "null"};
4580
- };
4581
 
4582
- // Given a mode spec (anything that resolveMode accepts), find and
4583
- // initialize an actual mode object.
4584
- CodeMirror.getMode = function(options, spec) {
4585
- var spec = CodeMirror.resolveMode(spec);
4586
- var mfactory = modes[spec.name];
4587
- if (!mfactory) return CodeMirror.getMode(options, "text/plain");
4588
- var modeObj = mfactory(options, spec);
4589
- if (modeExtensions.hasOwnProperty(spec.name)) {
4590
- var exts = modeExtensions[spec.name];
4591
- for (var prop in exts) {
4592
- if (!exts.hasOwnProperty(prop)) continue;
4593
- if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
4594
- modeObj[prop] = exts[prop];
4595
  }
4596
  }
4597
- modeObj.name = spec.name;
4598
- if (spec.helperType) modeObj.helperType = spec.helperType;
4599
- if (spec.modeProps) for (var prop in spec.modeProps)
4600
- modeObj[prop] = spec.modeProps[prop];
4601
 
4602
- return modeObj;
4603
- };
 
 
 
 
 
 
 
 
 
 
4604
 
4605
- // Minimal default mode.
4606
- CodeMirror.defineMode("null", function() {
4607
- return {token: function(stream) {stream.skipToEnd();}};
4608
- });
4609
- CodeMirror.defineMIME("text/plain", "null");
4610
 
4611
- // This can be used to attach properties to mode objects from
4612
- // outside the actual mode definition.
4613
- var modeExtensions = CodeMirror.modeExtensions = {};
4614
- CodeMirror.extendMode = function(mode, properties) {
4615
- var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
4616
- copyObj(properties, exts);
4617
- };
4618
 
4619
- // EXTENSIONS
 
 
 
 
 
4620
 
4621
- CodeMirror.defineExtension = function(name, func) {
4622
- CodeMirror.prototype[name] = func;
4623
- };
4624
- CodeMirror.defineDocExtension = function(name, func) {
4625
- Doc.prototype[name] = func;
4626
- };
4627
- CodeMirror.defineOption = option;
4628
 
4629
- var initHooks = [];
4630
- CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
 
 
 
 
 
 
 
 
4631
 
4632
- var helpers = CodeMirror.helpers = {};
4633
- CodeMirror.registerHelper = function(type, name, value) {
4634
- if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
4635
- helpers[type][name] = value;
4636
- };
4637
- CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
4638
- CodeMirror.registerHelper(type, name, value);
4639
- helpers[type]._global.push({pred: predicate, val: value});
4640
- };
4641
 
4642
- // MODE STATE HANDLING
 
 
 
4643
 
4644
- // Utility functions for working with state. Exported because nested
4645
- // modes need to do this for their inner modes.
 
 
 
 
 
 
 
 
4646
 
4647
- var copyState = CodeMirror.copyState = function(mode, state) {
4648
- if (state === true) return state;
4649
- if (mode.copyState) return mode.copyState(state);
4650
- var nstate = {};
4651
- for (var n in state) {
4652
- var val = state[n];
4653
- if (val instanceof Array) val = val.concat([]);
4654
- nstate[n] = val;
 
 
4655
  }
4656
- return nstate;
4657
- };
4658
 
4659
- var startState = CodeMirror.startState = function(mode, a1, a2) {
4660
- return mode.startState ? mode.startState(a1, a2) : true;
4661
- };
4662
 
4663
- // Given a mode and a state (for that mode), find the inner mode and
4664
- // state at the position that the state refers to.
4665
- CodeMirror.innerMode = function(mode, state) {
4666
- while (mode.innerMode) {
4667
- var info = mode.innerMode(state);
4668
- if (!info || info.mode == mode) break;
4669
- state = info.state;
4670
- mode = info.mode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4671
  }
4672
- return info || {mode: mode, state: state};
4673
- };
4674
 
4675
- // STANDARD COMMANDS
 
 
 
 
 
4676
 
4677
- // Commands are parameter-less actions that can be performed on an
4678
- // editor, mostly used for keybindings.
4679
- var commands = CodeMirror.commands = {
4680
- selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
4681
- singleSelection: function(cm) {
4682
- cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
4683
- },
4684
- killLine: function(cm) {
4685
- deleteNearSelection(cm, function(range) {
4686
- if (range.empty()) {
4687
- var len = getLine(cm.doc, range.head.line).text.length;
4688
- if (range.head.ch == len && range.head.line < cm.lastLine())
4689
- return {from: range.head, to: Pos(range.head.line + 1, 0)};
4690
- else
4691
- return {from: range.head, to: Pos(range.head.line, len)};
4692
- } else {
4693
- return {from: range.from(), to: range.to()};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4694
  }
4695
- });
4696
- },
4697
- deleteLine: function(cm) {
4698
- deleteNearSelection(cm, function(range) {
4699
- return {from: Pos(range.from().line, 0),
4700
- to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
4701
- });
4702
- },
4703
- delLineLeft: function(cm) {
4704
- deleteNearSelection(cm, function(range) {
4705
- return {from: Pos(range.from().line, 0), to: range.from()};
4706
- });
4707
- },
4708
- delWrappedLineLeft: function(cm) {
4709
- deleteNearSelection(cm, function(range) {
4710
- var top = cm.charCoords(range.head, "div").top + 5;
4711
- var leftPos = cm.coordsChar({left: 0, top: top}, "div");
4712
- return {from: leftPos, to: range.from()};
4713
- });
4714
- },
4715
- delWrappedLineRight: function(cm) {
4716
- deleteNearSelection(cm, function(range) {
4717
- var top = cm.charCoords(range.head, "div").top + 5;
4718
- var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
4719
- return {from: range.from(), to: rightPos };
4720
- });
4721
- },
4722
- undo: function(cm) {cm.undo();},
4723
- redo: function(cm) {cm.redo();},
4724
- undoSelection: function(cm) {cm.undoSelection();},
4725
- redoSelection: function(cm) {cm.redoSelection();},
4726
- goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
4727
- goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
4728
- goLineStart: function(cm) {
4729
- cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
4730
- {origin: "+move", bias: 1});
4731
- },
4732
- goLineStartSmart: function(cm) {
4733
- cm.extendSelectionsBy(function(range) {
4734
- var start = lineStart(cm, range.head.line);
4735
- var line = cm.getLineHandle(start.line);
4736
- var order = getOrder(line);
4737
- if (!order || order[0].level == 0) {
4738
- var firstNonWS = Math.max(0, line.text.search(/\S/));
4739
- var inWS = range.head.line == start.line && range.head.ch <= firstNonWS && range.head.ch;
4740
- return Pos(start.line, inWS ? 0 : firstNonWS);
4741
  }
4742
- return start;
4743
- }, {origin: "+move", bias: 1});
4744
- },
4745
- goLineEnd: function(cm) {
4746
- cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
4747
- {origin: "+move", bias: -1});
4748
- },
4749
- goLineRight: function(cm) {
4750
- cm.extendSelectionsBy(function(range) {
4751
- var top = cm.charCoords(range.head, "div").top + 5;
4752
- return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
4753
- }, sel_move);
4754
- },
4755
- goLineLeft: function(cm) {
4756
- cm.extendSelectionsBy(function(range) {
4757
- var top = cm.charCoords(range.head, "div").top + 5;
4758
- return cm.coordsChar({left: 0, top: top}, "div");
4759
- }, sel_move);
4760
- },
4761
- goLineUp: function(cm) {cm.moveV(-1, "line");},
4762
- goLineDown: function(cm) {cm.moveV(1, "line");},
4763
- goPageUp: function(cm) {cm.moveV(-1, "page");},
4764
- goPageDown: function(cm) {cm.moveV(1, "page");},
4765
- goCharLeft: function(cm) {cm.moveH(-1, "char");},
4766
- goCharRight: function(cm) {cm.moveH(1, "char");},
4767
- goColumnLeft: function(cm) {cm.moveH(-1, "column");},
4768
- goColumnRight: function(cm) {cm.moveH(1, "column");},
4769
- goWordLeft: function(cm) {cm.moveH(-1, "word");},
4770
- goGroupRight: function(cm) {cm.moveH(1, "group");},
4771
- goGroupLeft: function(cm) {cm.moveH(-1, "group");},
4772
- goWordRight: function(cm) {cm.moveH(1, "word");},
4773
- delCharBefore: function(cm) {cm.deleteH(-1, "char");},
4774
- delCharAfter: function(cm) {cm.deleteH(1, "char");},
4775
- delWordBefore: function(cm) {cm.deleteH(-1, "word");},
4776
- delWordAfter: function(cm) {cm.deleteH(1, "word");},
4777
- delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
4778
- delGroupAfter: function(cm) {cm.deleteH(1, "group");},
4779
- indentAuto: function(cm) {cm.indentSelection("smart");},
4780
- indentMore: function(cm) {cm.indentSelection("add");},
4781
- indentLess: function(cm) {cm.indentSelection("subtract");},
4782
- insertTab: function(cm) {cm.replaceSelection("\t");},
4783
- insertSoftTab: function(cm) {
4784
- var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
4785
- for (var i = 0; i < ranges.length; i++) {
4786
- var pos = ranges[i].from();
4787
- var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
4788
- spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
4789
  }
4790
- cm.replaceSelections(spaces);
4791
- },
4792
- defaultTab: function(cm) {
4793
- if (cm.somethingSelected()) cm.indentSelection("add");
4794
- else cm.execCommand("insertTab");
4795
- },
4796
- transposeChars: function(cm) {
4797
- runInOp(cm, function() {
4798
- var ranges = cm.listSelections(), newSel = [];
4799
- for (var i = 0; i < ranges.length; i++) {
4800
- var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
4801
- if (line) {
4802
- if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
4803
- if (cur.ch > 0) {
4804
- cur = new Pos(cur.line, cur.ch + 1);
4805
- cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
4806
- Pos(cur.line, cur.ch - 2), cur, "+transpose");
4807
- } else if (cur.line > cm.doc.first) {
4808
- var prev = getLine(cm.doc, cur.line - 1).text;
4809
- if (prev)
4810
- cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1),
4811
- Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
4812
- }
4813
- }
4814
- newSel.push(new Range(cur, cur));
4815
- }
4816
- cm.setSelections(newSel);
4817
- });
4818
- },
4819
- newlineAndIndent: function(cm) {
4820
- runInOp(cm, function() {
4821
- var len = cm.listSelections().length;
4822
- for (var i = 0; i < len; i++) {
4823
- var range = cm.listSelections()[i];
4824
- cm.replaceRange("\n", range.anchor, range.head, "+input");
4825
- cm.indentLine(range.from().line + 1, null, true);
4826
- ensureCursorVisible(cm);
4827
- }
4828
- });
4829
- },
4830
- toggleOverwrite: function(cm) {cm.toggleOverwrite();}
4831
- };
4832
-
4833
- // STANDARD KEYMAPS
4834
 
4835
- var keyMap = CodeMirror.keyMap = {};
4836
- keyMap.basic = {
4837
- "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
4838
- "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
4839
- "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
4840
- "Tab": "defaultTab", "Shift-Tab": "indentAuto",
4841
- "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
4842
- "Esc": "singleSelection"
4843
- };
4844
- // Note that the save and find-related commands aren't defined by
4845
- // default. User code or addons can define them. Unknown commands
4846
- // are simply ignored.
4847
- keyMap.pcDefault = {
4848
- "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
4849
- "Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
4850
- "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
4851
- "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
4852
- "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
4853
- "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
4854
- "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
4855
- fallthrough: "basic"
4856
- };
4857
- keyMap.macDefault = {
4858
- "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
4859
- "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
4860
- "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
4861
- "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
4862
- "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
4863
- "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
4864
- "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection",
4865
- fallthrough: ["basic", "emacsy"]
4866
- };
4867
- // Very basic readline/emacs-style bindings, which are standard on Mac.
4868
- keyMap.emacsy = {
4869
- "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
4870
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
4871
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
4872
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
4873
- };
4874
- keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
4875
 
4876
- // KEYMAP DISPATCH
 
 
 
 
4877
 
4878
- function getKeyMap(val) {
4879
- if (typeof val == "string") return keyMap[val];
4880
- else return val;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4881
  }
4882
 
4883
- // Given an array of keymaps and a key name, call handle on any
4884
- // bindings found, until that returns a truthy value, at which point
4885
- // we consider the key handled. Implements things like binding a key
4886
- // to false stopping further handling and keymap fallthrough.
4887
- var lookupKey = CodeMirror.lookupKey = function(name, maps, handle) {
4888
- function lookup(map) {
4889
- map = getKeyMap(map);
4890
- var found = map[name];
4891
- if (found === false) return "stop";
4892
- if (found != null && handle(found)) return true;
4893
- if (map.nofallthrough) return "stop";
 
 
 
 
 
 
 
 
 
4894
 
4895
- var fallthrough = map.fallthrough;
4896
- if (fallthrough == null) return false;
4897
- if (Object.prototype.toString.call(fallthrough) != "[object Array]")
4898
- return lookup(fallthrough);
4899
- for (var i = 0; i < fallthrough.length; ++i) {
4900
- var done = lookup(fallthrough[i]);
4901
- if (done) return done;
 
4902
  }
4903
- return false;
4904
  }
 
 
 
4905
 
4906
- for (var i = 0; i < maps.length; ++i) {
4907
- var done = lookup(maps[i]);
4908
- if (done) return done != "stop";
 
 
 
 
 
 
 
 
 
 
 
 
 
4909
  }
4910
- };
 
 
4911
 
4912
- // Modifier key presses don't count as 'real' key presses for the
4913
- // purpose of keymap fallthrough.
4914
- var isModifierKey = CodeMirror.isModifierKey = function(event) {
4915
- var name = keyNames[event.keyCode];
4916
- return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
4917
- };
4918
 
4919
- // Look up the name of a key as indicated by an event object.
4920
- var keyName = CodeMirror.keyName = function(event, noShift) {
4921
- if (presto && event.keyCode == 34 && event["char"]) return false;
4922
- var name = keyNames[event.keyCode];
4923
- if (name == null || event.altGraphKey) return false;
4924
- if (event.altKey) name = "Alt-" + name;
4925
- if (flipCtrlCmd ? event.metaKey : event.ctrlKey) name = "Ctrl-" + name;
4926
- if (flipCtrlCmd ? event.ctrlKey : event.metaKey) name = "Cmd-" + name;
4927
- if (!noShift && event.shiftKey) name = "Shift-" + name;
4928
- return name;
4929
- };
4930
 
4931
- // FROMTEXTAREA
 
 
4932
 
4933
- CodeMirror.fromTextArea = function(textarea, options) {
4934
- if (!options) options = {};
4935
- options.value = textarea.value;
4936
- if (!options.tabindex && textarea.tabindex)
4937
- options.tabindex = textarea.tabindex;
4938
- if (!options.placeholder && textarea.placeholder)
4939
- options.placeholder = textarea.placeholder;
4940
- // Set autofocus to true if this textarea is focused, or if it has
4941
- // autofocus and no other element is focused.
4942
- if (options.autofocus == null) {
4943
- var hasFocus = activeElt();
4944
- options.autofocus = hasFocus == textarea ||
4945
- textarea.getAttribute("autofocus") != null && hasFocus == document.body;
4946
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4947
 
4948
- function save() {textarea.value = cm.getValue();}
4949
- if (textarea.form) {
4950
- on(textarea.form, "submit", save);
4951
- // Deplorable hack to make the submit method do the right thing.
4952
- if (!options.leaveSubmitMethodAlone) {
4953
- var form = textarea.form, realSubmit = form.submit;
4954
- try {
4955
- var wrappedSubmit = form.submit = function() {
4956
- save();
4957
- form.submit = realSubmit;
4958
- form.submit();
4959
- form.submit = wrappedSubmit;
4960
- };
4961
- } catch(e) {}
4962
- }
4963
  }
4964
 
4965
- textarea.style.display = "none";
4966
- var cm = CodeMirror(function(node) {
4967
- textarea.parentNode.insertBefore(node, textarea.nextSibling);
4968
- }, options);
4969
- cm.save = save;
4970
- cm.getTextArea = function() { return textarea; };
4971
- cm.toTextArea = function() {
4972
- save();
4973
- textarea.parentNode.removeChild(cm.getWrapperElement());
4974
- textarea.style.display = "";
4975
- if (textarea.form) {
4976
- off(textarea.form, "submit", save);
4977
- if (typeof textarea.form.submit == "function")
4978
- textarea.form.submit = realSubmit;
4979
- }
4980
- };
4981
- return cm;
4982
- };
4983
 
4984
- // STRING STREAM
 
4985
 
4986
- // Fed to the mode parsers, provides helper functions to make
4987
- // parsers more succinct.
 
 
 
 
 
4988
 
4989
- var StringStream = CodeMirror.StringStream = function(string, tabSize) {
4990
- this.pos = this.start = 0;
4991
- this.string = string;
4992
- this.tabSize = tabSize || 8;
4993
- this.lastColumnPos = this.lastColumnValue = 0;
4994
- this.lineStart = 0;
4995
- };
4996
 
4997
- StringStream.prototype = {
4998
- eol: function() {return this.pos >= this.string.length;},
4999
- sol: function() {return this.pos == this.lineStart;},
5000
- peek: function() {return this.string.charAt(this.pos) || undefined;},
5001
- next: function() {
5002
- if (this.pos < this.string.length)
5003
- return this.string.charAt(this.pos++);
5004
- },
5005
- eat: function(match) {
5006
- var ch = this.string.charAt(this.pos);
5007
- if (typeof match == "string") var ok = ch == match;
5008
- else var ok = ch && (match.test ? match.test(ch) : match(ch));
5009
- if (ok) {++this.pos; return ch;}
5010
- },
5011
- eatWhile: function(match) {
5012
- var start = this.pos;
5013
- while (this.eat(match)){}
5014
- return this.pos > start;
5015
- },
5016
- eatSpace: function() {
5017
- var start = this.pos;
5018
- while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
5019
- return this.pos > start;
5020
- },
5021
- skipToEnd: function() {this.pos = this.string.length;},
5022
- skipTo: function(ch) {
5023
- var found = this.string.indexOf(ch, this.pos);
5024
- if (found > -1) {this.pos = found; return true;}
5025
- },
5026
- backUp: function(n) {this.pos -= n;},
5027
- column: function() {
5028
- if (this.lastColumnPos < this.start) {
5029
- this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
5030
- this.lastColumnPos = this.start;
5031
- }
5032
- return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
5033
- },
5034
- indentation: function() {
5035
- return countColumn(this.string, null, this.tabSize) -
5036
- (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
5037
- },
5038
- match: function(pattern, consume, caseInsensitive) {
5039
- if (typeof pattern == "string") {
5040
- var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
5041
- var substr = this.string.substr(this.pos, pattern.length);
5042
- if (cased(substr) == cased(pattern)) {
5043
- if (consume !== false) this.pos += pattern.length;
5044
- return true;
5045
- }
5046
- } else {
5047
- var match = this.string.slice(this.pos).match(pattern);
5048
- if (match && match.index > 0) return null;
5049
- if (match && consume !== false) this.pos += match[0].length;
5050
- return match;
5051
- }
5052
- },
5053
- current: function(){return this.string.slice(this.start, this.pos);},
5054
- hideFirstChars: function(n, inner) {
5055
- this.lineStart += n;
5056
- try { return inner(); }
5057
- finally { this.lineStart -= n; }
5058
- }
5059
- };
5060
 
5061
- // TEXTMARKERS
 
5062
 
5063
- // Created with markText and setBookmark methods. A TextMarker is a
5064
- // handle that can be used to clear or find a marked position in the
5065
- // document. Line objects hold arrays (markedSpans) containing
5066
- // {from, to, marker} object pointing to such marker objects, and
5067
- // indicating that such a marker is present on that line. Multiple
5068
- // lines may point to the same marker when it spans across lines.
5069
- // The spans will have null for their from/to properties when the
5070
- // marker continues beyond the start/end of the line. Markers have
5071
- // links back to the lines they currently touch.
5072
 
5073
- var TextMarker = CodeMirror.TextMarker = function(doc, type) {
5074
- this.lines = [];
5075
- this.type = type;
5076
- this.doc = doc;
5077
- };
5078
- eventMixin(TextMarker);
5079
 
5080
- // Clear the marker.
5081
- TextMarker.prototype.clear = function() {
5082
- if (this.explicitlyCleared) return;
5083
- var cm = this.doc.cm, withOp = cm && !cm.curOp;
5084
- if (withOp) startOperation(cm);
5085
- if (hasHandler(this, "clear")) {
5086
- var found = this.find();
5087
- if (found) signalLater(this, "clear", found.from, found.to);
5088
- }
5089
- var min = null, max = null;
5090
- for (var i = 0; i < this.lines.length; ++i) {
5091
- var line = this.lines[i];
5092
- var span = getMarkedSpanFor(line.markedSpans, this);
5093
- if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
5094
- else if (cm) {
5095
- if (span.to != null) max = lineNo(line);
5096
- if (span.from != null) min = lineNo(line);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5097
  }
5098
- line.markedSpans = removeMarkedSpan(line.markedSpans, span);
5099
- if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
5100
- updateLineHeight(line, textHeight(cm.display));
5101
  }
5102
- if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
5103
- var visual = visualLine(this.lines[i]), len = lineLength(visual);
5104
- if (len > cm.display.maxLineLength) {
5105
- cm.display.maxLine = visual;
5106
- cm.display.maxLineLength = len;
5107
- cm.display.maxLineChanged = true;
5108
- }
 
 
 
 
 
 
 
 
 
 
 
 
5109
  }
5110
 
5111
- if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
5112
- this.lines.length = 0;
5113
- this.explicitlyCleared = true;
5114
- if (this.atomic && this.doc.cantEdit) {
5115
- this.doc.cantEdit = false;
5116
- if (cm) reCheckSelection(cm.doc);
 
 
5117
  }
5118
- if (cm) signalLater(cm, "markerCleared", cm, this);
5119
- if (withOp) endOperation(cm);
5120
- if (this.parent) this.parent.clear();
5121
- };
5122
 
5123
- // Find the position of the marker in the document. Returns a {from,
5124
- // to} object by default. Side can be passed to get a specific side
5125
- // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
5126
- // Pos objects returned contain a line object, rather than a line
5127
- // number (used to prevent looking up the same line twice).
5128
- TextMarker.prototype.find = function(side, lineObj) {
5129
- if (side == null && this.type == "bookmark") side = 1;
5130
- var from, to;
5131
- for (var i = 0; i < this.lines.length; ++i) {
5132
- var line = this.lines[i];
5133
- var span = getMarkedSpanFor(line.markedSpans, this);
5134
- if (span.from != null) {
5135
- from = Pos(lineObj ? line : lineNo(line), span.from);
5136
- if (side == -1) return from;
5137
- }
5138
- if (span.to != null) {
5139
- to = Pos(lineObj ? line : lineNo(line), span.to);
5140
- if (side == 1) return to;
5141
  }
5142
  }
5143
- return from && {from: from, to: to};
5144
- };
5145
 
5146
- // Signals that the marker's widget changed, and surrounding layout
5147
- // should be recomputed.
5148
- TextMarker.prototype.changed = function() {
5149
- var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
5150
- if (!pos || !cm) return;
5151
- runInOp(cm, function() {
5152
- var line = pos.line, lineN = lineNo(pos.line);
5153
- var view = findViewForLine(cm, lineN);
5154
- if (view) {
5155
- clearLineMeasurementCacheFor(view);
5156
- cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
5157
- }
5158
- cm.curOp.updateMaxLine = true;
5159
- if (!lineIsHidden(widget.doc, line) && widget.height != null) {
5160
- var oldHeight = widget.height;
5161
- widget.height = null;
5162
- var dHeight = widgetHeight(widget) - oldHeight;
5163
- if (dHeight)
5164
- updateLineHeight(line, line.height + dHeight);
5165
- }
5166
- });
5167
  };
5168
 
5169
- TextMarker.prototype.attachLine = function(line) {
5170
- if (!this.lines.length && this.doc.cm) {
5171
- var op = this.doc.cm.curOp;
5172
- if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
5173
- (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
 
 
 
 
 
5174
  }
5175
- this.lines.push(line);
5176
  };
5177
- TextMarker.prototype.detachLine = function(line) {
5178
- this.lines.splice(indexOf(this.lines, line), 1);
5179
- if (!this.lines.length && this.doc.cm) {
5180
- var op = this.doc.cm.curOp;
5181
- (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
5182
- }
 
 
5183
  };
5184
 
5185
- // Collapsed markers have unique ids, in order to be able to order
5186
- // them, which is needed for uniquely determining an outer marker
5187
- // when they overlap (they may nest, but not partially overlap).
5188
- var nextMarkerId = 0;
5189
 
5190
- // Create a marker, wire it up to the right lines, and
5191
- function markText(doc, from, to, options, type) {
5192
- // Shared markers (across linked documents) are handled separately
5193
- // (markTextShared will call out to this again, once per
5194
- // document).
5195
- if (options && options.shared) return markTextShared(doc, from, to, options, type);
5196
- // Ensure we are in an operation.
5197
- if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
5198
 
5199
- var marker = new TextMarker(doc, type), diff = cmp(from, to);
5200
- if (options) copyObj(options, marker, false);
5201
- // Don't connect empty markers unless clearWhenEmpty is false
5202
- if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
5203
- return marker;
5204
- if (marker.replacedWith) {
5205
- // Showing up as a widget implies collapsed (widget replaces text)
5206
- marker.collapsed = true;
5207
- marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
5208
- if (!options.handleMouseEvents) marker.widgetNode.ignoreEvents = true;
5209
- if (options.insertLeft) marker.widgetNode.insertLeft = true;
5210
- }
5211
- if (marker.collapsed) {
5212
- if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
5213
- from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
5214
- throw new Error("Inserting collapsed marker partially overlapping an existing one");
5215
- sawCollapsedSpans = true;
5216
- }
5217
 
5218
- if (marker.addToHistory)
5219
- addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
 
 
 
 
 
 
5220
 
5221
- var curLine = from.line, cm = doc.cm, updateMaxLine;
5222
- doc.iter(curLine, to.line + 1, function(line) {
5223
- if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
5224
- updateMaxLine = true;
5225
- if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
5226
- addMarkedSpan(line, new MarkedSpan(marker,
5227
- curLine == from.line ? from.ch : null,
5228
- curLine == to.line ? to.ch : null));
5229
- ++curLine;
5230
- });
5231
- // lineIsHidden depends on the presence of the spans, so needs a second pass
5232
- if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
5233
- if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
5234
- });
5235
 
5236
- if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
 
 
5237
 
5238
- if (marker.readOnly) {
5239
- sawReadOnlySpans = true;
5240
- if (doc.history.done.length || doc.history.undone.length)
5241
- doc.clearHistory();
5242
- }
5243
- if (marker.collapsed) {
5244
- marker.id = ++nextMarkerId;
5245
- marker.atomic = true;
5246
- }
5247
- if (cm) {
5248
- // Sync editor state
5249
- if (updateMaxLine) cm.curOp.updateMaxLine = true;
5250
- if (marker.collapsed)
5251
- regChange(cm, from.line, to.line + 1);
5252
- else if (marker.className || marker.title || marker.startStyle || marker.endStyle)
5253
- for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
5254
- if (marker.atomic) reCheckSelection(cm.doc);
5255
- signalLater(cm, "markerAdded", cm, marker);
5256
  }
5257
- return marker;
5258
  }
5259
 
5260
- // SHARED TEXTMARKERS
 
 
5261
 
5262
- // A shared marker spans multiple linked documents. It is
5263
- // implemented as a meta-marker-object controlling multiple normal
5264
- // markers.
5265
- var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
5266
- this.markers = markers;
5267
- this.primary = primary;
5268
- for (var i = 0; i < markers.length; ++i)
5269
- markers[i].parent = this;
5270
- };
5271
- eventMixin(SharedTextMarker);
5272
 
5273
- SharedTextMarker.prototype.clear = function() {
5274
- if (this.explicitlyCleared) return;
5275
- this.explicitlyCleared = true;
5276
- for (var i = 0; i < this.markers.length; ++i)
5277
- this.markers[i].clear();
5278
- signalLater(this, "clear");
5279
- };
5280
- SharedTextMarker.prototype.find = function(side, lineObj) {
5281
- return this.primary.find(side, lineObj);
5282
- };
5283
 
5284
- function markTextShared(doc, from, to, options, type) {
5285
- options = copyObj(options);
5286
- options.shared = false;
5287
- var markers = [markText(doc, from, to, options, type)], primary = markers[0];
5288
- var widget = options.widgetNode;
5289
- linkedDocs(doc, function(doc) {
5290
- if (widget) options.widgetNode = widget.cloneNode(true);
5291
- markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
5292
- for (var i = 0; i < doc.linked.length; ++i)
5293
- if (doc.linked[i].isParent) return;
5294
- primary = lst(markers);
5295
- });
5296
- return new SharedTextMarker(markers, primary);
5297
  }
5298
 
5299
- function findSharedMarkers(doc) {
5300
- return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
5301
- function(m) { return m.parent; });
 
 
 
 
 
5302
  }
5303
 
5304
- function copySharedMarkers(doc, markers) {
5305
- for (var i = 0; i < markers.length; i++) {
5306
- var marker = markers[i], pos = marker.find();
5307
- var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
5308
- if (cmp(mFrom, mTo)) {
5309
- var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
5310
- marker.markers.push(subMark);
5311
- subMark.parent = marker;
5312
- }
5313
- }
5314
  }
5315
 
5316
- function detachSharedMarkers(markers) {
5317
- for (var i = 0; i < markers.length; i++) {
5318
- var marker = markers[i], linked = [marker.primary.doc];;
5319
- linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
5320
- for (var j = 0; j < marker.markers.length; j++) {
5321
- var subMarker = marker.markers[j];
5322
- if (indexOf(linked, subMarker.doc) == -1) {
5323
- subMarker.parent = null;
5324
- marker.markers.splice(j--, 1);
5325
- }
 
 
 
 
 
 
5326
  }
5327
  }
 
5328
  }
5329
 
5330
- // TEXTMARKER SPANS
5331
 
5332
- function MarkedSpan(marker, from, to) {
5333
- this.marker = marker;
5334
- this.from = from; this.to = to;
5335
  }
5336
 
5337
- // Search an array of spans for a span matching the given marker.
5338
- function getMarkedSpanFor(spans, marker) {
5339
- if (spans) for (var i = 0; i < spans.length; ++i) {
5340
- var span = spans[i];
5341
- if (span.marker == marker) return span;
5342
- }
5343
- }
5344
- // Remove a span from an array, returning undefined if no spans are
5345
- // left (we don't store arrays for lines without spans).
5346
- function removeMarkedSpan(spans, span) {
5347
- for (var r, i = 0; i < spans.length; ++i)
5348
- if (spans[i] != span) (r || (r = [])).push(spans[i]);
5349
- return r;
5350
  }
5351
- // Add a span to a line.
5352
- function addMarkedSpan(line, span) {
5353
- line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
5354
- span.marker.attachLine(line);
 
 
 
 
 
5355
  }
5356
 
5357
- // Used for the algorithm that adjusts markers for a change in the
5358
- // document. These functions cut an array of spans at a given
5359
- // character position, returning an array of remaining chunks (or
5360
- // undefined if nothing remains).
5361
- function markedSpansBefore(old, startCh, isInsert) {
5362
- if (old) for (var i = 0, nw; i < old.length; ++i) {
5363
- var span = old[i], marker = span.marker;
5364
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
5365
- if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
5366
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
5367
- (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
5368
- }
5369
  }
5370
- return nw;
5371
- }
5372
- function markedSpansAfter(old, endCh, isInsert) {
5373
- if (old) for (var i = 0, nw; i < old.length; ++i) {
5374
- var span = old[i], marker = span.marker;
5375
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
5376
- if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
5377
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
5378
- (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
5379
- span.to == null ? null : span.to - endCh));
5380
- }
5381
  }
5382
- return nw;
5383
- }
5384
-
5385
- // Given a change object, compute the new set of marker spans that
5386
- // cover the line in which the change took place. Removes spans
5387
- // entirely within the change, reconnects spans belonging to the
5388
- // same marker that appear on both sides of the change, and cuts off
5389
- // spans partially within the change. Returns an array of span
5390
- // arrays with one element for each line in (after) the change.
5391
- function stretchSpansOverChange(doc, change) {
5392
- var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
5393
- var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
5394
- if (!oldFirst && !oldLast) return null;
5395
 
5396
- var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
5397
- // Get the spans that 'stick out' on both sides
5398
- var first = markedSpansBefore(oldFirst, startCh, isInsert);
5399
- var last = markedSpansAfter(oldLast, endCh, isInsert);
5400
 
5401
- // Next, merge those two ends
5402
- var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
5403
- if (first) {
5404
- // Fix up .to properties of first
5405
- for (var i = 0; i < first.length; ++i) {
5406
- var span = first[i];
5407
- if (span.to == null) {
5408
- var found = getMarkedSpanFor(last, span.marker);
5409
- if (!found) span.to = startCh;
5410
- else if (sameLine) span.to = found.to == null ? null : found.to + offset;
5411
- }
5412
- }
5413
- }
5414
- if (last) {
5415
- // Fix up .from in last (or move them into first in case of sameLine)
5416
- for (var i = 0; i < last.length; ++i) {
5417
- var span = last[i];
5418
- if (span.to != null) span.to += offset;
5419
- if (span.from == null) {
5420
- var found = getMarkedSpanFor(first, span.marker);
5421
- if (!found) {
5422
- span.from = offset;
5423
- if (sameLine) (first || (first = [])).push(span);
5424
- }
5425
- } else {
5426
- span.from += offset;
5427
- if (sameLine) (first || (first = [])).push(span);
5428
- }
5429
  }
 
 
 
 
 
 
 
 
 
5430
  }
5431
- // Make sure we didn't create any zero-length spans
5432
- if (first) first = clearEmptySpans(first);
5433
- if (last && last != first) last = clearEmptySpans(last);
5434
 
5435
- var newMarkers = [first];
5436
- if (!sameLine) {
5437
- // Fill gap with whole-line-spans
5438
- var gap = change.text.length - 2, gapMarkers;
5439
- if (gap > 0 && first)
5440
- for (var i = 0; i < first.length; ++i)
5441
- if (first[i].to == null)
5442
- (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
5443
- for (var i = 0; i < gap; ++i)
5444
- newMarkers.push(gapMarkers);
5445
- newMarkers.push(last);
5446
- }
5447
- return newMarkers;
5448
  }
5449
 
5450
- // Remove spans that are empty and don't have a clearWhenEmpty
5451
- // option of false.
5452
- function clearEmptySpans(spans) {
5453
- for (var i = 0; i < spans.length; ++i) {
5454
- var span = spans[i];
5455
- if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
5456
- spans.splice(i--, 1);
 
 
 
 
5457
  }
5458
- if (!spans.length) return null;
5459
- return spans;
5460
  }
5461
 
5462
- // Used for un/re-doing changes from the history. Combines the
5463
- // result of computing the existing spans with the set of spans that
5464
- // existed in the history (so that deleting around a span and then
5465
- // undoing brings back the span).
5466
- function mergeOldSpans(doc, change) {
5467
- var old = getOldSpans(doc, change);
5468
- var stretched = stretchSpansOverChange(doc, change);
5469
- if (!old) return stretched;
5470
- if (!stretched) return old;
 
 
 
5471
 
5472
- for (var i = 0; i < old.length; ++i) {
5473
- var oldCur = old[i], stretchCur = stretched[i];
5474
- if (oldCur && stretchCur) {
5475
- spans: for (var j = 0; j < stretchCur.length; ++j) {
5476
- var span = stretchCur[j];
5477
- for (var k = 0; k < oldCur.length; ++k)
5478
- if (oldCur[k].marker == span.marker) continue spans;
5479
- oldCur.push(span);
5480
- }
5481
- } else if (stretchCur) {
5482
- old[i] = stretchCur;
5483
- }
5484
- }
5485
- return old;
5486
  }
5487
 
5488
- // Used to 'clip' out readOnly ranges when making a change.
5489
- function removeReadOnlyRanges(doc, from, to) {
5490
- var markers = null;
5491
- doc.iter(from.line, to.line + 1, function(line) {
5492
- if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
5493
- var mark = line.markedSpans[i].marker;
5494
- if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
5495
- (markers || (markers = [])).push(mark);
5496
- }
5497
  });
5498
- if (!markers) return null;
5499
- var parts = [{from: from, to: to}];
5500
- for (var i = 0; i < markers.length; ++i) {
5501
- var mk = markers[i], m = mk.find(0);
5502
- for (var j = 0; j < parts.length; ++j) {
5503
- var p = parts[j];
5504
- if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
5505
- var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
5506
- if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
5507
- newParts.push({from: p.from, to: m.from});
5508
- if (dto > 0 || !mk.inclusiveRight && !dto)
5509
- newParts.push({from: m.to, to: p.to});
5510
- parts.splice.apply(parts, newParts);
5511
- j += newParts.length - 1;
5512
- }
5513
- }
5514
- return parts;
5515
  }
5516
 
5517
- // Connect or disconnect spans from a line.
5518
- function detachMarkedSpans(line) {
5519
- var spans = line.markedSpans;
5520
- if (!spans) return;
5521
- for (var i = 0; i < spans.length; ++i)
5522
- spans[i].marker.detachLine(line);
5523
- line.markedSpans = null;
5524
- }
5525
- function attachMarkedSpans(line, spans) {
5526
- if (!spans) return;
5527
- for (var i = 0; i < spans.length; ++i)
5528
- spans[i].marker.attachLine(line);
5529
- line.markedSpans = spans;
5530
  }
5531
 
5532
- // Helpers used when computing which overlapping collapsed span
5533
- // counts as the larger one.
5534
- function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
5535
- function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
 
 
 
 
5536
 
5537
- // Returns a number indicating which of two overlapping collapsed
5538
- // spans is larger (and thus includes the other). Falls back to
5539
- // comparing ids when the spans cover exactly the same range.
5540
- function compareCollapsedMarkers(a, b) {
5541
- var lenDiff = a.lines.length - b.lines.length;
5542
- if (lenDiff != 0) return lenDiff;
5543
- var aPos = a.find(), bPos = b.find();
5544
- var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
5545
- if (fromCmp) return -fromCmp;
5546
- var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
5547
- if (toCmp) return toCmp;
5548
- return b.id - a.id;
5549
- }
5550
-
5551
- // Find out whether a line ends or starts in a collapsed span. If
5552
- // so, return the marker for that span.
5553
- function collapsedSpanAtSide(line, start) {
5554
- var sps = sawCollapsedSpans && line.markedSpans, found;
5555
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
5556
- sp = sps[i];
5557
- if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
5558
- (!found || compareCollapsedMarkers(found, sp.marker) < 0))
5559
- found = sp.marker;
5560
  }
5561
- return found;
5562
  }
5563
- function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
5564
- function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
5565
 
5566
- // Test whether there exists a collapsed span that partially
5567
- // overlaps (covers the start or end, but not both) of a new span.
5568
- // Such overlap is not allowed.
5569
- function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
5570
- var line = getLine(doc, lineNo);
5571
- var sps = sawCollapsedSpans && line.markedSpans;
5572
- if (sps) for (var i = 0; i < sps.length; ++i) {
5573
- var sp = sps[i];
5574
- if (!sp.marker.collapsed) continue;
5575
- var found = sp.marker.find(0);
5576
- var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
5577
- var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
5578
- if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
5579
- if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
5580
- fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
5581
- return true;
5582
  }
5583
  }
5584
 
5585
- // A visual line is a line as drawn on the screen. Folding, for
5586
- // example, can cause multiple logical lines to appear on the same
5587
- // visual line. This finds the start of the visual line that the
5588
- // given line is part of (usually that is the line itself).
5589
- function visualLine(line) {
5590
- var merged;
5591
- while (merged = collapsedSpanAtStart(line))
5592
- line = merged.find(-1, true).line;
5593
- return line;
5594
- }
5595
 
5596
- // Returns an array of logical lines that continue the visual line
5597
- // started by the argument, or undefined if there are no such lines.
5598
- function visualLineContinued(line) {
5599
- var merged, lines;
5600
- while (merged = collapsedSpanAtEnd(line)) {
5601
- line = merged.find(1, true).line;
5602
- (lines || (lines = [])).push(line);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5603
  }
5604
- return lines;
5605
- }
 
 
 
5606
 
5607
- // Get the line number of the start of the visual line that the
5608
- // given line number is part of.
5609
- function visualLineNo(doc, lineN) {
5610
- var line = getLine(doc, lineN), vis = visualLine(line);
5611
- if (line == vis) return lineN;
5612
- return lineNo(vis);
5613
- }
5614
- // Get the line number of the start of the next visual line after
5615
- // the given line.
5616
- function visualLineEndNo(doc, lineN) {
5617
- if (lineN > doc.lastLine()) return lineN;
5618
- var line = getLine(doc, lineN), merged;
5619
- if (!lineIsHidden(doc, line)) return lineN;
5620
- while (merged = collapsedSpanAtEnd(line))
5621
- line = merged.find(1, true).line;
5622
- return lineNo(line) + 1;
5623
  }
5624
 
5625
- // Compute whether a line is hidden. Lines count as hidden when they
5626
- // are part of a visual line that starts with another line, or when
5627
- // they are entirely covered by collapsed, non-widget span.
5628
- function lineIsHidden(doc, line) {
5629
- var sps = sawCollapsedSpans && line.markedSpans;
5630
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
5631
- sp = sps[i];
5632
- if (!sp.marker.collapsed) continue;
5633
- if (sp.from == null) return true;
5634
- if (sp.marker.widgetNode) continue;
5635
- if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
5636
- return true;
5637
- }
5638
- }
5639
- function lineIsHiddenInner(doc, line, span) {
5640
- if (span.to == null) {
5641
- var end = span.marker.find(1, true);
5642
- return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
5643
- }
5644
- if (span.marker.inclusiveRight && span.to == line.text.length)
5645
- return true;
5646
- for (var sp, i = 0; i < line.markedSpans.length; ++i) {
5647
- sp = line.markedSpans[i];
5648
- if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
5649
- (sp.to == null || sp.to != span.from) &&
5650
- (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
5651
- lineIsHiddenInner(doc, line, sp)) return true;
5652
- }
5653
  }
5654
 
5655
- // LINE WIDGETS
5656
-
5657
- // Line widgets are block elements displayed above or below a line.
 
 
 
5658
 
5659
- var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
5660
- if (options) for (var opt in options) if (options.hasOwnProperty(opt))
5661
- this[opt] = options[opt];
5662
- this.cm = cm;
5663
- this.node = node;
5664
- };
5665
- eventMixin(LineWidget);
 
 
 
 
5666
 
5667
- function adjustScrollWhenAboveVisible(cm, line, diff) {
5668
- if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
5669
- addToScrollPos(cm, null, diff);
 
 
5670
  }
5671
 
5672
- LineWidget.prototype.clear = function() {
5673
- var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
5674
- if (no == null || !ws) return;
5675
- for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
5676
- if (!ws.length) line.widgets = null;
5677
- var height = widgetHeight(this);
5678
- runInOp(cm, function() {
5679
- adjustScrollWhenAboveVisible(cm, line, -height);
5680
- regLineChange(cm, no, "widget");
5681
- updateLineHeight(line, Math.max(0, line.height - height));
5682
- });
5683
- };
5684
- LineWidget.prototype.changed = function() {
5685
- var oldH = this.height, cm = this.cm, line = this.line;
5686
- this.height = null;
5687
- var diff = widgetHeight(this) - oldH;
5688
- if (!diff) return;
5689
- runInOp(cm, function() {
5690
- cm.curOp.forceUpdate = true;
5691
- adjustScrollWhenAboveVisible(cm, line, diff);
5692
- updateLineHeight(line, line.height + diff);
5693
- });
5694
- };
5695
-
5696
- function widgetHeight(widget) {
5697
- if (widget.height != null) return widget.height;
5698
- if (!contains(document.body, widget.node)) {
5699
- var parentStyle = "position: relative;";
5700
- if (widget.coverGutter)
5701
- parentStyle += "margin-left: -" + widget.cm.getGutterElement().offsetWidth + "px;";
5702
- removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, parentStyle));
5703
- }
5704
- return widget.height = widget.node.offsetHeight;
5705
  }
5706
 
5707
- function addLineWidget(cm, handle, node, options) {
5708
- var widget = new LineWidget(cm, node, options);
5709
- if (widget.noHScroll) cm.display.alignWidgets = true;
5710
- changeLine(cm.doc, handle, "widget", function(line) {
5711
- var widgets = line.widgets || (line.widgets = []);
5712
- if (widget.insertAt == null) widgets.push(widget);
5713
- else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
5714
- widget.line = line;
5715
- if (!lineIsHidden(cm.doc, line)) {
5716
- var aboveVisible = heightAtLine(line) < cm.doc.scrollTop;
5717
- updateLineHeight(line, line.height + widgetHeight(widget));
5718
- if (aboveVisible) addToScrollPos(cm, null, widget.height);
5719
- cm.curOp.forceUpdate = true;
5720
- }
5721
- return true;
5722
  });
5723
- return widget;
5724
- }
5725
-
5726
- // LINE DATA STRUCTURE
5727
-
5728
- // Line objects. These hold state related to a line, including
5729
- // highlighting info (the styles array).
5730
- var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
5731
- this.text = text;
5732
- attachMarkedSpans(this, markedSpans);
5733
- this.height = estimateHeight ? estimateHeight(this) : 1;
5734
- };
5735
- eventMixin(Line);
5736
- Line.prototype.lineNo = function() { return lineNo(this); };
5737
-
5738
- // Change the content (text, markers) of a line. Automatically
5739
- // invalidates cached information and tries to re-estimate the
5740
- // line's height.
5741
- function updateLine(line, text, markedSpans, estimateHeight) {
5742
- line.text = text;
5743
- if (line.stateAfter) line.stateAfter = null;
5744
- if (line.styles) line.styles = null;
5745
- if (line.order != null) line.order = null;
5746
- detachMarkedSpans(line);
5747
- attachMarkedSpans(line, markedSpans);
5748
- var estHeight = estimateHeight ? estimateHeight(line) : 1;
5749
- if (estHeight != line.height) updateLineHeight(line, estHeight);
5750
- }
5751
-
5752
- // Detach a line from the document tree and its markers.
5753
- function cleanUpLine(line) {
5754
- line.parent = null;
5755
- detachMarkedSpans(line);
5756
  }
5757
 
5758
- function extractLineClasses(type, output) {
5759
- if (type) for (;;) {
5760
- var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
5761
- if (!lineClass) break;
5762
- type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
5763
- var prop = lineClass[1] ? "bgClass" : "textClass";
5764
- if (output[prop] == null)
5765
- output[prop] = lineClass[2];
5766
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
5767
- output[prop] += " " + lineClass[2];
5768
  }
5769
- return type;
5770
  }
5771
 
5772
- function callBlankLine(mode, state) {
5773
- if (mode.blankLine) return mode.blankLine(state);
5774
- if (!mode.innerMode) return;
5775
- var inner = CodeMirror.innerMode(mode, state);
5776
- if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
 
 
 
5777
  }
5778
 
5779
- function readToken(mode, stream, state) {
5780
- for (var i = 0; i < 10; i++) {
5781
- var style = mode.token(stream, state);
5782
- if (stream.pos > stream.start) return style;
5783
- }
5784
- throw new Error("Mode " + mode.name + " failed to advance stream.");
5785
- }
 
 
5786
 
5787
- // Run the given mode's parser over a line, calling f for each token.
5788
- function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
5789
- var flattenSpans = mode.flattenSpans;
5790
- if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
5791
- var curStart = 0, curStyle = null;
5792
- var stream = new StringStream(text, cm.options.tabSize), style;
5793
- if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
5794
- while (!stream.eol()) {
5795
- if (stream.pos > cm.options.maxHighlightLength) {
5796
- flattenSpans = false;
5797
- if (forceToEnd) processLine(cm, text, state, stream.pos);
5798
- stream.pos = text.length;
5799
- style = null;
5800
- } else {
5801
- style = extractLineClasses(readToken(mode, stream, state), lineClasses);
5802
- }
5803
- if (cm.options.addModeClass) {
5804
- var mName = CodeMirror.innerMode(mode, state).mode.name;
5805
- if (mName) style = "m-" + (style ? mName + " " + style : mName);
5806
- }
5807
- if (!flattenSpans || curStyle != style) {
5808
- if (curStart < stream.start) f(stream.start, curStyle);
5809
- curStart = stream.start; curStyle = style;
5810
  }
5811
- stream.start = stream.pos;
5812
- }
5813
- while (curStart < stream.pos) {
5814
- // Webkit seems to refuse to render text nodes longer than 57444 characters
5815
- var pos = Math.min(stream.pos, curStart + 50000);
5816
- f(pos, curStyle);
5817
- curStart = pos;
5818
  }
 
5819
  }
5820
 
5821
- // Compute a style array (an array starting with a mode generation
5822
- // -- for invalidation -- followed by pairs of end positions and
5823
- // style strings), which is used to highlight the tokens on the
5824
- // line.
5825
- function highlightLine(cm, line, state, forceToEnd) {
5826
- // A styles array always starts with a number identifying the
5827
- // mode/overlays that it is based on (for easy invalidation).
5828
- var st = [cm.state.modeGen], lineClasses = {};
5829
- // Compute the base array of styles
5830
- runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
5831
- st.push(end, style);
5832
- }, lineClasses, forceToEnd);
5833
-
5834
- // Run overlays, adjust style array.
5835
- for (var o = 0; o < cm.state.overlays.length; ++o) {
5836
- var overlay = cm.state.overlays[o], i = 1, at = 0;
5837
- runMode(cm, line.text, overlay.mode, true, function(end, style) {
5838
- var start = i;
5839
- // Ensure there's a token end at the current position, and that i points at it
5840
- while (at < end) {
5841
- var i_end = st[i];
5842
- if (i_end > end)
5843
- st.splice(i, 1, end, st[i+1], i_end);
5844
- i += 2;
5845
- at = Math.min(end, i_end);
5846
- }
5847
- if (!style) return;
5848
- if (overlay.opaque) {
5849
- st.splice(start, i - start, end, "cm-overlay " + style);
5850
- i = start + 2;
5851
- } else {
5852
- for (; start < i; start += 2) {
5853
- var cur = st[start+1];
5854
- st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
5855
  }
5856
- }
5857
- }, lineClasses);
5858
  }
5859
-
5860
- return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
5861
  }
5862
 
5863
- function getLineStyles(cm, line) {
5864
- if (!line.styles || line.styles[0] != cm.state.modeGen) {
5865
- var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
5866
- line.styles = result.styles;
5867
- if (result.classes) line.styleClasses = result.classes;
5868
- else if (line.styleClasses) line.styleClasses = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5869
  }
5870
- return line.styles;
5871
  }
5872
 
5873
- // Lightweight form of highlight -- proceed over this line and
5874
- // update state, but don't save a style array. Used for lines that
5875
- // aren't currently visible.
5876
- function processLine(cm, text, state, startAt) {
5877
- var mode = cm.doc.mode;
5878
- var stream = new StringStream(text, cm.options.tabSize);
5879
- stream.start = stream.pos = startAt || 0;
5880
- if (text == "") callBlankLine(mode, state);
5881
- while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
5882
- readToken(mode, stream, state);
5883
- stream.start = stream.pos;
5884
- }
5885
  }
5886
 
5887
- // Convert a style as returned by a mode (either null, or a string
5888
- // containing one or more styles) to a CSS style. This is cached,
5889
- // and also looks for line-wide styles.
5890
- var styleToClassCache = {}, styleToClassCacheWithMode = {};
5891
- function interpretTokenStyle(style, options) {
5892
- if (!style || /^\s*$/.test(style)) return null;
5893
- var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
5894
- return cache[style] ||
5895
- (cache[style] = style.replace(/\S+/g, "cm-$&"));
5896
  }
5897
 
5898
- // Render the DOM representation of the text of a line. Also builds
5899
- // up a 'line map', which points at the DOM nodes that represent
5900
- // specific stretches of text, and is used by the measuring code.
5901
- // The returned object contains the DOM node, this map, and
5902
- // information about line-wide styles that were set by the mode.
5903
- function buildLineContent(cm, lineView) {
5904
- // The padding-right forces the element to have a 'border', which
5905
- // is needed on Webkit to be able to get line-level bounding
5906
- // rectangles for it (in measureChar).
5907
- var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
5908
- var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm};
5909
- lineView.measure = {};
5910
 
5911
- // Iterate over the logical lines that make up this visual line.
5912
- for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
5913
- var line = i ? lineView.rest[i - 1] : lineView.line, order;
5914
- builder.pos = 0;
5915
- builder.addToken = buildToken;
5916
- // Optionally wire in some hacks into the token-rendering
5917
- // algorithm, to deal with browser quirks.
5918
- if ((ie || webkit) && cm.getOption("lineWrapping"))
5919
- builder.addToken = buildTokenSplitSpaces(builder.addToken);
5920
- if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
5921
- builder.addToken = buildTokenBadBidi(builder.addToken, order);
5922
- builder.map = [];
5923
- insertLineContent(line, builder, getLineStyles(cm, line));
5924
- if (line.styleClasses) {
5925
- if (line.styleClasses.bgClass)
5926
- builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
5927
- if (line.styleClasses.textClass)
5928
- builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
5929
- }
5930
 
5931
- // Ensure at least a single node is present, for measuring.
5932
- if (builder.map.length == 0)
5933
- builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
 
 
 
 
5934
 
5935
- // Store the map and a cache object for the current logical line
5936
- if (i == 0) {
5937
- lineView.measure.map = builder.map;
5938
- lineView.measure.cache = {};
5939
- } else {
5940
- (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
5941
- (lineView.measure.caches || (lineView.measure.caches = [])).push({});
5942
- }
5943
- }
 
 
 
5944
 
5945
- signal(cm, "renderLine", cm, lineView.line, builder.pre);
5946
- if (builder.pre.className)
5947
- builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
5948
- return builder;
 
 
 
 
5949
  }
5950
 
5951
- function defaultSpecialCharPlaceholder(ch) {
5952
- var token = elt("span", "\u2022", "cm-invalidchar");
5953
- token.title = "\\u" + ch.charCodeAt(0).toString(16);
5954
- return token;
5955
  }
5956
 
5957
- // Build up the DOM representation for a single token, and add it to
5958
- // the line map. Takes care to render special characters separately.
5959
- function buildToken(builder, text, style, startStyle, endStyle, title) {
5960
- if (!text) return;
5961
- var special = builder.cm.options.specialChars, mustWrap = false;
5962
- if (!special.test(text)) {
5963
- builder.col += text.length;
5964
- var content = document.createTextNode(text);
5965
- builder.map.push(builder.pos, builder.pos + text.length, content);
5966
- if (ie && ie_version < 9) mustWrap = true;
5967
- builder.pos += text.length;
5968
- } else {
5969
- var content = document.createDocumentFragment(), pos = 0;
5970
- while (true) {
5971
- special.lastIndex = pos;
5972
- var m = special.exec(text);
5973
- var skipped = m ? m.index - pos : text.length - pos;
5974
- if (skipped) {
5975
- var txt = document.createTextNode(text.slice(pos, pos + skipped));
5976
- if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
5977
- else content.appendChild(txt);
5978
- builder.map.push(builder.pos, builder.pos + skipped, txt);
5979
- builder.col += skipped;
5980
- builder.pos += skipped;
5981
- }
5982
- if (!m) break;
5983
- pos += skipped + 1;
5984
- if (m[0] == "\t") {
5985
- var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
5986
- var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
5987
- builder.col += tabWidth;
5988
- } else {
5989
- var txt = builder.cm.options.specialCharPlaceholder(m[0]);
5990
- if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
5991
- else content.appendChild(txt);
5992
- builder.col += 1;
5993
- }
5994
- builder.map.push(builder.pos, builder.pos + 1, txt);
5995
- builder.pos++;
5996
- }
5997
- }
5998
- if (style || startStyle || endStyle || mustWrap) {
5999
- var fullStyle = style || "";
6000
- if (startStyle) fullStyle += startStyle;
6001
- if (endStyle) fullStyle += endStyle;
6002
- var token = elt("span", [content], fullStyle);
6003
- if (title) token.title = title;
6004
- return builder.content.appendChild(token);
6005
- }
6006
- builder.content.appendChild(content);
6007
  }
6008
 
6009
- function buildTokenSplitSpaces(inner) {
6010
- function split(old) {
6011
- var out = " ";
6012
- for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
6013
- out += " ";
6014
- return out;
 
 
 
6015
  }
6016
- return function(builder, text, style, startStyle, endStyle, title) {
6017
- inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
6018
- };
6019
  }
6020
 
6021
- // Work around nonsense dimensions being reported for stretches of
6022
- // right-to-left text.
6023
- function buildTokenBadBidi(inner, order) {
6024
- return function(builder, text, style, startStyle, endStyle, title) {
6025
- style = style ? style + " cm-force-border" : "cm-force-border";
6026
- var start = builder.pos, end = start + text.length;
6027
- for (;;) {
6028
- // Find the part that overlaps with the start of this text
6029
- for (var i = 0; i < order.length; i++) {
6030
- var part = order[i];
6031
- if (part.to > start && part.from <= start) break;
6032
- }
6033
- if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title);
6034
- inner(builder, text.slice(0, part.to - start), style, startStyle, null, title);
6035
- startStyle = null;
6036
- text = text.slice(part.to - start);
6037
- start = part.to;
6038
- }
6039
- };
6040
  }
6041
 
6042
- function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
6043
- var widget = !ignoreWidget && marker.widgetNode;
6044
- if (widget) {
6045
- builder.map.push(builder.pos, builder.pos + size, widget);
6046
- builder.content.appendChild(widget);
 
 
 
 
 
 
 
 
6047
  }
6048
- builder.pos += size;
6049
  }
6050
 
6051
- // Outputs a number of spans to make up a line, taking highlighting
6052
- // and marked text into account.
6053
- function insertLineContent(line, builder, styles) {
6054
- var spans = line.markedSpans, allText = line.text, at = 0;
6055
- if (!spans) {
6056
- for (var i = 1; i < styles.length; i+=2)
6057
- builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
6058
- return;
6059
- }
6060
 
6061
- var len = allText.length, pos = 0, i = 1, text = "", style;
6062
- var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
6063
- for (;;) {
6064
- if (nextChange == pos) { // Update current marker set
6065
- spanStyle = spanEndStyle = spanStartStyle = title = "";
6066
- collapsed = null; nextChange = Infinity;
6067
- var foundBookmarks = [];
6068
- for (var j = 0; j < spans.length; ++j) {
6069
- var sp = spans[j], m = sp.marker;
6070
- if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
6071
- if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
6072
- if (m.className) spanStyle += " " + m.className;
6073
- if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
6074
- if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
6075
- if (m.title && !title) title = m.title;
6076
- if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
6077
- collapsed = sp;
6078
- } else if (sp.from > pos && nextChange > sp.from) {
6079
- nextChange = sp.from;
6080
  }
6081
- if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);
6082
  }
6083
- if (collapsed && (collapsed.from || 0) == pos) {
6084
- buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
6085
- collapsed.marker, collapsed.from == null);
6086
- if (collapsed.to == null) return;
 
 
 
 
6087
  }
6088
- if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
6089
- buildCollapsedSpan(builder, 0, foundBookmarks[j]);
6090
- }
6091
- if (pos >= len) break;
6092
 
6093
- var upto = Math.min(len, nextChange);
6094
- while (true) {
6095
- if (text) {
6096
- var end = pos + text.length;
6097
- if (!collapsed) {
6098
- var tokenText = end > upto ? text.slice(0, upto - pos) : text;
6099
- builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
6100
- spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title);
6101
- }
6102
- if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
6103
- pos = end;
6104
- spanStartStyle = "";
6105
- }
6106
- text = allText.slice(at, at = styles[i++]);
6107
- style = interpretTokenStyle(styles[i++], builder.cm.options);
6108
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6109
  }
6110
  }
6111
 
6112
- // DOCUMENT DATA STRUCTURE
 
 
6113
 
6114
- // By default, updates that start and end at the beginning of a line
6115
- // are treated specially, in order to make the association of line
6116
- // widgets and marker elements with the text behave more intuitive.
6117
- function isWholeLineUpdate(doc, change) {
6118
- return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
6119
- (!doc.cm || doc.cm.options.wholeLineUpdateBefore);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6120
  }
6121
 
6122
- // Perform a change on the document data structure.
6123
- function updateDoc(doc, change, markedSpans, estimateHeight) {
6124
- function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
6125
- function update(line, text, spans) {
6126
- updateLine(line, text, spans, estimateHeight);
6127
- signalLater(line, "change", line, change);
6128
  }
6129
 
6130
- var from = change.from, to = change.to, text = change.text;
6131
- var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
6132
- var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
 
6133
 
6134
- // Adjust the line structure
6135
- if (isWholeLineUpdate(doc, change)) {
6136
- // This is a whole-line replace. Treated specially to make
6137
- // sure line objects move the way they are supposed to.
6138
- for (var i = 0, added = []; i < text.length - 1; ++i)
6139
- added.push(new Line(text[i], spansFor(i), estimateHeight));
6140
- update(lastLine, lastLine.text, lastSpans);
6141
- if (nlines) doc.remove(from.line, nlines);
6142
- if (added.length) doc.insert(from.line, added);
6143
- } else if (firstLine == lastLine) {
6144
- if (text.length == 1) {
6145
- update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
6146
- } else {
6147
- for (var added = [], i = 1; i < text.length - 1; ++i)
6148
- added.push(new Line(text[i], spansFor(i), estimateHeight));
6149
- added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
6150
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
6151
- doc.insert(from.line + 1, added);
6152
- }
6153
- } else if (text.length == 1) {
6154
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
6155
- doc.remove(from.line + 1, nlines);
6156
  } else {
6157
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
6158
- update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
6159
- for (var i = 1, added = []; i < text.length - 1; ++i)
6160
- added.push(new Line(text[i], spansFor(i), estimateHeight));
6161
- if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
6162
- doc.insert(from.line + 1, added);
6163
  }
6164
-
6165
- signalLater(doc, "change", doc, change);
6166
  }
6167
 
6168
- // The document is represented as a BTree consisting of leaves, with
6169
- // chunk of lines in them, and branches, with up to ten leaves or
6170
- // other branch nodes below them. The top node is always a branch
6171
- // node, and is the document object itself (meaning it has
6172
- // additional methods and properties).
6173
- //
6174
- // All nodes have parent links. The tree is used both to go from
6175
- // line numbers to line objects, and to go from objects to numbers.
6176
- // It also indexes by height, and is used to convert between height
6177
- // and line object, and to find the total height of the document.
6178
- //
6179
- // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
6180
 
6181
- function LeafChunk(lines) {
6182
- this.lines = lines;
6183
- this.parent = null;
6184
- for (var i = 0, height = 0; i < lines.length; ++i) {
6185
- lines[i].parent = this;
6186
- height += lines[i].height;
6187
- }
6188
- this.height = height;
6189
- }
6190
 
6191
- LeafChunk.prototype = {
6192
- chunkSize: function() { return this.lines.length; },
6193
- // Remove the n lines at offset 'at'.
6194
- removeInner: function(at, n) {
6195
- for (var i = at, e = at + n; i < e; ++i) {
6196
- var line = this.lines[i];
6197
- this.height -= line.height;
6198
- cleanUpLine(line);
6199
- signalLater(line, "delete");
6200
  }
6201
- this.lines.splice(at, n);
6202
- },
6203
- // Helper used to collapse a small branch into a single leaf.
6204
- collapse: function(lines) {
6205
- lines.push.apply(lines, this.lines);
6206
- },
6207
- // Insert the given array of lines at offset 'at', count them as
6208
- // having the given height.
6209
- insertInner: function(at, lines, height) {
6210
- this.height += height;
6211
- this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
6212
- for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
6213
- },
6214
- // Used to iterate over a part of the tree.
6215
- iterN: function(at, n, op) {
6216
- for (var e = at + n; at < e; ++at)
6217
- if (op(this.lines[at])) return true;
6218
- }
6219
- };
6220
 
6221
- function BranchChunk(children) {
6222
- this.children = children;
6223
- var size = 0, height = 0;
6224
- for (var i = 0; i < children.length; ++i) {
6225
- var ch = children[i];
6226
- size += ch.chunkSize(); height += ch.height;
6227
- ch.parent = this;
 
 
 
 
 
 
 
 
6228
  }
6229
- this.size = size;
6230
- this.height = height;
6231
- this.parent = null;
6232
- }
6233
 
6234
- BranchChunk.prototype = {
6235
- chunkSize: function() { return this.size; },
6236
- removeInner: function(at, n) {
6237
- this.size -= n;
6238
- for (var i = 0; i < this.children.length; ++i) {
6239
- var child = this.children[i], sz = child.chunkSize();
6240
- if (at < sz) {
6241
- var rm = Math.min(n, sz - at), oldHeight = child.height;
6242
- child.removeInner(at, rm);
6243
- this.height -= oldHeight - child.height;
6244
- if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
6245
- if ((n -= rm) == 0) break;
6246
- at = 0;
6247
- } else at -= sz;
6248
- }
6249
- // If the result is smaller than 25 lines, ensure that it is a
6250
- // single leaf node.
6251
- if (this.size - n < 25 &&
6252
- (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
6253
- var lines = [];
6254
- this.collapse(lines);
6255
- this.children = [new LeafChunk(lines)];
6256
- this.children[0].parent = this;
6257
- }
6258
- },
6259
- collapse: function(lines) {
6260
- for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
6261
- },
6262
- insertInner: function(at, lines, height) {
6263
- this.size += lines.length;
6264
- this.height += height;
6265
- for (var i = 0; i < this.children.length; ++i) {
6266
- var child = this.children[i], sz = child.chunkSize();
6267
- if (at <= sz) {
6268
- child.insertInner(at, lines, height);
6269
- if (child.lines && child.lines.length > 50) {
6270
- while (child.lines.length > 50) {
6271
- var spilled = child.lines.splice(child.lines.length - 25, 25);
6272
- var newleaf = new LeafChunk(spilled);
6273
- child.height -= newleaf.height;
6274
- this.children.splice(i + 1, 0, newleaf);
6275
- newleaf.parent = this;
6276
- }
6277
- this.maybeSpill();
6278
- }
6279
- break;
6280
- }
6281
- at -= sz;
6282
- }
6283
- },
6284
- // When a node has grown, check whether it should be split.
6285
- maybeSpill: function() {
6286
- if (this.children.length <= 10) return;
6287
- var me = this;
6288
- do {
6289
- var spilled = me.children.splice(me.children.length - 5, 5);
6290
- var sibling = new BranchChunk(spilled);
6291
- if (!me.parent) { // Become the parent node
6292
- var copy = new BranchChunk(me.children);
6293
- copy.parent = me;
6294
- me.children = [copy, sibling];
6295
- me = copy;
6296
- } else {
6297
- me.size -= sibling.size;
6298
- me.height -= sibling.height;
6299
- var myIndex = indexOf(me.parent.children, me);
6300
- me.parent.children.splice(myIndex + 1, 0, sibling);
6301
  }
6302
- sibling.parent = me.parent;
6303
- } while (me.children.length > 10);
6304
- me.parent.maybeSpill();
6305
- },
6306
- iterN: function(at, n, op) {
6307
- for (var i = 0; i < this.children.length; ++i) {
6308
- var child = this.children[i], sz = child.chunkSize();
6309
- if (at < sz) {
6310
- var used = Math.min(n, sz - at);
6311
- if (child.iterN(at, used, op)) return true;
6312
- if ((n -= used) == 0) break;
6313
- at = 0;
6314
- } else at -= sz;
6315
- }
6316
  }
6317
- };
6318
 
6319
- var nextDocId = 0;
6320
- var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
6321
- if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
6322
- if (firstLine == null) firstLine = 0;
 
 
6323
 
6324
- BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
6325
- this.first = firstLine;
6326
- this.scrollTop = this.scrollLeft = 0;
6327
- this.cantEdit = false;
6328
- this.cleanGeneration = 1;
6329
- this.frontier = firstLine;
6330
- var start = Pos(firstLine, 0);
6331
- this.sel = simpleSelection(start);
6332
- this.history = new History(null);
6333
- this.id = ++nextDocId;
6334
- this.modeOption = mode;
6335
 
6336
- if (typeof text == "string") text = splitLines(text);
6337
- updateDoc(this, {from: start, to: start, text: text});
6338
- setSelection(this, simpleSelection(start), sel_dontScroll);
6339
- };
 
 
 
6340
 
6341
- Doc.prototype = createObj(BranchChunk.prototype, {
6342
- constructor: Doc,
6343
- // Iterate over the document. Supports two forms -- with only one
6344
- // argument, it calls that for each line in the document. With
6345
- // three, it iterates over the range given by the first two (with
6346
- // the second being non-inclusive).
6347
- iter: function(from, to, op) {
6348
- if (op) this.iterN(from - this.first, to - from, op);
6349
- else this.iterN(this.first, this.first + this.size, from);
6350
- },
6351
 
6352
- // Non-public interface for adding and removing lines.
6353
- insert: function(at, lines) {
6354
- var height = 0;
6355
- for (var i = 0; i < lines.length; ++i) height += lines[i].height;
6356
- this.insertInner(at - this.first, lines, height);
6357
- },
6358
- remove: function(at, n) { this.removeInner(at - this.first, n); },
6359
 
6360
- // From here, the methods are part of the public interface. Most
6361
- // are also available from CodeMirror (editor) instances.
 
 
 
 
 
 
 
6362
 
6363
- getValue: function(lineSep) {
6364
- var lines = getLines(this, this.first, this.first + this.size);
6365
- if (lineSep === false) return lines;
6366
- return lines.join(lineSep || "\n");
6367
- },
6368
- setValue: docMethodOp(function(code) {
6369
- var top = Pos(this.first, 0), last = this.first + this.size - 1;
6370
- makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
6371
- text: splitLines(code), origin: "setValue"}, true);
6372
- setSelection(this, simpleSelection(top));
6373
- }),
6374
- replaceRange: function(code, from, to, origin) {
6375
- from = clipPos(this, from);
6376
- to = to ? clipPos(this, to) : from;
6377
- replaceRange(this, code, from, to, origin);
6378
- },
6379
- getRange: function(from, to, lineSep) {
6380
- var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
6381
- if (lineSep === false) return lines;
6382
- return lines.join(lineSep || "\n");
6383
- },
6384
 
6385
- getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
 
 
6386
 
6387
- getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
6388
- getLineNumber: function(line) {return lineNo(line);},
 
 
 
 
 
 
 
 
 
 
 
 
 
6389
 
6390
- getLineHandleVisualStart: function(line) {
6391
- if (typeof line == "number") line = getLine(this, line);
6392
- return visualLine(line);
6393
- },
 
6394
 
6395
- lineCount: function() {return this.size;},
6396
- firstLine: function() {return this.first;},
6397
- lastLine: function() {return this.first + this.size - 1;},
 
 
6398
 
6399
- clipPos: function(pos) {return clipPos(this, pos);},
 
 
 
 
 
 
 
 
 
 
 
6400
 
6401
- getCursor: function(start) {
6402
- var range = this.sel.primary(), pos;
6403
- if (start == null || start == "head") pos = range.head;
6404
- else if (start == "anchor") pos = range.anchor;
6405
- else if (start == "end" || start == "to" || start === false) pos = range.to();
6406
- else pos = range.from();
6407
- return pos;
6408
- },
6409
- listSelections: function() { return this.sel.ranges; },
6410
- somethingSelected: function() {return this.sel.somethingSelected();},
6411
 
6412
- setCursor: docMethodOp(function(line, ch, options) {
6413
- setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
6414
- }),
6415
- setSelection: docMethodOp(function(anchor, head, options) {
6416
- setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
6417
- }),
6418
- extendSelection: docMethodOp(function(head, other, options) {
6419
- extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
6420
- }),
6421
- extendSelections: docMethodOp(function(heads, options) {
6422
- extendSelections(this, clipPosArray(this, heads, options));
6423
- }),
6424
- extendSelectionsBy: docMethodOp(function(f, options) {
6425
- extendSelections(this, map(this.sel.ranges, f), options);
6426
- }),
6427
- setSelections: docMethodOp(function(ranges, primary, options) {
6428
- if (!ranges.length) return;
6429
- for (var i = 0, out = []; i < ranges.length; i++)
6430
- out[i] = new Range(clipPos(this, ranges[i].anchor),
6431
- clipPos(this, ranges[i].head));
6432
- if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
6433
- setSelection(this, normalizeSelection(out, primary), options);
6434
- }),
6435
- addSelection: docMethodOp(function(anchor, head, options) {
6436
- var ranges = this.sel.ranges.slice(0);
6437
- ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
6438
- setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
6439
- }),
6440
 
6441
- getSelection: function(lineSep) {
6442
- var ranges = this.sel.ranges, lines;
6443
- for (var i = 0; i < ranges.length; i++) {
6444
- var sel = getBetween(this, ranges[i].from(), ranges[i].to());
6445
- lines = lines ? lines.concat(sel) : sel;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6446
  }
6447
- if (lineSep === false) return lines;
6448
- else return lines.join(lineSep || "\n");
6449
- },
6450
- getSelections: function(lineSep) {
6451
- var parts = [], ranges = this.sel.ranges;
6452
- for (var i = 0; i < ranges.length; i++) {
6453
- var sel = getBetween(this, ranges[i].from(), ranges[i].to());
6454
- if (lineSep !== false) sel = sel.join(lineSep || "\n");
6455
- parts[i] = sel;
6456
  }
6457
- return parts;
6458
- },
6459
- replaceSelection: function(code, collapse, origin) {
6460
- var dup = [];
6461
- for (var i = 0; i < this.sel.ranges.length; i++)
6462
- dup[i] = code;
6463
- this.replaceSelections(dup, collapse, origin || "+input");
6464
- },
6465
- replaceSelections: docMethodOp(function(code, collapse, origin) {
6466
- var changes = [], sel = this.sel;
6467
- for (var i = 0; i < sel.ranges.length; i++) {
6468
- var range = sel.ranges[i];
6469
- changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
6470
  }
6471
- var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
6472
- for (var i = changes.length - 1; i >= 0; i--)
6473
- makeChange(this, changes[i]);
6474
- if (newSel) setSelectionReplaceHistory(this, newSel);
6475
- else if (this.cm) ensureCursorVisible(this.cm);
6476
- }),
6477
- undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
6478
- redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
6479
- undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
6480
- redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
6481
 
6482
- setExtending: function(val) {this.extend = val;},
6483
- getExtending: function() {return this.extend;},
 
 
 
6484
 
6485
- historySize: function() {
6486
- var hist = this.history, done = 0, undone = 0;
6487
- for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
6488
- for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
6489
- return {undo: done, redo: undone};
6490
- },
6491
- clearHistory: function() {this.history = new History(this.history.maxGeneration);},
 
 
 
 
6492
 
6493
- markClean: function() {
6494
- this.cleanGeneration = this.changeGeneration(true);
6495
- },
6496
- changeGeneration: function(forceSplit) {
6497
- if (forceSplit)
6498
- this.history.lastOp = this.history.lastOrigin = null;
6499
- return this.history.generation;
6500
- },
6501
- isClean: function (gen) {
6502
- return this.history.generation == (gen || this.cleanGeneration);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6503
  },
6504
 
6505
- getHistory: function() {
6506
- return {done: copyHistoryArray(this.history.done),
6507
- undone: copyHistoryArray(this.history.undone)};
6508
  },
6509
- setHistory: function(histData) {
6510
- var hist = this.history = new History(this.history.maxGeneration);
6511
- hist.done = copyHistoryArray(histData.done.slice(0), null, true);
6512
- hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
 
 
 
 
 
6513
  },
6514
 
6515
- addLineClass: docMethodOp(function(handle, where, cls) {
6516
- return changeLine(this, handle, "class", function(line) {
6517
- var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
6518
- if (!line[prop]) line[prop] = cls;
6519
- else if (new RegExp("(?:^|\\s)" + cls + "(?:$|\\s)").test(line[prop])) return false;
6520
- else line[prop] += " " + cls;
6521
- return true;
6522
- });
6523
- }),
6524
- removeLineClass: docMethodOp(function(handle, where, cls) {
6525
- return changeLine(this, handle, "class", function(line) {
6526
- var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
6527
- var cur = line[prop];
6528
- if (!cur) return false;
6529
- else if (cls == null) line[prop] = null;
6530
- else {
6531
- var found = cur.match(new RegExp("(?:^|\\s+)" + cls + "(?:$|\\s+)"));
6532
- if (!found) return false;
6533
- var end = found.index + found[0].length;
6534
- line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
6535
- }
6536
- return true;
6537
- });
6538
- }),
6539
 
6540
- markText: function(from, to, options) {
6541
- return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6542
  },
6543
- setBookmark: function(pos, options) {
6544
- var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
6545
- insertLeft: options && options.insertLeft,
6546
- clearWhenEmpty: false, shared: options && options.shared};
6547
- pos = clipPos(this, pos);
6548
- return markText(this, pos, pos, realOpts, "bookmark");
6549
  },
6550
- findMarksAt: function(pos) {
6551
- pos = clipPos(this, pos);
6552
- var markers = [], spans = getLine(this, pos.line).markedSpans;
6553
- if (spans) for (var i = 0; i < spans.length; ++i) {
6554
- var span = spans[i];
6555
- if ((span.from == null || span.from <= pos.ch) &&
6556
- (span.to == null || span.to >= pos.ch))
6557
- markers.push(span.marker.parent || span.marker);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6558
  }
6559
- return markers;
6560
  },
6561
- findMarks: function(from, to, filter) {
6562
- from = clipPos(this, from); to = clipPos(this, to);
6563
- var found = [], lineNo = from.line;
6564
- this.iter(from.line, to.line + 1, function(line) {
6565
- var spans = line.markedSpans;
6566
- if (spans) for (var i = 0; i < spans.length; i++) {
6567
- var span = spans[i];
6568
- if (!(lineNo == from.line && from.ch > span.to ||
6569
- span.from == null && lineNo != from.line||
6570
- lineNo == to.line && span.from > to.ch) &&
6571
- (!filter || filter(span.marker)))
6572
- found.push(span.marker.parent || span.marker);
 
 
 
 
 
 
6573
  }
6574
- ++lineNo;
6575
- });
6576
- return found;
6577
  },
6578
- getAllMarks: function() {
6579
- var markers = [];
6580
- this.iter(function(line) {
6581
- var sps = line.markedSpans;
6582
- if (sps) for (var i = 0; i < sps.length; ++i)
6583
- if (sps[i].from != null) markers.push(sps[i].marker);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6584
  });
6585
- return markers;
6586
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6587
 
6588
- posFromIndex: function(off) {
6589
- var ch, lineNo = this.first;
6590
- this.iter(function(line) {
6591
- var sz = line.text.length + 1;
6592
- if (sz > off) { ch = off; return true; }
6593
- off -= sz;
6594
- ++lineNo;
6595
- });
6596
- return clipPos(this, Pos(lineNo, ch));
6597
- },
6598
- indexFromPos: function (coords) {
6599
- coords = clipPos(this, coords);
6600
- var index = coords.ch;
6601
- if (coords.line < this.first || coords.ch < 0) return 0;
6602
- this.iter(this.first, coords.line, function (line) {
6603
- index += line.text.length + 1;
6604
- });
6605
- return index;
6606
- },
6607
 
6608
- copy: function(copyHistory) {
6609
- var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
6610
- doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
6611
- doc.sel = this.sel;
6612
- doc.extend = false;
6613
- if (copyHistory) {
6614
- doc.history.undoDepth = this.history.undoDepth;
6615
- doc.setHistory(this.getHistory());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6616
  }
6617
- return doc;
6618
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6619
 
6620
- linkedDoc: function(options) {
6621
- if (!options) options = {};
6622
- var from = this.first, to = this.first + this.size;
6623
- if (options.from != null && options.from > from) from = options.from;
6624
- if (options.to != null && options.to < to) to = options.to;
6625
- var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
6626
- if (options.sharedHist) copy.history = this.history;
6627
- (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
6628
- copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
6629
- copySharedMarkers(copy, findSharedMarkers(this));
6630
- return copy;
6631
- },
6632
- unlinkDoc: function(other) {
6633
- if (other instanceof CodeMirror) other = other.doc;
6634
- if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
6635
- var link = this.linked[i];
6636
- if (link.doc != other) continue;
6637
- this.linked.splice(i, 1);
6638
- other.unlinkDoc(this);
6639
- detachSharedMarkers(findSharedMarkers(this));
6640
- break;
6641
  }
6642
- // If the histories were shared, split them again
6643
- if (other.history == this.history) {
6644
- var splitIds = [other.id];
6645
- linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
6646
- other.history = new History(null);
6647
- other.history.done = copyHistoryArray(this.history.done, splitIds);
6648
- other.history.undone = copyHistoryArray(this.history.undone, splitIds);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6649
  }
6650
- },
6651
- iterLinkedDocs: function(f) {linkedDocs(this, f);},
 
 
 
 
 
 
 
 
 
 
6652
 
6653
- getMode: function() {return this.mode;},
6654
- getEditor: function() {return this.cm;}
6655
- });
 
6656
 
6657
- // Public alias.
6658
- Doc.prototype.eachLine = Doc.prototype.iter;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6659
 
6660
- // Set up methods on CodeMirror's prototype to redirect to the editor's document.
6661
- var dontDelegate = "iter insert remove copy getEditor".split(" ");
6662
- for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
6663
- CodeMirror.prototype[prop] = (function(method) {
6664
- return function() {return method.apply(this.doc, arguments);};
6665
- })(Doc.prototype[prop]);
6666
 
6667
- eventMixin(Doc);
 
 
6668
 
6669
- // Call f for all linked documents.
6670
- function linkedDocs(doc, f, sharedHistOnly) {
6671
- function propagate(doc, skip, sharedHist) {
6672
- if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
6673
- var rel = doc.linked[i];
6674
- if (rel.doc == skip) continue;
6675
- var shared = sharedHist && rel.sharedHist;
6676
- if (sharedHistOnly && !shared) continue;
6677
- f(rel.doc, shared);
6678
- propagate(rel.doc, doc, shared);
 
 
 
 
 
 
 
 
6679
  }
6680
  }
6681
- propagate(doc, null, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6682
  }
6683
 
6684
- // Attach a document to an editor.
6685
- function attachDoc(cm, doc) {
6686
- if (doc.cm) throw new Error("This document is already in use.");
6687
- cm.doc = doc;
6688
- doc.cm = cm;
6689
- estimateLineHeights(cm);
6690
- loadMode(cm);
6691
- if (!cm.options.lineWrapping) findMaxLine(cm);
6692
- cm.options.mode = doc.modeOption;
6693
- regChange(cm);
6694
  }
6695
 
6696
- // LINE UTILITIES
 
 
 
6697
 
6698
- // Find the line object corresponding to the given line number.
6699
- function getLine(doc, n) {
6700
- n -= doc.first;
6701
- if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
6702
- for (var chunk = doc; !chunk.lines;) {
6703
- for (var i = 0;; ++i) {
6704
- var child = chunk.children[i], sz = child.chunkSize();
6705
- if (n < sz) { chunk = child; break; }
6706
- n -= sz;
 
 
 
 
 
6707
  }
 
6708
  }
6709
- return chunk.lines[n];
6710
  }
6711
 
6712
- // Get the part of a document between two positions, as an array of
6713
- // strings.
6714
- function getBetween(doc, start, end) {
6715
- var out = [], n = start.line;
6716
- doc.iter(start.line, end.line + 1, function(line) {
6717
- var text = line.text;
6718
- if (n == end.line) text = text.slice(0, end.ch);
6719
- if (n == start.line) text = text.slice(start.ch);
6720
- out.push(text);
6721
- ++n;
6722
- });
6723
- return out;
6724
  }
6725
- // Get the lines between from and to, as array of strings.
6726
- function getLines(doc, from, to) {
6727
- var out = [];
6728
- doc.iter(from, to, function(line) { out.push(line.text); });
6729
- return out;
6730
  }
6731
 
6732
- // Update the height of a line, propagating the height change
6733
- // upwards to parent nodes.
6734
- function updateLineHeight(line, height) {
6735
- var diff = height - line.height;
6736
- if (diff) for (var n = line; n; n = n.parent) n.height += diff;
 
 
 
 
 
 
 
 
6737
  }
6738
 
6739
- // Given a line object, find its line number by walking up through
6740
- // its parent links.
6741
- function lineNo(line) {
6742
- if (line.parent == null) return null;
6743
- var cur = line.parent, no = indexOf(cur.lines, line);
6744
- for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
6745
- for (var i = 0;; ++i) {
6746
- if (chunk.children[i] == cur) break;
6747
- no += chunk.children[i].chunkSize();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6748
  }
 
6749
  }
6750
- return no + cur.first;
6751
- }
6752
 
6753
- // Find the line at the given vertical position, using the height
6754
- // information in the document tree.
6755
- function lineAtHeight(chunk, h) {
6756
- var n = chunk.first;
6757
- outer: do {
6758
- for (var i = 0; i < chunk.children.length; ++i) {
6759
- var child = chunk.children[i], ch = child.height;
6760
- if (h < ch) { chunk = child; continue outer; }
6761
- h -= ch;
6762
- n += child.chunkSize();
 
 
 
 
 
 
 
 
 
 
 
 
6763
  }
6764
- return n;
6765
- } while (!chunk.lines);
6766
- for (var i = 0; i < chunk.lines.length; ++i) {
6767
- var line = chunk.lines[i], lh = line.height;
6768
- if (h < lh) break;
6769
- h -= lh;
6770
  }
6771
- return n + i;
 
 
6772
  }
6773
 
 
 
 
 
 
 
 
 
 
6774
 
6775
- // Find the height above the given line.
6776
- function heightAtLine(lineObj) {
6777
- lineObj = visualLine(lineObj);
6778
-
6779
- var h = 0, chunk = lineObj.parent;
6780
- for (var i = 0; i < chunk.lines.length; ++i) {
6781
- var line = chunk.lines[i];
6782
- if (line == lineObj) break;
6783
- else h += line.height;
6784
  }
6785
- for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
6786
- for (var i = 0; i < p.children.length; ++i) {
6787
- var cur = p.children[i];
6788
- if (cur == chunk) break;
6789
- else h += cur.height;
6790
- }
6791
  }
6792
- return h;
6793
  }
6794
 
6795
- // Get the bidi ordering for the given line (and cache it). Returns
6796
- // false for lines that are fully left-to-right, and an array of
6797
- // BidiSpan objects otherwise.
6798
- function getOrder(line) {
6799
- var order = line.order;
6800
- if (order == null) order = line.order = bidiOrdering(line.text);
6801
- return order;
6802
- }
6803
 
6804
- // HISTORY
 
 
 
 
 
 
 
6805
 
6806
- function History(startGen) {
6807
- // Arrays of change events and selections. Doing something adds an
6808
- // event to done and clears undo. Undoing moves events from done
6809
- // to undone, redoing moves them in the other direction.
6810
- this.done = []; this.undone = [];
6811
- this.undoDepth = Infinity;
6812
- // Used to track when changes can be merged into a single undo
6813
- // event
6814
- this.lastModTime = this.lastSelTime = 0;
6815
- this.lastOp = null;
6816
- this.lastOrigin = this.lastSelOrigin = null;
6817
- // Used by the isClean() method
6818
- this.generation = this.maxGeneration = startGen || 1;
6819
- }
6820
 
6821
- // Create a history change event from an updateDoc-style change
6822
- // object.
6823
- function historyChangeFromChange(doc, change) {
6824
- var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
6825
- attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
6826
- linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
6827
- return histChange;
6828
- }
6829
 
6830
- // Pop all selection events off the end of a history array. Stop at
6831
- // a change event.
6832
- function clearSelectionEvents(array) {
6833
- while (array.length) {
6834
- var last = lst(array);
6835
- if (last.ranges) array.pop();
6836
- else break;
6837
- }
6838
- }
6839
 
6840
- // Find the top change event in the history. Pop off selection
6841
- // events that are in the way.
6842
- function lastChangeEvent(hist, force) {
6843
- if (force) {
6844
- clearSelectionEvents(hist.done);
6845
- return lst(hist.done);
6846
- } else if (hist.done.length && !lst(hist.done).ranges) {
6847
- return lst(hist.done);
6848
- } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
6849
- hist.done.pop();
6850
- return lst(hist.done);
6851
- }
6852
- }
6853
 
6854
- // Register a change in the history. Merges changes that are within
6855
- // a single operation, ore are close together with an origin that
6856
- // allows merging (starting with "+") into a single event.
6857
- function addChangeToHistory(doc, change, selAfter, opId) {
6858
- var hist = doc.history;
6859
- hist.undone.length = 0;
6860
- var time = +new Date, cur;
6861
 
6862
- if ((hist.lastOp == opId ||
6863
- hist.lastOrigin == change.origin && change.origin &&
6864
- ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
6865
- change.origin.charAt(0) == "*")) &&
6866
- (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
6867
- // Merge this change into the last event
6868
- var last = lst(cur.changes);
6869
- if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
6870
- // Optimized case for simple insertion -- don't want to add
6871
- // new changesets for every character typed
6872
- last.to = changeEnd(change);
6873
  } else {
6874
- // Add new sub-event
6875
- cur.changes.push(historyChangeFromChange(doc, change));
 
 
 
 
 
 
6876
  }
6877
- } else {
6878
- // Can not be merged, start a new event.
6879
- var before = lst(hist.done);
6880
- if (!before || !before.ranges)
6881
- pushSelectionToHistory(doc.sel, hist.done);
6882
- cur = {changes: [historyChangeFromChange(doc, change)],
6883
- generation: hist.generation};
6884
- hist.done.push(cur);
6885
- while (hist.done.length > hist.undoDepth) {
6886
- hist.done.shift();
6887
- if (!hist.done[0].ranges) hist.done.shift();
6888
  }
6889
- }
6890
- hist.done.push(selAfter);
6891
- hist.generation = ++hist.maxGeneration;
6892
- hist.lastModTime = hist.lastSelTime = time;
6893
- hist.lastOp = opId;
6894
- hist.lastOrigin = hist.lastSelOrigin = change.origin;
6895
-
6896
- if (!last) signal(doc, "historyAdded");
6897
- }
6898
-
6899
- function selectionEventCanBeMerged(doc, origin, prev, sel) {
6900
- var ch = origin.charAt(0);
6901
- return ch == "*" ||
6902
- ch == "+" &&
6903
- prev.ranges.length == sel.ranges.length &&
6904
- prev.somethingSelected() == sel.somethingSelected() &&
6905
- new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
6906
- }
6907
-
6908
- // Called whenever the selection changes, sets the new selection as
6909
- // the pending selection in the history, and pushes the old pending
6910
- // selection into the 'done' array when it was significantly
6911
- // different (in number of selected ranges, emptiness, or time).
6912
- function addSelectionToHistory(doc, sel, opId, options) {
6913
- var hist = doc.history, origin = options && options.origin;
6914
 
6915
- // A new event is started when the previous origin does not match
6916
- // the current, or the origins don't allow matching. Origins
6917
- // starting with * are always merged, those starting with + are
6918
- // merged when similar and close together in time.
6919
- if (opId == hist.lastOp ||
6920
- (origin && hist.lastSelOrigin == origin &&
6921
- (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
6922
- selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
6923
- hist.done[hist.done.length - 1] = sel;
6924
- else
6925
- pushSelectionToHistory(sel, hist.done);
6926
 
6927
- hist.lastSelTime = +new Date;
6928
- hist.lastSelOrigin = origin;
6929
- hist.lastOp = opId;
6930
- if (options && options.clearRedo !== false)
6931
- clearSelectionEvents(hist.undone);
6932
- }
6933
 
6934
- function pushSelectionToHistory(sel, dest) {
6935
- var top = lst(dest);
6936
- if (!(top && top.ranges && top.equals(sel)))
6937
- dest.push(sel);
6938
- }
6939
 
6940
- // Used to store marked span information in the history.
6941
- function attachLocalSpans(doc, change, from, to) {
6942
- var existing = change["spans_" + doc.id], n = 0;
6943
- doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
6944
- if (line.markedSpans)
6945
- (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
6946
- ++n;
6947
- });
6948
- }
6949
 
6950
- // When un/re-doing restores text containing marked spans, those
6951
- // that have been explicitly cleared should not be restored.
6952
- function removeClearedSpans(spans) {
6953
- if (!spans) return null;
6954
- for (var i = 0, out; i < spans.length; ++i) {
6955
- if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
6956
- else if (out) out.push(spans[i]);
6957
  }
6958
- return !out ? spans : out.length ? out : null;
6959
- }
6960
 
6961
- // Retrieve and filter the old marked spans stored in a change event.
6962
- function getOldSpans(doc, change) {
6963
- var found = change["spans_" + doc.id];
6964
- if (!found) return null;
6965
- for (var i = 0, nw = []; i < change.text.length; ++i)
6966
- nw.push(removeClearedSpans(found[i]));
6967
- return nw;
6968
- }
6969
 
6970
- // Used both to provide a JSON-safe object in .getHistory, and, when
6971
- // detaching a document, to split the history in two
6972
- function copyHistoryArray(events, newGroup, instantiateSel) {
6973
- for (var i = 0, copy = []; i < events.length; ++i) {
6974
- var event = events[i];
6975
- if (event.ranges) {
6976
- copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
6977
- continue;
6978
- }
6979
- var changes = event.changes, newChanges = [];
6980
- copy.push({changes: newChanges});
6981
- for (var j = 0; j < changes.length; ++j) {
6982
- var change = changes[j], m;
6983
- newChanges.push({from: change.from, to: change.to, text: change.text});
6984
- if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
6985
- if (indexOf(newGroup, Number(m[1])) > -1) {
6986
- lst(newChanges)[prop] = change[prop];
6987
- delete change[prop];
6988
- }
 
 
 
 
 
6989
  }
 
 
 
6990
  }
 
 
6991
  }
6992
- return copy;
6993
- }
6994
 
6995
- // Rebasing/resetting history to deal with externally-sourced changes
 
6996
 
6997
- function rebaseHistSelSingle(pos, from, to, diff) {
6998
- if (to < pos.line) {
6999
- pos.line += diff;
7000
- } else if (from < pos.line) {
7001
- pos.line = from;
7002
- pos.ch = 0;
7003
- }
7004
- }
7005
 
7006
- // Tries to rebase an array of history events given a change in the
7007
- // document. If the change touches the same lines as the event, the
7008
- // event, and everything 'behind' it, is discarded. If the change is
7009
- // before the event, the event's positions are updated. Uses a
7010
- // copy-on-write scheme for the positions, to avoid having to
7011
- // reallocate them all on every rebase, but also avoid problems with
7012
- // shared position objects being unsafely updated.
7013
- function rebaseHistArray(array, from, to, diff) {
7014
- for (var i = 0; i < array.length; ++i) {
7015
- var sub = array[i], ok = true;
7016
- if (sub.ranges) {
7017
- if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
7018
- for (var j = 0; j < sub.ranges.length; j++) {
7019
- rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
7020
- rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
7021
- }
7022
- continue;
7023
- }
7024
- for (var j = 0; j < sub.changes.length; ++j) {
7025
- var cur = sub.changes[j];
7026
- if (to < cur.from.line) {
7027
- cur.from = Pos(cur.from.line + diff, cur.from.ch);
7028
- cur.to = Pos(cur.to.line + diff, cur.to.ch);
7029
- } else if (from <= cur.to.line) {
7030
- ok = false;
7031
- break;
7032
- }
7033
- }
7034
- if (!ok) {
7035
- array.splice(0, i + 1);
7036
- i = 0;
7037
- }
7038
  }
7039
- }
 
 
7040
 
7041
- function rebaseHist(hist, change) {
7042
- var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
7043
- rebaseHistArray(hist.done, from, to, diff);
7044
- rebaseHistArray(hist.undone, from, to, diff);
7045
- }
7046
 
7047
- // EVENT UTILITIES
 
 
 
 
 
7048
 
7049
- // Due to the fact that we still support jurassic IE versions, some
7050
- // compatibility wrappers are needed.
 
 
 
 
 
 
7051
 
7052
- var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
7053
- if (e.preventDefault) e.preventDefault();
7054
- else e.returnValue = false;
 
7055
  };
7056
- var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
7057
- if (e.stopPropagation) e.stopPropagation();
7058
- else e.cancelBubble = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7059
  };
7060
- function e_defaultPrevented(e) {
7061
- return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
7062
- }
7063
- var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
7064
 
7065
- function e_target(e) {return e.target || e.srcElement;}
7066
- function e_button(e) {
7067
- var b = e.which;
7068
- if (b == null) {
7069
- if (e.button & 1) b = 1;
7070
- else if (e.button & 2) b = 3;
7071
- else if (e.button & 4) b = 2;
7072
  }
7073
- if (mac && e.ctrlKey && b == 1) b = 3;
7074
- return b;
7075
- }
7076
 
7077
- // EVENT HANDLING
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7078
 
7079
- // Lightweight event framework. on/off also work on DOM nodes,
7080
- // registering native DOM handlers.
7081
 
7082
- var on = CodeMirror.on = function(emitter, type, f) {
7083
- if (emitter.addEventListener)
7084
- emitter.addEventListener(type, f, false);
7085
- else if (emitter.attachEvent)
7086
- emitter.attachEvent("on" + type, f);
7087
- else {
7088
- var map = emitter._handlers || (emitter._handlers = {});
7089
- var arr = map[type] || (map[type] = []);
7090
- arr.push(f);
7091
- }
7092
  };
7093
 
7094
- var off = CodeMirror.off = function(emitter, type, f) {
7095
- if (emitter.removeEventListener)
7096
- emitter.removeEventListener(type, f, false);
7097
- else if (emitter.detachEvent)
7098
- emitter.detachEvent("on" + type, f);
7099
- else {
7100
- var arr = emitter._handlers && emitter._handlers[type];
7101
- if (!arr) return;
7102
- for (var i = 0; i < arr.length; ++i)
7103
- if (arr[i] == f) { arr.splice(i, 1); break; }
7104
- }
7105
  };
7106
 
7107
- var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
7108
- var arr = emitter._handlers && emitter._handlers[type];
7109
- if (!arr) return;
7110
- var args = Array.prototype.slice.call(arguments, 2);
7111
- for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
7112
  };
7113
 
7114
- var orphanDelayedCallbacks = null;
 
 
7115
 
7116
- // Often, we want to signal events at a point where we are in the
7117
- // middle of some work, but don't want the handler to start calling
7118
- // other methods on the editor, which might be in an inconsistent
7119
- // state or simply not expect any other events to happen.
7120
- // signalLater looks whether there are any handlers, and schedules
7121
- // them to be executed when the last operation ends, or, if no
7122
- // operation is active, when a timeout fires.
7123
- function signalLater(emitter, type /*, values...*/) {
7124
- var arr = emitter._handlers && emitter._handlers[type];
7125
- if (!arr) return;
7126
- var args = Array.prototype.slice.call(arguments, 2), list;
7127
- if (operationGroup) {
7128
- list = operationGroup.delayedCallbacks;
7129
- } else if (orphanDelayedCallbacks) {
7130
- list = orphanDelayedCallbacks;
7131
- } else {
7132
- list = orphanDelayedCallbacks = [];
7133
- setTimeout(fireOrphanDelayed, 0);
7134
- }
7135
- function bnd(f) {return function(){f.apply(null, args);};};
7136
- for (var i = 0; i < arr.length; ++i)
7137
- list.push(bnd(arr[i]));
7138
- }
7139
 
7140
- function fireOrphanDelayed() {
7141
- var delayed = orphanDelayedCallbacks;
7142
- orphanDelayedCallbacks = null;
7143
- for (var i = 0; i < delayed.length; ++i) delayed[i]();
7144
- }
7145
 
7146
- // The DOM events that CodeMirror handles can be overridden by
7147
- // registering a (non-DOM) handler on the editor for the event name,
7148
- // and preventDefault-ing the event in that handler.
7149
- function signalDOMEvent(cm, e, override) {
7150
- signal(cm, override || e.type, cm, e);
7151
- return e_defaultPrevented(e) || e.codemirrorIgnore;
7152
- }
7153
 
7154
- function signalCursorActivity(cm) {
7155
- var arr = cm._handlers && cm._handlers.cursorActivity;
7156
- if (!arr) return;
7157
- var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
7158
- for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
7159
- set.push(arr[i]);
 
 
7160
  }
7161
 
7162
- function hasHandler(emitter, type) {
7163
- var arr = emitter._handlers && emitter._handlers[type];
7164
- return arr && arr.length > 0;
 
7165
  }
7166
 
7167
- // Add on and off methods to a constructor's prototype, to make
7168
- // registering events on such objects more convenient.
7169
- function eventMixin(ctor) {
7170
- ctor.prototype.on = function(type, f) {on(this, type, f);};
7171
- ctor.prototype.off = function(type, f) {off(this, type, f);};
7172
- }
7173
 
7174
- // MISC UTILITIES
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7175
 
7176
- // Number of pixels added to scroller and sizer to hide scrollbar
7177
- var scrollerCutOff = 30;
 
7178
 
7179
- // Returned or thrown by various protocols to signal 'I'm not
7180
- // handling this'.
7181
- var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
 
 
 
 
 
 
 
 
 
 
 
7182
 
7183
- // Reused option objects for setSelection & friends
7184
- var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7185
 
7186
- function Delayed() {this.id = null;}
7187
- Delayed.prototype.set = function(ms, f) {
7188
- clearTimeout(this.id);
7189
- this.id = setTimeout(f, ms);
7190
- };
 
 
 
 
 
 
 
7191
 
7192
- // Counts the column offset in a string, taking tabs into account.
7193
- // Used mostly to find indentation.
7194
- var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
7195
- if (end == null) {
7196
- end = string.search(/[^\s\u00a0]/);
7197
- if (end == -1) end = string.length;
7198
  }
7199
- for (var i = startIndex || 0, n = startValue || 0;;) {
7200
- var nextTab = string.indexOf("\t", i);
7201
- if (nextTab < 0 || nextTab >= end)
7202
- return n + (end - i);
7203
- n += nextTab - i;
7204
- n += tabSize - (n % tabSize);
7205
- i = nextTab + 1;
 
 
 
 
 
 
 
 
 
7206
  }
7207
- };
 
7208
 
7209
- // The inverse of countColumn -- find the offset that corresponds to
7210
- // a particular column.
7211
- function findColumn(string, goal, tabSize) {
7212
- for (var pos = 0, col = 0;;) {
7213
- var nextTab = string.indexOf("\t", pos);
7214
- if (nextTab == -1) nextTab = string.length;
7215
- var skipped = nextTab - pos;
7216
- if (nextTab == string.length || col + skipped >= goal)
7217
- return pos + Math.min(skipped, goal - col);
7218
- col += nextTab - pos;
7219
- col += tabSize - (col % tabSize);
7220
- pos = nextTab + 1;
7221
- if (col >= goal) return pos;
 
7222
  }
7223
  }
7224
 
7225
- var spaceStrs = [""];
7226
- function spaceStr(n) {
7227
- while (spaceStrs.length <= n)
7228
- spaceStrs.push(lst(spaceStrs) + " ");
7229
- return spaceStrs[n];
7230
- }
7231
 
7232
- function lst(arr) { return arr[arr.length-1]; }
 
 
 
7233
 
7234
- var selectInput = function(node) { node.select(); };
7235
- if (ios) // Mobile Safari apparently has a bug where select() is broken.
7236
- selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
7237
- else if (ie) // Suppress mysterious IE10 errors
7238
- selectInput = function(node) { try { node.select(); } catch(_e) {} };
 
 
 
 
 
7239
 
7240
- function indexOf(array, elt) {
7241
- for (var i = 0; i < array.length; ++i)
7242
- if (array[i] == elt) return i;
7243
- return -1;
7244
- }
7245
- if ([].indexOf) indexOf = function(array, elt) { return array.indexOf(elt); };
7246
- function map(array, f) {
7247
- var out = [];
7248
- for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
7249
- return out;
7250
- }
7251
- if ([].map) map = function(array, f) { return array.map(f); };
7252
 
7253
- function createObj(base, props) {
7254
- var inst;
7255
- if (Object.create) {
7256
- inst = Object.create(base);
7257
- } else {
7258
- var ctor = function() {};
7259
- ctor.prototype = base;
7260
- inst = new ctor();
7261
- }
7262
- if (props) copyObj(props, inst);
7263
- return inst;
7264
- };
7265
 
7266
- function copyObj(obj, target, overwrite) {
7267
- if (!target) target = {};
7268
- for (var prop in obj)
7269
- if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
7270
- target[prop] = obj[prop];
7271
- return target;
7272
- }
7273
 
7274
- function bind(f) {
7275
- var args = Array.prototype.slice.call(arguments, 1);
7276
- return function(){return f.apply(null, args);};
7277
- }
7278
 
7279
- var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
7280
- var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
7281
- return /\w/.test(ch) || ch > "\x80" &&
7282
- (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
7283
- };
7284
- function isWordChar(ch, helper) {
7285
- if (!helper) return isWordCharBasic(ch);
7286
- if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
7287
- return helper.test(ch);
7288
- }
7289
 
7290
- function isEmpty(obj) {
7291
- for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
7292
- return true;
7293
- }
7294
 
7295
- // Extending unicode characters. A series of a non-extending char +
7296
- // any number of extending chars is treated as a single unit as far
7297
- // as editing and measuring is concerned. This is not fully correct,
7298
- // since some scripts/fonts/browsers also treat other configurations
7299
- // of code points as a group.
7300
- var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
7301
- function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7302
 
7303
- // DOM UTILITIES
 
 
 
 
 
 
7304
 
7305
- function elt(tag, content, className, style) {
7306
- var e = document.createElement(tag);
7307
- if (className) e.className = className;
7308
- if (style) e.style.cssText = style;
7309
- if (typeof content == "string") e.appendChild(document.createTextNode(content));
7310
- else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
7311
- return e;
7312
- }
7313
 
7314
- var range;
7315
- if (document.createRange) range = function(node, start, end) {
7316
- var r = document.createRange();
7317
- r.setEnd(node, end);
7318
- r.setStart(node, start);
7319
- return r;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7320
  };
7321
- else range = function(node, start, end) {
7322
- var r = document.body.createTextRange();
7323
- r.moveToElementText(node.parentNode);
7324
- r.collapse(true);
7325
- r.moveEnd("character", end);
7326
- r.moveStart("character", start);
7327
- return r;
7328
  };
7329
 
7330
- function removeChildren(e) {
7331
- for (var count = e.childNodes.length; count > 0; --count)
7332
- e.removeChild(e.firstChild);
7333
- return e;
7334
- }
7335
 
7336
- function removeChildrenAndAdd(parent, e) {
7337
- return removeChildren(parent).appendChild(e);
7338
- }
 
 
 
 
 
 
7339
 
7340
- function contains(parent, child) {
7341
- if (parent.contains)
7342
- return parent.contains(child);
7343
- while (child = child.parentNode)
7344
- if (child == parent) return true;
7345
- }
7346
 
7347
- function activeElt() { return document.activeElement; }
7348
- // Older versions of IE throws unspecified error when touching
7349
- // document.activeElement in some cases (during loading, in iframe)
7350
- if (ie && ie_version < 11) activeElt = function() {
7351
- try { return document.activeElement; }
7352
- catch(e) { return document.body; }
 
 
7353
  };
7354
 
7355
- function classTest(cls) { return new RegExp("\\b" + cls + "\\b\\s*"); }
7356
- function rmClass(node, cls) {
7357
- var test = classTest(cls);
7358
- if (test.test(node.className)) node.className = node.className.replace(test, "");
7359
- }
7360
- function addClass(node, cls) {
7361
- if (!classTest(cls).test(node.className)) node.className += " " + cls;
7362
- }
7363
- function joinClasses(a, b) {
7364
- var as = a.split(" ");
7365
- for (var i = 0; i < as.length; i++)
7366
- if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
7367
- return b;
7368
- }
 
 
7369
 
7370
- // WINDOW-WIDE EVENTS
7371
 
7372
- // These must be handled carefully, because naively registering a
7373
- // handler for each editor will cause the editors to never be
7374
- // garbage collected.
7375
 
7376
- function forEachCodeMirror(f) {
7377
- if (!document.body.getElementsByClassName) return;
7378
- var byClass = document.body.getElementsByClassName("CodeMirror");
7379
- for (var i = 0; i < byClass.length; i++) {
7380
- var cm = byClass[i].CodeMirror;
7381
- if (cm) f(cm);
7382
  }
7383
- }
7384
 
7385
- var globalsRegistered = false;
7386
- function ensureGlobalHandlers() {
7387
- if (globalsRegistered) return;
7388
- registerGlobalHandlers();
7389
- globalsRegistered = true;
7390
- }
7391
- function registerGlobalHandlers() {
7392
- // When the window resizes, we need to refresh active editors.
7393
- var resizeTimer;
7394
- on(window, "resize", function() {
7395
- if (resizeTimer == null) resizeTimer = setTimeout(function() {
7396
- resizeTimer = null;
7397
- knownScrollbarWidth = null;
7398
- forEachCodeMirror(onResize);
7399
- }, 100);
7400
- });
7401
- // When the window loses focus, we want to show the editor as blurred
7402
- on(window, "blur", function() {
7403
- forEachCodeMirror(onBlur);
7404
  });
7405
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7406
 
7407
- // FEATURE DETECTION
 
 
 
 
 
 
 
7408
 
7409
- // Detect drag-and-drop
7410
- var dragAndDrop = function() {
7411
- // There is *some* kind of drag-and-drop support in IE6-8, but I
7412
- // couldn't get it to work yet.
7413
- if (ie && ie_version < 9) return false;
7414
- var div = elt('div');
7415
- return "draggable" in div || "dragDrop" in div;
7416
- }();
 
7417
 
7418
- var knownScrollbarWidth;
7419
- function scrollbarWidth(measure) {
7420
- if (knownScrollbarWidth != null) return knownScrollbarWidth;
7421
- var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll");
7422
- removeChildrenAndAdd(measure, test);
7423
- if (test.offsetWidth)
7424
- knownScrollbarWidth = test.offsetHeight - test.clientHeight;
7425
- return knownScrollbarWidth || 0;
7426
- }
 
 
7427
 
7428
- var zwspSupported;
7429
- function zeroWidthElement(measure) {
7430
- if (zwspSupported == null) {
7431
- var test = elt("span", "\u200b");
7432
- removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
7433
- if (measure.firstChild.offsetHeight != 0)
7434
- zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
7435
  }
7436
- if (zwspSupported) return elt("span", "\u200b");
7437
- else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
7438
- }
7439
 
7440
- // Feature-detect IE's crummy client rect reporting for bidi text
7441
- var badBidiRects;
7442
- function hasBadBidiRects(measure) {
7443
- if (badBidiRects != null) return badBidiRects;
7444
- var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
7445
- var r0 = range(txt, 0, 1).getBoundingClientRect();
7446
- if (r0.left == r0.right) return false;
7447
- var r1 = range(txt, 1, 2).getBoundingClientRect();
7448
- return badBidiRects = (r1.right - r0.right < 3);
7449
- }
7450
 
7451
- // See if "".split is the broken IE version, if so, provide an
7452
- // alternative way to split lines.
7453
- var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
7454
- var pos = 0, result = [], l = string.length;
7455
- while (pos <= l) {
7456
- var nl = string.indexOf("\n", pos);
7457
- if (nl == -1) nl = string.length;
7458
- var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
7459
- var rt = line.indexOf("\r");
7460
- if (rt != -1) {
7461
- result.push(line.slice(0, rt));
7462
- pos += rt + 1;
7463
- } else {
7464
- result.push(line);
7465
- pos = nl + 1;
7466
  }
7467
- }
7468
- return result;
7469
- } : function(string){return string.split(/\r\n?|\n/);};
7470
 
7471
- var hasSelection = window.getSelection ? function(te) {
7472
- try { return te.selectionStart != te.selectionEnd; }
7473
- catch(e) { return false; }
7474
- } : function(te) {
7475
- try {var range = te.ownerDocument.selection.createRange();}
7476
- catch(e) {}
7477
- if (!range || range.parentElement() != te) return false;
7478
- return range.compareEndPoints("StartToEnd", range) != 0;
7479
  };
7480
 
7481
- var hasCopyEvent = (function() {
7482
- var e = elt("div");
7483
- if ("oncopy" in e) return true;
7484
- e.setAttribute("oncopy", "return;");
7485
- return typeof e.oncopy == "function";
7486
- })();
7487
 
7488
- var badZoomedRects = null;
7489
- function hasBadZoomedRects(measure) {
7490
- if (badZoomedRects != null) return badZoomedRects;
7491
- var node = removeChildrenAndAdd(measure, elt("span", "x"));
7492
- var normal = node.getBoundingClientRect();
7493
- var fromRange = range(node, 0, 1).getBoundingClientRect();
7494
- return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
7495
- }
7496
-
7497
- // KEY NAMES
7498
-
7499
- var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
7500
- 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
7501
- 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
7502
- 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
7503
- 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
7504
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
7505
- 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
7506
- CodeMirror.keyNames = keyNames;
7507
- (function() {
7508
- // Number keys
7509
- for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
7510
- // Alphabetic keys
7511
- for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
7512
- // Function keys
7513
- for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
7514
- })();
7515
 
7516
- // BIDI HELPERS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7517
 
7518
- function iterateBidiSections(order, from, to, f) {
7519
- if (!order) return f(from, to, "ltr");
7520
- var found = false;
7521
- for (var i = 0; i < order.length; ++i) {
7522
- var part = order[i];
7523
- if (part.from < to && part.to > from || from == to && part.to == from) {
7524
- f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
7525
- found = true;
 
 
 
 
 
 
7526
  }
7527
  }
7528
- if (!found) f(from, to, "ltr");
7529
- }
7530
-
7531
- function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
7532
- function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
7533
-
7534
- function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
7535
- function lineRight(line) {
7536
- var order = getOrder(line);
7537
- if (!order) return line.text.length;
7538
- return bidiRight(lst(order));
7539
- }
7540
 
7541
- function lineStart(cm, lineN) {
7542
- var line = getLine(cm.doc, lineN);
7543
- var visual = visualLine(line);
7544
- if (visual != line) lineN = lineNo(visual);
7545
- var order = getOrder(visual);
7546
- var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
7547
- return Pos(lineN, ch);
7548
- }
7549
- function lineEnd(cm, lineN) {
7550
- var merged, line = getLine(cm.doc, lineN);
7551
- while (merged = collapsedSpanAtEnd(line)) {
7552
- line = merged.find(1, true).line;
7553
- lineN = null;
 
 
 
7554
  }
7555
- var order = getOrder(line);
7556
- var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
7557
- return Pos(lineN == null ? lineNo(line) : lineN, ch);
7558
- }
7559
 
7560
- function compareBidiLevel(order, a, b) {
7561
- var linedir = order[0].level;
7562
- if (a == linedir) return true;
7563
- if (b == linedir) return false;
7564
- return a < b;
7565
- }
7566
- var bidiOther;
7567
- function getBidiPartAt(order, pos) {
7568
- bidiOther = null;
7569
- for (var i = 0, found; i < order.length; ++i) {
7570
- var cur = order[i];
7571
- if (cur.from < pos && cur.to > pos) return i;
7572
- if ((cur.from == pos || cur.to == pos)) {
7573
- if (found == null) {
7574
- found = i;
7575
- } else if (compareBidiLevel(order, cur.level, order[found].level)) {
7576
- if (cur.from != cur.to) bidiOther = found;
7577
- return i;
7578
- } else {
7579
- if (cur.from != cur.to) bidiOther = i;
7580
- return found;
7581
- }
7582
- }
7583
  }
7584
- return found;
7585
- }
7586
 
7587
- function moveInLine(line, pos, dir, byUnit) {
7588
- if (!byUnit) return pos + dir;
7589
- do pos += dir;
7590
- while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
7591
- return pos;
7592
- }
7593
 
7594
- // This is needed in order to move 'visually' through bi-directional
7595
- // text -- i.e., pressing left should make the cursor go left, even
7596
- // when in RTL text. The tricky part is the 'jumps', where RTL and
7597
- // LTR text touch each other. This often requires the cursor offset
7598
- // to move more than one unit, in order to visually move one unit.
7599
- function moveVisually(line, start, dir, byUnit) {
7600
- var bidi = getOrder(line);
7601
- if (!bidi) return moveLogically(line, start, dir, byUnit);
7602
- var pos = getBidiPartAt(bidi, start), part = bidi[pos];
7603
- var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
7604
 
7605
- for (;;) {
7606
- if (target > part.from && target < part.to) return target;
7607
- if (target == part.from || target == part.to) {
7608
- if (getBidiPartAt(bidi, target) == pos) return target;
7609
- part = bidi[pos += dir];
7610
- return (dir > 0) == part.level % 2 ? part.to : part.from;
7611
- } else {
7612
- part = bidi[pos += dir];
7613
- if (!part) return null;
7614
- if ((dir > 0) == part.level % 2)
7615
- target = moveInLine(line, part.to, -1, byUnit);
7616
- else
7617
- target = moveInLine(line, part.from, 1, byUnit);
7618
- }
 
7619
  }
7620
- }
7621
 
7622
- function moveLogically(line, start, dir, byUnit) {
7623
- var target = start + dir;
7624
- if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
7625
- return target < 0 || target > line.text.length ? null : target;
7626
- }
7627
 
7628
- // Bidirectional ordering algorithm
7629
- // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
7630
- // that this (partially) implements.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7631
 
7632
- // One-char codes used for character types:
7633
- // L (L): Left-to-Right
7634
- // R (R): Right-to-Left
7635
- // r (AL): Right-to-Left Arabic
7636
- // 1 (EN): European Number
7637
- // + (ES): European Number Separator
7638
- // % (ET): European Number Terminator
7639
- // n (AN): Arabic Number
7640
- // , (CS): Common Number Separator
7641
- // m (NSM): Non-Spacing Mark
7642
- // b (BN): Boundary Neutral
7643
- // s (B): Paragraph Separator
7644
- // t (S): Segment Separator
7645
- // w (WS): Whitespace
7646
- // N (ON): Other Neutrals
7647
 
7648
- // Returns null if characters are ordered as they appear
7649
- // (left-to-right), or an array of sections ({from, to, level}
7650
- // objects) in the order in which they occur visually.
7651
- var bidiOrdering = (function() {
7652
- // Character types for codepoints 0 to 0xff
7653
- var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
7654
- // Character types for codepoints 0x600 to 0x6ff
7655
- var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
7656
- function charType(code) {
7657
- if (code <= 0xf7) return lowTypes.charAt(code);
7658
- else if (0x590 <= code && code <= 0x5f4) return "R";
7659
- else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
7660
- else if (0x6ee <= code && code <= 0x8ac) return "r";
7661
- else if (0x2000 <= code && code <= 0x200b) return "w";
7662
- else if (code == 0x200c) return "b";
7663
- else return "L";
7664
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7665
 
7666
- var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
7667
- var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
7668
- // Browsers seem to always treat the boundaries of block elements as being L.
7669
- var outerType = "L";
7670
 
7671
- function BidiSpan(level, from, to) {
7672
- this.level = level;
7673
- this.from = from; this.to = to;
7674
- }
7675
 
7676
- return function(str) {
7677
- if (!bidiRE.test(str)) return false;
7678
- var len = str.length, types = [];
7679
- for (var i = 0, type; i < len; ++i)
7680
- types.push(type = charType(str.charCodeAt(i)));
7681
 
7682
- // W1. Examine each non-spacing mark (NSM) in the level run, and
7683
- // change the type of the NSM to the type of the previous
7684
- // character. If the NSM is at the start of the level run, it will
7685
- // get the type of sor.
7686
- for (var i = 0, prev = outerType; i < len; ++i) {
7687
- var type = types[i];
7688
- if (type == "m") types[i] = prev;
7689
- else prev = type;
7690
- }
7691
 
7692
- // W2. Search backwards from each instance of a European number
7693
- // until the first strong type (R, L, AL, or sor) is found. If an
7694
- // AL is found, change the type of the European number to Arabic
7695
- // number.
7696
- // W3. Change all ALs to R.
7697
- for (var i = 0, cur = outerType; i < len; ++i) {
7698
- var type = types[i];
7699
- if (type == "1" && cur == "r") types[i] = "n";
7700
- else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
7701
- }
7702
 
7703
- // W4. A single European separator between two European numbers
7704
- // changes to a European number. A single common separator between
7705
- // two numbers of the same type changes to that type.
7706
- for (var i = 1, prev = types[0]; i < len - 1; ++i) {
7707
- var type = types[i];
7708
- if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
7709
- else if (type == "," && prev == types[i+1] &&
7710
- (prev == "1" || prev == "n")) types[i] = prev;
7711
- prev = type;
7712
- }
7713
 
7714
- // W5. A sequence of European terminators adjacent to European
7715
- // numbers changes to all European numbers.
7716
- // W6. Otherwise, separators and terminators change to Other
7717
- // Neutral.
7718
- for (var i = 0; i < len; ++i) {
7719
- var type = types[i];
7720
- if (type == ",") types[i] = "N";
7721
- else if (type == "%") {
7722
- for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
7723
- var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
7724
- for (var j = i; j < end; ++j) types[j] = replace;
7725
- i = end - 1;
7726
- }
7727
- }
7728
 
7729
- // W7. Search backwards from each instance of a European number
7730
- // until the first strong type (R, L, or sor) is found. If an L is
7731
- // found, then change the type of the European number to L.
7732
- for (var i = 0, cur = outerType; i < len; ++i) {
7733
- var type = types[i];
7734
- if (cur == "L" && type == "1") types[i] = "L";
7735
- else if (isStrong.test(type)) cur = type;
7736
- }
7737
 
7738
- // N1. A sequence of neutrals takes the direction of the
7739
- // surrounding strong text if the text on both sides has the same
7740
- // direction. European and Arabic numbers act as if they were R in
7741
- // terms of their influence on neutrals. Start-of-level-run (sor)
7742
- // and end-of-level-run (eor) are used at level run boundaries.
7743
- // N2. Any remaining neutrals take the embedding direction.
7744
- for (var i = 0; i < len; ++i) {
7745
- if (isNeutral.test(types[i])) {
7746
- for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
7747
- var before = (i ? types[i-1] : outerType) == "L";
7748
- var after = (end < len ? types[end] : outerType) == "L";
7749
- var replace = before || after ? "L" : "R";
7750
- for (var j = i; j < end; ++j) types[j] = replace;
7751
- i = end - 1;
7752
- }
7753
- }
7754
 
7755
- // Here we depart from the documented algorithm, in order to avoid
7756
- // building up an actual levels array. Since there are only three
7757
- // levels (0, 1, 2) in an implementation that doesn't take
7758
- // explicit embedding into account, we can build up the order on
7759
- // the fly, without following the level-based algorithm.
7760
- var order = [], m;
7761
- for (var i = 0; i < len;) {
7762
- if (countsAsLeft.test(types[i])) {
7763
- var start = i;
7764
- for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
7765
- order.push(new BidiSpan(0, start, i));
7766
- } else {
7767
- var pos = i, at = order.length;
7768
- for (++i; i < len && types[i] != "L"; ++i) {}
7769
- for (var j = pos; j < i;) {
7770
- if (countsAsNum.test(types[j])) {
7771
- if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
7772
- var nstart = j;
7773
- for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
7774
- order.splice(at, 0, new BidiSpan(2, nstart, j));
7775
- pos = j;
7776
- } else ++j;
7777
- }
7778
- if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
7779
- }
7780
- }
7781
- if (order[0].level == 1 && (m = str.match(/^\s+/))) {
7782
- order[0].from = m[0].length;
7783
- order.unshift(new BidiSpan(0, 0, m[0].length));
7784
- }
7785
- if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
7786
- lst(order).to -= m[0].length;
7787
- order.push(new BidiSpan(0, len - m[0].length, len));
7788
- }
7789
- if (order[0].level != lst(order).level)
7790
- order.push(new BidiSpan(order[0].level, len, len));
7791
 
7792
- return order;
7793
- };
7794
- })();
7795
 
7796
- // THE END
7797
 
7798
- CodeMirror.version = "4.4.0";
7799
 
7800
  return CodeMirror;
7801
- });
 
1
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: https://codemirror.net/LICENSE
3
 
4
+ // This is CodeMirror (https://codemirror.net), a code editor
5
  // implemented in JavaScript on top of the browser's DOM.
6
  //
7
  // You can find some technical background for some of the code below
8
  // at http://marijnhaverbeke.nl/blog/#cm-internals .
9
 
10
+ (function (global, factory) {
11
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
12
+ typeof define === 'function' && define.amd ? define(factory) :
13
+ (global.CodeMirror = factory());
14
+ }(this, (function () { 'use strict';
 
 
 
 
 
 
15
 
16
  // Kludges for bugs and behavior differences that can't be feature
17
  // detected are enabled based on userAgent etc sniffing.
18
+ var userAgent = navigator.userAgent;
19
+ var platform = navigator.platform;
20
+
21
+ var gecko = /gecko\/\d/i.test(userAgent);
22
+ var ie_upto10 = /MSIE \d/.test(userAgent);
23
+ var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
24
+ var edge = /Edge\/(\d+)/.exec(userAgent);
25
+ var ie = ie_upto10 || ie_11up || edge;
26
+ var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
27
+ var webkit = !edge && /WebKit\//.test(userAgent);
28
+ var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
29
+ var chrome = !edge && /Chrome\//.test(userAgent);
30
+ var presto = /Opera\//.test(userAgent);
31
  var safari = /Apple Computer/.test(navigator.vendor);
32
+ var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
33
+ var phantom = /PhantomJS/.test(userAgent);
 
34
 
35
+ var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
36
+ var android = /Android/.test(userAgent);
37
  // This is woefully incomplete. Suggestions for alternative methods welcome.
38
+ var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
39
+ var mac = ios || /Mac/.test(platform);
40
+ var chromeOS = /\bCrOS\b/.test(userAgent);
41
+ var windows = /win/i.test(platform);
42
 
43
+ var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
44
+ if (presto_version) { presto_version = Number(presto_version[1]); }
45
  if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
46
  // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
47
  var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
48
  var captureRightClick = gecko || (ie && ie_version >= 9);
49
 
50
+ function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ var rmClass = function(node, cls) {
53
+ var current = node.className;
54
+ var match = classTest(cls).exec(current);
55
+ if (match) {
56
+ var after = current.slice(match.index + match[0].length);
57
+ node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
58
+ }
59
+ };
60
 
61
+ function removeChildren(e) {
62
+ for (var count = e.childNodes.length; count > 0; --count)
63
+ { e.removeChild(e.firstChild); }
64
+ return e
65
+ }
66
 
67
+ function removeChildrenAndAdd(parent, e) {
68
+ return removeChildren(parent).appendChild(e)
 
 
 
69
  }
70
 
71
+ function elt(tag, content, className, style) {
72
+ var e = document.createElement(tag);
73
+ if (className) { e.className = className; }
74
+ if (style) { e.style.cssText = style; }
75
+ if (typeof content == "string") { e.appendChild(document.createTextNode(content)); }
76
+ else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } }
77
+ return e
78
+ }
79
+ // wrapper for elt, which removes the elt from the accessibility tree
80
+ function eltP(tag, content, className, style) {
81
+ var e = elt(tag, content, className, style);
82
+ e.setAttribute("role", "presentation");
83
+ return e
84
+ }
85
 
86
+ var range;
87
+ if (document.createRange) { range = function(node, start, end, endNode) {
88
+ var r = document.createRange();
89
+ r.setEnd(endNode || node, end);
90
+ r.setStart(node, start);
91
+ return r
92
+ }; }
93
+ else { range = function(node, start, end) {
94
+ var r = document.body.createTextRange();
95
+ try { r.moveToElementText(node.parentNode); }
96
+ catch(e) { return r }
97
+ r.collapse(true);
98
+ r.moveEnd("character", end);
99
+ r.moveStart("character", start);
100
+ return r
101
+ }; }
102
 
103
+ function contains(parent, child) {
104
+ if (child.nodeType == 3) // Android browser always returns false when child is a textnode
105
+ { child = child.parentNode; }
106
+ if (parent.contains)
107
+ { return parent.contains(child) }
108
+ do {
109
+ if (child.nodeType == 11) { child = child.host; }
110
+ if (child == parent) { return true }
111
+ } while (child = child.parentNode)
112
+ }
113
 
114
+ function activeElt() {
115
+ // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
116
+ // IE < 10 will throw when accessed while the page is loading or in an iframe.
117
+ // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
118
+ var activeElement;
119
+ try {
120
+ activeElement = document.activeElement;
121
+ } catch(e) {
122
+ activeElement = document.body || null;
123
+ }
124
+ while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
125
+ { activeElement = activeElement.shadowRoot.activeElement; }
126
+ return activeElement
127
+ }
128
 
129
+ function addClass(node, cls) {
130
+ var current = node.className;
131
+ if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; }
132
+ }
133
+ function joinClasses(a, b) {
134
+ var as = a.split(" ");
135
+ for (var i = 0; i < as.length; i++)
136
+ { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } }
137
+ return b
138
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
+ var selectInput = function(node) { node.select(); };
141
+ if (ios) // Mobile Safari apparently has a bug where select() is broken.
142
+ { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; }
143
+ else if (ie) // Suppress mysterious IE10 errors
144
+ { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
 
 
 
 
145
 
146
+ function bind(f) {
147
+ var args = Array.prototype.slice.call(arguments, 1);
148
+ return function(){return f.apply(null, args)}
149
+ }
150
 
151
+ function copyObj(obj, target, overwrite) {
152
+ if (!target) { target = {}; }
153
+ for (var prop in obj)
154
+ { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
155
+ { target[prop] = obj[prop]; } }
156
+ return target
157
+ }
 
 
 
 
158
 
159
+ // Counts the column offset in a string, taking tabs into account.
160
+ // Used mostly to find indentation.
161
+ function countColumn(string, end, tabSize, startIndex, startValue) {
162
+ if (end == null) {
163
+ end = string.search(/[^\s\u00a0]/);
164
+ if (end == -1) { end = string.length; }
165
+ }
166
+ for (var i = startIndex || 0, n = startValue || 0;;) {
167
+ var nextTab = string.indexOf("\t", i);
168
+ if (nextTab < 0 || nextTab >= end)
169
+ { return n + (end - i) }
170
+ n += nextTab - i;
171
+ n += tabSize - (n % tabSize);
172
+ i = nextTab + 1;
173
+ }
174
+ }
175
 
176
+ var Delayed = function() {
177
+ this.id = null;
178
+ this.f = null;
179
+ this.time = 0;
180
+ this.handler = bind(this.onTimeout, this);
181
+ };
182
+ Delayed.prototype.onTimeout = function (self) {
183
+ self.id = 0;
184
+ if (self.time <= +new Date) {
185
+ self.f();
186
+ } else {
187
+ setTimeout(self.handler, self.time - +new Date);
188
+ }
189
+ };
190
+ Delayed.prototype.set = function (ms, f) {
191
+ this.f = f;
192
+ var time = +new Date + ms;
193
+ if (!this.id || time < this.time) {
194
+ clearTimeout(this.id);
195
+ this.id = setTimeout(this.handler, ms);
196
+ this.time = time;
197
+ }
198
+ };
199
 
200
+ function indexOf(array, elt) {
201
+ for (var i = 0; i < array.length; ++i)
202
+ { if (array[i] == elt) { return i } }
203
+ return -1
204
+ }
205
 
206
+ // Number of pixels added to scroller and sizer to hide scrollbar
207
+ var scrollerGap = 30;
 
 
 
208
 
209
+ // Returned or thrown by various protocols to signal 'I'm not
210
+ // handling this'.
211
+ var Pass = {toString: function(){return "CodeMirror.Pass"}};
212
 
213
+ // Reused option objects for setSelection & friends
214
+ var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
215
 
216
+ // The inverse of countColumn -- find the offset that corresponds to
217
+ // a particular column.
218
+ function findColumn(string, goal, tabSize) {
219
+ for (var pos = 0, col = 0;;) {
220
+ var nextTab = string.indexOf("\t", pos);
221
+ if (nextTab == -1) { nextTab = string.length; }
222
+ var skipped = nextTab - pos;
223
+ if (nextTab == string.length || col + skipped >= goal)
224
+ { return pos + Math.min(skipped, goal - col) }
225
+ col += nextTab - pos;
226
+ col += tabSize - (col % tabSize);
227
+ pos = nextTab + 1;
228
+ if (col >= goal) { return pos }
229
+ }
230
  }
231
 
232
+ var spaceStrs = [""];
233
+ function spaceStr(n) {
234
+ while (spaceStrs.length <= n)
235
+ { spaceStrs.push(lst(spaceStrs) + " "); }
236
+ return spaceStrs[n]
237
+ }
238
 
239
+ function lst(arr) { return arr[arr.length-1] }
240
 
241
+ function map(array, f) {
242
+ var out = [];
243
+ for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); }
244
+ return out
245
  }
246
 
247
+ function insertSorted(array, value, score) {
248
+ var pos = 0, priority = score(value);
249
+ while (pos < array.length && score(array[pos]) <= priority) { pos++; }
250
+ array.splice(pos, 0, value);
 
 
 
 
 
251
  }
252
 
253
+ function nothing() {}
254
+
255
+ function createObj(base, props) {
256
+ var inst;
257
+ if (Object.create) {
258
+ inst = Object.create(base);
259
  } else {
260
+ nothing.prototype = base;
261
+ inst = new nothing();
262
  }
263
+ if (props) { copyObj(props, inst); }
264
+ return inst
 
 
265
  }
266
 
267
+ var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
268
+ function isWordCharBasic(ch) {
269
+ return /\w/.test(ch) || ch > "\x80" &&
270
+ (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  }
272
+ function isWordChar(ch, helper) {
273
+ if (!helper) { return isWordCharBasic(ch) }
274
+ if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
275
+ return helper.test(ch)
 
 
 
276
  }
277
 
278
+ function isEmpty(obj) {
279
+ for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
280
+ return true
 
281
  }
282
 
283
+ // Extending unicode characters. A series of a non-extending char +
284
+ // any number of extending chars is treated as a single unit as far
285
+ // as editing and measuring is concerned. This is not fully correct,
286
+ // since some scripts/fonts/browsers also treat other configurations
287
+ // of code points as a group.
288
+ var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
289
+ function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
290
+
291
+ // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
292
+ function skipExtendingChars(str, pos, dir) {
293
+ while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; }
294
+ return pos
295
  }
296
 
297
+ // Returns the value from the range [`from`; `to`] that satisfies
298
+ // `pred` and is closest to `from`. Assumes that at least `to`
299
+ // satisfies `pred`. Supports `from` being greater than `to`.
300
+ function findFirst(pred, from, to) {
301
+ // At any point we are certain `to` satisfies `pred`, don't know
302
+ // whether `from` does.
303
+ var dir = from > to ? -1 : 1;
304
+ for (;;) {
305
+ if (from == to) { return from }
306
+ var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
307
+ if (mid == from) { return pred(mid) ? from : to }
308
+ if (pred(mid)) { to = mid; }
309
+ else { from = mid + dir; }
310
+ }
311
  }
312
 
313
+ // BIDI HELPERS
314
+
315
+ function iterateBidiSections(order, from, to, f) {
316
+ if (!order) { return f(from, to, "ltr", 0) }
317
+ var found = false;
318
+ for (var i = 0; i < order.length; ++i) {
319
+ var part = order[i];
320
+ if (part.from < to && part.to > from || from == to && part.to == from) {
321
+ f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
322
+ found = true;
 
323
  }
324
  }
325
+ if (!found) { f(from, to, "ltr"); }
 
326
  }
327
 
328
+ var bidiOther = null;
329
+ function getBidiPartAt(order, ch, sticky) {
330
+ var found;
331
+ bidiOther = null;
332
+ for (var i = 0; i < order.length; ++i) {
333
+ var cur = order[i];
334
+ if (cur.from < ch && cur.to > ch) { return i }
335
+ if (cur.to == ch) {
336
+ if (cur.from != cur.to && sticky == "before") { found = i; }
337
+ else { bidiOther = i; }
338
+ }
339
+ if (cur.from == ch) {
340
+ if (cur.from != cur.to && sticky != "before") { found = i; }
341
+ else { bidiOther = i; }
342
+ }
343
+ }
344
+ return found != null ? found : bidiOther
345
  }
346
 
347
+ // Bidirectional ordering algorithm
348
+ // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
349
+ // that this (partially) implements.
350
+
351
+ // One-char codes used for character types:
352
+ // L (L): Left-to-Right
353
+ // R (R): Right-to-Left
354
+ // r (AL): Right-to-Left Arabic
355
+ // 1 (EN): European Number
356
+ // + (ES): European Number Separator
357
+ // % (ET): European Number Terminator
358
+ // n (AN): Arabic Number
359
+ // , (CS): Common Number Separator
360
+ // m (NSM): Non-Spacing Mark
361
+ // b (BN): Boundary Neutral
362
+ // s (B): Paragraph Separator
363
+ // t (S): Segment Separator
364
+ // w (WS): Whitespace
365
+ // N (ON): Other Neutrals
366
+
367
+ // Returns null if characters are ordered as they appear
368
+ // (left-to-right), or an array of sections ({from, to, level}
369
+ // objects) in the order in which they occur visually.
370
+ var bidiOrdering = (function() {
371
+ // Character types for codepoints 0 to 0xff
372
+ var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
373
+ // Character types for codepoints 0x600 to 0x6f9
374
+ var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
375
+ function charType(code) {
376
+ if (code <= 0xf7) { return lowTypes.charAt(code) }
377
+ else if (0x590 <= code && code <= 0x5f4) { return "R" }
378
+ else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
379
+ else if (0x6ee <= code && code <= 0x8ac) { return "r" }
380
+ else if (0x2000 <= code && code <= 0x200b) { return "w" }
381
+ else if (code == 0x200c) { return "b" }
382
+ else { return "L" }
383
  }
384
+
385
+ var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
386
+ var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
387
+
388
+ function BidiSpan(level, from, to) {
389
+ this.level = level;
390
+ this.from = from; this.to = to;
391
  }
 
 
392
 
393
+ return function(str, direction) {
394
+ var outerType = direction == "ltr" ? "L" : "R";
395
+
396
+ if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
397
+ var len = str.length, types = [];
398
+ for (var i = 0; i < len; ++i)
399
+ { types.push(charType(str.charCodeAt(i))); }
400
+
401
+ // W1. Examine each non-spacing mark (NSM) in the level run, and
402
+ // change the type of the NSM to the type of the previous
403
+ // character. If the NSM is at the start of the level run, it will
404
+ // get the type of sor.
405
+ for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
406
+ var type = types[i$1];
407
+ if (type == "m") { types[i$1] = prev; }
408
+ else { prev = type; }
409
  }
 
 
410
 
411
+ // W2. Search backwards from each instance of a European number
412
+ // until the first strong type (R, L, AL, or sor) is found. If an
413
+ // AL is found, change the type of the European number to Arabic
414
+ // number.
415
+ // W3. Change all ALs to R.
416
+ for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
417
+ var type$1 = types[i$2];
418
+ if (type$1 == "1" && cur == "r") { types[i$2] = "n"; }
419
+ else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } }
420
+ }
 
421
 
422
+ // W4. A single European separator between two European numbers
423
+ // changes to a European number. A single common separator between
424
+ // two numbers of the same type changes to that type.
425
+ for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
426
+ var type$2 = types[i$3];
427
+ if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; }
428
+ else if (type$2 == "," && prev$1 == types[i$3+1] &&
429
+ (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; }
430
+ prev$1 = type$2;
431
+ }
432
 
433
+ // W5. A sequence of European terminators adjacent to European
434
+ // numbers changes to all European numbers.
435
+ // W6. Otherwise, separators and terminators change to Other
436
+ // Neutral.
437
+ for (var i$4 = 0; i$4 < len; ++i$4) {
438
+ var type$3 = types[i$4];
439
+ if (type$3 == ",") { types[i$4] = "N"; }
440
+ else if (type$3 == "%") {
441
+ var end = (void 0);
442
+ for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
443
+ var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
444
+ for (var j = i$4; j < end; ++j) { types[j] = replace; }
445
+ i$4 = end - 1;
446
+ }
447
+ }
448
 
449
+ // W7. Search backwards from each instance of a European number
450
+ // until the first strong type (R, L, or sor) is found. If an L is
451
+ // found, then change the type of the European number to L.
452
+ for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
453
+ var type$4 = types[i$5];
454
+ if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; }
455
+ else if (isStrong.test(type$4)) { cur$1 = type$4; }
456
+ }
 
 
 
 
 
457
 
458
+ // N1. A sequence of neutrals takes the direction of the
459
+ // surrounding strong text if the text on both sides has the same
460
+ // direction. European and Arabic numbers act as if they were R in
461
+ // terms of their influence on neutrals. Start-of-level-run (sor)
462
+ // and end-of-level-run (eor) are used at level run boundaries.
463
+ // N2. Any remaining neutrals take the embedding direction.
464
+ for (var i$6 = 0; i$6 < len; ++i$6) {
465
+ if (isNeutral.test(types[i$6])) {
466
+ var end$1 = (void 0);
467
+ for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
468
+ var before = (i$6 ? types[i$6-1] : outerType) == "L";
469
+ var after = (end$1 < len ? types[end$1] : outerType) == "L";
470
+ var replace$1 = before == after ? (before ? "L" : "R") : outerType;
471
+ for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; }
472
+ i$6 = end$1 - 1;
473
+ }
474
+ }
475
 
476
+ // Here we depart from the documented algorithm, in order to avoid
477
+ // building up an actual levels array. Since there are only three
478
+ // levels (0, 1, 2) in an implementation that doesn't take
479
+ // explicit embedding into account, we can build up the order on
480
+ // the fly, without following the level-based algorithm.
481
+ var order = [], m;
482
+ for (var i$7 = 0; i$7 < len;) {
483
+ if (countsAsLeft.test(types[i$7])) {
484
+ var start = i$7;
485
+ for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
486
+ order.push(new BidiSpan(0, start, i$7));
487
+ } else {
488
+ var pos = i$7, at = order.length;
489
+ for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
490
+ for (var j$2 = pos; j$2 < i$7;) {
491
+ if (countsAsNum.test(types[j$2])) {
492
+ if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }
493
+ var nstart = j$2;
494
+ for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
495
+ order.splice(at, 0, new BidiSpan(2, nstart, j$2));
496
+ pos = j$2;
497
+ } else { ++j$2; }
498
+ }
499
+ if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); }
500
+ }
501
+ }
502
+ if (direction == "ltr") {
503
+ if (order[0].level == 1 && (m = str.match(/^\s+/))) {
504
+ order[0].from = m[0].length;
505
+ order.unshift(new BidiSpan(0, 0, m[0].length));
506
+ }
507
+ if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
508
+ lst(order).to -= m[0].length;
509
+ order.push(new BidiSpan(0, len - m[0].length, len));
510
+ }
 
 
 
 
511
  }
512
+
513
+ return direction == "rtl" ? order.reverse() : order
514
  }
515
+ })();
516
+
517
+ // Get the bidi ordering for the given line (and cache it). Returns
518
+ // false for lines that are fully left-to-right, and an array of
519
+ // BidiSpan objects otherwise.
520
+ function getOrder(line, direction) {
521
+ var order = line.order;
522
+ if (order == null) { order = line.order = bidiOrdering(line.text, direction); }
523
+ return order
524
  }
525
 
526
+ // EVENT HANDLING
 
 
 
 
 
 
527
 
528
+ // Lightweight event framework. on/off also work on DOM nodes,
529
+ // registering native DOM handlers.
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
+ var noHandlers = [];
532
 
533
+ var on = function(emitter, type, f) {
534
+ if (emitter.addEventListener) {
535
+ emitter.addEventListener(type, f, false);
536
+ } else if (emitter.attachEvent) {
537
+ emitter.attachEvent("on" + type, f);
538
+ } else {
539
+ var map$$1 = emitter._handlers || (emitter._handlers = {});
540
+ map$$1[type] = (map$$1[type] || noHandlers).concat(f);
 
 
 
 
 
541
  }
542
+ };
543
+
544
+ function getHandlers(emitter, type) {
545
+ return emitter._handlers && emitter._handlers[type] || noHandlers
546
  }
547
 
548
+ function off(emitter, type, f) {
549
+ if (emitter.removeEventListener) {
550
+ emitter.removeEventListener(type, f, false);
551
+ } else if (emitter.detachEvent) {
552
+ emitter.detachEvent("on" + type, f);
553
+ } else {
554
+ var map$$1 = emitter._handlers, arr = map$$1 && map$$1[type];
555
+ if (arr) {
556
+ var index = indexOf(arr, f);
557
+ if (index > -1)
558
+ { map$$1[type] = arr.slice(0, index).concat(arr.slice(index + 1)); }
559
+ }
 
 
 
 
 
560
  }
 
561
  }
562
 
563
+ function signal(emitter, type /*, values...*/) {
564
+ var handlers = getHandlers(emitter, type);
565
+ if (!handlers.length) { return }
566
+ var args = Array.prototype.slice.call(arguments, 2);
567
+ for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); }
568
  }
569
 
570
+ // The DOM events that CodeMirror handles can be overridden by
571
+ // registering a (non-DOM) handler on the editor for the event name,
572
+ // and preventDefault-ing the event in that handler.
573
+ function signalDOMEvent(cm, e, override) {
574
+ if (typeof e == "string")
575
+ { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; }
576
+ signal(cm, override || e.type, cm, e);
577
+ return e_defaultPrevented(e) || e.codemirrorIgnore
578
  }
579
 
580
+ function signalCursorActivity(cm) {
581
+ var arr = cm._handlers && cm._handlers.cursorActivity;
582
+ if (!arr) { return }
583
+ var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
584
+ for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
585
+ { set.push(arr[i]); } }
586
+ }
587
 
588
+ function hasHandler(emitter, type) {
589
+ return getHandlers(emitter, type).length > 0
 
 
 
 
 
 
 
590
  }
591
 
592
+ // Add on and off methods to a constructor's prototype, to make
593
+ // registering events on such objects more convenient.
594
+ function eventMixin(ctor) {
595
+ ctor.prototype.on = function(type, f) {on(this, type, f);};
596
+ ctor.prototype.off = function(type, f) {off(this, type, f);};
597
+ }
 
 
 
598
 
599
+ // Due to the fact that we still support jurassic IE versions, some
600
+ // compatibility wrappers are needed.
 
 
 
 
601
 
602
+ function e_preventDefault(e) {
603
+ if (e.preventDefault) { e.preventDefault(); }
604
+ else { e.returnValue = false; }
605
+ }
606
+ function e_stopPropagation(e) {
607
+ if (e.stopPropagation) { e.stopPropagation(); }
608
+ else { e.cancelBubble = true; }
609
+ }
610
+ function e_defaultPrevented(e) {
611
+ return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
612
+ }
613
+ function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
614
 
615
+ function e_target(e) {return e.target || e.srcElement}
616
+ function e_button(e) {
617
+ var b = e.which;
618
+ if (b == null) {
619
+ if (e.button & 1) { b = 1; }
620
+ else if (e.button & 2) { b = 3; }
621
+ else if (e.button & 4) { b = 2; }
 
 
622
  }
623
+ if (mac && e.ctrlKey && b == 1) { b = 3; }
624
+ return b
625
+ }
626
 
627
+ // Detect drag-and-drop
628
+ var dragAndDrop = function() {
629
+ // There is *some* kind of drag-and-drop support in IE6-8, but I
630
+ // couldn't get it to work yet.
631
+ if (ie && ie_version < 9) { return false }
632
+ var div = elt('div');
633
+ return "draggable" in div || "dragDrop" in div
634
+ }();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
 
636
+ var zwspSupported;
637
+ function zeroWidthElement(measure) {
638
+ if (zwspSupported == null) {
639
+ var test = elt("span", "\u200b");
640
+ removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
641
+ if (measure.firstChild.offsetHeight != 0)
642
+ { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); }
643
  }
644
+ var node = zwspSupported ? elt("span", "\u200b") :
645
+ elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
646
+ node.setAttribute("cm-text", "");
647
+ return node
648
+ }
649
 
650
+ // Feature-detect IE's crummy client rect reporting for bidi text
651
+ var badBidiRects;
652
+ function hasBadBidiRects(measure) {
653
+ if (badBidiRects != null) { return badBidiRects }
654
+ var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
655
+ var r0 = range(txt, 0, 1).getBoundingClientRect();
656
+ var r1 = range(txt, 1, 2).getBoundingClientRect();
657
+ removeChildren(measure);
658
+ if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
659
+ return badBidiRects = (r1.right - r0.right < 3)
660
  }
661
 
662
+ // See if "".split is the broken IE version, if so, provide an
663
+ // alternative way to split lines.
664
+ var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
665
+ var pos = 0, result = [], l = string.length;
666
+ while (pos <= l) {
667
+ var nl = string.indexOf("\n", pos);
668
+ if (nl == -1) { nl = string.length; }
669
+ var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
670
+ var rt = line.indexOf("\r");
671
+ if (rt != -1) {
672
+ result.push(line.slice(0, rt));
673
+ pos += rt + 1;
674
  } else {
675
+ result.push(line);
676
+ pos = nl + 1;
 
 
 
 
 
 
 
 
677
  }
 
 
 
 
 
 
678
  }
679
+ return result
680
+ } : function (string) { return string.split(/\r\n?|\n/); };
681
 
682
+ var hasSelection = window.getSelection ? function (te) {
683
+ try { return te.selectionStart != te.selectionEnd }
684
+ catch(e) { return false }
685
+ } : function (te) {
686
+ var range$$1;
687
+ try {range$$1 = te.ownerDocument.selection.createRange();}
688
+ catch(e) {}
689
+ if (!range$$1 || range$$1.parentElement() != te) { return false }
690
+ return range$$1.compareEndPoints("StartToEnd", range$$1) != 0
691
+ };
692
 
693
+ var hasCopyEvent = (function () {
694
+ var e = elt("div");
695
+ if ("oncopy" in e) { return true }
696
+ e.setAttribute("oncopy", "return;");
697
+ return typeof e.oncopy == "function"
698
+ })();
 
 
 
 
699
 
700
+ var badZoomedRects = null;
701
+ function hasBadZoomedRects(measure) {
702
+ if (badZoomedRects != null) { return badZoomedRects }
703
+ var node = removeChildrenAndAdd(measure, elt("span", "x"));
704
+ var normal = node.getBoundingClientRect();
705
+ var fromRange = range(node, 0, 1).getBoundingClientRect();
706
+ return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
707
  }
708
 
709
+ // Known modes, by name and by MIME
710
+ var modes = {}, mimeModes = {};
 
 
 
 
 
 
711
 
712
+ // Extra arguments are stored as the mode's dependencies, which is
713
+ // used by (legacy) mechanisms like loadmode.js to automatically
714
+ // load a mode. (Preferred mechanism is the require/define calls.)
715
+ function defineMode(name, mode) {
716
+ if (arguments.length > 2)
717
+ { mode.dependencies = Array.prototype.slice.call(arguments, 2); }
718
+ modes[name] = mode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  }
720
 
721
+ function defineMIME(mime, spec) {
722
+ mimeModes[mime] = spec;
 
 
 
723
  }
724
 
725
+ // Given a MIME type, a {name, ...options} config object, or a name
726
+ // string, return a mode config object.
727
+ function resolveMode(spec) {
728
+ if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
729
+ spec = mimeModes[spec];
730
+ } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
731
+ var found = mimeModes[spec.name];
732
+ if (typeof found == "string") { found = {name: found}; }
733
+ spec = createObj(found, spec);
734
+ spec.name = found.name;
735
+ } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
736
+ return resolveMode("application/xml")
737
+ } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
738
+ return resolveMode("application/json")
739
  }
740
+ if (typeof spec == "string") { return {name: spec} }
741
+ else { return spec || {name: "null"} }
 
 
 
742
  }
743
 
744
+ // Given a mode spec (anything that resolveMode accepts), find and
745
+ // initialize an actual mode object.
746
+ function getMode(options, spec) {
747
+ spec = resolveMode(spec);
748
+ var mfactory = modes[spec.name];
749
+ if (!mfactory) { return getMode(options, "text/plain") }
750
+ var modeObj = mfactory(options, spec);
751
+ if (modeExtensions.hasOwnProperty(spec.name)) {
752
+ var exts = modeExtensions[spec.name];
753
+ for (var prop in exts) {
754
+ if (!exts.hasOwnProperty(prop)) { continue }
755
+ if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; }
756
+ modeObj[prop] = exts[prop];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
757
  }
 
758
  }
759
+ modeObj.name = spec.name;
760
+ if (spec.helperType) { modeObj.helperType = spec.helperType; }
761
+ if (spec.modeProps) { for (var prop$1 in spec.modeProps)
762
+ { modeObj[prop$1] = spec.modeProps[prop$1]; } }
763
 
764
+ return modeObj
 
 
 
 
 
 
 
 
 
 
 
765
  }
766
 
767
+ // This can be used to attach properties to mode objects from
768
+ // outside the actual mode definition.
769
+ var modeExtensions = {};
770
+ function extendMode(mode, properties) {
771
+ var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
772
+ copyObj(properties, exts);
 
 
 
 
 
773
  }
774
 
775
+ function copyState(mode, state) {
776
+ if (state === true) { return state }
777
+ if (mode.copyState) { return mode.copyState(state) }
778
+ var nstate = {};
779
+ for (var n in state) {
780
+ var val = state[n];
781
+ if (val instanceof Array) { val = val.concat([]); }
782
+ nstate[n] = val;
 
783
  }
784
+ return nstate
785
  }
786
 
787
+ // Given a mode and a state (for that mode), find the inner mode and
788
+ // state at the position that the state refers to.
789
+ function innerMode(mode, state) {
790
+ var info;
791
+ while (mode.innerMode) {
792
+ info = mode.innerMode(state);
793
+ if (!info || info.mode == mode) { break }
794
+ state = info.state;
795
+ mode = info.mode;
796
  }
797
+ return info || {mode: mode, state: state}
798
  }
799
 
800
+ function startState(mode, a1, a2) {
801
+ return mode.startState ? mode.startState(a1, a2) : true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
802
  }
803
 
804
+ // STRING STREAM
 
 
 
 
 
 
 
 
805
 
806
+ // Fed to the mode parsers, provides helper functions to make
807
+ // parsers more succinct.
808
+
809
+ var StringStream = function(string, tabSize, lineOracle) {
810
+ this.pos = this.start = 0;
811
+ this.string = string;
812
+ this.tabSize = tabSize || 8;
813
+ this.lastColumnPos = this.lastColumnValue = 0;
814
+ this.lineStart = 0;
815
+ this.lineOracle = lineOracle;
816
+ };
817
+
818
+ StringStream.prototype.eol = function () {return this.pos >= this.string.length};
819
+ StringStream.prototype.sol = function () {return this.pos == this.lineStart};
820
+ StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
821
+ StringStream.prototype.next = function () {
822
+ if (this.pos < this.string.length)
823
+ { return this.string.charAt(this.pos++) }
824
+ };
825
+ StringStream.prototype.eat = function (match) {
826
+ var ch = this.string.charAt(this.pos);
827
+ var ok;
828
+ if (typeof match == "string") { ok = ch == match; }
829
+ else { ok = ch && (match.test ? match.test(ch) : match(ch)); }
830
+ if (ok) {++this.pos; return ch}
831
+ };
832
+ StringStream.prototype.eatWhile = function (match) {
833
+ var start = this.pos;
834
+ while (this.eat(match)){}
835
+ return this.pos > start
836
+ };
837
+ StringStream.prototype.eatSpace = function () {
838
+ var this$1 = this;
839
+
840
+ var start = this.pos;
841
+ while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos; }
842
+ return this.pos > start
843
+ };
844
+ StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;};
845
+ StringStream.prototype.skipTo = function (ch) {
846
+ var found = this.string.indexOf(ch, this.pos);
847
+ if (found > -1) {this.pos = found; return true}
848
+ };
849
+ StringStream.prototype.backUp = function (n) {this.pos -= n;};
850
+ StringStream.prototype.column = function () {
851
+ if (this.lastColumnPos < this.start) {
852
+ this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
853
+ this.lastColumnPos = this.start;
854
  }
855
+ return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
856
+ };
857
+ StringStream.prototype.indentation = function () {
858
+ return countColumn(this.string, null, this.tabSize) -
859
+ (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
860
+ };
861
+ StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
862
+ if (typeof pattern == "string") {
863
+ var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; };
864
+ var substr = this.string.substr(this.pos, pattern.length);
865
+ if (cased(substr) == cased(pattern)) {
866
+ if (consume !== false) { this.pos += pattern.length; }
867
+ return true
 
 
 
 
 
868
  }
869
+ } else {
870
+ var match = this.string.slice(this.pos).match(pattern);
871
+ if (match && match.index > 0) { return null }
872
+ if (match && consume !== false) { this.pos += match[0].length; }
873
+ return match
874
  }
875
+ };
876
+ StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
877
+ StringStream.prototype.hideFirstChars = function (n, inner) {
878
+ this.lineStart += n;
879
+ try { return inner() }
880
+ finally { this.lineStart -= n; }
881
+ };
882
+ StringStream.prototype.lookAhead = function (n) {
883
+ var oracle = this.lineOracle;
884
+ return oracle && oracle.lookAhead(n)
885
+ };
886
+ StringStream.prototype.baseToken = function () {
887
+ var oracle = this.lineOracle;
888
+ return oracle && oracle.baseToken(this.pos)
889
+ };
890
 
891
+ // Find the line object corresponding to the given line number.
892
+ function getLine(doc, n) {
893
+ n -= doc.first;
894
+ if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
895
+ var chunk = doc;
896
+ while (!chunk.lines) {
897
+ for (var i = 0;; ++i) {
898
+ var child = chunk.children[i], sz = child.chunkSize();
899
+ if (n < sz) { chunk = child; break }
900
+ n -= sz;
901
+ }
902
  }
903
+ return chunk.lines[n]
904
  }
905
 
906
+ // Get the part of a document between two positions, as an array of
907
+ // strings.
908
+ function getBetween(doc, start, end) {
909
+ var out = [], n = start.line;
910
+ doc.iter(start.line, end.line + 1, function (line) {
911
+ var text = line.text;
912
+ if (n == end.line) { text = text.slice(0, end.ch); }
913
+ if (n == start.line) { text = text.slice(start.ch); }
914
+ out.push(text);
915
+ ++n;
916
+ });
917
+ return out
918
+ }
919
+ // Get the lines between from and to, as array of strings.
920
+ function getLines(doc, from, to) {
921
+ var out = [];
922
+ doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value
923
+ return out
924
  }
925
 
926
+ // Update the height of a line, propagating the height change
927
+ // upwards to parent nodes.
928
+ function updateLineHeight(line, height) {
929
+ var diff = height - line.height;
930
+ if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } }
 
931
  }
932
 
933
+ // Given a line object, find its line number by walking up through
934
+ // its parent links.
935
+ function lineNo(line) {
936
+ if (line.parent == null) { return null }
937
+ var cur = line.parent, no = indexOf(cur.lines, line);
938
+ for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
939
+ for (var i = 0;; ++i) {
940
+ if (chunk.children[i] == cur) { break }
941
+ no += chunk.children[i].chunkSize();
942
+ }
 
 
943
  }
944
+ return no + cur.first
945
  }
946
 
947
+ // Find the line at the given vertical position, using the height
948
+ // information in the document tree.
949
+ function lineAtHeight(chunk, h) {
950
+ var n = chunk.first;
951
+ outer: do {
952
+ for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
953
+ var child = chunk.children[i$1], ch = child.height;
954
+ if (h < ch) { chunk = child; continue outer }
955
+ h -= ch;
956
+ n += child.chunkSize();
957
  }
958
+ return n
959
+ } while (!chunk.lines)
960
+ var i = 0;
961
+ for (; i < chunk.lines.length; ++i) {
962
+ var line = chunk.lines[i], lh = line.height;
963
+ if (h < lh) { break }
964
+ h -= lh;
965
  }
966
+ return n + i
967
  }
968
 
969
+ function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970
 
971
+ function lineNumberFor(options, i) {
972
+ return String(options.lineNumberFormatter(i + options.firstLineNumber))
 
 
 
 
 
 
973
  }
974
 
975
+ // A Pos instance represents a position within the text.
976
+ function Pos(line, ch, sticky) {
977
+ if ( sticky === void 0 ) sticky = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
978
 
979
+ if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
980
+ this.line = line;
981
+ this.ch = ch;
982
+ this.sticky = sticky;
983
  }
984
 
985
+ // Compare two positions, return 0 if they are the same, a negative
986
+ // number when a is less, and a positive number otherwise.
987
+ function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
 
 
 
 
988
 
989
+ function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
990
 
991
+ function copyPos(x) {return Pos(x.line, x.ch)}
992
+ function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
993
+ function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
994
 
995
  // Most of the external API clips given positions to make sure they
996
  // actually exist within the document.
997
+ function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
998
  function clipPos(doc, pos) {
999
+ if (pos.line < doc.first) { return Pos(doc.first, 0) }
1000
  var last = doc.first + doc.size - 1;
1001
+ if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
1002
+ return clipToLen(pos, getLine(doc, pos.line).text.length)
1003
  }
1004
  function clipToLen(pos, linelen) {
1005
  var ch = pos.ch;
1006
+ if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
1007
+ else if (ch < 0) { return Pos(pos.line, 0) }
1008
+ else { return pos }
1009
  }
 
1010
  function clipPosArray(doc, array) {
1011
+ var out = [];
1012
+ for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); }
1013
+ return out
1014
  }
1015
 
1016
+ var SavedContext = function(state, lookAhead) {
1017
+ this.state = state;
1018
+ this.lookAhead = lookAhead;
1019
+ };
1020
 
1021
+ var Context = function(doc, state, line, lookAhead) {
1022
+ this.state = state;
1023
+ this.doc = doc;
1024
+ this.line = line;
1025
+ this.maxLookAhead = lookAhead || 0;
1026
+ this.baseTokens = null;
1027
+ this.baseTokenPos = 1;
1028
+ };
1029
 
1030
+ Context.prototype.lookAhead = function (n) {
1031
+ var line = this.doc.getLine(this.line + n);
1032
+ if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; }
1033
+ return line
1034
+ };
1035
+
1036
+ Context.prototype.baseToken = function (n) {
1037
+ var this$1 = this;
1038
+
1039
+ if (!this.baseTokens) { return null }
1040
+ while (this.baseTokens[this.baseTokenPos] <= n)
1041
+ { this$1.baseTokenPos += 2; }
1042
+ var type = this.baseTokens[this.baseTokenPos + 1];
1043
+ return {type: type && type.replace(/( |^)overlay .*/, ""),
1044
+ size: this.baseTokens[this.baseTokenPos] - n}
1045
+ };
1046
+
1047
+ Context.prototype.nextLine = function () {
1048
+ this.line++;
1049
+ if (this.maxLookAhead > 0) { this.maxLookAhead--; }
1050
+ };
1051
+
1052
+ Context.fromSaved = function (doc, saved, line) {
1053
+ if (saved instanceof SavedContext)
1054
+ { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }
1055
+ else
1056
+ { return new Context(doc, copyState(doc.mode, saved), line) }
1057
+ };
1058
+
1059
+ Context.prototype.save = function (copy) {
1060
+ var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
1061
+ return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
1062
+ };
1063
+
1064
+
1065
+ // Compute a style array (an array starting with a mode generation
1066
+ // -- for invalidation -- followed by pairs of end positions and
1067
+ // style strings), which is used to highlight the tokens on the
1068
+ // line.
1069
+ function highlightLine(cm, line, context, forceToEnd) {
1070
+ // A styles array always starts with a number identifying the
1071
+ // mode/overlays that it is based on (for easy invalidation).
1072
+ var st = [cm.state.modeGen], lineClasses = {};
1073
+ // Compute the base array of styles
1074
+ runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
1075
+ lineClasses, forceToEnd);
1076
+ var state = context.state;
1077
+
1078
+ // Run overlays, adjust style array.
1079
+ var loop = function ( o ) {
1080
+ context.baseTokens = st;
1081
+ var overlay = cm.state.overlays[o], i = 1, at = 0;
1082
+ context.state = true;
1083
+ runMode(cm, line.text, overlay.mode, context, function (end, style) {
1084
+ var start = i;
1085
+ // Ensure there's a token end at the current position, and that i points at it
1086
+ while (at < end) {
1087
+ var i_end = st[i];
1088
+ if (i_end > end)
1089
+ { st.splice(i, 1, end, st[i+1], i_end); }
1090
+ i += 2;
1091
+ at = Math.min(end, i_end);
1092
  }
1093
+ if (!style) { return }
1094
+ if (overlay.opaque) {
1095
+ st.splice(start, i - start, end, "overlay " + style);
1096
+ i = start + 2;
1097
+ } else {
1098
+ for (; start < i; start += 2) {
1099
+ var cur = st[start+1];
1100
+ st[start+1] = (cur ? cur + " " : "") + "overlay " + style;
1101
+ }
1102
+ }
1103
+ }, lineClasses);
1104
+ context.state = state;
1105
+ context.baseTokens = null;
1106
+ context.baseTokenPos = 1;
1107
+ };
1108
+
1109
+ for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
1110
+
1111
+ return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
1112
+ }
1113
+
1114
+ function getLineStyles(cm, line, updateFrontier) {
1115
+ if (!line.styles || line.styles[0] != cm.state.modeGen) {
1116
+ var context = getContextBefore(cm, lineNo(line));
1117
+ var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
1118
+ var result = highlightLine(cm, line, context);
1119
+ if (resetState) { context.state = resetState; }
1120
+ line.stateAfter = context.save(!resetState);
1121
+ line.styles = result.styles;
1122
+ if (result.classes) { line.styleClasses = result.classes; }
1123
+ else if (line.styleClasses) { line.styleClasses = null; }
1124
+ if (updateFrontier === cm.doc.highlightFrontier)
1125
+ { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }
1126
  }
1127
+ return line.styles
1128
  }
1129
 
1130
+ function getContextBefore(cm, n, precise) {
1131
+ var doc = cm.doc, display = cm.display;
1132
+ if (!doc.mode.startState) { return new Context(doc, true, n) }
1133
+ var start = findStartLine(cm, n, precise);
1134
+ var saved = start > doc.first && getLine(doc, start - 1).stateAfter;
1135
+ var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);
1136
+
1137
+ doc.iter(start, n, function (line) {
1138
+ processLine(cm, line.text, context);
1139
+ var pos = context.line;
1140
+ line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
1141
+ context.nextLine();
1142
+ });
1143
+ if (precise) { doc.modeFrontier = context.line; }
1144
+ return context
1145
  }
1146
 
1147
+ // Lightweight form of highlight -- proceed over this line and
1148
+ // update state, but don't save a style array. Used for lines that
1149
+ // aren't currently visible.
1150
+ function processLine(cm, text, context, startAt) {
1151
+ var mode = cm.doc.mode;
1152
+ var stream = new StringStream(text, cm.options.tabSize, context);
1153
+ stream.start = stream.pos = startAt || 0;
1154
+ if (text == "") { callBlankLine(mode, context.state); }
1155
+ while (!stream.eol()) {
1156
+ readToken(mode, stream, context.state);
1157
+ stream.start = stream.pos;
1158
+ }
1159
  }
1160
 
1161
+ function callBlankLine(mode, state) {
1162
+ if (mode.blankLine) { return mode.blankLine(state) }
1163
+ if (!mode.innerMode) { return }
1164
+ var inner = innerMode(mode, state);
1165
+ if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
1166
  }
1167
 
1168
+ function readToken(mode, stream, state, inner) {
1169
+ for (var i = 0; i < 10; i++) {
1170
+ if (inner) { inner[0] = innerMode(mode, state).mode; }
1171
+ var style = mode.token(stream, state);
1172
+ if (stream.pos > stream.start) { return style }
1173
+ }
1174
+ throw new Error("Mode " + mode.name + " failed to advance stream.")
1175
  }
1176
 
1177
+ var Token = function(stream, type, state) {
1178
+ this.start = stream.start; this.end = stream.pos;
1179
+ this.string = stream.current();
1180
+ this.type = type || null;
1181
+ this.state = state;
1182
+ };
1183
+
1184
+ // Utility for getTokenAt and getLineTokens
1185
+ function takeToken(cm, pos, precise, asArray) {
1186
+ var doc = cm.doc, mode = doc.mode, style;
1187
+ pos = clipPos(doc, pos);
1188
+ var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
1189
+ var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
1190
+ if (asArray) { tokens = []; }
1191
+ while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
1192
+ stream.start = stream.pos;
1193
+ style = readToken(mode, stream, context.state);
1194
+ if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
1195
+ }
1196
+ return asArray ? tokens : new Token(stream, style, context.state)
1197
  }
1198
 
1199
+ function extractLineClasses(type, output) {
1200
+ if (type) { for (;;) {
1201
+ var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
1202
+ if (!lineClass) { break }
1203
+ type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
1204
+ var prop = lineClass[1] ? "bgClass" : "textClass";
1205
+ if (output[prop] == null)
1206
+ { output[prop] = lineClass[2]; }
1207
+ else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
1208
+ { output[prop] += " " + lineClass[2]; }
1209
+ } }
1210
+ return type
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
  }
1212
 
1213
+ // Run the given mode's parser over a line, calling f for each token.
1214
+ function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
1215
+ var flattenSpans = mode.flattenSpans;
1216
+ if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }
1217
+ var curStart = 0, curStyle = null;
1218
+ var stream = new StringStream(text, cm.options.tabSize, context), style;
1219
+ var inner = cm.options.addModeClass && [null];
1220
+ if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }
1221
+ while (!stream.eol()) {
1222
+ if (stream.pos > cm.options.maxHighlightLength) {
1223
+ flattenSpans = false;
1224
+ if (forceToEnd) { processLine(cm, text, context, stream.pos); }
1225
+ stream.pos = text.length;
1226
+ style = null;
1227
+ } else {
1228
+ style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1229
  }
1230
+ if (inner) {
1231
+ var mName = inner[0].name;
1232
+ if (mName) { style = "m-" + (style ? mName + " " + style : mName); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1233
  }
1234
+ if (!flattenSpans || curStyle != style) {
1235
+ while (curStart < stream.start) {
1236
+ curStart = Math.min(stream.start, curStart + 5000);
1237
+ f(curStart, curStyle);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1238
  }
1239
+ curStyle = style;
1240
  }
1241
+ stream.start = stream.pos;
1242
+ }
1243
+ while (curStart < stream.pos) {
1244
+ // Webkit seems to refuse to render text nodes longer than 57444
1245
+ // characters, and returns inaccurate measurements in nodes
1246
+ // starting around 5000 chars.
1247
+ var pos = Math.min(stream.pos, curStart + 5000);
1248
+ f(pos, curStyle);
1249
+ curStart = pos;
1250
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1251
  }
1252
 
1253
  // Finds the line to start with when starting a parse. Tries to
1259
  var minindent, minline, doc = cm.doc;
1260
  var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
1261
  for (var search = n; search > lim; --search) {
1262
+ if (search <= doc.first) { return doc.first }
1263
+ var line = getLine(doc, search - 1), after = line.stateAfter;
1264
+ if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
1265
+ { return search }
1266
  var indented = countColumn(line.text, null, cm.options.tabSize);
1267
  if (minline == null || minindent > indented) {
1268
  minline = search - 1;
1269
  minindent = indented;
1270
  }
1271
  }
1272
+ return minline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1273
  }
1274
 
1275
+ function retreatFrontier(doc, n) {
1276
+ doc.modeFrontier = Math.min(doc.modeFrontier, n);
1277
+ if (doc.highlightFrontier < n - 10) { return }
1278
+ var start = doc.first;
1279
+ for (var line = n - 1; line > start; line--) {
1280
+ var saved = getLine(doc, line).stateAfter;
1281
+ // change is on 3
1282
+ // state on line 1 looked ahead 2 -- so saw 3
1283
+ // test 1 + 2 < 3 should cover this
1284
+ if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
1285
+ start = line + 1;
1286
+ break
 
 
 
 
 
1287
  }
 
1288
  }
1289
+ doc.highlightFrontier = Math.min(doc.highlightFrontier, start);
1290
  }
1291
 
1292
+ // Optimize some code when these features are not used.
1293
+ var sawReadOnlySpans = false, sawCollapsedSpans = false;
 
 
 
 
 
 
 
 
 
 
 
1294
 
1295
+ function seeReadOnlySpans() {
1296
+ sawReadOnlySpans = true;
 
 
 
 
 
 
 
 
 
1297
  }
1298
 
1299
+ function seeCollapsedSpans() {
1300
+ sawCollapsedSpans = true;
 
 
1301
  }
1302
 
1303
+ // TEXTMARKER SPANS
1304
+
1305
+ function MarkedSpan(marker, from, to) {
1306
+ this.marker = marker;
1307
+ this.from = from; this.to = to;
 
 
1308
  }
1309
 
1310
+ // Search an array of spans for a span matching the given marker.
1311
+ function getMarkedSpanFor(spans, marker) {
1312
+ if (spans) { for (var i = 0; i < spans.length; ++i) {
1313
+ var span = spans[i];
1314
+ if (span.marker == marker) { return span }
1315
+ } }
1316
+ }
1317
+ // Remove a span from an array, returning undefined if no spans are
1318
+ // left (we don't store arrays for lines without spans).
1319
+ function removeMarkedSpan(spans, span) {
1320
+ var r;
1321
+ for (var i = 0; i < spans.length; ++i)
1322
+ { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
1323
+ return r
1324
+ }
1325
+ // Add a span to a line.
1326
+ function addMarkedSpan(line, span) {
1327
+ line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
1328
+ span.marker.attachLine(line);
 
 
1329
  }
1330
 
1331
+ // Used for the algorithm that adjusts markers for a change in the
1332
+ // document. These functions cut an array of spans at a given
1333
+ // character position, returning an array of remaining chunks (or
1334
+ // undefined if nothing remains).
1335
+ function markedSpansBefore(old, startCh, isInsert) {
1336
+ var nw;
1337
+ if (old) { for (var i = 0; i < old.length; ++i) {
1338
+ var span = old[i], marker = span.marker;
1339
+ var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
1340
+ if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
1341
+ var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
1342
+ ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
 
1343
  }
1344
+ } }
1345
+ return nw
1346
+ }
1347
+ function markedSpansAfter(old, endCh, isInsert) {
1348
+ var nw;
1349
+ if (old) { for (var i = 0; i < old.length; ++i) {
1350
+ var span = old[i], marker = span.marker;
1351
+ var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
1352
+ if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
1353
+ var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
1354
+ ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
1355
+ span.to == null ? null : span.to - endCh));
1356
+ }
1357
+ } }
1358
+ return nw
1359
  }
1360
 
1361
+ // Given a change object, compute the new set of marker spans that
1362
+ // cover the line in which the change took place. Removes spans
1363
+ // entirely within the change, reconnects spans belonging to the
1364
+ // same marker that appear on both sides of the change, and cuts off
1365
+ // spans partially within the change. Returns an array of span
1366
+ // arrays with one element for each line in (after) the change.
1367
+ function stretchSpansOverChange(doc, change) {
1368
+ if (change.full) { return null }
1369
+ var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
1370
+ var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
1371
+ if (!oldFirst && !oldLast) { return null }
1372
 
1373
+ var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
1374
+ // Get the spans that 'stick out' on both sides
1375
+ var first = markedSpansBefore(oldFirst, startCh, isInsert);
1376
+ var last = markedSpansAfter(oldLast, endCh, isInsert);
1377
 
1378
+ // Next, merge those two ends
1379
+ var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
1380
+ if (first) {
1381
+ // Fix up .to properties of first
1382
+ for (var i = 0; i < first.length; ++i) {
1383
+ var span = first[i];
1384
+ if (span.to == null) {
1385
+ var found = getMarkedSpanFor(last, span.marker);
1386
+ if (!found) { span.to = startCh; }
1387
+ else if (sameLine) { span.to = found.to == null ? null : found.to + offset; }
1388
+ }
 
 
 
 
1389
  }
1390
+ }
1391
+ if (last) {
1392
+ // Fix up .from in last (or move them into first in case of sameLine)
1393
+ for (var i$1 = 0; i$1 < last.length; ++i$1) {
1394
+ var span$1 = last[i$1];
1395
+ if (span$1.to != null) { span$1.to += offset; }
1396
+ if (span$1.from == null) {
1397
+ var found$1 = getMarkedSpanFor(first, span$1.marker);
1398
+ if (!found$1) {
1399
+ span$1.from = offset;
1400
+ if (sameLine) { (first || (first = [])).push(span$1); }
 
 
1401
  }
1402
+ } else {
1403
+ span$1.from += offset;
1404
+ if (sameLine) { (first || (first = [])).push(span$1); }
1405
+ }
1406
  }
1407
  }
1408
+ // Make sure we didn't create any zero-length spans
1409
+ if (first) { first = clearEmptySpans(first); }
1410
+ if (last && last != first) { last = clearEmptySpans(last); }
1411
 
1412
+ var newMarkers = [first];
1413
+ if (!sameLine) {
1414
+ // Fill gap with whole-line-spans
1415
+ var gap = change.text.length - 2, gapMarkers;
1416
+ if (gap > 0 && first)
1417
+ { for (var i$2 = 0; i$2 < first.length; ++i$2)
1418
+ { if (first[i$2].to == null)
1419
+ { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } }
1420
+ for (var i$3 = 0; i$3 < gap; ++i$3)
1421
+ { newMarkers.push(gapMarkers); }
1422
+ newMarkers.push(last);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1423
  }
1424
+ return newMarkers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1425
  }
1426
 
1427
+ // Remove spans that are empty and don't have a clearWhenEmpty
1428
+ // option of false.
1429
+ function clearEmptySpans(spans) {
1430
+ for (var i = 0; i < spans.length; ++i) {
1431
+ var span = spans[i];
1432
+ if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
1433
+ { spans.splice(i--, 1); }
1434
+ }
1435
+ if (!spans.length) { return null }
1436
+ return spans
1437
  }
1438
 
1439
+ // Used to 'clip' out readOnly ranges when making a change.
1440
+ function removeReadOnlyRanges(doc, from, to) {
1441
+ var markers = null;
1442
+ doc.iter(from.line, to.line + 1, function (line) {
1443
+ if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
1444
+ var mark = line.markedSpans[i].marker;
1445
+ if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
1446
+ { (markers || (markers = [])).push(mark); }
1447
+ } }
1448
+ });
1449
+ if (!markers) { return null }
1450
+ var parts = [{from: from, to: to}];
1451
+ for (var i = 0; i < markers.length; ++i) {
1452
+ var mk = markers[i], m = mk.find(0);
1453
+ for (var j = 0; j < parts.length; ++j) {
1454
+ var p = parts[j];
1455
+ if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
1456
+ var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
1457
+ if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
1458
+ { newParts.push({from: p.from, to: m.from}); }
1459
+ if (dto > 0 || !mk.inclusiveRight && !dto)
1460
+ { newParts.push({from: m.to, to: p.to}); }
1461
+ parts.splice.apply(parts, newParts);
1462
+ j += newParts.length - 3;
1463
+ }
1464
  }
1465
+ return parts
1466
  }
1467
 
1468
+ // Connect or disconnect spans from a line.
1469
+ function detachMarkedSpans(line) {
1470
+ var spans = line.markedSpans;
1471
+ if (!spans) { return }
1472
+ for (var i = 0; i < spans.length; ++i)
1473
+ { spans[i].marker.detachLine(line); }
1474
+ line.markedSpans = null;
1475
  }
1476
+ function attachMarkedSpans(line, spans) {
1477
+ if (!spans) { return }
1478
+ for (var i = 0; i < spans.length; ++i)
1479
+ { spans[i].marker.attachLine(line); }
1480
+ line.markedSpans = spans;
 
1481
  }
1482
 
1483
+ // Helpers used when computing which overlapping collapsed span
1484
+ // counts as the larger one.
1485
+ function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
1486
+ function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
1487
 
1488
+ // Returns a number indicating which of two overlapping collapsed
1489
+ // spans is larger (and thus includes the other). Falls back to
1490
+ // comparing ids when the spans cover exactly the same range.
1491
+ function compareCollapsedMarkers(a, b) {
1492
+ var lenDiff = a.lines.length - b.lines.length;
1493
+ if (lenDiff != 0) { return lenDiff }
1494
+ var aPos = a.find(), bPos = b.find();
1495
+ var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
1496
+ if (fromCmp) { return -fromCmp }
1497
+ var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
1498
+ if (toCmp) { return toCmp }
1499
+ return b.id - a.id
 
 
 
 
 
 
 
 
 
1500
  }
1501
 
1502
+ // Find out whether a line ends or starts in a collapsed span. If
1503
+ // so, return the marker for that span.
1504
+ function collapsedSpanAtSide(line, start) {
1505
+ var sps = sawCollapsedSpans && line.markedSpans, found;
1506
+ if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
1507
+ sp = sps[i];
1508
+ if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
1509
+ (!found || compareCollapsedMarkers(found, sp.marker) < 0))
1510
+ { found = sp.marker; }
1511
+ } }
1512
+ return found
1513
+ }
1514
+ function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
1515
+ function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
1516
 
1517
+ function collapsedSpanAround(line, ch) {
1518
+ var sps = sawCollapsedSpans && line.markedSpans, found;
1519
+ if (sps) { for (var i = 0; i < sps.length; ++i) {
1520
+ var sp = sps[i];
1521
+ if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) &&
1522
+ (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; }
1523
+ } }
1524
+ return found
1525
  }
1526
 
1527
+ // Test whether there exists a collapsed span that partially
1528
+ // overlaps (covers the start or end, but not both) of a new span.
1529
+ // Such overlap is not allowed.
1530
+ function conflictingCollapsedRange(doc, lineNo$$1, from, to, marker) {
1531
+ var line = getLine(doc, lineNo$$1);
1532
+ var sps = sawCollapsedSpans && line.markedSpans;
1533
+ if (sps) { for (var i = 0; i < sps.length; ++i) {
1534
+ var sp = sps[i];
1535
+ if (!sp.marker.collapsed) { continue }
1536
+ var found = sp.marker.find(0);
1537
+ var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
1538
+ var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
1539
+ if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
1540
+ if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
1541
+ fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
1542
+ { return true }
1543
+ } }
1544
  }
1545
 
1546
+ // A visual line is a line as drawn on the screen. Folding, for
1547
+ // example, can cause multiple logical lines to appear on the same
1548
+ // visual line. This finds the start of the visual line that the
1549
+ // given line is part of (usually that is the line itself).
1550
+ function visualLine(line) {
1551
+ var merged;
1552
+ while (merged = collapsedSpanAtStart(line))
1553
+ { line = merged.find(-1, true).line; }
1554
+ return line
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1555
  }
1556
 
1557
+ function visualLineEnd(line) {
1558
+ var merged;
1559
+ while (merged = collapsedSpanAtEnd(line))
1560
+ { line = merged.find(1, true).line; }
1561
+ return line
 
 
 
1562
  }
1563
 
1564
+ // Returns an array of logical lines that continue the visual line
1565
+ // started by the argument, or undefined if there are no such lines.
1566
+ function visualLineContinued(line) {
1567
+ var merged, lines;
1568
+ while (merged = collapsedSpanAtEnd(line)) {
1569
+ line = merged.find(1, true).line
1570
+ ;(lines || (lines = [])).push(line);
1571
+ }
1572
+ return lines
 
 
1573
  }
1574
 
1575
+ // Get the line number of the start of the visual line that the
1576
+ // given line number is part of.
1577
+ function visualLineNo(doc, lineN) {
1578
+ var line = getLine(doc, lineN), vis = visualLine(line);
1579
+ if (line == vis) { return lineN }
1580
+ return lineNo(vis)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1581
  }
1582
 
1583
+ // Get the line number of the start of the next visual line after
1584
+ // the given line.
1585
+ function visualLineEndNo(doc, lineN) {
1586
+ if (lineN > doc.lastLine()) { return lineN }
1587
+ var line = getLine(doc, lineN), merged;
1588
+ if (!lineIsHidden(doc, line)) { return lineN }
1589
+ while (merged = collapsedSpanAtEnd(line))
1590
+ { line = merged.find(1, true).line; }
1591
+ return lineNo(line) + 1
1592
+ }
1593
 
1594
+ // Compute whether a line is hidden. Lines count as hidden when they
1595
+ // are part of a visual line that starts with another line, or when
1596
+ // they are entirely covered by collapsed, non-widget span.
1597
+ function lineIsHidden(doc, line) {
1598
+ var sps = sawCollapsedSpans && line.markedSpans;
1599
+ if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
1600
+ sp = sps[i];
1601
+ if (!sp.marker.collapsed) { continue }
1602
+ if (sp.from == null) { return true }
1603
+ if (sp.marker.widgetNode) { continue }
1604
+ if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
1605
+ { return true }
1606
+ } }
1607
+ }
1608
+ function lineIsHiddenInner(doc, line, span) {
1609
+ if (span.to == null) {
1610
+ var end = span.marker.find(1, true);
1611
+ return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
1612
+ }
1613
+ if (span.marker.inclusiveRight && span.to == line.text.length)
1614
+ { return true }
1615
+ for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
1616
+ sp = line.markedSpans[i];
1617
+ if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
1618
+ (sp.to == null || sp.to != span.from) &&
1619
+ (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
1620
+ lineIsHiddenInner(doc, line, sp)) { return true }
1621
  }
1622
+ }
1623
 
1624
+ // Find the height above the given line.
1625
+ function heightAtLine(lineObj) {
1626
+ lineObj = visualLine(lineObj);
1627
 
1628
+ var h = 0, chunk = lineObj.parent;
1629
+ for (var i = 0; i < chunk.lines.length; ++i) {
1630
+ var line = chunk.lines[i];
1631
+ if (line == lineObj) { break }
1632
+ else { h += line.height; }
1633
+ }
1634
+ for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
1635
+ for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
1636
+ var cur = p.children[i$1];
1637
+ if (cur == chunk) { break }
1638
+ else { h += cur.height; }
 
 
 
 
1639
  }
 
 
 
1640
  }
1641
+ return h
1642
  }
1643
 
1644
+ // Compute the character length of a line, taking into account
1645
+ // collapsed ranges (see markText) that might hide parts, and join
1646
+ // other lines onto it.
1647
+ function lineLength(line) {
1648
+ if (line.height == 0) { return 0 }
1649
+ var len = line.text.length, merged, cur = line;
1650
+ while (merged = collapsedSpanAtStart(cur)) {
1651
+ var found = merged.find(0, true);
1652
+ cur = found.from.line;
1653
+ len += found.from.ch - found.to.ch;
 
 
 
1654
  }
1655
+ cur = line;
1656
+ while (merged = collapsedSpanAtEnd(cur)) {
1657
+ var found$1 = merged.find(0, true);
1658
+ len -= cur.text.length - found$1.from.ch;
1659
+ cur = found$1.to.line;
1660
+ len += cur.text.length - found$1.to.ch;
1661
+ }
1662
+ return len
1663
  }
1664
 
1665
+ // Find the longest line in the document.
1666
+ function findMaxLine(cm) {
1667
+ var d = cm.display, doc = cm.doc;
1668
+ d.maxLine = getLine(doc, doc.first);
1669
+ d.maxLineLength = lineLength(d.maxLine);
1670
+ d.maxLineChanged = true;
1671
+ doc.iter(function (line) {
1672
+ var len = lineLength(line);
1673
+ if (len > d.maxLineLength) {
1674
+ d.maxLineLength = len;
1675
+ d.maxLine = line;
1676
+ }
1677
+ });
1678
  }
1679
 
1680
+ // LINE DATA STRUCTURE
 
 
 
 
 
 
1681
 
1682
+ // Line objects. These hold state related to a line, including
1683
+ // highlighting info (the styles array).
1684
+ var Line = function(text, markedSpans, estimateHeight) {
1685
+ this.text = text;
1686
+ attachMarkedSpans(this, markedSpans);
1687
+ this.height = estimateHeight ? estimateHeight(this) : 1;
1688
+ };
1689
 
1690
+ Line.prototype.lineNo = function () { return lineNo(this) };
1691
+ eventMixin(Line);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1692
 
1693
+ // Change the content (text, markers) of a line. Automatically
1694
+ // invalidates cached information and tries to re-estimate the
1695
+ // line's height.
1696
+ function updateLine(line, text, markedSpans, estimateHeight) {
1697
+ line.text = text;
1698
+ if (line.stateAfter) { line.stateAfter = null; }
1699
+ if (line.styles) { line.styles = null; }
1700
+ if (line.order != null) { line.order = null; }
1701
+ detachMarkedSpans(line);
1702
+ attachMarkedSpans(line, markedSpans);
1703
+ var estHeight = estimateHeight ? estimateHeight(line) : 1;
1704
+ if (estHeight != line.height) { updateLineHeight(line, estHeight); }
 
 
1705
  }
1706
 
1707
+ // Detach a line from the document tree and its markers.
1708
+ function cleanUpLine(line) {
1709
+ line.parent = null;
1710
+ detachMarkedSpans(line);
 
 
 
 
 
 
 
 
1711
  }
1712
 
1713
+ // Convert a style as returned by a mode (either null, or a string
1714
+ // containing one or more styles) to a CSS style. This is cached,
1715
+ // and also looks for line-wide styles.
1716
+ var styleToClassCache = {}, styleToClassCacheWithMode = {};
1717
+ function interpretTokenStyle(style, options) {
1718
+ if (!style || /^\s*$/.test(style)) { return null }
1719
+ var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
1720
+ return cache[style] ||
1721
+ (cache[style] = style.replace(/\S+/g, "cm-$&"))
 
 
 
 
 
1722
  }
1723
 
1724
+ // Render the DOM representation of the text of a line. Also builds
1725
+ // up a 'line map', which points at the DOM nodes that represent
1726
+ // specific stretches of text, and is used by the measuring code.
1727
+ // The returned object contains the DOM node, this map, and
1728
+ // information about line-wide styles that were set by the mode.
1729
+ function buildLineContent(cm, lineView) {
1730
+ // The padding-right forces the element to have a 'border', which
1731
+ // is needed on Webkit to be able to get line-level bounding
1732
+ // rectangles for it (in measureChar).
1733
+ var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
1734
+ var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
1735
+ col: 0, pos: 0, cm: cm,
1736
+ trailingSpace: false,
1737
+ splitSpaces: cm.getOption("lineWrapping")};
1738
+ lineView.measure = {};
1739
 
1740
+ // Iterate over the logical lines that make up this visual line.
1741
+ for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
1742
+ var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0);
1743
+ builder.pos = 0;
1744
+ builder.addToken = buildToken;
1745
+ // Optionally wire in some hacks into the token-rendering
1746
+ // algorithm, to deal with browser quirks.
1747
+ if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
1748
+ { builder.addToken = buildTokenBadBidi(builder.addToken, order); }
1749
+ builder.map = [];
1750
+ var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
1751
+ insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
1752
+ if (line.styleClasses) {
1753
+ if (line.styleClasses.bgClass)
1754
+ { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); }
1755
+ if (line.styleClasses.textClass)
1756
+ { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); }
1757
+ }
1758
 
1759
+ // Ensure at least a single node is present, for measuring.
1760
+ if (builder.map.length == 0)
1761
+ { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); }
1762
 
1763
+ // Store the map and a cache object for the current logical line
1764
+ if (i == 0) {
1765
+ lineView.measure.map = builder.map;
1766
+ lineView.measure.cache = {};
1767
+ } else {
1768
+ (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
1769
+ ;(lineView.measure.caches || (lineView.measure.caches = [])).push({});
1770
+ }
1771
+ }
1772
 
1773
+ // See issue #2901
1774
+ if (webkit) {
1775
+ var last = builder.content.lastChild;
1776
+ if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
1777
+ { builder.content.className = "cm-tab-wrap-hack"; }
 
 
1778
  }
1779
 
1780
+ signal(cm, "renderLine", cm, lineView.line, builder.pre);
1781
+ if (builder.pre.className)
1782
+ { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); }
 
1783
 
1784
+ return builder
1785
+ }
1786
 
1787
+ function defaultSpecialCharPlaceholder(ch) {
1788
+ var token = elt("span", "\u2022", "cm-invalidchar");
1789
+ token.title = "\\u" + ch.charCodeAt(0).toString(16);
1790
+ token.setAttribute("aria-label", token.title);
1791
+ return token
 
 
 
 
 
 
 
 
 
 
 
 
1792
  }
1793
 
1794
+ // Build up the DOM representation for a single token, and add it to
1795
+ // the line map. Takes care to render special characters separately.
1796
+ function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {
1797
+ if (!text) { return }
1798
+ var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
1799
+ var special = builder.cm.state.specialChars, mustWrap = false;
1800
+ var content;
1801
+ if (!special.test(text)) {
1802
+ builder.col += text.length;
1803
+ content = document.createTextNode(displayText);
1804
+ builder.map.push(builder.pos, builder.pos + text.length, content);
1805
+ if (ie && ie_version < 9) { mustWrap = true; }
1806
+ builder.pos += text.length;
1807
+ } else {
1808
+ content = document.createDocumentFragment();
1809
+ var pos = 0;
1810
+ while (true) {
1811
+ special.lastIndex = pos;
1812
+ var m = special.exec(text);
1813
+ var skipped = m ? m.index - pos : text.length - pos;
1814
+ if (skipped) {
1815
+ var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
1816
+ if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); }
1817
+ else { content.appendChild(txt); }
1818
+ builder.map.push(builder.pos, builder.pos + skipped, txt);
1819
+ builder.col += skipped;
1820
+ builder.pos += skipped;
1821
+ }
1822
+ if (!m) { break }
1823
+ pos += skipped + 1;
1824
+ var txt$1 = (void 0);
1825
+ if (m[0] == "\t") {
1826
+ var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
1827
+ txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
1828
+ txt$1.setAttribute("role", "presentation");
1829
+ txt$1.setAttribute("cm-text", "\t");
1830
+ builder.col += tabWidth;
1831
+ } else if (m[0] == "\r" || m[0] == "\n") {
1832
+ txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
1833
+ txt$1.setAttribute("cm-text", m[0]);
1834
+ builder.col += 1;
1835
+ } else {
1836
+ txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
1837
+ txt$1.setAttribute("cm-text", m[0]);
1838
+ if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); }
1839
+ else { content.appendChild(txt$1); }
1840
+ builder.col += 1;
1841
+ }
1842
+ builder.map.push(builder.pos, builder.pos + 1, txt$1);
1843
+ builder.pos++;
1844
+ }
1845
+ }
1846
+ builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
1847
+ if (style || startStyle || endStyle || mustWrap || css) {
1848
+ var fullStyle = style || "";
1849
+ if (startStyle) { fullStyle += startStyle; }
1850
+ if (endStyle) { fullStyle += endStyle; }
1851
+ var token = elt("span", [content], fullStyle, css);
1852
+ if (attributes) {
1853
+ for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class")
1854
+ { token.setAttribute(attr, attributes[attr]); } }
1855
+ }
1856
+ return builder.content.appendChild(token)
1857
+ }
1858
+ builder.content.appendChild(content);
1859
+ }
1860
 
1861
+ // Change some spaces to NBSP to prevent the browser from collapsing
1862
+ // trailing spaces at the end of a line when rendering text (issue #1362).
1863
+ function splitSpaces(text, trailingBefore) {
1864
+ if (text.length > 1 && !/ /.test(text)) { return text }
1865
+ var spaceBefore = trailingBefore, result = "";
1866
+ for (var i = 0; i < text.length; i++) {
1867
+ var ch = text.charAt(i);
1868
+ if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
1869
+ { ch = "\u00a0"; }
1870
+ result += ch;
1871
+ spaceBefore = ch == " ";
1872
+ }
1873
+ return result
1874
+ }
1875
 
1876
+ // Work around nonsense dimensions being reported for stretches of
1877
+ // right-to-left text.
1878
+ function buildTokenBadBidi(inner, order) {
1879
+ return function (builder, text, style, startStyle, endStyle, css, attributes) {
1880
+ style = style ? style + " cm-force-border" : "cm-force-border";
1881
+ var start = builder.pos, end = start + text.length;
1882
+ for (;;) {
1883
+ // Find the part that overlaps with the start of this text
1884
+ var part = (void 0);
1885
+ for (var i = 0; i < order.length; i++) {
1886
+ part = order[i];
1887
+ if (part.to > start && part.from <= start) { break }
1888
+ }
1889
+ if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) }
1890
+ inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes);
1891
+ startStyle = null;
1892
+ text = text.slice(part.to - start);
1893
+ start = part.to;
1894
+ }
1895
+ }
1896
+ }
1897
 
1898
+ function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
1899
+ var widget = !ignoreWidget && marker.widgetNode;
1900
+ if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); }
1901
+ if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
1902
+ if (!widget)
1903
+ { widget = builder.content.appendChild(document.createElement("span")); }
1904
+ widget.setAttribute("cm-marker", marker.id);
1905
  }
1906
+ if (widget) {
1907
+ builder.cm.display.input.setUneditable(widget);
1908
+ builder.content.appendChild(widget);
 
1909
  }
1910
+ builder.pos += size;
1911
+ builder.trailingSpace = false;
1912
+ }
1913
+
1914
+ // Outputs a number of spans to make up a line, taking highlighting
1915
+ // and marked text into account.
1916
+ function insertLineContent(line, builder, styles) {
1917
+ var spans = line.markedSpans, allText = line.text, at = 0;
1918
+ if (!spans) {
1919
+ for (var i$1 = 1; i$1 < styles.length; i$1+=2)
1920
+ { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); }
1921
+ return
1922
  }
1923
 
1924
+ var len = allText.length, pos = 0, i = 1, text = "", style, css;
1925
+ var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes;
1926
+ for (;;) {
1927
+ if (nextChange == pos) { // Update current marker set
1928
+ spanStyle = spanEndStyle = spanStartStyle = css = "";
1929
+ attributes = null;
1930
+ collapsed = null; nextChange = Infinity;
1931
+ var foundBookmarks = [], endStyles = (void 0);
1932
+ for (var j = 0; j < spans.length; ++j) {
1933
+ var sp = spans[j], m = sp.marker;
1934
+ if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
1935
+ foundBookmarks.push(m);
1936
+ } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
1937
+ if (sp.to != null && sp.to != pos && nextChange > sp.to) {
1938
+ nextChange = sp.to;
1939
+ spanEndStyle = "";
1940
+ }
1941
+ if (m.className) { spanStyle += " " + m.className; }
1942
+ if (m.css) { css = (css ? css + ";" : "") + m.css; }
1943
+ if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; }
1944
+ if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); }
1945
+ // support for the old title property
1946
+ // https://github.com/codemirror/CodeMirror/pull/5673
1947
+ if (m.title) { (attributes || (attributes = {})).title = m.title; }
1948
+ if (m.attributes) {
1949
+ for (var attr in m.attributes)
1950
+ { (attributes || (attributes = {}))[attr] = m.attributes[attr]; }
1951
+ }
1952
+ if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
1953
+ { collapsed = sp; }
1954
+ } else if (sp.from > pos && nextChange > sp.from) {
1955
+ nextChange = sp.from;
1956
+ }
1957
+ }
1958
+ if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
1959
+ { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } }
1960
 
1961
+ if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
1962
+ { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } }
1963
+ if (collapsed && (collapsed.from || 0) == pos) {
1964
+ buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
1965
+ collapsed.marker, collapsed.from == null);
1966
+ if (collapsed.to == null) { return }
1967
+ if (collapsed.to == pos) { collapsed = false; }
1968
+ }
1969
+ }
1970
+ if (pos >= len) { break }
1971
 
1972
+ var upto = Math.min(len, nextChange);
1973
+ while (true) {
1974
+ if (text) {
1975
+ var end = pos + text.length;
1976
+ if (!collapsed) {
1977
+ var tokenText = end > upto ? text.slice(0, upto - pos) : text;
1978
+ builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
1979
+ spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes);
1980
+ }
1981
+ if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
1982
+ pos = end;
1983
+ spanStartStyle = "";
1984
+ }
1985
+ text = allText.slice(at, at = styles[i++]);
1986
+ style = interpretTokenStyle(styles[i++], builder.cm.options);
1987
+ }
1988
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1989
  }
1990
 
 
1991
 
1992
  // These objects are used to represent the visible (currently drawn)
1993
  // part of the document. A LineView may correspond to multiple
2011
  nextPos = pos + view.size;
2012
  array.push(view);
2013
  }
2014
+ return array
2015
  }
2016
 
2017
+ var operationGroup = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2018
 
2019
+ function pushOperation(op) {
2020
+ if (operationGroup) {
2021
+ operationGroup.ops.push(op);
2022
+ } else {
2023
+ op.ownsGroup = operationGroup = {
2024
+ ops: [op],
2025
+ delayedCallbacks: []
2026
+ };
2027
+ }
2028
+ }
2029
 
2030
+ function fireCallbacksForOps(group) {
2031
+ // Calls delayed callbacks and cursorActivity handlers until no
2032
+ // new ones appear
2033
+ var callbacks = group.delayedCallbacks, i = 0;
2034
+ do {
2035
+ for (; i < callbacks.length; i++)
2036
+ { callbacks[i].call(null); }
2037
+ for (var j = 0; j < group.ops.length; j++) {
2038
+ var op = group.ops[j];
2039
+ if (op.cursorActivityHandlers)
2040
+ { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
2041
+ { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2042
  }
2043
+ } while (i < callbacks.length)
2044
+ }
2045
 
2046
+ function finishOperation(op, endCb) {
2047
+ var group = op.ownsGroup;
2048
+ if (!group) { return }
2049
+
2050
+ try { fireCallbacksForOps(group); }
2051
+ finally {
2052
+ operationGroup = null;
2053
+ endCb(group);
2054
  }
2055
  }
2056
 
2057
+ var orphanDelayedCallbacks = null;
 
 
 
 
 
 
2058
 
2059
+ // Often, we want to signal events at a point where we are in the
2060
+ // middle of some work, but don't want the handler to start calling
2061
+ // other methods on the editor, which might be in an inconsistent
2062
+ // state or simply not expect any other events to happen.
2063
+ // signalLater looks whether there are any handlers, and schedules
2064
+ // them to be executed when the last operation ends, or, if no
2065
+ // operation is active, when a timeout fires.
2066
+ function signalLater(emitter, type /*, values...*/) {
2067
+ var arr = getHandlers(emitter, type);
2068
+ if (!arr.length) { return }
2069
+ var args = Array.prototype.slice.call(arguments, 2), list;
2070
+ if (operationGroup) {
2071
+ list = operationGroup.delayedCallbacks;
2072
+ } else if (orphanDelayedCallbacks) {
2073
+ list = orphanDelayedCallbacks;
2074
+ } else {
2075
+ list = orphanDelayedCallbacks = [];
2076
+ setTimeout(fireOrphanDelayed, 0);
2077
+ }
2078
+ var loop = function ( i ) {
2079
+ list.push(function () { return arr[i].apply(null, args); });
2080
+ };
2081
+
2082
+ for (var i = 0; i < arr.length; ++i)
2083
+ loop( i );
2084
  }
2085
 
2086
+ function fireOrphanDelayed() {
2087
+ var delayed = orphanDelayedCallbacks;
2088
+ orphanDelayedCallbacks = null;
2089
+ for (var i = 0; i < delayed.length; ++i) { delayed[i](); }
 
2090
  }
2091
 
2092
+ // When an aspect of a line changes, a string is added to
2093
+ // lineView.changes. This updates the relevant part of the line's
2094
+ // DOM structure.
2095
+ function updateLineForChanges(cm, lineView, lineN, dims) {
2096
+ for (var j = 0; j < lineView.changes.length; j++) {
2097
+ var type = lineView.changes[j];
2098
+ if (type == "text") { updateLineText(cm, lineView); }
2099
+ else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); }
2100
+ else if (type == "class") { updateLineClasses(cm, lineView); }
2101
+ else if (type == "widget") { updateLineWidgets(cm, lineView, dims); }
2102
  }
2103
+ lineView.changes = null;
2104
  }
2105
 
2106
+ // Lines with gutter elements, widgets or a background class need to
2107
+ // be wrapped, and have the extra elements added to the wrapper div
2108
+ function ensureLineWrapped(lineView) {
2109
+ if (lineView.node == lineView.text) {
2110
+ lineView.node = elt("div", null, null, "position: relative");
2111
+ if (lineView.text.parentNode)
2112
+ { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); }
2113
+ lineView.node.appendChild(lineView.text);
2114
+ if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; }
 
 
 
 
 
 
 
 
 
 
 
2115
  }
2116
+ return lineView.node
2117
  }
2118
 
2119
+ function updateLineBackground(cm, lineView) {
2120
+ var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
2121
+ if (cls) { cls += " CodeMirror-linebackground"; }
2122
+ if (lineView.background) {
2123
+ if (cls) { lineView.background.className = cls; }
2124
+ else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
2125
+ } else if (cls) {
2126
+ var wrap = ensureLineWrapped(lineView);
2127
+ lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
2128
+ cm.display.input.setUneditable(lineView.background);
 
 
 
 
 
 
 
2129
  }
 
2130
  }
2131
 
2132
+ // Wrapper around buildLineContent which will reuse the structure
2133
+ // in display.externalMeasured when possible.
2134
+ function getLineContent(cm, lineView) {
2135
+ var ext = cm.display.externalMeasured;
2136
+ if (ext && ext.line == lineView.line) {
2137
+ cm.display.externalMeasured = null;
2138
+ lineView.measure = ext.measure;
2139
+ return ext.built
2140
  }
2141
+ return buildLineContent(cm, lineView)
 
 
 
 
 
 
 
 
 
 
 
 
2142
  }
2143
 
2144
+ // Redraw the line's text. Interacts with the background and text
2145
+ // classes because the mode may output tokens that influence these
2146
+ // classes.
2147
+ function updateLineText(cm, lineView) {
2148
+ var cls = lineView.text.className;
2149
+ var built = getLineContent(cm, lineView);
2150
+ if (lineView.text == lineView.node) { lineView.node = built.pre; }
2151
+ lineView.text.parentNode.replaceChild(built.pre, lineView.text);
2152
+ lineView.text = built.pre;
2153
+ if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
2154
+ lineView.bgClass = built.bgClass;
2155
+ lineView.textClass = built.textClass;
2156
+ updateLineClasses(cm, lineView);
2157
+ } else if (cls) {
2158
+ lineView.text.className = cls;
2159
  }
 
2160
  }
2161
 
2162
+ function updateLineClasses(cm, lineView) {
2163
+ updateLineBackground(cm, lineView);
2164
+ if (lineView.line.wrapClass)
2165
+ { ensureLineWrapped(lineView).className = lineView.line.wrapClass; }
2166
+ else if (lineView.node != lineView.text)
2167
+ { lineView.node.className = ""; }
2168
+ var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
2169
+ lineView.text.className = textClass || "";
2170
+ }
2171
 
2172
+ function updateLineGutter(cm, lineView, lineN, dims) {
2173
+ if (lineView.gutter) {
2174
+ lineView.node.removeChild(lineView.gutter);
2175
+ lineView.gutter = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2176
  }
2177
+ if (lineView.gutterBackground) {
2178
+ lineView.node.removeChild(lineView.gutterBackground);
2179
+ lineView.gutterBackground = null;
 
 
 
 
 
 
 
2180
  }
2181
+ if (lineView.line.gutterClass) {
2182
+ var wrap = ensureLineWrapped(lineView);
2183
+ lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
2184
+ ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"));
2185
+ cm.display.input.setUneditable(lineView.gutterBackground);
2186
+ wrap.insertBefore(lineView.gutterBackground, lineView.text);
 
 
 
 
 
 
 
 
 
 
 
 
 
2187
  }
2188
+ var markers = lineView.line.gutterMarkers;
2189
+ if (cm.options.lineNumbers || markers) {
2190
+ var wrap$1 = ensureLineWrapped(lineView);
2191
+ var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
2192
+ cm.display.input.setUneditable(gutterWrap);
2193
+ wrap$1.insertBefore(gutterWrap, lineView.text);
2194
+ if (lineView.line.gutterClass)
2195
+ { gutterWrap.className += " " + lineView.line.gutterClass; }
2196
+ if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
2197
+ { lineView.lineNumber = gutterWrap.appendChild(
2198
+ elt("div", lineNumberFor(cm.options, lineN),
2199
+ "CodeMirror-linenumber CodeMirror-gutter-elt",
2200
+ ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); }
2201
+ if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) {
2202
+ var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id];
2203
+ if (found)
2204
+ { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
2205
+ ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); }
2206
+ } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2207
  }
 
 
 
 
 
 
 
 
 
 
2208
  }
2209
 
2210
+ function updateLineWidgets(cm, lineView, dims) {
2211
+ if (lineView.alignable) { lineView.alignable = null; }
2212
+ for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
2213
+ next = node.nextSibling;
2214
+ if (node.className == "CodeMirror-linewidget")
2215
+ { lineView.node.removeChild(node); }
 
 
 
 
 
 
 
 
 
 
2216
  }
2217
+ insertLineWidgets(cm, lineView, dims);
2218
  }
2219
 
2220
+ // Build a line's DOM representation from scratch
2221
+ function buildLineElement(cm, lineView, lineN, dims) {
2222
+ var built = getLineContent(cm, lineView);
2223
+ lineView.text = lineView.node = built.pre;
2224
+ if (built.bgClass) { lineView.bgClass = built.bgClass; }
2225
+ if (built.textClass) { lineView.textClass = built.textClass; }
2226
 
2227
+ updateLineClasses(cm, lineView);
2228
+ updateLineGutter(cm, lineView, lineN, dims);
2229
+ insertLineWidgets(cm, lineView, dims);
2230
+ return lineView.node
2231
  }
2232
 
2233
+ // A lineView may contain multiple logical lines (when merged by
2234
+ // collapsed spans). The widgets for all of them need to be drawn.
2235
+ function insertLineWidgets(cm, lineView, dims) {
2236
+ insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
2237
+ if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
2238
+ { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } }
2239
  }
2240
 
2241
+ function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
2242
+ if (!line.widgets) { return }
2243
+ var wrap = ensureLineWrapped(lineView);
2244
+ for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
2245
+ var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
2246
+ if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); }
2247
+ positionLineWidget(widget, node, lineView, dims);
2248
+ cm.display.input.setUneditable(node);
2249
+ if (allowAbove && widget.above)
2250
+ { wrap.insertBefore(node, lineView.gutter || lineView.text); }
2251
+ else
2252
+ { wrap.appendChild(node); }
2253
+ signalLater(widget, "redraw");
2254
+ }
2255
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2256
 
2257
+ function positionLineWidget(widget, node, lineView, dims) {
2258
+ if (widget.noHScroll) {
2259
+ (lineView.alignable || (lineView.alignable = [])).push(node);
2260
+ var width = dims.wrapperWidth;
2261
+ node.style.left = dims.fixedPos + "px";
2262
+ if (!widget.coverGutter) {
2263
+ width -= dims.gutterTotalWidth;
2264
+ node.style.paddingLeft = dims.gutterTotalWidth + "px";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2265
  }
2266
+ node.style.width = width + "px";
2267
+ }
2268
+ if (widget.coverGutter) {
2269
+ node.style.zIndex = 5;
2270
+ node.style.position = "relative";
2271
+ if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; }
2272
  }
 
 
 
 
 
 
 
 
2273
  }
2274
 
2275
+ function widgetHeight(widget) {
2276
+ if (widget.height != null) { return widget.height }
2277
+ var cm = widget.doc.cm;
2278
+ if (!cm) { return 0 }
2279
+ if (!contains(document.body, widget.node)) {
2280
+ var parentStyle = "position: relative;";
2281
+ if (widget.coverGutter)
2282
+ { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; }
2283
+ if (widget.noHScroll)
2284
+ { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; }
2285
+ removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
2286
+ }
2287
+ return widget.height = widget.node.parentNode.offsetHeight
2288
  }
2289
 
 
 
2290
  // Return true when the given mouse event happened in a widget
2291
  function eventInWidget(display, e) {
2292
  for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
2293
+ if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
2294
+ (n.parentNode == display.sizer && n != display.mover))
2295
+ { return true }
2296
  }
2297
  }
2298
 
2299
+ // POSITION MEASUREMENT
2300
+
2301
+ function paddingTop(display) {return display.lineSpace.offsetTop}
2302
+ function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
2303
+ function paddingH(display) {
2304
+ if (display.cachedPaddingH) { return display.cachedPaddingH }
2305
+ var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like"));
2306
+ var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
2307
+ var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
2308
+ if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
2309
+ return data
 
 
 
 
 
 
 
 
 
 
 
2310
  }
2311
 
2312
+ function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
2313
+ function displayWidth(cm) {
2314
+ return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
2315
+ }
2316
+ function displayHeight(cm) {
2317
+ return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
2318
+ }
 
 
2319
 
2320
+ // Ensure the lineView.wrapping.heights array is populated. This is
2321
+ // an array of bottom offsets for the lines that make up a drawn
2322
+ // line. When lineWrapping is on, there might be more than one
2323
+ // height.
2324
+ function ensureLineHeights(cm, lineView, rect) {
2325
+ var wrapping = cm.options.lineWrapping;
2326
+ var curWidth = wrapping && displayWidth(cm);
2327
+ if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
2328
+ var heights = lineView.measure.heights = [];
2329
+ if (wrapping) {
2330
+ lineView.measure.width = curWidth;
2331
+ var rects = lineView.text.firstChild.getClientRects();
2332
+ for (var i = 0; i < rects.length - 1; i++) {
2333
+ var cur = rects[i], next = rects[i + 1];
2334
+ if (Math.abs(cur.bottom - next.bottom) > 2)
2335
+ { heights.push((cur.bottom + next.top) / 2 - rect.top); }
2336
+ }
2337
  }
2338
+ heights.push(rect.bottom - rect.top);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2339
  }
2340
  }
2341
 
2342
+ // Find a line map (mapping character offsets to text nodes) and a
2343
+ // measurement cache for the given line number. (A line view might
2344
+ // contain multiple lines when collapsed ranges are present.)
2345
+ function mapFromLineView(lineView, line, lineN) {
2346
+ if (lineView.line == line)
2347
+ { return {map: lineView.measure.map, cache: lineView.measure.cache} }
2348
+ for (var i = 0; i < lineView.rest.length; i++)
2349
+ { if (lineView.rest[i] == line)
2350
+ { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
2351
+ for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
2352
+ { if (lineNo(lineView.rest[i$1]) > lineN)
2353
+ { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
2354
+ }
 
2355
 
2356
+ // Render a line into the hidden node display.externalMeasured. Used
2357
+ // when measurement is needed for a line that's not in the viewport.
2358
+ function updateExternalMeasurement(cm, line) {
2359
+ line = visualLine(line);
2360
+ var lineN = lineNo(line);
2361
+ var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
2362
+ view.lineN = lineN;
2363
+ var built = view.built = buildLineContent(cm, view);
2364
+ view.text = built.pre;
2365
+ removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
2366
+ return view
2367
  }
2368
 
2369
+ // Get a {top, bottom, left, right} box (in line-local coordinates)
2370
+ // for a given character.
2371
+ function measureChar(cm, line, ch, bias) {
2372
+ return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2373
  }
2374
 
2375
+ // Find a line view that corresponds to the given line number.
2376
+ function findViewForLine(cm, lineN) {
2377
+ if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
2378
+ { return cm.display.view[findViewIndex(cm, lineN)] }
2379
+ var ext = cm.display.externalMeasured;
2380
+ if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
2381
+ { return ext }
2382
+ }
2383
 
2384
+ // Measurement can be split in two steps, the set-up work that
2385
+ // applies to the whole line, and the measurement of the actual
2386
+ // character. Functions like coordsChar, that need to do a lot of
2387
+ // measurements in a row, can thus ensure that the set-up work is
2388
+ // only done once.
2389
+ function prepareMeasureForLine(cm, line) {
2390
+ var lineN = lineNo(line);
2391
+ var view = findViewForLine(cm, lineN);
2392
+ if (view && !view.text) {
2393
+ view = null;
2394
+ } else if (view && view.changes) {
2395
+ updateLineForChanges(cm, view, lineN, getDimensions(cm));
2396
+ cm.curOp.forceUpdate = true;
2397
  }
2398
+ if (!view)
2399
+ { view = updateExternalMeasurement(cm, line); }
2400
 
2401
+ var info = mapFromLineView(view, line, lineN);
2402
+ return {
2403
+ line: line, view: view, rect: null,
2404
+ map: info.map, cache: info.cache, before: info.before,
2405
+ hasHeights: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2406
  }
2407
+ }
2408
 
2409
+ // Given a prepared measurement object, measures the position of an
2410
+ // actual character (or fetches it from the cache).
2411
+ function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
2412
+ if (prepared.before) { ch = -1; }
2413
+ var key = ch + (bias || ""), found;
2414
+ if (prepared.cache.hasOwnProperty(key)) {
2415
+ found = prepared.cache[key];
2416
  } else {
2417
+ if (!prepared.rect)
2418
+ { prepared.rect = prepared.view.text.getBoundingClientRect(); }
2419
+ if (!prepared.hasHeights) {
2420
+ ensureLineHeights(cm, prepared.view, prepared.rect);
2421
+ prepared.hasHeights = true;
2422
+ }
2423
+ found = measureCharInner(cm, prepared, ch, bias);
2424
+ if (!found.bogus) { prepared.cache[key] = found; }
2425
  }
2426
+ return {left: found.left, right: found.right,
2427
+ top: varHeight ? found.rtop : found.top,
2428
+ bottom: varHeight ? found.rbottom : found.bottom}
2429
+ }
2430
 
2431
+ var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
 
 
 
2432
 
2433
+ function nodeAndOffsetInLineMap(map$$1, ch, bias) {
2434
+ var node, start, end, collapse, mStart, mEnd;
2435
+ // First, search the line map for the text node corresponding to,
2436
+ // or closest to, the target character.
2437
+ for (var i = 0; i < map$$1.length; i += 3) {
2438
+ mStart = map$$1[i];
2439
+ mEnd = map$$1[i + 1];
2440
+ if (ch < mStart) {
2441
+ start = 0; end = 1;
2442
+ collapse = "left";
2443
+ } else if (ch < mEnd) {
2444
+ start = ch - mStart;
2445
+ end = start + 1;
2446
+ } else if (i == map$$1.length - 3 || ch == mEnd && map$$1[i + 3] > ch) {
2447
+ end = mEnd - mStart;
2448
+ start = end - 1;
2449
+ if (ch >= mEnd) { collapse = "right"; }
2450
+ }
2451
+ if (start != null) {
2452
+ node = map$$1[i + 2];
2453
+ if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
2454
+ { collapse = bias; }
2455
+ if (bias == "left" && start == 0)
2456
+ { while (i && map$$1[i - 2] == map$$1[i - 3] && map$$1[i - 1].insertLeft) {
2457
+ node = map$$1[(i -= 3) + 2];
2458
+ collapse = "left";
2459
+ } }
2460
+ if (bias == "right" && start == mEnd - mStart)
2461
+ { while (i < map$$1.length - 3 && map$$1[i + 3] == map$$1[i + 4] && !map$$1[i + 5].insertLeft) {
2462
+ node = map$$1[(i += 3) + 2];
2463
+ collapse = "right";
2464
+ } }
2465
+ break
 
 
 
2466
  }
2467
  }
2468
+ return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
2469
+ }
2470
 
2471
+ function getUsefulRect(rects, bias) {
2472
+ var rect = nullRect;
2473
+ if (bias == "left") { for (var i = 0; i < rects.length; i++) {
2474
+ if ((rect = rects[i]).left != rect.right) { break }
2475
+ } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
2476
+ if ((rect = rects[i$1]).left != rect.right) { break }
2477
+ } }
2478
+ return rect
2479
+ }
2480
 
2481
+ function measureCharInner(cm, prepared, ch, bias) {
2482
+ var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
2483
+ var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
2484
+
2485
+ var rect;
2486
+ if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
2487
+ for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
2488
+ while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; }
2489
+ while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; }
2490
+ if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
2491
+ { rect = node.parentNode.getBoundingClientRect(); }
2492
+ else
2493
+ { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }
2494
+ if (rect.left || rect.right || start == 0) { break }
2495
+ end = start;
2496
+ start = start - 1;
2497
+ collapse = "right";
2498
  }
2499
+ if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); }
2500
+ } else { // If it is a widget, simply get the box for the whole widget.
2501
+ if (start > 0) { collapse = bias = "right"; }
2502
+ var rects;
2503
+ if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
2504
+ { rect = rects[bias == "right" ? rects.length - 1 : 0]; }
2505
+ else
2506
+ { rect = node.getBoundingClientRect(); }
2507
  }
2508
+ if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
2509
+ var rSpan = node.parentNode.getClientRects()[0];
2510
+ if (rSpan)
2511
+ { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; }
2512
+ else
2513
+ { rect = nullRect; }
 
 
2514
  }
2515
 
2516
+ var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
2517
+ var mid = (rtop + rbot) / 2;
2518
+ var heights = prepared.view.measure.heights;
2519
+ var i = 0;
2520
+ for (; i < heights.length - 1; i++)
2521
+ { if (mid < heights[i]) { break } }
2522
+ var top = i ? heights[i - 1] : 0, bot = heights[i];
2523
+ var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
2524
+ right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
2525
+ top: top, bottom: bot};
2526
+ if (!rect.left && !rect.right) { result.bogus = true; }
2527
+ if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
2528
+
2529
+ return result
2530
  }
2531
 
2532
+ // Work around problem with bounding client rects on ranges being
2533
+ // returned incorrectly when zoomed on IE10 and below.
2534
+ function maybeUpdateRectForZooming(measure, rect) {
2535
+ if (!window.screen || screen.logicalXDPI == null ||
2536
+ screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
2537
+ { return rect }
2538
+ var scaleX = screen.logicalXDPI / screen.deviceXDPI;
2539
+ var scaleY = screen.logicalYDPI / screen.deviceYDPI;
2540
+ return {left: rect.left * scaleX, right: rect.right * scaleX,
2541
+ top: rect.top * scaleY, bottom: rect.bottom * scaleY}
2542
+ }
2543
 
2544
+ function clearLineMeasurementCacheFor(lineView) {
2545
+ if (lineView.measure) {
2546
+ lineView.measure.cache = {};
2547
+ lineView.measure.heights = null;
2548
+ if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
2549
+ { lineView.measure.caches[i] = {}; } }
2550
+ }
2551
+ }
2552
 
2553
+ function clearLineMeasurementCache(cm) {
2554
+ cm.display.externalMeasure = null;
2555
+ removeChildren(cm.display.lineMeasure);
2556
+ for (var i = 0; i < cm.display.view.length; i++)
2557
+ { clearLineMeasurementCacheFor(cm.display.view[i]); }
2558
+ }
2559
 
2560
+ function clearCaches(cm) {
2561
+ clearLineMeasurementCache(cm);
2562
+ cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
2563
+ if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; }
2564
+ cm.display.lineNumChars = null;
 
 
 
 
2565
  }
2566
 
2567
+ function pageScrollX() {
2568
+ // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
2569
+ // which causes page_Offset and bounding client rects to use
2570
+ // different reference viewports and invalidate our calculations.
2571
+ if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
2572
+ return window.pageXOffset || (document.documentElement || document.body).scrollLeft
2573
+ }
2574
+ function pageScrollY() {
2575
+ if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
2576
+ return window.pageYOffset || (document.documentElement || document.body).scrollTop
2577
  }
2578
 
2579
+ function widgetTopHeight(lineObj) {
2580
+ var height = 0;
2581
+ if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
2582
+ { height += widgetHeight(lineObj.widgets[i]); } } }
2583
+ return height
2584
+ }
2585
 
2586
+ // Converts a {top, bottom, left, right} box from line-local
2587
+ // coordinates into another coordinate system. Context may be one of
2588
+ // "line", "div" (display.lineDiv), "local"./null (editor), "window",
2589
+ // or "page".
2590
+ function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
2591
+ if (!includeWidgets) {
2592
+ var height = widgetTopHeight(lineObj);
2593
+ rect.top += height; rect.bottom += height;
2594
+ }
2595
+ if (context == "line") { return rect }
2596
+ if (!context) { context = "local"; }
2597
+ var yOff = heightAtLine(lineObj);
2598
+ if (context == "local") { yOff += paddingTop(cm.display); }
2599
+ else { yOff -= cm.display.viewOffset; }
2600
+ if (context == "page" || context == "window") {
2601
+ var lOff = cm.display.lineSpace.getBoundingClientRect();
2602
+ yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
2603
+ var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
2604
+ rect.left += xOff; rect.right += xOff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2605
  }
2606
+ rect.top += yOff; rect.bottom += yOff;
2607
+ return rect
2608
  }
2609
 
2610
+ // Coverts a box from "div" coords to another coordinate system.
2611
+ // Context may be "window", "page", "div", or "local"./null.
2612
+ function fromCoordSystem(cm, coords, context) {
2613
+ if (context == "div") { return coords }
2614
+ var left = coords.left, top = coords.top;
2615
+ // First move into "page" coordinate system
2616
+ if (context == "page") {
2617
+ left -= pageScrollX();
2618
+ top -= pageScrollY();
2619
+ } else if (context == "local" || !context) {
2620
+ var localBox = cm.display.sizer.getBoundingClientRect();
2621
+ left += localBox.left;
2622
+ top += localBox.top;
2623
+ }
2624
 
2625
+ var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
2626
+ return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
2627
+ }
2628
 
2629
+ function charCoords(cm, pos, context, lineObj, bias) {
2630
+ if (!lineObj) { lineObj = getLine(cm.doc, pos.line); }
2631
+ return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
 
 
 
 
 
 
 
 
 
 
 
2632
  }
2633
 
2634
+ // Returns a box for a given cursor position, which may have an
2635
+ // 'other' property containing the position of the secondary cursor
2636
+ // on a bidi boundary.
2637
+ // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
2638
+ // and after `char - 1` in writing order of `char - 1`
2639
+ // A cursor Pos(line, char, "after") is on the same visual line as `char`
2640
+ // and before `char` in writing order of `char`
2641
+ // Examples (upper-case letters are RTL, lower-case are LTR):
2642
+ // Pos(0, 1, ...)
2643
+ // before after
2644
+ // ab a|b a|b
2645
+ // aB a|B aB|
2646
+ // Ab |Ab A|b
2647
+ // AB B|A B|A
2648
+ // Every position after the last character on a line is considered to stick
2649
+ // to the last character on the line.
2650
+ function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
2651
+ lineObj = lineObj || getLine(cm.doc, pos.line);
2652
+ if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
2653
+ function get(ch, right) {
2654
+ var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
2655
+ if (right) { m.left = m.right; } else { m.right = m.left; }
2656
+ return intoCoordSystem(cm, lineObj, m, context)
2657
+ }
2658
+ var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
2659
+ if (ch >= lineObj.text.length) {
2660
+ ch = lineObj.text.length;
2661
+ sticky = "before";
2662
+ } else if (ch <= 0) {
2663
+ ch = 0;
2664
+ sticky = "after";
2665
+ }
2666
+ if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
2667
 
2668
+ function getBidi(ch, partPos, invert) {
2669
+ var part = order[partPos], right = part.level == 1;
2670
+ return get(invert ? ch - 1 : ch, right != invert)
2671
+ }
2672
+ var partPos = getBidiPartAt(order, ch, sticky);
2673
+ var other = bidiOther;
2674
+ var val = getBidi(ch, partPos, sticky == "before");
2675
+ if (other != null) { val.other = getBidi(ch, other, sticky != "before"); }
2676
+ return val
 
2677
  }
2678
+
2679
+ // Used to cheaply estimate the coordinates for a position. Used for
2680
+ // intermediate scroll updates.
2681
+ function estimateCoords(cm, pos) {
2682
+ var left = 0;
2683
+ pos = clipPos(cm.doc, pos);
2684
+ if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; }
2685
+ var lineObj = getLine(cm.doc, pos.line);
2686
+ var top = heightAtLine(lineObj) + paddingTop(cm.display);
2687
+ return {left: left, right: left, top: top, bottom: top + lineObj.height}
2688
  }
2689
 
2690
+ // Positions returned by coordsChar contain some extra information.
2691
+ // xRel is the relative x position of the input coordinates compared
2692
+ // to the found position (so xRel > 0 means the coordinates are to
2693
+ // the right of the character position, for example). When outside
2694
+ // is true, that means the coordinates lie outside the line's
2695
+ // vertical range.
2696
+ function PosWithInfo(line, ch, sticky, outside, xRel) {
2697
+ var pos = Pos(line, ch, sticky);
2698
+ pos.xRel = xRel;
2699
+ if (outside) { pos.outside = outside; }
2700
+ return pos
2701
+ }
2702
 
2703
+ // Compute the character position closest to the given coordinates.
2704
+ // Input must be lineSpace-local ("div" coordinate system).
2705
+ function coordsChar(cm, x, y) {
2706
+ var doc = cm.doc;
2707
+ y += cm.display.viewOffset;
2708
+ if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) }
2709
+ var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
2710
+ if (lineN > last)
2711
+ { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) }
2712
+ if (x < 0) { x = 0; }
2713
 
2714
+ var lineObj = getLine(doc, lineN);
2715
+ for (;;) {
2716
+ var found = coordsCharInner(cm, lineObj, lineN, x, y);
2717
+ var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));
2718
+ if (!collapsed) { return found }
2719
+ var rangeEnd = collapsed.find(1);
2720
+ if (rangeEnd.line == lineN) { return rangeEnd }
2721
+ lineObj = getLine(doc, lineN = rangeEnd.line);
2722
+ }
2723
+ }
2724
 
2725
+ function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
2726
+ y -= widgetTopHeight(lineObj);
2727
+ var end = lineObj.text.length;
2728
+ var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0);
2729
+ end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end);
2730
+ return {begin: begin, end: end}
2731
+ }
2732
 
2733
+ function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
2734
+ if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
2735
+ var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
2736
+ return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
2737
+ }
 
 
 
 
 
 
 
 
 
2738
 
2739
+ // Returns true if the given side of a box is after the given
2740
+ // coordinates, in top-to-bottom, left-to-right order.
2741
+ function boxIsAfter(box, x, y, left) {
2742
+ return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
2743
+ }
 
 
 
 
 
 
 
 
 
2744
 
2745
+ function coordsCharInner(cm, lineObj, lineNo$$1, x, y) {
2746
+ // Move y into line-local coordinate space
2747
+ y -= heightAtLine(lineObj);
2748
+ var preparedMeasure = prepareMeasureForLine(cm, lineObj);
2749
+ // When directly calling `measureCharPrepared`, we have to adjust
2750
+ // for the widgets at this line.
2751
+ var widgetHeight$$1 = widgetTopHeight(lineObj);
2752
+ var begin = 0, end = lineObj.text.length, ltr = true;
2753
+
2754
+ var order = getOrder(lineObj, cm.doc.direction);
2755
+ // If the line isn't plain left-to-right text, first figure out
2756
+ // which bidi section the coordinates fall into.
2757
+ if (order) {
2758
+ var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)
2759
+ (cm, lineObj, lineNo$$1, preparedMeasure, order, x, y);
2760
+ ltr = part.level != 1;
2761
+ // The awkward -1 offsets are needed because findFirst (called
2762
+ // on these below) will treat its first bound as inclusive,
2763
+ // second as exclusive, but we want to actually address the
2764
+ // characters in the part's range
2765
+ begin = ltr ? part.from : part.to - 1;
2766
+ end = ltr ? part.to : part.from - 1;
2767
+ }
2768
+
2769
+ // A binary search to find the first character whose bounding box
2770
+ // starts after the coordinates. If we run across any whose box wrap
2771
+ // the coordinates, store that.
2772
+ var chAround = null, boxAround = null;
2773
+ var ch = findFirst(function (ch) {
2774
+ var box = measureCharPrepared(cm, preparedMeasure, ch);
2775
+ box.top += widgetHeight$$1; box.bottom += widgetHeight$$1;
2776
+ if (!boxIsAfter(box, x, y, false)) { return false }
2777
+ if (box.top <= y && box.left <= x) {
2778
+ chAround = ch;
2779
+ boxAround = box;
2780
+ }
2781
+ return true
2782
+ }, begin, end);
2783
+
2784
+ var baseX, sticky, outside = false;
2785
+ // If a box around the coordinates was found, use that
2786
+ if (boxAround) {
2787
+ // Distinguish coordinates nearer to the left or right side of the box
2788
+ var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;
2789
+ ch = chAround + (atStart ? 0 : 1);
2790
+ sticky = atStart ? "after" : "before";
2791
+ baseX = atLeft ? boxAround.left : boxAround.right;
2792
+ } else {
2793
+ // (Adjust for extended bound, if necessary.)
2794
+ if (!ltr && (ch == end || ch == begin)) { ch++; }
2795
+ // To determine which side to associate with, get the box to the
2796
+ // left of the character and compare it's vertical position to the
2797
+ // coordinates
2798
+ sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" :
2799
+ (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$$1 <= y) == ltr ?
2800
+ "after" : "before";
2801
+ // Now get accurate coordinates for this place, in order to get a
2802
+ // base X position
2803
+ var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
2804
+ baseX = coords.left;
2805
+ outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0;
2806
+ }
2807
+
2808
+ ch = skipExtendingChars(lineObj.text, ch, 1);
2809
+ return PosWithInfo(lineNo$$1, ch, sticky, outside, x - baseX)
2810
+ }
2811
+
2812
+ function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {
2813
+ // Bidi parts are sorted left-to-right, and in a non-line-wrapping
2814
+ // situation, we can take this ordering to correspond to the visual
2815
+ // ordering. This finds the first part whose end is after the given
2816
+ // coordinates.
2817
+ var index = findFirst(function (i) {
2818
+ var part = order[i], ltr = part.level != 1;
2819
+ return boxIsAfter(cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? "before" : "after"),
2820
+ "line", lineObj, preparedMeasure), x, y, true)
2821
+ }, 0, order.length - 1);
2822
+ var part = order[index];
2823
+ // If this isn't the first part, the part's start is also after
2824
+ // the coordinates, and the coordinates aren't on the same line as
2825
+ // that start, move one part back.
2826
+ if (index > 0) {
2827
+ var ltr = part.level != 1;
2828
+ var start = cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? "after" : "before"),
2829
+ "line", lineObj, preparedMeasure);
2830
+ if (boxIsAfter(start, x, y, true) && start.top > y)
2831
+ { part = order[index - 1]; }
2832
+ }
2833
+ return part
2834
+ }
2835
+
2836
+ function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
2837
+ // In a wrapped line, rtl text on wrapping boundaries can do things
2838
+ // that don't correspond to the ordering in our `order` array at
2839
+ // all, so a binary search doesn't work, and we want to return a
2840
+ // part that only spans one line so that the binary search in
2841
+ // coordsCharInner is safe. As such, we first find the extent of the
2842
+ // wrapped line, and then do a flat search in which we discard any
2843
+ // spans that aren't on the line.
2844
+ var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
2845
+ var begin = ref.begin;
2846
+ var end = ref.end;
2847
+ if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; }
2848
+ var part = null, closestDist = null;
2849
+ for (var i = 0; i < order.length; i++) {
2850
+ var p = order[i];
2851
+ if (p.from >= end || p.to <= begin) { continue }
2852
+ var ltr = p.level != 1;
2853
+ var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
2854
+ // Weigh against spans ending before this, so that they are only
2855
+ // picked if nothing ends after
2856
+ var dist = endX < x ? x - endX + 1e9 : endX - x;
2857
+ if (!part || closestDist > dist) {
2858
+ part = p;
2859
+ closestDist = dist;
2860
+ }
2861
+ }
2862
+ if (!part) { part = order[order.length - 1]; }
2863
+ // Clip the part to the wrapped line.
2864
+ if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; }
2865
+ if (part.to > end) { part = {from: part.from, to: end, level: part.level}; }
2866
+ return part
2867
+ }
2868
 
2869
+ var measureText;
2870
+ // Compute the default text height.
2871
+ function textHeight(display) {
2872
+ if (display.cachedTextHeight != null) { return display.cachedTextHeight }
2873
+ if (measureText == null) {
2874
+ measureText = elt("pre", null, "CodeMirror-line-like");
2875
+ // Measure a bunch of lines, for browsers that compute
2876
+ // fractional heights.
2877
+ for (var i = 0; i < 49; ++i) {
2878
+ measureText.appendChild(document.createTextNode("x"));
2879
+ measureText.appendChild(elt("br"));
 
 
 
 
 
 
2880
  }
2881
+ measureText.appendChild(document.createTextNode("x"));
2882
  }
2883
+ removeChildrenAndAdd(display.measure, measureText);
2884
+ var height = measureText.offsetHeight / 50;
2885
+ if (height > 3) { display.cachedTextHeight = height; }
2886
+ removeChildren(display.measure);
2887
+ return height || 1
2888
  }
2889
 
2890
+ // Compute the default character width.
2891
+ function charWidth(display) {
2892
+ if (display.cachedCharWidth != null) { return display.cachedCharWidth }
2893
+ var anchor = elt("span", "xxxxxxxxxx");
2894
+ var pre = elt("pre", [anchor], "CodeMirror-line-like");
2895
+ removeChildrenAndAdd(display.measure, pre);
2896
+ var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
2897
+ if (width > 2) { display.cachedCharWidth = width; }
2898
+ return width || 10
2899
+ }
2900
 
2901
+ // Do a bulk-read of the DOM positions and sizes needed to draw the
2902
+ // view, so that we don't interleave reading and writing to the DOM.
2903
+ function getDimensions(cm) {
2904
+ var d = cm.display, left = {}, width = {};
2905
+ var gutterLeft = d.gutters.clientLeft;
2906
+ for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
2907
+ var id = cm.display.gutterSpecs[i].className;
2908
+ left[id] = n.offsetLeft + n.clientLeft + gutterLeft;
2909
+ width[id] = n.clientWidth;
 
 
 
 
 
 
 
 
2910
  }
2911
+ return {fixedPos: compensateForHScroll(d),
2912
+ gutterTotalWidth: d.gutters.offsetWidth,
2913
+ gutterLeft: left,
2914
+ gutterWidth: width,
2915
+ wrapperWidth: d.wrapper.clientWidth}
2916
  }
2917
 
2918
+ // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
2919
+ // but using getBoundingClientRect to get a sub-pixel-accurate
2920
+ // result.
2921
+ function compensateForHScroll(display) {
2922
+ return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
 
2923
  }
2924
 
2925
+ // Returns a function that estimates the height of a line, to use as
2926
+ // first approximation until the line becomes visible (and is thus
2927
+ // properly measurable).
2928
+ function estimateHeight(cm) {
2929
+ var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
2930
+ var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
2931
+ return function (line) {
2932
+ if (lineIsHidden(cm.doc, line)) { return 0 }
 
 
 
 
 
 
 
 
2933
 
2934
+ var widgetsHeight = 0;
2935
+ if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
2936
+ if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }
2937
+ } }
 
 
 
 
 
 
 
 
2938
 
2939
+ if (wrapping)
2940
+ { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
2941
+ else
2942
+ { return widgetsHeight + th }
2943
  }
 
2944
  }
2945
 
2946
+ function estimateLineHeights(cm) {
2947
+ var doc = cm.doc, est = estimateHeight(cm);
2948
+ doc.iter(function (line) {
2949
+ var estHeight = est(line);
2950
+ if (estHeight != line.height) { updateLineHeight(line, estHeight); }
2951
+ });
 
 
 
 
2952
  }
2953
 
2954
+ // Given a mouse event, find the corresponding position. If liberal
2955
+ // is false, it checks whether a gutter or scrollbar was clicked,
2956
+ // and returns null if it was. forRect is used by rectangular
2957
+ // selections, and tries to estimate a character position even for
2958
+ // coordinates beyond the right of the text.
2959
+ function posFromMouse(cm, e, liberal, forRect) {
2960
+ var display = cm.display;
2961
+ if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
 
 
 
 
 
 
 
 
2962
 
2963
+ var x, y, space = display.lineSpace.getBoundingClientRect();
2964
+ // Fails unpredictably on IE[67] when mouse is dragged around quickly.
2965
+ try { x = e.clientX - space.left; y = e.clientY - space.top; }
2966
+ catch (e) { return null }
2967
+ var coords = coordsChar(cm, x, y), line;
2968
+ if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
2969
+ var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
2970
+ coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
2971
+ }
2972
+ return coords
2973
  }
2974
 
2975
+ // Find the view element corresponding to a given line. Return null
2976
+ // when the line isn't visible.
2977
+ function findViewIndex(cm, n) {
2978
+ if (n >= cm.display.viewTo) { return null }
2979
+ n -= cm.display.viewFrom;
2980
+ if (n < 0) { return null }
2981
+ var view = cm.display.view;
2982
+ for (var i = 0; i < view.length; i++) {
2983
+ n -= view[i].size;
2984
+ if (n < 0) { return i }
2985
  }
 
 
2986
  }
2987
 
2988
+ // Updates the display.view data structure for a given change to the
2989
+ // document. From and to are in pre-change coordinates. Lendiff is
2990
+ // the amount of lines added or subtracted by the change. This is
2991
+ // used for changes that span multiple lines, or change the way
2992
+ // lines are divided into visual lines. regLineChange (below)
2993
+ // registers single-line changes.
2994
+ function regChange(cm, from, to, lendiff) {
2995
+ if (from == null) { from = cm.doc.first; }
2996
+ if (to == null) { to = cm.doc.first + cm.doc.size; }
2997
+ if (!lendiff) { lendiff = 0; }
2998
 
2999
+ var display = cm.display;
3000
+ if (lendiff && to < display.viewTo &&
3001
+ (display.updateLineNumbers == null || display.updateLineNumbers > from))
3002
+ { display.updateLineNumbers = from; }
 
 
 
 
 
 
 
3003
 
3004
+ cm.curOp.viewChanged = true;
3005
 
3006
+ if (from >= display.viewTo) { // Change after
3007
+ if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
3008
+ { resetView(cm); }
3009
+ } else if (to <= display.viewFrom) { // Change before
3010
+ if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
3011
+ resetView(cm);
3012
+ } else {
3013
+ display.viewFrom += lendiff;
3014
+ display.viewTo += lendiff;
3015
+ }
3016
+ } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
3017
+ resetView(cm);
3018
+ } else if (from <= display.viewFrom) { // Top overlap
3019
+ var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
3020
+ if (cut) {
3021
+ display.view = display.view.slice(cut.index);
3022
+ display.viewFrom = cut.lineN;
3023
+ display.viewTo += lendiff;
3024
+ } else {
3025
+ resetView(cm);
3026
+ }
3027
+ } else if (to >= display.viewTo) { // Bottom overlap
3028
+ var cut$1 = viewCuttingPoint(cm, from, from, -1);
3029
+ if (cut$1) {
3030
+ display.view = display.view.slice(0, cut$1.index);
3031
+ display.viewTo = cut$1.lineN;
3032
+ } else {
3033
+ resetView(cm);
3034
+ }
3035
+ } else { // Gap in the middle
3036
+ var cutTop = viewCuttingPoint(cm, from, from, -1);
3037
+ var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
3038
+ if (cutTop && cutBot) {
3039
+ display.view = display.view.slice(0, cutTop.index)
3040
+ .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
3041
+ .concat(display.view.slice(cutBot.index));
3042
+ display.viewTo += lendiff;
3043
+ } else {
3044
+ resetView(cm);
3045
  }
3046
  }
3047
+
3048
+ var ext = display.externalMeasured;
3049
+ if (ext) {
3050
+ if (to < ext.lineN)
3051
+ { ext.lineN += lendiff; }
3052
+ else if (from < ext.lineN + ext.size)
3053
+ { display.externalMeasured = null; }
 
3054
  }
 
 
3055
  }
3056
 
3057
+ // Register a change to a single line. Type must be one of "text",
3058
+ // "gutter", "class", "widget"
3059
+ function regLineChange(cm, line, type) {
3060
+ cm.curOp.viewChanged = true;
3061
+ var display = cm.display, ext = cm.display.externalMeasured;
3062
+ if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
3063
+ { display.externalMeasured = null; }
 
 
3064
 
3065
+ if (line < display.viewFrom || line >= display.viewTo) { return }
3066
+ var lineView = display.view[findViewIndex(cm, line)];
3067
+ if (lineView.node == null) { return }
3068
+ var arr = lineView.changes || (lineView.changes = []);
3069
+ if (indexOf(arr, type) == -1) { arr.push(type); }
3070
+ }
3071
 
3072
+ // Clear the view.
3073
+ function resetView(cm) {
3074
+ cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
3075
+ cm.display.view = [];
3076
+ cm.display.viewOffset = 0;
3077
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3078
 
3079
+ function viewCuttingPoint(cm, oldN, newN, dir) {
3080
+ var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
3081
+ if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
3082
+ { return {index: index, lineN: newN} }
3083
+ var n = cm.display.viewFrom;
3084
+ for (var i = 0; i < index; i++)
3085
+ { n += view[i].size; }
3086
+ if (n != oldN) {
3087
+ if (dir > 0) {
3088
+ if (index == view.length - 1) { return null }
3089
+ diff = (n + view[index].size) - oldN;
3090
+ index++;
3091
+ } else {
3092
+ diff = n - oldN;
3093
  }
3094
+ oldN += diff; newN += diff;
3095
  }
3096
+ while (visualLineNo(cm.doc, newN) != newN) {
3097
+ if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
3098
+ newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
3099
+ index += dir;
 
 
 
 
 
 
 
 
 
 
 
 
 
3100
  }
3101
+ return {index: index, lineN: newN}
3102
+ }
3103
 
3104
+ // Force the view to cover a given range, adding empty view element
3105
+ // or clipping off existing ones as needed.
3106
+ function adjustView(cm, from, to) {
3107
+ var display = cm.display, view = display.view;
3108
+ if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
3109
+ display.view = buildViewArray(cm, from, to);
3110
+ display.viewFrom = from;
 
3111
  } else {
3112
+ if (display.viewFrom > from)
3113
+ { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }
3114
+ else if (display.viewFrom < from)
3115
+ { display.view = display.view.slice(findViewIndex(cm, from)); }
3116
+ display.viewFrom = from;
3117
+ if (display.viewTo < to)
3118
+ { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }
3119
+ else if (display.viewTo > to)
3120
+ { display.view = display.view.slice(0, findViewIndex(cm, to)); }
3121
  }
3122
+ display.viewTo = to;
3123
  }
3124
 
3125
+ // Count the number of lines in the view whose DOM representation is
3126
+ // out of date (or nonexistent).
3127
+ function countDirtyView(cm) {
3128
+ var view = cm.display.view, dirty = 0;
3129
+ for (var i = 0; i < view.length; i++) {
3130
+ var lineView = view[i];
3131
+ if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; }
3132
+ }
3133
+ return dirty
3134
  }
3135
 
3136
+ function updateSelection(cm) {
3137
+ cm.display.input.showSelection(cm.display.input.prepareSelection());
3138
+ }
 
 
 
 
 
 
3139
 
3140
+ function prepareSelection(cm, primary) {
3141
+ if ( primary === void 0 ) primary = true;
 
 
 
3142
 
3143
+ var doc = cm.doc, result = {};
3144
+ var curFragment = result.cursors = document.createDocumentFragment();
3145
+ var selFragment = result.selection = document.createDocumentFragment();
 
3146
 
 
 
3147
  for (var i = 0; i < doc.sel.ranges.length; i++) {
3148
+ if (!primary && i == doc.sel.primIndex) { continue }
3149
+ var range$$1 = doc.sel.ranges[i];
3150
+ if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) { continue }
3151
+ var collapsed = range$$1.empty();
3152
+ if (collapsed || cm.options.showCursorWhenSelecting)
3153
+ { drawSelectionCursor(cm, range$$1.head, curFragment); }
3154
+ if (!collapsed)
3155
+ { drawSelectionRange(cm, range$$1, selFragment); }
3156
  }
3157
+ return result
3158
  }
3159
 
3160
+ // Draws a cursor for the given range
3161
+ function drawSelectionCursor(cm, head, output) {
3162
+ var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
 
 
 
3163
 
3164
+ var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
3165
+ cursor.style.left = pos.left + "px";
3166
+ cursor.style.top = pos.top + "px";
3167
+ cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
3168
+
3169
+ if (pos.other) {
3170
+ // Secondary cursor, shown when on a 'jump' in bi-directional text
3171
+ var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
3172
+ otherCursor.style.display = "";
3173
+ otherCursor.style.left = pos.other.left + "px";
3174
+ otherCursor.style.top = pos.other.top + "px";
3175
+ otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
 
 
 
 
 
3176
  }
 
3177
  }
3178
 
3179
+ function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3180
 
3181
+ // Draws the given range as a highlighted selection
3182
+ function drawSelectionRange(cm, range$$1, output) {
3183
+ var display = cm.display, doc = cm.doc;
3184
+ var fragment = document.createDocumentFragment();
3185
+ var padding = paddingH(cm.display), leftSide = padding.left;
3186
+ var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
3187
+ var docLTR = doc.direction == "ltr";
3188
 
3189
+ function add(left, top, width, bottom) {
3190
+ if (top < 0) { top = 0; }
3191
+ top = Math.round(top);
3192
+ bottom = Math.round(bottom);
3193
+ fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")));
 
 
 
3194
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3195
 
3196
+ function drawForLine(line, fromArg, toArg) {
3197
+ var lineObj = getLine(doc, line);
3198
+ var lineLen = lineObj.text.length;
3199
+ var start, end;
3200
+ function coords(ch, bias) {
3201
+ return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
3202
+ }
3203
+
3204
+ function wrapX(pos, dir, side) {
3205
+ var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
3206
+ var prop = (dir == "ltr") == (side == "after") ? "left" : "right";
3207
+ var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
3208
+ return coords(ch, prop)[prop]
3209
+ }
3210
+
3211
+ var order = getOrder(lineObj, doc.direction);
3212
+ iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
3213
+ var ltr = dir == "ltr";
3214
+ var fromPos = coords(from, ltr ? "left" : "right");
3215
+ var toPos = coords(to - 1, ltr ? "right" : "left");
3216
+
3217
+ var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;
3218
+ var first = i == 0, last = !order || i == order.length - 1;
3219
+ if (toPos.top - fromPos.top <= 3) { // Single line
3220
+ var openLeft = (docLTR ? openStart : openEnd) && first;
3221
+ var openRight = (docLTR ? openEnd : openStart) && last;
3222
+ var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
3223
+ var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
3224
+ add(left, fromPos.top, right - left, fromPos.bottom);
3225
+ } else { // Multiple lines
3226
+ var topLeft, topRight, botLeft, botRight;
3227
+ if (ltr) {
3228
+ topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
3229
+ topRight = docLTR ? rightSide : wrapX(from, dir, "before");
3230
+ botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
3231
+ botRight = docLTR && openEnd && last ? rightSide : toPos.right;
3232
+ } else {
3233
+ topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
3234
+ topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
3235
+ botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
3236
+ botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
3237
+ }
3238
+ add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
3239
+ if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); }
3240
+ add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
3241
+ }
3242
 
3243
+ if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; }
3244
+ if (cmpCoords(toPos, start) < 0) { start = toPos; }
3245
+ if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; }
3246
+ if (cmpCoords(toPos, end) < 0) { end = toPos; }
3247
+ });
3248
+ return {start: start, end: end}
3249
  }
 
 
3250
 
3251
+ var sFrom = range$$1.from(), sTo = range$$1.to();
3252
+ if (sFrom.line == sTo.line) {
3253
+ drawForLine(sFrom.line, sFrom.ch, sTo.ch);
3254
+ } else {
3255
+ var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
3256
+ var singleVLine = visualLine(fromLine) == visualLine(toLine);
3257
+ var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
3258
+ var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
3259
+ if (singleVLine) {
3260
+ if (leftEnd.top < rightStart.top - 2) {
3261
+ add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
3262
+ add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
3263
+ } else {
3264
+ add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
3265
  }
 
3266
  }
3267
+ if (leftEnd.bottom < rightStart.top)
3268
+ { add(leftSide, leftEnd.bottom, null, rightStart.top); }
3269
  }
3270
 
3271
+ output.appendChild(fragment);
3272
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3273
 
3274
+ // Cursor-blinking
3275
+ function restartBlink(cm) {
3276
+ if (!cm.state.focused) { return }
3277
+ var display = cm.display;
3278
+ clearInterval(display.blinker);
3279
+ var on = true;
3280
+ display.cursorDiv.style.visibility = "";
3281
+ if (cm.options.cursorBlinkRate > 0)
3282
+ { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
3283
+ cm.options.cursorBlinkRate); }
3284
+ else if (cm.options.cursorBlinkRate < 0)
3285
+ { display.cursorDiv.style.visibility = "hidden"; }
3286
  }
3287
 
3288
+ function ensureFocus(cm) {
3289
+ if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
 
 
 
 
 
 
 
 
 
 
 
 
3290
  }
3291
 
3292
+ function delayBlurEvent(cm) {
3293
+ cm.state.delayingBlurEvent = true;
3294
+ setTimeout(function () { if (cm.state.delayingBlurEvent) {
3295
+ cm.state.delayingBlurEvent = false;
3296
+ onBlur(cm);
3297
+ } }, 100);
3298
+ }
3299
 
3300
+ function onFocus(cm, e) {
3301
+ if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
 
 
 
3302
 
3303
+ if (cm.options.readOnly == "nocursor") { return }
3304
+ if (!cm.state.focused) {
3305
+ signal(cm, "focus", cm, e);
3306
+ cm.state.focused = true;
3307
+ addClass(cm.display.wrapper, "CodeMirror-focused");
3308
+ // This test prevents this from firing when a context
3309
+ // menu is closed (since the input reset would kill the
3310
+ // select-all detection hack)
3311
+ if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
3312
+ cm.display.input.reset();
3313
+ if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730
3314
+ }
3315
+ cm.display.input.receivedFocus();
3316
  }
3317
+ restartBlink(cm);
 
 
 
 
 
 
3318
  }
3319
+ function onBlur(cm, e) {
3320
+ if (cm.state.delayingBlurEvent) { return }
3321
 
3322
+ if (cm.state.focused) {
3323
+ signal(cm, "blur", cm, e);
3324
+ cm.state.focused = false;
3325
+ rmClass(cm.display.wrapper, "CodeMirror-focused");
 
 
 
 
 
 
 
 
 
 
3326
  }
3327
+ clearInterval(cm.display.blinker);
3328
+ setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150);
3329
+ }
3330
 
3331
+ // Read the actual heights of the rendered lines, and update their
3332
+ // stored heights to match.
3333
+ function updateHeightsInViewport(cm) {
3334
+ var display = cm.display;
3335
+ var prevBottom = display.lineDiv.offsetTop;
3336
+ for (var i = 0; i < display.view.length; i++) {
3337
+ var cur = display.view[i], wrapping = cm.options.lineWrapping;
3338
+ var height = (void 0), width = 0;
3339
+ if (cur.hidden) { continue }
3340
+ if (ie && ie_version < 8) {
3341
+ var bot = cur.node.offsetTop + cur.node.offsetHeight;
3342
+ height = bot - prevBottom;
3343
+ prevBottom = bot;
3344
+ } else {
3345
+ var box = cur.node.getBoundingClientRect();
3346
+ height = box.bottom - box.top;
3347
+ // Check that lines don't extend past the right of the current
3348
+ // editor width
3349
+ if (!wrapping && cur.text.firstChild)
3350
+ { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; }
3351
+ }
3352
+ var diff = cur.line.height - height;
3353
+ if (diff > .005 || diff < -.005) {
3354
+ updateLineHeight(cur.line, height);
3355
+ updateWidgetHeight(cur.line);
3356
+ if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
3357
+ { updateWidgetHeight(cur.rest[j]); } }
3358
+ }
3359
+ if (width > cm.display.sizerWidth) {
3360
+ var chWidth = Math.ceil(width / charWidth(cm.display));
3361
+ if (chWidth > cm.display.maxLineLength) {
3362
+ cm.display.maxLineLength = chWidth;
3363
+ cm.display.maxLine = cur.line;
3364
+ cm.display.maxLineChanged = true;
3365
  }
3366
+ }
 
3367
  }
3368
+ }
3369
 
3370
+ // Read and store the height of line widgets associated with the
3371
+ // given line.
3372
+ function updateWidgetHeight(line) {
3373
+ if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {
3374
+ var w = line.widgets[i], parent = w.node.parentNode;
3375
+ if (parent) { w.height = parent.offsetHeight; }
3376
+ } }
3377
+ }
3378
 
3379
+ // Compute the lines that are visible in a given viewport (defaults
3380
+ // the the current scroll position). viewport may contain top,
3381
+ // height, and ensure (see op.scrollToPos) properties.
3382
+ function visibleLines(display, doc, viewport) {
3383
+ var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
3384
+ top = Math.floor(top - paddingTop(display));
3385
+ var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
3386
 
3387
+ var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
3388
+ // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
3389
+ // forces those lines into the viewport (if possible).
3390
+ if (viewport && viewport.ensure) {
3391
+ var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
3392
+ if (ensureFrom < from) {
3393
+ from = ensureFrom;
3394
+ to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
3395
+ } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
3396
+ from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
3397
+ to = ensureTo;
3398
+ }
3399
  }
3400
+ return {from: from, to: Math.max(to, from + 1)}
 
 
 
 
 
 
 
3401
  }
3402
 
3403
  // SCROLLING THINGS INTO VIEW
3404
 
3405
  // If an editor sits on the top or bottom of the window, partially
3406
  // scrolled out of view, this ensures that the cursor is visible.
3407
+ function maybeScrollWindow(cm, rect) {
3408
+ if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
3409
+
3410
  var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
3411
+ if (rect.top + box.top < 0) { doScroll = true; }
3412
+ else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
3413
  if (doScroll != null && !phantom) {
3414
+ var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
 
 
 
3415
  cm.display.lineSpace.appendChild(scrollNode);
3416
  scrollNode.scrollIntoView(doScroll);
3417
  cm.display.lineSpace.removeChild(scrollNode);
3422
  // it actually became visible (as line heights are accurately
3423
  // measured, the position of something may 'drift' during drawing).
3424
  function scrollPosIntoView(cm, pos, end, margin) {
3425
+ if (margin == null) { margin = 0; }
3426
+ var rect;
3427
+ if (!cm.options.lineWrapping && pos == end) {
3428
+ // Set pos and end to the cursor positions around the character pos sticks to
3429
+ // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
3430
+ // If pos == Pos(_, 0, "before"), pos and end are unchanged
3431
+ pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
3432
+ end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
3433
+ }
3434
+ for (var limit = 0; limit < 5; limit++) {
3435
+ var changed = false;
3436
+ var coords = cursorCoords(cm, pos);
3437
  var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
3438
+ rect = {left: Math.min(coords.left, endCoords.left),
3439
+ top: Math.min(coords.top, endCoords.top) - margin,
3440
+ right: Math.max(coords.left, endCoords.left),
3441
+ bottom: Math.max(coords.bottom, endCoords.bottom) + margin};
3442
+ var scrollPos = calculateScrollPos(cm, rect);
3443
  var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
3444
  if (scrollPos.scrollTop != null) {
3445
+ updateScrollTop(cm, scrollPos.scrollTop);
3446
+ if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; }
3447
  }
3448
  if (scrollPos.scrollLeft != null) {
3449
  setScrollLeft(cm, scrollPos.scrollLeft);
3450
+ if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; }
3451
  }
3452
+ if (!changed) { break }
3453
  }
3454
+ return rect
3455
  }
3456
 
3457
  // Scroll a given set of coordinates into view (immediately).
3458
+ function scrollIntoView(cm, rect) {
3459
+ var scrollPos = calculateScrollPos(cm, rect);
3460
+ if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); }
3461
+ if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); }
3462
  }
3463
 
3464
  // Calculate a new scroll position needed to scroll the given
3465
  // rectangle into view. Returns an object with scrollTop and
3466
  // scrollLeft properties. When these are undefined, the
3467
  // vertical/horizontal position does not need to be adjusted.
3468
+ function calculateScrollPos(cm, rect) {
3469
  var display = cm.display, snapMargin = textHeight(cm.display);
3470
+ if (rect.top < 0) { rect.top = 0; }
3471
  var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
3472
+ var screen = displayHeight(cm), result = {};
3473
+ if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; }
3474
  var docBottom = cm.doc.height + paddingVert(display);
3475
+ var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;
3476
+ if (rect.top < screentop) {
3477
+ result.scrollTop = atTop ? 0 : rect.top;
3478
+ } else if (rect.bottom > screentop + screen) {
3479
+ var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);
3480
+ if (newTop != screentop) { result.scrollTop = newTop; }
3481
  }
3482
 
3483
  var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
3484
+ var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
3485
+ var tooWide = rect.right - rect.left > screenw;
3486
+ if (tooWide) { rect.right = rect.left + screenw; }
3487
+ if (rect.left < 10)
3488
+ { result.scrollLeft = 0; }
3489
+ else if (rect.left < screenleft)
3490
+ { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
3491
+ else if (rect.right > screenw + screenleft - 3)
3492
+ { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
3493
+ return result
 
3494
  }
3495
 
3496
  // Store a relative adjustment to the scroll position in the current
3497
  // operation (to be applied when the operation finishes).
3498
+ function addToScrollTop(cm, top) {
3499
+ if (top == null) { return }
3500
+ resolveScrollToPos(cm);
3501
+ cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
 
 
3502
  }
3503
 
3504
  // Make sure that at the end of the operation the current cursor is
3505
  // shown.
3506
  function ensureCursorVisible(cm) {
3507
  resolveScrollToPos(cm);
3508
+ var cur = cm.getCursor();
3509
+ cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin};
3510
+ }
3511
+
3512
+ function scrollToCoords(cm, x, y) {
3513
+ if (x != null || y != null) { resolveScrollToPos(cm); }
3514
+ if (x != null) { cm.curOp.scrollLeft = x; }
3515
+ if (y != null) { cm.curOp.scrollTop = y; }
3516
+ }
3517
+
3518
+ function scrollToRange(cm, range$$1) {
3519
+ resolveScrollToPos(cm);
3520
+ cm.curOp.scrollToPos = range$$1;
3521
  }
3522
 
3523
  // When an operation has its scrollToPos property set, and another
3525
  // 'simulates' scrolling that position into view in a cheap way, so
3526
  // that the effect of intermediate scroll commands is not ignored.
3527
  function resolveScrollToPos(cm) {
3528
+ var range$$1 = cm.curOp.scrollToPos;
3529
+ if (range$$1) {
3530
  cm.curOp.scrollToPos = null;
3531
+ var from = estimateCoords(cm, range$$1.from), to = estimateCoords(cm, range$$1.to);
3532
+ scrollToCoordsRange(cm, from, to, range$$1.margin);
 
 
 
 
3533
  }
3534
  }
3535
 
3536
+ function scrollToCoordsRange(cm, from, to, margin) {
3537
+ var sPos = calculateScrollPos(cm, {
3538
+ left: Math.min(from.left, to.left),
3539
+ top: Math.min(from.top, to.top) - margin,
3540
+ right: Math.max(from.right, to.right),
3541
+ bottom: Math.max(from.bottom, to.bottom) + margin
3542
+ });
3543
+ scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
3544
+ }
3545
 
3546
+ // Sync the scrollable area and scrollbars, ensure the viewport
3547
+ // covers the visible area.
3548
+ function updateScrollTop(cm, val) {
3549
+ if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
3550
+ if (!gecko) { updateDisplaySimple(cm, {top: val}); }
3551
+ setScrollTop(cm, val, true);
3552
+ if (gecko) { updateDisplaySimple(cm); }
3553
+ startWorker(cm, 100);
3554
+ }
 
 
 
 
 
3555
 
3556
+ function setScrollTop(cm, val, forceScroll) {
3557
+ val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
3558
+ if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
3559
+ cm.doc.scrollTop = val;
3560
+ cm.display.scrollbars.setScrollTop(val);
3561
+ if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; }
3562
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3563
 
3564
+ // Sync scroller and scrollbar, ensure the gutter elements are
3565
+ // aligned.
3566
+ function setScrollLeft(cm, val, isScroller, forceScroll) {
3567
+ val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
3568
+ if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
3569
+ cm.doc.scrollLeft = val;
3570
+ alignHorizontally(cm);
3571
+ if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; }
3572
+ cm.display.scrollbars.setScrollLeft(val);
3573
+ }
3574
 
3575
+ // SCROLLBARS
3576
+
3577
+ // Prepare DOM reads needed to update the scrollbars. Done in one
3578
+ // shot to minimize update/measure roundtrips.
3579
+ function measureForScrollbars(cm) {
3580
+ var d = cm.display, gutterW = d.gutters.offsetWidth;
3581
+ var docH = Math.round(cm.doc.height + paddingVert(cm.display));
3582
+ return {
3583
+ clientHeight: d.scroller.clientHeight,
3584
+ viewHeight: d.wrapper.clientHeight,
3585
+ scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
3586
+ viewWidth: d.wrapper.clientWidth,
3587
+ barLeft: cm.options.fixedGutter ? gutterW : 0,
3588
+ docHeight: docH,
3589
+ scrollHeight: docH + scrollGap(cm) + d.barHeight,
3590
+ nativeBarWidth: d.nativeBarWidth,
3591
+ gutterWidth: gutterW
3592
  }
 
3593
  }
3594
 
3595
+ var NativeScrollbars = function(place, scroll, cm) {
3596
+ this.cm = cm;
3597
+ var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
3598
+ var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
3599
+ vert.tabIndex = horiz.tabIndex = -1;
3600
+ place(vert); place(horiz);
 
 
 
 
 
3601
 
3602
+ on(vert, "scroll", function () {
3603
+ if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); }
3604
+ });
3605
+ on(horiz, "scroll", function () {
3606
+ if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3607
  });
 
3608
 
3609
+ this.checkedZeroWidth = false;
3610
+ // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
3611
+ if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; }
3612
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3613
 
3614
+ NativeScrollbars.prototype.update = function (measure) {
3615
+ var needsH = measure.scrollWidth > measure.clientWidth + 1;
3616
+ var needsV = measure.scrollHeight > measure.clientHeight + 1;
3617
+ var sWidth = measure.nativeBarWidth;
 
 
 
 
 
 
 
 
 
 
 
 
 
3618
 
3619
+ if (needsV) {
3620
+ this.vert.style.display = "block";
3621
+ this.vert.style.bottom = needsH ? sWidth + "px" : "0";
3622
+ var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
3623
+ // A bug in IE8 can cause this value to be negative, so guard it.
3624
+ this.vert.firstChild.style.height =
3625
+ Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
3626
+ } else {
3627
+ this.vert.style.display = "";
3628
+ this.vert.firstChild.style.height = "0";
3629
  }
 
 
 
 
3630
 
3631
+ if (needsH) {
3632
+ this.horiz.style.display = "block";
3633
+ this.horiz.style.right = needsV ? sWidth + "px" : "0";
3634
+ this.horiz.style.left = measure.barLeft + "px";
3635
+ var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
3636
+ this.horiz.firstChild.style.width =
3637
+ Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
3638
+ } else {
3639
+ this.horiz.style.display = "";
3640
+ this.horiz.firstChild.style.width = "0";
 
 
 
 
 
 
3641
  }
 
 
3642
 
3643
+ if (!this.checkedZeroWidth && measure.clientHeight > 0) {
3644
+ if (sWidth == 0) { this.zeroWidthHack(); }
3645
+ this.checkedZeroWidth = true;
 
 
 
 
 
 
 
 
 
 
 
3646
  }
 
 
3647
 
3648
+ return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
3649
+ };
3650
 
3651
+ NativeScrollbars.prototype.setScrollLeft = function (pos) {
3652
+ if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; }
3653
+ if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); }
3654
+ };
3655
 
3656
+ NativeScrollbars.prototype.setScrollTop = function (pos) {
3657
+ if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; }
3658
+ if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); }
3659
+ };
3660
 
3661
+ NativeScrollbars.prototype.zeroWidthHack = function () {
3662
+ var w = mac && !mac_geMountainLion ? "12px" : "18px";
3663
+ this.horiz.style.height = this.vert.style.width = w;
3664
+ this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
3665
+ this.disableHoriz = new Delayed;
3666
+ this.disableVert = new Delayed;
3667
+ };
3668
 
3669
+ NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
3670
+ bar.style.pointerEvents = "auto";
3671
+ function maybeDisable() {
3672
+ // To find out whether the scrollbar is still visible, we
3673
+ // check whether the element under the pixel in the bottom
3674
+ // right corner of the scrollbar box is the scrollbar box
3675
+ // itself (when the bar is still visible) or its filler child
3676
+ // (when the bar is hidden). If it is still visible, we keep
3677
+ // it enabled, if it's hidden, we disable pointer events.
3678
+ var box = bar.getBoundingClientRect();
3679
+ var elt$$1 = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
3680
+ : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
3681
+ if (elt$$1 != bar) { bar.style.pointerEvents = "none"; }
3682
+ else { delay.set(1000, maybeDisable); }
3683
+ }
3684
+ delay.set(1000, maybeDisable);
3685
+ };
3686
 
3687
+ NativeScrollbars.prototype.clear = function () {
3688
+ var parent = this.horiz.parentNode;
3689
+ parent.removeChild(this.horiz);
3690
+ parent.removeChild(this.vert);
3691
+ };
3692
 
3693
+ var NullScrollbars = function () {};
 
 
 
 
 
 
 
 
 
 
3694
 
3695
+ NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
3696
+ NullScrollbars.prototype.setScrollLeft = function () {};
3697
+ NullScrollbars.prototype.setScrollTop = function () {};
3698
+ NullScrollbars.prototype.clear = function () {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3699
 
3700
+ function updateScrollbars(cm, measure) {
3701
+ if (!measure) { measure = measureForScrollbars(cm); }
3702
+ var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
3703
+ updateScrollbarsInner(cm, measure);
3704
+ for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
3705
+ if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
3706
+ { updateHeightsInViewport(cm); }
3707
+ updateScrollbarsInner(cm, measureForScrollbars(cm));
3708
+ startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
3709
+ }
3710
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
3711
 
3712
+ // Re-synchronize the fake scrollbars with the actual size of the
3713
+ // content.
3714
+ function updateScrollbarsInner(cm, measure) {
3715
+ var d = cm.display;
3716
+ var sizes = d.scrollbars.update(measure);
 
 
 
 
 
 
 
 
 
 
 
 
 
3717
 
3718
+ d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
3719
+ d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
3720
+ d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
 
 
 
 
 
 
 
 
 
 
 
 
3721
 
3722
+ if (sizes.right && sizes.bottom) {
3723
+ d.scrollbarFiller.style.display = "block";
3724
+ d.scrollbarFiller.style.height = sizes.bottom + "px";
3725
+ d.scrollbarFiller.style.width = sizes.right + "px";
3726
+ } else { d.scrollbarFiller.style.display = ""; }
3727
+ if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
3728
+ d.gutterFiller.style.display = "block";
3729
+ d.gutterFiller.style.height = sizes.bottom + "px";
3730
+ d.gutterFiller.style.width = measure.gutterWidth + "px";
3731
+ } else { d.gutterFiller.style.display = ""; }
3732
+ }
3733
 
3734
+ var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
 
 
3735
 
3736
+ function initScrollbars(cm) {
3737
+ if (cm.display.scrollbars) {
3738
+ cm.display.scrollbars.clear();
3739
+ if (cm.display.scrollbars.addClass)
3740
+ { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
3741
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3742
 
3743
+ cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
3744
+ cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
3745
+ // Prevent clicks in the scrollbars from killing focus
3746
+ on(node, "mousedown", function () {
3747
+ if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); }
3748
+ });
3749
+ node.setAttribute("cm-not-content", "true");
3750
+ }, function (pos, axis) {
3751
+ if (axis == "horizontal") { setScrollLeft(cm, pos); }
3752
+ else { updateScrollTop(cm, pos); }
3753
+ }, cm);
3754
+ if (cm.display.scrollbars.addClass)
3755
+ { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
3756
+ }
3757
 
3758
+ // Operations are used to wrap a series of changes to the editor
3759
+ // state in such a way that each change won't have to update the
3760
+ // cursor and display (which would be awkward, slow, and
3761
+ // error-prone). Instead, display updates are batched and then all
3762
+ // combined and executed at once.
 
 
3763
 
3764
+ var nextOpId = 0;
3765
+ // Start a new operation.
3766
+ function startOperation(cm) {
3767
+ cm.curOp = {
3768
+ cm: cm,
3769
+ viewChanged: false, // Flag that indicates that lines might need to be redrawn
3770
+ startHeight: cm.doc.height, // Used to detect need to update scrollbar
3771
+ forceUpdate: false, // Used to force a redraw
3772
+ updateInput: 0, // Whether to reset the input textarea
3773
+ typing: false, // Whether this reset should be careful to leave existing text (for compositing)
3774
+ changeObjs: null, // Accumulated changes, for firing change events
3775
+ cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
3776
+ cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
3777
+ selectionChanged: false, // Whether the selection needs to be redrawn
3778
+ updateMaxLine: false, // Set when the widest line needs to be determined anew
3779
+ scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
3780
+ scrollToPos: null, // Used to scroll to a specific position
3781
+ focus: false,
3782
+ id: ++nextOpId // Unique ID
3783
+ };
3784
+ pushOperation(cm.curOp);
3785
+ }
3786
 
3787
+ // Finish an operation, updating the display and signalling delayed events
3788
+ function endOperation(cm) {
3789
+ var op = cm.curOp;
3790
+ if (op) { finishOperation(op, function (group) {
3791
+ for (var i = 0; i < group.ops.length; i++)
3792
+ { group.ops[i].cm.curOp = null; }
3793
+ endOperations(group);
3794
+ }); }
3795
+ }
3796
 
3797
+ // The DOM updates done when an operation finishes are batched so
3798
+ // that the minimum number of relayouts are required.
3799
+ function endOperations(group) {
3800
+ var ops = group.ops;
3801
+ for (var i = 0; i < ops.length; i++) // Read DOM
3802
+ { endOperation_R1(ops[i]); }
3803
+ for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
3804
+ { endOperation_W1(ops[i$1]); }
3805
+ for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
3806
+ { endOperation_R2(ops[i$2]); }
3807
+ for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
3808
+ { endOperation_W2(ops[i$3]); }
3809
+ for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
3810
+ { endOperation_finish(ops[i$4]); }
3811
+ }
3812
 
3813
+ function endOperation_R1(op) {
3814
+ var cm = op.cm, display = cm.display;
3815
+ maybeClipScrollbars(cm);
3816
+ if (op.updateMaxLine) { findMaxLine(cm); }
3817
 
3818
+ op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
3819
+ op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
3820
+ op.scrollToPos.to.line >= display.viewTo) ||
3821
+ display.maxLineChanged && cm.options.lineWrapping;
3822
+ op.update = op.mustUpdate &&
3823
+ new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
3824
+ }
 
3825
 
3826
+ function endOperation_W1(op) {
3827
+ op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
3828
+ }
 
 
 
 
 
 
 
 
3829
 
3830
+ function endOperation_R2(op) {
3831
+ var cm = op.cm, display = cm.display;
3832
+ if (op.updatedDisplay) { updateHeightsInViewport(cm); }
3833
 
3834
+ op.barMeasure = measureForScrollbars(cm);
3835
 
3836
+ // If the max line changed since it was last measured, measure it,
3837
+ // and ensure the document's width matches it.
3838
+ // updateDisplay_W2 will use these properties to do the actual resizing
3839
+ if (display.maxLineChanged && !cm.options.lineWrapping) {
3840
+ op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
3841
+ cm.display.sizerWidth = op.adjustWidthTo;
3842
+ op.barMeasure.scrollWidth =
3843
+ Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
3844
+ op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
3845
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3846
 
3847
+ if (op.updatedDisplay || op.selectionChanged)
3848
+ { op.preparedSelection = display.input.prepareSelection(); }
3849
+ }
 
3850
 
3851
+ function endOperation_W2(op) {
3852
+ var cm = op.cm;
 
 
 
 
 
 
 
3853
 
3854
+ if (op.adjustWidthTo != null) {
3855
+ cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
3856
+ if (op.maxScrollLeft < cm.doc.scrollLeft)
3857
+ { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); }
3858
+ cm.display.maxLineChanged = false;
3859
+ }
 
 
 
3860
 
3861
+ var takeFocus = op.focus && op.focus == activeElt();
3862
+ if (op.preparedSelection)
3863
+ { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
3864
+ if (op.updatedDisplay || op.startHeight != cm.doc.height)
3865
+ { updateScrollbars(cm, op.barMeasure); }
3866
+ if (op.updatedDisplay)
3867
+ { setDocumentHeight(cm, op.barMeasure); }
 
 
 
3868
 
3869
+ if (op.selectionChanged) { restartBlink(cm); }
 
 
 
 
 
 
 
 
 
 
 
3870
 
3871
+ if (cm.state.focused && op.updateInput)
3872
+ { cm.display.input.reset(op.typing); }
3873
+ if (takeFocus) { ensureFocus(op.cm); }
3874
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
3875
 
3876
+ function endOperation_finish(op) {
3877
+ var cm = op.cm, display = cm.display, doc = cm.doc;
 
 
 
 
3878
 
3879
+ if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); }
 
 
3880
 
3881
+ // Abort mouse wheel delta measurement, when scrolling explicitly
3882
+ if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
3883
+ { display.wheelStartX = display.wheelStartY = null; }
 
 
 
 
 
 
 
 
3884
 
3885
+ // Propagate the scroll position to the actual DOM scroller
3886
+ if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3887
 
3888
+ if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); }
3889
+ // If we need to scroll a specific position into view, do so.
3890
+ if (op.scrollToPos) {
3891
+ var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
3892
+ clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
3893
+ maybeScrollWindow(cm, rect);
3894
+ }
 
 
 
 
 
 
 
 
 
 
3895
 
3896
+ // Fire events for markers that are hidden/unidden by editing or
3897
+ // undoing
3898
+ var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
3899
+ if (hidden) { for (var i = 0; i < hidden.length; ++i)
3900
+ { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } }
3901
+ if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
3902
+ { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } }
 
 
 
 
 
 
3903
 
3904
+ if (display.wrapper.offsetHeight)
3905
+ { doc.scrollTop = cm.display.scroller.scrollTop; }
 
 
 
 
 
 
 
 
3906
 
3907
+ // Fire change events, and delayed event handlers
3908
+ if (op.changeObjs)
3909
+ { signal(cm, "changes", cm, op.changeObjs); }
3910
+ if (op.update)
3911
+ { op.update.finish(); }
3912
+ }
3913
 
3914
+ // Run the given function in an operation
3915
+ function runInOp(cm, f) {
3916
+ if (cm.curOp) { return f() }
3917
+ startOperation(cm);
3918
+ try { return f() }
3919
+ finally { endOperation(cm); }
3920
+ }
3921
+ // Wraps a function in an operation. Returns the wrapped function.
3922
+ function operation(cm, f) {
3923
+ return function() {
3924
+ if (cm.curOp) { return f.apply(cm, arguments) }
3925
+ startOperation(cm);
3926
+ try { return f.apply(cm, arguments) }
3927
+ finally { endOperation(cm); }
3928
+ }
3929
+ }
3930
+ // Used to add methods to editor and doc instances, wrapping them in
3931
+ // operations.
3932
+ function methodOp(f) {
3933
+ return function() {
3934
+ if (this.curOp) { return f.apply(this, arguments) }
3935
+ startOperation(this);
3936
+ try { return f.apply(this, arguments) }
3937
+ finally { endOperation(this); }
3938
+ }
3939
+ }
3940
+ function docMethodOp(f) {
3941
+ return function() {
3942
+ var cm = this.cm;
3943
+ if (!cm || cm.curOp) { return f.apply(this, arguments) }
3944
+ startOperation(cm);
3945
+ try { return f.apply(this, arguments) }
3946
+ finally { endOperation(cm); }
3947
+ }
3948
+ }
3949
 
3950
+ // HIGHLIGHT WORKER
 
 
 
3951
 
3952
+ function startWorker(cm, time) {
3953
+ if (cm.doc.highlightFrontier < cm.display.viewTo)
3954
+ { cm.state.highlight.set(time, bind(highlightWorker, cm)); }
 
3955
  }
3956
 
3957
+ function highlightWorker(cm) {
3958
+ var doc = cm.doc;
3959
+ if (doc.highlightFrontier >= cm.display.viewTo) { return }
3960
+ var end = +new Date + cm.options.workTime;
3961
+ var context = getContextBefore(cm, doc.highlightFrontier);
3962
+ var changedLines = [];
 
 
 
 
 
 
3963
 
3964
+ doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
3965
+ if (context.line >= cm.display.viewFrom) { // Visible
3966
+ var oldStyles = line.styles;
3967
+ var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;
3968
+ var highlighted = highlightLine(cm, line, context, true);
3969
+ if (resetState) { context.state = resetState; }
3970
+ line.styles = highlighted.styles;
3971
+ var oldCls = line.styleClasses, newCls = highlighted.classes;
3972
+ if (newCls) { line.styleClasses = newCls; }
3973
+ else if (oldCls) { line.styleClasses = null; }
3974
+ var ischange = !oldStyles || oldStyles.length != line.styles.length ||
3975
+ oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
3976
+ for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; }
3977
+ if (ischange) { changedLines.push(context.line); }
3978
+ line.stateAfter = context.save();
3979
+ context.nextLine();
3980
+ } else {
3981
+ if (line.text.length <= cm.options.maxHighlightLength)
3982
+ { processLine(cm, line.text, context); }
3983
+ line.stateAfter = context.line % 5 == 0 ? context.save() : null;
3984
+ context.nextLine();
3985
+ }
3986
+ if (+new Date > end) {
3987
+ startWorker(cm, cm.options.workDelay);
3988
+ return true
3989
+ }
3990
+ });
3991
+ doc.highlightFrontier = context.line;
3992
+ doc.modeFrontier = Math.max(doc.modeFrontier, context.line);
3993
+ if (changedLines.length) { runInOp(cm, function () {
3994
+ for (var i = 0; i < changedLines.length; i++)
3995
+ { regLineChange(cm, changedLines[i], "text"); }
3996
+ }); }
3997
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3998
 
3999
+ // DISPLAY DRAWING
 
 
 
4000
 
4001
+ var DisplayUpdate = function(cm, viewport, force) {
4002
+ var display = cm.display;
4003
 
4004
+ this.viewport = viewport;
4005
+ // Store some values that we'll need later (but don't want to force a relayout for)
4006
+ this.visible = visibleLines(display, cm.doc, viewport);
4007
+ this.editorIsHidden = !display.wrapper.offsetWidth;
4008
+ this.wrapperHeight = display.wrapper.clientHeight;
4009
+ this.wrapperWidth = display.wrapper.clientWidth;
4010
+ this.oldDisplayWidth = displayWidth(cm);
4011
+ this.force = force;
4012
+ this.dims = getDimensions(cm);
4013
+ this.events = [];
4014
+ };
4015
 
4016
+ DisplayUpdate.prototype.signal = function (emitter, type) {
4017
+ if (hasHandler(emitter, type))
4018
+ { this.events.push(arguments); }
 
 
 
 
 
 
 
4019
  };
4020
+ DisplayUpdate.prototype.finish = function () {
4021
+ var this$1 = this;
4022
 
4023
+ for (var i = 0; i < this.events.length; i++)
4024
+ { signal.apply(null, this$1.events[i]); }
4025
  };
4026
 
4027
+ function maybeClipScrollbars(cm) {
4028
+ var display = cm.display;
4029
+ if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
4030
+ display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
4031
+ display.heightForcer.style.height = scrollGap(cm) + "px";
4032
+ display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
4033
+ display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
4034
+ display.scrollbarsClipped = true;
 
 
 
 
4035
  }
4036
+ }
 
 
4037
 
4038
+ function selectionSnapshot(cm) {
4039
+ if (cm.hasFocus()) { return null }
4040
+ var active = activeElt();
4041
+ if (!active || !contains(cm.display.lineDiv, active)) { return null }
4042
+ var result = {activeElt: active};
4043
+ if (window.getSelection) {
4044
+ var sel = window.getSelection();
4045
+ if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
4046
+ result.anchorNode = sel.anchorNode;
4047
+ result.anchorOffset = sel.anchorOffset;
4048
+ result.focusNode = sel.focusNode;
4049
+ result.focusOffset = sel.focusOffset;
 
4050
  }
4051
  }
4052
+ return result
4053
+ }
 
 
4054
 
4055
+ function restoreSelection(snapshot) {
4056
+ if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
4057
+ snapshot.activeElt.focus();
4058
+ if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
4059
+ var sel = window.getSelection(), range$$1 = document.createRange();
4060
+ range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
4061
+ range$$1.collapse(false);
4062
+ sel.removeAllRanges();
4063
+ sel.addRange(range$$1);
4064
+ sel.extend(snapshot.focusNode, snapshot.focusOffset);
4065
+ }
4066
+ }
4067
 
4068
+ // Does the actual updating of the line display. Bails out
4069
+ // (returning false) when there is nothing to be done and forced is
4070
+ // false.
4071
+ function updateDisplayIfNeeded(cm, update) {
4072
+ var display = cm.display, doc = cm.doc;
4073
 
4074
+ if (update.editorIsHidden) {
4075
+ resetView(cm);
4076
+ return false
4077
+ }
 
 
 
4078
 
4079
+ // Bail out if the visible area is already rendered and nothing changed.
4080
+ if (!update.force &&
4081
+ update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
4082
+ (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
4083
+ display.renderedView == display.view && countDirtyView(cm) == 0)
4084
+ { return false }
4085
 
4086
+ if (maybeUpdateLineNumberWidth(cm)) {
4087
+ resetView(cm);
4088
+ update.dims = getDimensions(cm);
4089
+ }
 
 
 
4090
 
4091
+ // Compute a suitable new viewport (from & to)
4092
+ var end = doc.first + doc.size;
4093
+ var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
4094
+ var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
4095
+ if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); }
4096
+ if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); }
4097
+ if (sawCollapsedSpans) {
4098
+ from = visualLineNo(cm.doc, from);
4099
+ to = visualLineEndNo(cm.doc, to);
4100
+ }
4101
 
4102
+ var different = from != display.viewFrom || to != display.viewTo ||
4103
+ display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
4104
+ adjustView(cm, from, to);
4105
+
4106
+ display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
4107
+ // Position the mover div to align with the current scroll position
4108
+ cm.display.mover.style.top = display.viewOffset + "px";
 
 
4109
 
4110
+ var toUpdate = countDirtyView(cm);
4111
+ if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
4112
+ (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
4113
+ { return false }
4114
 
4115
+ // For big changes, we hide the enclosing element during the
4116
+ // update, since that speeds up the operations on most browsers.
4117
+ var selSnapshot = selectionSnapshot(cm);
4118
+ if (toUpdate > 4) { display.lineDiv.style.display = "none"; }
4119
+ patchDisplay(cm, display.updateLineNumbers, update.dims);
4120
+ if (toUpdate > 4) { display.lineDiv.style.display = ""; }
4121
+ display.renderedView = display.view;
4122
+ // There might have been a widget with a focused element that got
4123
+ // hidden or updated, if so re-focus it.
4124
+ restoreSelection(selSnapshot);
4125
 
4126
+ // Prevent selection and cursors from interfering with the scroll
4127
+ // width and height.
4128
+ removeChildren(display.cursorDiv);
4129
+ removeChildren(display.selectionDiv);
4130
+ display.gutters.style.height = display.sizer.style.minHeight = 0;
4131
+
4132
+ if (different) {
4133
+ display.lastWrapHeight = update.wrapperHeight;
4134
+ display.lastWrapWidth = update.wrapperWidth;
4135
+ startWorker(cm, 400);
4136
  }
 
 
4137
 
4138
+ display.updateLineNumbers = null;
 
 
4139
 
4140
+ return true
4141
+ }
4142
+
4143
+ function postUpdateDisplay(cm, update) {
4144
+ var viewport = update.viewport;
4145
+
4146
+ for (var first = true;; first = false) {
4147
+ if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
4148
+ // Clip forced viewport to actual scrollable area.
4149
+ if (viewport && viewport.top != null)
4150
+ { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; }
4151
+ // Updated line heights might result in the drawn area not
4152
+ // actually covering the viewport. Keep looping until it does.
4153
+ update.visible = visibleLines(cm.display, cm.doc, viewport);
4154
+ if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
4155
+ { break }
4156
+ }
4157
+ if (!updateDisplayIfNeeded(cm, update)) { break }
4158
+ updateHeightsInViewport(cm);
4159
+ var barMeasure = measureForScrollbars(cm);
4160
+ updateSelection(cm);
4161
+ updateScrollbars(cm, barMeasure);
4162
+ setDocumentHeight(cm, barMeasure);
4163
+ update.force = false;
4164
  }
 
 
4165
 
4166
+ update.signal(cm, "update", cm);
4167
+ if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
4168
+ update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
4169
+ cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
4170
+ }
4171
+ }
4172
 
4173
+ function updateDisplaySimple(cm, viewport) {
4174
+ var update = new DisplayUpdate(cm, viewport);
4175
+ if (updateDisplayIfNeeded(cm, update)) {
4176
+ updateHeightsInViewport(cm);
4177
+ postUpdateDisplay(cm, update);
4178
+ var barMeasure = measureForScrollbars(cm);
4179
+ updateSelection(cm);
4180
+ updateScrollbars(cm, barMeasure);
4181
+ setDocumentHeight(cm, barMeasure);
4182
+ update.finish();
4183
+ }
4184
+ }
4185
+
4186
+ // Sync the actual display DOM structure with display.view, removing
4187
+ // nodes for lines that are no longer in view, and creating the ones
4188
+ // that are not there yet, and updating the ones that are out of
4189
+ // date.
4190
+ function patchDisplay(cm, updateNumbersFrom, dims) {
4191
+ var display = cm.display, lineNumbers = cm.options.lineNumbers;
4192
+ var container = display.lineDiv, cur = container.firstChild;
4193
+
4194
+ function rm(node) {
4195
+ var next = node.nextSibling;
4196
+ // Works around a throw-scroll bug in OS X Webkit
4197
+ if (webkit && mac && cm.display.currentWheelTarget == node)
4198
+ { node.style.display = "none"; }
4199
+ else
4200
+ { node.parentNode.removeChild(node); }
4201
+ return next
4202
+ }
4203
+
4204
+ var view = display.view, lineN = display.viewFrom;
4205
+ // Loop over the elements in the view, syncing cur (the DOM nodes
4206
+ // in display.lineDiv) with the view as we go.
4207
+ for (var i = 0; i < view.length; i++) {
4208
+ var lineView = view[i];
4209
+ if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
4210
+ var node = buildLineElement(cm, lineView, lineN, dims);
4211
+ container.insertBefore(node, cur);
4212
+ } else { // Already drawn
4213
+ while (cur != lineView.node) { cur = rm(cur); }
4214
+ var updateNumber = lineNumbers && updateNumbersFrom != null &&
4215
+ updateNumbersFrom <= lineN && lineView.lineNumber;
4216
+ if (lineView.changes) {
4217
+ if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
4218
+ updateLineForChanges(cm, lineView, lineN, dims);
4219
  }
4220
+ if (updateNumber) {
4221
+ removeChildren(lineView.lineNumber);
4222
+ lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4223
  }
4224
+ cur = lineView.node.nextSibling;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4225
  }
4226
+ lineN += lineView.size;
4227
+ }
4228
+ while (cur) { cur = rm(cur); }
4229
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4230
 
4231
+ function updateGutterSpace(display) {
4232
+ var width = display.gutters.offsetWidth;
4233
+ display.sizer.style.marginLeft = width + "px";
4234
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4235
 
4236
+ function setDocumentHeight(cm, measure) {
4237
+ cm.display.sizer.style.minHeight = measure.docHeight + "px";
4238
+ cm.display.heightForcer.style.top = measure.docHeight + "px";
4239
+ cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
4240
+ }
4241
 
4242
+ // Re-align line numbers and gutter marks to compensate for
4243
+ // horizontal scrolling.
4244
+ function alignHorizontally(cm) {
4245
+ var display = cm.display, view = display.view;
4246
+ if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
4247
+ var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
4248
+ var gutterW = display.gutters.offsetWidth, left = comp + "px";
4249
+ for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
4250
+ if (cm.options.fixedGutter) {
4251
+ if (view[i].gutter)
4252
+ { view[i].gutter.style.left = left; }
4253
+ if (view[i].gutterBackground)
4254
+ { view[i].gutterBackground.style.left = left; }
4255
+ }
4256
+ var align = view[i].alignable;
4257
+ if (align) { for (var j = 0; j < align.length; j++)
4258
+ { align[j].style.left = left; } }
4259
+ } }
4260
+ if (cm.options.fixedGutter)
4261
+ { display.gutters.style.left = (comp + gutterW) + "px"; }
4262
  }
4263
 
4264
+ // Used to ensure that the line number gutter is still the right
4265
+ // size for the current document size. Returns true when an update
4266
+ // is needed.
4267
+ function maybeUpdateLineNumberWidth(cm) {
4268
+ if (!cm.options.lineNumbers) { return false }
4269
+ var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
4270
+ if (last.length != display.lineNumChars) {
4271
+ var test = display.measure.appendChild(elt("div", [elt("div", last)],
4272
+ "CodeMirror-linenumber CodeMirror-gutter-elt"));
4273
+ var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
4274
+ display.lineGutter.style.width = "";
4275
+ display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
4276
+ display.lineNumWidth = display.lineNumInnerWidth + padding;
4277
+ display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
4278
+ display.lineGutter.style.width = display.lineNumWidth + "px";
4279
+ updateGutterSpace(cm.display);
4280
+ return true
4281
+ }
4282
+ return false
4283
+ }
4284
 
4285
+ function getGutters(gutters, lineNumbers) {
4286
+ var result = [], sawLineNumbers = false;
4287
+ for (var i = 0; i < gutters.length; i++) {
4288
+ var name = gutters[i], style = null;
4289
+ if (typeof name != "string") { style = name.style; name = name.className; }
4290
+ if (name == "CodeMirror-linenumbers") {
4291
+ if (!lineNumbers) { continue }
4292
+ else { sawLineNumbers = true; }
4293
  }
4294
+ result.push({className: name, style: style});
4295
  }
4296
+ if (lineNumbers && !sawLineNumbers) { result.push({className: "CodeMirror-linenumbers", style: null}); }
4297
+ return result
4298
+ }
4299
 
4300
+ // Rebuild the gutter elements, ensure the margin to the left of the
4301
+ // code matches their width.
4302
+ function renderGutters(display) {
4303
+ var gutters = display.gutters, specs = display.gutterSpecs;
4304
+ removeChildren(gutters);
4305
+ display.lineGutter = null;
4306
+ for (var i = 0; i < specs.length; ++i) {
4307
+ var ref = specs[i];
4308
+ var className = ref.className;
4309
+ var style = ref.style;
4310
+ var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className));
4311
+ if (style) { gElt.style.cssText = style; }
4312
+ if (className == "CodeMirror-linenumbers") {
4313
+ display.lineGutter = gElt;
4314
+ gElt.style.width = (display.lineNumWidth || 1) + "px";
4315
+ }
4316
  }
4317
+ gutters.style.display = specs.length ? "" : "none";
4318
+ updateGutterSpace(display);
4319
+ }
4320
 
4321
+ function updateGutters(cm) {
4322
+ renderGutters(cm.display);
4323
+ regChange(cm);
4324
+ alignHorizontally(cm);
4325
+ }
 
4326
 
4327
+ // The display handles the DOM integration, both for input reading
4328
+ // and content drawing. It holds references to DOM nodes and
4329
+ // display-related state.
 
 
 
 
 
 
 
 
4330
 
4331
+ function Display(place, doc, input, options) {
4332
+ var d = this;
4333
+ this.input = input;
4334
 
4335
+ // Covers bottom-right square when both scrollbars are present.
4336
+ d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
4337
+ d.scrollbarFiller.setAttribute("cm-not-content", "true");
4338
+ // Covers bottom of gutter when coverGutterNextToScrollbar is on
4339
+ // and h scrollbar is present.
4340
+ d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
4341
+ d.gutterFiller.setAttribute("cm-not-content", "true");
4342
+ // Will contain the actual code, positioned to cover the viewport.
4343
+ d.lineDiv = eltP("div", null, "CodeMirror-code");
4344
+ // Elements are added to these to represent selection and cursors.
4345
+ d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
4346
+ d.cursorDiv = elt("div", null, "CodeMirror-cursors");
4347
+ // A visibility: hidden element used to find the size of things.
4348
+ d.measure = elt("div", null, "CodeMirror-measure");
4349
+ // When lines outside of the viewport are measured, they are drawn in this.
4350
+ d.lineMeasure = elt("div", null, "CodeMirror-measure");
4351
+ // Wraps everything that needs to exist inside the vertically-padded coordinate system
4352
+ d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
4353
+ null, "position: relative; outline: none");
4354
+ var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
4355
+ // Moved around its parent to cover visible view.
4356
+ d.mover = elt("div", [lines], null, "position: relative");
4357
+ // Set to the height of the document, allowing scrolling.
4358
+ d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
4359
+ d.sizerWidth = null;
4360
+ // Behavior of elts with overflow: auto and padding is
4361
+ // inconsistent across browsers. This is used to ensure the
4362
+ // scrollable area is big enough.
4363
+ d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
4364
+ // Will contain the gutters, if any.
4365
+ d.gutters = elt("div", null, "CodeMirror-gutters");
4366
+ d.lineGutter = null;
4367
+ // Actual scrollable element.
4368
+ d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
4369
+ d.scroller.setAttribute("tabIndex", "-1");
4370
+ // The element in which the editor lives.
4371
+ d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
4372
 
4373
+ // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
4374
+ if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
4375
+ if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
4376
+
4377
+ if (place) {
4378
+ if (place.appendChild) { place.appendChild(d.wrapper); }
4379
+ else { place(d.wrapper); }
 
 
 
 
 
 
 
 
4380
  }
4381
 
4382
+ // Current rendered range (may be bigger than the view window).
4383
+ d.viewFrom = d.viewTo = doc.first;
4384
+ d.reportedViewFrom = d.reportedViewTo = doc.first;
4385
+ // Information about the rendered lines.
4386
+ d.view = [];
4387
+ d.renderedView = null;
4388
+ // Holds info about a single rendered line when it was rendered
4389
+ // for measurement, while not in view.
4390
+ d.externalMeasured = null;
4391
+ // Empty space (in pixels) above the view
4392
+ d.viewOffset = 0;
4393
+ d.lastWrapHeight = d.lastWrapWidth = 0;
4394
+ d.updateLineNumbers = null;
 
 
 
 
 
4395
 
4396
+ d.nativeBarWidth = d.barHeight = d.barWidth = 0;
4397
+ d.scrollbarsClipped = false;
4398
 
4399
+ // Used to only resize the line number gutter when necessary (when
4400
+ // the amount of lines crosses a boundary that makes its width change)
4401
+ d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
4402
+ // Set to true when a non-horizontal-scrolling line widget is
4403
+ // added. As an optimization, line widget aligning is skipped when
4404
+ // this is false.
4405
+ d.alignWidgets = false;
4406
 
4407
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
 
 
 
 
 
 
4408
 
4409
+ // Tracks the maximum line length so that the horizontal scrollbar
4410
+ // can be kept static when scrolling.
4411
+ d.maxLine = null;
4412
+ d.maxLineLength = 0;
4413
+ d.maxLineChanged = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4414
 
4415
+ // Used for measuring wheel scrolling granularity
4416
+ d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
4417
 
4418
+ // True when shift is held down.
4419
+ d.shift = false;
 
 
 
 
 
 
 
4420
 
4421
+ // Used to track whether anything happened since the context menu
4422
+ // was opened.
4423
+ d.selForContextMenu = null;
 
 
 
4424
 
4425
+ d.activeTouch = null;
4426
+
4427
+ d.gutterSpecs = getGutters(options.gutters, options.lineNumbers);
4428
+ renderGutters(d);
4429
+
4430
+ input.init(d);
4431
+ }
4432
+
4433
+ // Since the delta values reported on mouse wheel events are
4434
+ // unstandardized between browsers and even browser versions, and
4435
+ // generally horribly unpredictable, this code starts by measuring
4436
+ // the scroll effect that the first few mouse wheel events have,
4437
+ // and, from that, detects the way it can convert deltas to pixel
4438
+ // offsets afterwards.
4439
+ //
4440
+ // The reason we want to know the amount a wheel event will scroll
4441
+ // is that it gives us a chance to update the display before the
4442
+ // actual scrolling happens, reducing flickering.
4443
+
4444
+ var wheelSamples = 0, wheelPixelsPerUnit = null;
4445
+ // Fill in a browser-detected starting value on browsers where we
4446
+ // know one. These don't have to be accurate -- the result of them
4447
+ // being wrong would just be a slight flicker on the first wheel
4448
+ // scroll (if it is large enough).
4449
+ if (ie) { wheelPixelsPerUnit = -.53; }
4450
+ else if (gecko) { wheelPixelsPerUnit = 15; }
4451
+ else if (chrome) { wheelPixelsPerUnit = -.7; }
4452
+ else if (safari) { wheelPixelsPerUnit = -1/3; }
4453
+
4454
+ function wheelEventDelta(e) {
4455
+ var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
4456
+ if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; }
4457
+ if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; }
4458
+ else if (dy == null) { dy = e.wheelDelta; }
4459
+ return {x: dx, y: dy}
4460
+ }
4461
+ function wheelEventPixels(e) {
4462
+ var delta = wheelEventDelta(e);
4463
+ delta.x *= wheelPixelsPerUnit;
4464
+ delta.y *= wheelPixelsPerUnit;
4465
+ return delta
4466
+ }
4467
+
4468
+ function onScrollWheel(cm, e) {
4469
+ var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
4470
+
4471
+ var display = cm.display, scroll = display.scroller;
4472
+ // Quit if there's nothing to scroll here
4473
+ var canScrollX = scroll.scrollWidth > scroll.clientWidth;
4474
+ var canScrollY = scroll.scrollHeight > scroll.clientHeight;
4475
+ if (!(dx && canScrollX || dy && canScrollY)) { return }
4476
+
4477
+ // Webkit browsers on OS X abort momentum scrolls when the target
4478
+ // of the scroll event is removed from the scrollable element.
4479
+ // This hack (see related code in patchDisplay) makes sure the
4480
+ // element is kept around.
4481
+ if (dy && mac && webkit) {
4482
+ outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
4483
+ for (var i = 0; i < view.length; i++) {
4484
+ if (view[i].node == cur) {
4485
+ cm.display.currentWheelTarget = cur;
4486
+ break outer
4487
+ }
4488
+ }
4489
  }
 
 
 
4490
  }
4491
+
4492
+ // On some browsers, horizontal scrolling will cause redraws to
4493
+ // happen before the gutter has been realigned, causing it to
4494
+ // wriggle around in a most unseemly way. When we have an
4495
+ // estimated pixels/delta value, we just handle horizontal
4496
+ // scrolling entirely here. It'll be slightly off from native, but
4497
+ // better than glitching out.
4498
+ if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
4499
+ if (dy && canScrollY)
4500
+ { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
4501
+ setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
4502
+ // Only prevent default scrolling if vertical scrolling is
4503
+ // actually possible. Otherwise, it causes vertical scroll
4504
+ // jitter on OSX trackpads when deltaX is small and deltaY
4505
+ // is large (issue #3579)
4506
+ if (!dy || (dy && canScrollY))
4507
+ { e_preventDefault(e); }
4508
+ display.wheelStartX = null; // Abort measurement, if in progress
4509
+ return
4510
  }
4511
 
4512
+ // 'Project' the visible viewport to cover the area that is being
4513
+ // scrolled into view (if we know enough to estimate it).
4514
+ if (dy && wheelPixelsPerUnit != null) {
4515
+ var pixels = dy * wheelPixelsPerUnit;
4516
+ var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
4517
+ if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
4518
+ else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
4519
+ updateDisplaySimple(cm, {top: top, bottom: bot});
4520
  }
 
 
 
 
4521
 
4522
+ if (wheelSamples < 20) {
4523
+ if (display.wheelStartX == null) {
4524
+ display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
4525
+ display.wheelDX = dx; display.wheelDY = dy;
4526
+ setTimeout(function () {
4527
+ if (display.wheelStartX == null) { return }
4528
+ var movedX = scroll.scrollLeft - display.wheelStartX;
4529
+ var movedY = scroll.scrollTop - display.wheelStartY;
4530
+ var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
4531
+ (movedX && display.wheelDX && movedX / display.wheelDX);
4532
+ display.wheelStartX = display.wheelStartY = null;
4533
+ if (!sample) { return }
4534
+ wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
4535
+ ++wheelSamples;
4536
+ }, 200);
4537
+ } else {
4538
+ display.wheelDX += dx; display.wheelDY += dy;
 
4539
  }
4540
  }
4541
+ }
 
4542
 
4543
+ // Selection objects are immutable. A new one is created every time
4544
+ // the selection changes. A selection is one or more non-overlapping
4545
+ // (and non-touching) ranges, sorted, and an integer that indicates
4546
+ // which one is the primary selection (the one that's scrolled into
4547
+ // view, that getCursor returns, etc).
4548
+ var Selection = function(ranges, primIndex) {
4549
+ this.ranges = ranges;
4550
+ this.primIndex = primIndex;
 
 
 
 
 
 
 
 
 
 
 
 
 
4551
  };
4552
 
4553
+ Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
4554
+
4555
+ Selection.prototype.equals = function (other) {
4556
+ var this$1 = this;
4557
+
4558
+ if (other == this) { return true }
4559
+ if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
4560
+ for (var i = 0; i < this.ranges.length; i++) {
4561
+ var here = this$1.ranges[i], there = other.ranges[i];
4562
+ if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
4563
  }
4564
+ return true
4565
  };
4566
+
4567
+ Selection.prototype.deepCopy = function () {
4568
+ var this$1 = this;
4569
+
4570
+ var out = [];
4571
+ for (var i = 0; i < this.ranges.length; i++)
4572
+ { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)); }
4573
+ return new Selection(out, this.primIndex)
4574
  };
4575
 
4576
+ Selection.prototype.somethingSelected = function () {
4577
+ var this$1 = this;
 
 
4578
 
4579
+ for (var i = 0; i < this.ranges.length; i++)
4580
+ { if (!this$1.ranges[i].empty()) { return true } }
4581
+ return false
4582
+ };
 
 
 
 
4583
 
4584
+ Selection.prototype.contains = function (pos, end) {
4585
+ var this$1 = this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4586
 
4587
+ if (!end) { end = pos; }
4588
+ for (var i = 0; i < this.ranges.length; i++) {
4589
+ var range = this$1.ranges[i];
4590
+ if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
4591
+ { return i }
4592
+ }
4593
+ return -1
4594
+ };
4595
 
4596
+ var Range = function(anchor, head) {
4597
+ this.anchor = anchor; this.head = head;
4598
+ };
 
 
 
 
 
 
 
 
 
 
 
4599
 
4600
+ Range.prototype.from = function () { return minPos(this.anchor, this.head) };
4601
+ Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
4602
+ Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
4603
 
4604
+ // Take an unsorted, potentially overlapping set of ranges, and
4605
+ // build a selection out of it. 'Consumes' ranges array (modifying
4606
+ // it).
4607
+ function normalizeSelection(cm, ranges, primIndex) {
4608
+ var mayTouch = cm && cm.options.selectionsMayTouch;
4609
+ var prim = ranges[primIndex];
4610
+ ranges.sort(function (a, b) { return cmp(a.from(), b.from()); });
4611
+ primIndex = indexOf(ranges, prim);
4612
+ for (var i = 1; i < ranges.length; i++) {
4613
+ var cur = ranges[i], prev = ranges[i - 1];
4614
+ var diff = cmp(prev.to(), cur.from());
4615
+ if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) {
4616
+ var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
4617
+ var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
4618
+ if (i <= primIndex) { --primIndex; }
4619
+ ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
4620
+ }
 
4621
  }
4622
+ return new Selection(ranges, primIndex)
4623
  }
4624
 
4625
+ function simpleSelection(anchor, head) {
4626
+ return new Selection([new Range(anchor, head || anchor)], 0)
4627
+ }
4628
 
4629
+ // Compute the position of the end of a change (its 'to' property
4630
+ // refers to the pre-change end).
4631
+ function changeEnd(change) {
4632
+ if (!change.text) { return change.to }
4633
+ return Pos(change.from.line + change.text.length - 1,
4634
+ lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
4635
+ }
 
 
 
4636
 
4637
+ // Adjust a position to refer to the post-change position of the
4638
+ // same text, or the end of the change if the change covers it.
4639
+ function adjustForChange(pos, change) {
4640
+ if (cmp(pos, change.from) < 0) { return pos }
4641
+ if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
 
 
 
 
 
4642
 
4643
+ var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
4644
+ if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }
4645
+ return Pos(line, ch)
 
 
 
 
 
 
 
 
 
 
4646
  }
4647
 
4648
+ function computeSelAfterChange(doc, change) {
4649
+ var out = [];
4650
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
4651
+ var range = doc.sel.ranges[i];
4652
+ out.push(new Range(adjustForChange(range.anchor, change),
4653
+ adjustForChange(range.head, change)));
4654
+ }
4655
+ return normalizeSelection(doc.cm, out, doc.sel.primIndex)
4656
  }
4657
 
4658
+ function offsetPos(pos, old, nw) {
4659
+ if (pos.line == old.line)
4660
+ { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
4661
+ else
4662
+ { return Pos(nw.line + (pos.line - old.line), pos.ch) }
 
 
 
 
 
4663
  }
4664
 
4665
+ // Used by replaceSelections to allow moving the selection to the
4666
+ // start or around the replaced test. Hint may be "start" or "around".
4667
+ function computeReplacedSel(doc, changes, hint) {
4668
+ var out = [];
4669
+ var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
4670
+ for (var i = 0; i < changes.length; i++) {
4671
+ var change = changes[i];
4672
+ var from = offsetPos(change.from, oldPrev, newPrev);
4673
+ var to = offsetPos(changeEnd(change), oldPrev, newPrev);
4674
+ oldPrev = change.to;
4675
+ newPrev = to;
4676
+ if (hint == "around") {
4677
+ var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
4678
+ out[i] = new Range(inv ? to : from, inv ? from : to);
4679
+ } else {
4680
+ out[i] = new Range(from, from);
4681
  }
4682
  }
4683
+ return new Selection(out, doc.sel.primIndex)
4684
  }
4685
 
4686
+ // Used to get the editor into a consistent state again when options change.
4687
 
4688
+ function loadMode(cm) {
4689
+ cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
4690
+ resetModeState(cm);
4691
  }
4692
 
4693
+ function resetModeState(cm) {
4694
+ cm.doc.iter(function (line) {
4695
+ if (line.stateAfter) { line.stateAfter = null; }
4696
+ if (line.styles) { line.styles = null; }
4697
+ });
4698
+ cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
4699
+ startWorker(cm, 100);
4700
+ cm.state.modeGen++;
4701
+ if (cm.curOp) { regChange(cm); }
 
 
 
 
4702
  }
4703
+
4704
+ // DOCUMENT DATA STRUCTURE
4705
+
4706
+ // By default, updates that start and end at the beginning of a line
4707
+ // are treated specially, in order to make the association of line
4708
+ // widgets and marker elements with the text behave more intuitive.
4709
+ function isWholeLineUpdate(doc, change) {
4710
+ return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
4711
+ (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
4712
  }
4713
 
4714
+ // Perform a change on the document data structure.
4715
+ function updateDoc(doc, change, markedSpans, estimateHeight$$1) {
4716
+ function spansFor(n) {return markedSpans ? markedSpans[n] : null}
4717
+ function update(line, text, spans) {
4718
+ updateLine(line, text, spans, estimateHeight$$1);
4719
+ signalLater(line, "change", line, change);
 
 
 
 
 
 
4720
  }
4721
+ function linesFor(start, end) {
4722
+ var result = [];
4723
+ for (var i = start; i < end; ++i)
4724
+ { result.push(new Line(text[i], spansFor(i), estimateHeight$$1)); }
4725
+ return result
 
 
 
 
 
 
4726
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
4727
 
4728
+ var from = change.from, to = change.to, text = change.text;
4729
+ var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
4730
+ var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
 
4731
 
4732
+ // Adjust the line structure
4733
+ if (change.full) {
4734
+ doc.insert(0, linesFor(0, text.length));
4735
+ doc.remove(text.length, doc.size - text.length);
4736
+ } else if (isWholeLineUpdate(doc, change)) {
4737
+ // This is a whole-line replace. Treated specially to make
4738
+ // sure line objects move the way they are supposed to.
4739
+ var added = linesFor(0, text.length - 1);
4740
+ update(lastLine, lastLine.text, lastSpans);
4741
+ if (nlines) { doc.remove(from.line, nlines); }
4742
+ if (added.length) { doc.insert(from.line, added); }
4743
+ } else if (firstLine == lastLine) {
4744
+ if (text.length == 1) {
4745
+ update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
4746
+ } else {
4747
+ var added$1 = linesFor(1, text.length - 1);
4748
+ added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$$1));
4749
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
4750
+ doc.insert(from.line + 1, added$1);
 
 
 
 
 
 
 
 
 
4751
  }
4752
+ } else if (text.length == 1) {
4753
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
4754
+ doc.remove(from.line + 1, nlines);
4755
+ } else {
4756
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
4757
+ update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
4758
+ var added$2 = linesFor(1, text.length - 1);
4759
+ if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); }
4760
+ doc.insert(from.line + 1, added$2);
4761
  }
 
 
 
4762
 
4763
+ signalLater(doc, "change", doc, change);
 
 
 
 
 
 
 
 
 
 
 
 
4764
  }
4765
 
4766
+ // Call f for all linked documents.
4767
+ function linkedDocs(doc, f, sharedHistOnly) {
4768
+ function propagate(doc, skip, sharedHist) {
4769
+ if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
4770
+ var rel = doc.linked[i];
4771
+ if (rel.doc == skip) { continue }
4772
+ var shared = sharedHist && rel.sharedHist;
4773
+ if (sharedHistOnly && !shared) { continue }
4774
+ f(rel.doc, shared);
4775
+ propagate(rel.doc, doc, shared);
4776
+ } }
4777
  }
4778
+ propagate(doc, null, true);
 
4779
  }
4780
 
4781
+ // Attach a document to an editor.
4782
+ function attachDoc(cm, doc) {
4783
+ if (doc.cm) { throw new Error("This document is already in use.") }
4784
+ cm.doc = doc;
4785
+ doc.cm = cm;
4786
+ estimateLineHeights(cm);
4787
+ loadMode(cm);
4788
+ setDirectionClass(cm);
4789
+ if (!cm.options.lineWrapping) { findMaxLine(cm); }
4790
+ cm.options.mode = doc.modeOption;
4791
+ regChange(cm);
4792
+ }
4793
 
4794
+ function setDirectionClass(cm) {
4795
+ (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
 
 
 
 
 
 
 
 
 
 
 
 
4796
  }
4797
 
4798
+ function directionChanged(cm) {
4799
+ runInOp(cm, function () {
4800
+ setDirectionClass(cm);
4801
+ regChange(cm);
 
 
 
 
 
4802
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4803
  }
4804
 
4805
+ function History(startGen) {
4806
+ // Arrays of change events and selections. Doing something adds an
4807
+ // event to done and clears undo. Undoing moves events from done
4808
+ // to undone, redoing moves them in the other direction.
4809
+ this.done = []; this.undone = [];
4810
+ this.undoDepth = Infinity;
4811
+ // Used to track when changes can be merged into a single undo
4812
+ // event
4813
+ this.lastModTime = this.lastSelTime = 0;
4814
+ this.lastOp = this.lastSelOp = null;
4815
+ this.lastOrigin = this.lastSelOrigin = null;
4816
+ // Used by the isClean() method
4817
+ this.generation = this.maxGeneration = startGen || 1;
4818
  }
4819
 
4820
+ // Create a history change event from an updateDoc-style change
4821
+ // object.
4822
+ function historyChangeFromChange(doc, change) {
4823
+ var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
4824
+ attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
4825
+ linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true);
4826
+ return histChange
4827
+ }
4828
 
4829
+ // Pop all selection events off the end of a history array. Stop at
4830
+ // a change event.
4831
+ function clearSelectionEvents(array) {
4832
+ while (array.length) {
4833
+ var last = lst(array);
4834
+ if (last.ranges) { array.pop(); }
4835
+ else { break }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4836
  }
 
4837
  }
 
 
4838
 
4839
+ // Find the top change event in the history. Pop off selection
4840
+ // events that are in the way.
4841
+ function lastChangeEvent(hist, force) {
4842
+ if (force) {
4843
+ clearSelectionEvents(hist.done);
4844
+ return lst(hist.done)
4845
+ } else if (hist.done.length && !lst(hist.done).ranges) {
4846
+ return lst(hist.done)
4847
+ } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
4848
+ hist.done.pop();
4849
+ return lst(hist.done)
 
 
 
 
 
4850
  }
4851
  }
4852
 
4853
+ // Register a change in the history. Merges changes that are within
4854
+ // a single operation, or are close together with an origin that
4855
+ // allows merging (starting with "+") into a single event.
4856
+ function addChangeToHistory(doc, change, selAfter, opId) {
4857
+ var hist = doc.history;
4858
+ hist.undone.length = 0;
4859
+ var time = +new Date, cur;
4860
+ var last;
 
 
4861
 
4862
+ if ((hist.lastOp == opId ||
4863
+ hist.lastOrigin == change.origin && change.origin &&
4864
+ ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
4865
+ change.origin.charAt(0) == "*")) &&
4866
+ (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
4867
+ // Merge this change into the last event
4868
+ last = lst(cur.changes);
4869
+ if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
4870
+ // Optimized case for simple insertion -- don't want to add
4871
+ // new changesets for every character typed
4872
+ last.to = changeEnd(change);
4873
+ } else {
4874
+ // Add new sub-event
4875
+ cur.changes.push(historyChangeFromChange(doc, change));
4876
+ }
4877
+ } else {
4878
+ // Can not be merged, start a new event.
4879
+ var before = lst(hist.done);
4880
+ if (!before || !before.ranges)
4881
+ { pushSelectionToHistory(doc.sel, hist.done); }
4882
+ cur = {changes: [historyChangeFromChange(doc, change)],
4883
+ generation: hist.generation};
4884
+ hist.done.push(cur);
4885
+ while (hist.done.length > hist.undoDepth) {
4886
+ hist.done.shift();
4887
+ if (!hist.done[0].ranges) { hist.done.shift(); }
4888
+ }
4889
  }
4890
+ hist.done.push(selAfter);
4891
+ hist.generation = ++hist.maxGeneration;
4892
+ hist.lastModTime = hist.lastSelTime = time;
4893
+ hist.lastOp = hist.lastSelOp = opId;
4894
+ hist.lastOrigin = hist.lastSelOrigin = change.origin;
4895
 
4896
+ if (!last) { signal(doc, "historyAdded"); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4897
  }
4898
 
4899
+ function selectionEventCanBeMerged(doc, origin, prev, sel) {
4900
+ var ch = origin.charAt(0);
4901
+ return ch == "*" ||
4902
+ ch == "+" &&
4903
+ prev.ranges.length == sel.ranges.length &&
4904
+ prev.somethingSelected() == sel.somethingSelected() &&
4905
+ new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4906
  }
4907
 
4908
+ // Called whenever the selection changes, sets the new selection as
4909
+ // the pending selection in the history, and pushes the old pending
4910
+ // selection into the 'done' array when it was significantly
4911
+ // different (in number of selected ranges, emptiness, or time).
4912
+ function addSelectionToHistory(doc, sel, opId, options) {
4913
+ var hist = doc.history, origin = options && options.origin;
4914
 
4915
+ // A new event is started when the previous origin does not match
4916
+ // the current, or the origins don't allow matching. Origins
4917
+ // starting with * are always merged, those starting with + are
4918
+ // merged when similar and close together in time.
4919
+ if (opId == hist.lastSelOp ||
4920
+ (origin && hist.lastSelOrigin == origin &&
4921
+ (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
4922
+ selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
4923
+ { hist.done[hist.done.length - 1] = sel; }
4924
+ else
4925
+ { pushSelectionToHistory(sel, hist.done); }
4926
 
4927
+ hist.lastSelTime = +new Date;
4928
+ hist.lastSelOrigin = origin;
4929
+ hist.lastSelOp = opId;
4930
+ if (options && options.clearRedo !== false)
4931
+ { clearSelectionEvents(hist.undone); }
4932
  }
4933
 
4934
+ function pushSelectionToHistory(sel, dest) {
4935
+ var top = lst(dest);
4936
+ if (!(top && top.ranges && top.equals(sel)))
4937
+ { dest.push(sel); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4938
  }
4939
 
4940
+ // Used to store marked span information in the history.
4941
+ function attachLocalSpans(doc, change, from, to) {
4942
+ var existing = change["spans_" + doc.id], n = 0;
4943
+ doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
4944
+ if (line.markedSpans)
4945
+ { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; }
4946
+ ++n;
 
 
 
 
 
 
 
 
4947
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4948
  }
4949
 
4950
+ // When un/re-doing restores text containing marked spans, those
4951
+ // that have been explicitly cleared should not be restored.
4952
+ function removeClearedSpans(spans) {
4953
+ if (!spans) { return null }
4954
+ var out;
4955
+ for (var i = 0; i < spans.length; ++i) {
4956
+ if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } }
4957
+ else if (out) { out.push(spans[i]); }
 
 
4958
  }
4959
+ return !out ? spans : out.length ? out : null
4960
  }
4961
 
4962
+ // Retrieve and filter the old marked spans stored in a change event.
4963
+ function getOldSpans(doc, change) {
4964
+ var found = change["spans_" + doc.id];
4965
+ if (!found) { return null }
4966
+ var nw = [];
4967
+ for (var i = 0; i < change.text.length; ++i)
4968
+ { nw.push(removeClearedSpans(found[i])); }
4969
+ return nw
4970
  }
4971
 
4972
+ // Used for un/re-doing changes from the history. Combines the
4973
+ // result of computing the existing spans with the set of spans that
4974
+ // existed in the history (so that deleting around a span and then
4975
+ // undoing brings back the span).
4976
+ function mergeOldSpans(doc, change) {
4977
+ var old = getOldSpans(doc, change);
4978
+ var stretched = stretchSpansOverChange(doc, change);
4979
+ if (!old) { return stretched }
4980
+ if (!stretched) { return old }
4981
 
4982
+ for (var i = 0; i < old.length; ++i) {
4983
+ var oldCur = old[i], stretchCur = stretched[i];
4984
+ if (oldCur && stretchCur) {
4985
+ spans: for (var j = 0; j < stretchCur.length; ++j) {
4986
+ var span = stretchCur[j];
4987
+ for (var k = 0; k < oldCur.length; ++k)
4988
+ { if (oldCur[k].marker == span.marker) { continue spans } }
4989
+ oldCur.push(span);
4990
+ }
4991
+ } else if (stretchCur) {
4992
+ old[i] = stretchCur;
 
 
 
 
 
 
 
 
 
 
 
 
4993
  }
 
 
 
 
 
 
 
4994
  }
4995
+ return old
4996
  }
4997
 
4998
+ // Used both to provide a JSON-safe object in .getHistory, and, when
4999
+ // detaching a document, to split the history in two
5000
+ function copyHistoryArray(events, newGroup, instantiateSel) {
5001
+ var copy = [];
5002
+ for (var i = 0; i < events.length; ++i) {
5003
+ var event = events[i];
5004
+ if (event.ranges) {
5005
+ copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
5006
+ continue
5007
+ }
5008
+ var changes = event.changes, newChanges = [];
5009
+ copy.push({changes: newChanges});
5010
+ for (var j = 0; j < changes.length; ++j) {
5011
+ var change = changes[j], m = (void 0);
5012
+ newChanges.push({from: change.from, to: change.to, text: change.text});
5013
+ if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
5014
+ if (indexOf(newGroup, Number(m[1])) > -1) {
5015
+ lst(newChanges)[prop] = change[prop];
5016
+ delete change[prop];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5017
  }
5018
+ } } }
5019
+ }
5020
  }
5021
+ return copy
 
5022
  }
5023
 
5024
+ // The 'scroll' parameter given to many of these indicated whether
5025
+ // the new cursor position should be scrolled into view after
5026
+ // modifying the selection.
5027
+
5028
+ // If shift is held or the extend flag is set, extends a range to
5029
+ // include a given position (and optionally a second position).
5030
+ // Otherwise, simply returns the range between the given positions.
5031
+ // Used for cursor motion and such.
5032
+ function extendRange(range, head, other, extend) {
5033
+ if (extend) {
5034
+ var anchor = range.anchor;
5035
+ if (other) {
5036
+ var posBefore = cmp(head, anchor) < 0;
5037
+ if (posBefore != (cmp(other, anchor) < 0)) {
5038
+ anchor = head;
5039
+ head = other;
5040
+ } else if (posBefore != (cmp(head, other) < 0)) {
5041
+ head = other;
5042
+ }
5043
+ }
5044
+ return new Range(anchor, head)
5045
+ } else {
5046
+ return new Range(other || head, head)
5047
  }
 
5048
  }
5049
 
5050
+ // Extend the primary selection range, discard the rest.
5051
+ function extendSelection(doc, head, other, options, extend) {
5052
+ if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); }
5053
+ setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);
 
 
 
 
 
 
 
 
5054
  }
5055
 
5056
+ // Extend all selections (pos is an array of selections with length
5057
+ // equal the number of selections)
5058
+ function extendSelections(doc, heads, options) {
5059
+ var out = [];
5060
+ var extend = doc.cm && (doc.cm.display.shift || doc.extend);
5061
+ for (var i = 0; i < doc.sel.ranges.length; i++)
5062
+ { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); }
5063
+ var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex);
5064
+ setSelection(doc, newSel, options);
5065
  }
5066
 
5067
+ // Updates a single range in the selection.
5068
+ function replaceOneSelection(doc, i, range, options) {
5069
+ var ranges = doc.sel.ranges.slice(0);
5070
+ ranges[i] = range;
5071
+ setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options);
5072
+ }
 
 
 
 
 
 
5073
 
5074
+ // Reset the selection to a single range.
5075
+ function setSimpleSelection(doc, anchor, head, options) {
5076
+ setSelection(doc, simpleSelection(anchor, head), options);
5077
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5078
 
5079
+ // Give beforeSelectionChange handlers a change to influence a
5080
+ // selection update.
5081
+ function filterSelectionChange(doc, sel, options) {
5082
+ var obj = {
5083
+ ranges: sel.ranges,
5084
+ update: function(ranges) {
5085
+ var this$1 = this;
5086
 
5087
+ this.ranges = [];
5088
+ for (var i = 0; i < ranges.length; i++)
5089
+ { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
5090
+ clipPos(doc, ranges[i].head)); }
5091
+ },
5092
+ origin: options && options.origin
5093
+ };
5094
+ signal(doc, "beforeSelectionChange", doc, obj);
5095
+ if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); }
5096
+ if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) }
5097
+ else { return sel }
5098
+ }
5099
 
5100
+ function setSelectionReplaceHistory(doc, sel, options) {
5101
+ var done = doc.history.done, last = lst(done);
5102
+ if (last && last.ranges) {
5103
+ done[done.length - 1] = sel;
5104
+ setSelectionNoUndo(doc, sel, options);
5105
+ } else {
5106
+ setSelection(doc, sel, options);
5107
+ }
5108
  }
5109
 
5110
+ // Set a new selection.
5111
+ function setSelection(doc, sel, options) {
5112
+ setSelectionNoUndo(doc, sel, options);
5113
+ addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
5114
  }
5115
 
5116
+ function setSelectionNoUndo(doc, sel, options) {
5117
+ if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
5118
+ { sel = filterSelectionChange(doc, sel, options); }
5119
+
5120
+ var bias = options && options.bias ||
5121
+ (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
5122
+ setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
5123
+
5124
+ if (!(options && options.scroll === false) && doc.cm)
5125
+ { ensureCursorVisible(doc.cm); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5126
  }
5127
 
5128
+ function setSelectionInner(doc, sel) {
5129
+ if (sel.equals(doc.sel)) { return }
5130
+
5131
+ doc.sel = sel;
5132
+
5133
+ if (doc.cm) {
5134
+ doc.cm.curOp.updateInput = 1;
5135
+ doc.cm.curOp.selectionChanged = true;
5136
+ signalCursorActivity(doc.cm);
5137
  }
5138
+ signalLater(doc, "cursorActivity", doc);
 
 
5139
  }
5140
 
5141
+ // Verify that the selection does not partially select any atomic
5142
+ // marked ranges.
5143
+ function reCheckSelection(doc) {
5144
+ setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5145
  }
5146
 
5147
+ // Return a selection that does not partially select any atomic
5148
+ // ranges.
5149
+ function skipAtomicInSelection(doc, sel, bias, mayClear) {
5150
+ var out;
5151
+ for (var i = 0; i < sel.ranges.length; i++) {
5152
+ var range = sel.ranges[i];
5153
+ var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
5154
+ var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
5155
+ var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
5156
+ if (out || newAnchor != range.anchor || newHead != range.head) {
5157
+ if (!out) { out = sel.ranges.slice(0, i); }
5158
+ out[i] = new Range(newAnchor, newHead);
5159
+ }
5160
  }
5161
+ return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel
5162
  }
5163
 
5164
+ function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
5165
+ var line = getLine(doc, pos.line);
5166
+ if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
5167
+ var sp = line.markedSpans[i], m = sp.marker;
 
 
 
 
 
5168
 
5169
+ // Determine if we should prevent the cursor being placed to the left/right of an atomic marker
5170
+ // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it
5171
+ // is with selectLeft/Right
5172
+ var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft;
5173
+ var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight;
5174
+
5175
+ if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
5176
+ (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
5177
+ if (mayClear) {
5178
+ signal(m, "beforeCursorEnter");
5179
+ if (m.explicitlyCleared) {
5180
+ if (!line.markedSpans) { break }
5181
+ else {--i; continue}
 
 
 
 
 
 
5182
  }
 
5183
  }
5184
+ if (!m.atomic) { continue }
5185
+
5186
+ if (oldPos) {
5187
+ var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
5188
+ if (dir < 0 ? preventCursorRight : preventCursorLeft)
5189
+ { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
5190
+ if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
5191
+ { return skipAtomicInner(doc, near, pos, dir, mayClear) }
5192
  }
 
 
 
 
5193
 
5194
+ var far = m.find(dir < 0 ? -1 : 1);
5195
+ if (dir < 0 ? preventCursorLeft : preventCursorRight)
5196
+ { far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
5197
+ return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
 
 
 
 
 
 
 
 
 
 
 
5198
  }
5199
+ } }
5200
+ return pos
5201
+ }
5202
+
5203
+ // Ensure a given position is not inside an atomic range.
5204
+ function skipAtomic(doc, pos, oldPos, bias, mayClear) {
5205
+ var dir = bias || 1;
5206
+ var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
5207
+ (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
5208
+ skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
5209
+ (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
5210
+ if (!found) {
5211
+ doc.cantEdit = true;
5212
+ return Pos(doc.first, 0)
5213
+ }
5214
+ return found
5215
+ }
5216
+
5217
+ function movePos(doc, pos, dir, line) {
5218
+ if (dir < 0 && pos.ch == 0) {
5219
+ if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
5220
+ else { return null }
5221
+ } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
5222
+ if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
5223
+ else { return null }
5224
+ } else {
5225
+ return new Pos(pos.line, pos.ch + dir)
5226
  }
5227
  }
5228
 
5229
+ function selectAll(cm) {
5230
+ cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
5231
+ }
5232
 
5233
+ // UPDATING
5234
+
5235
+ // Allow "beforeChange" event handlers to influence a change
5236
+ function filterChange(doc, change, update) {
5237
+ var obj = {
5238
+ canceled: false,
5239
+ from: change.from,
5240
+ to: change.to,
5241
+ text: change.text,
5242
+ origin: change.origin,
5243
+ cancel: function () { return obj.canceled = true; }
5244
+ };
5245
+ if (update) { obj.update = function (from, to, text, origin) {
5246
+ if (from) { obj.from = clipPos(doc, from); }
5247
+ if (to) { obj.to = clipPos(doc, to); }
5248
+ if (text) { obj.text = text; }
5249
+ if (origin !== undefined) { obj.origin = origin; }
5250
+ }; }
5251
+ signal(doc, "beforeChange", doc, obj);
5252
+ if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); }
5253
+
5254
+ if (obj.canceled) {
5255
+ if (doc.cm) { doc.cm.curOp.updateInput = 2; }
5256
+ return null
5257
+ }
5258
+ return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
5259
  }
5260
 
5261
+ // Apply a change to a document, and add it to the document's
5262
+ // history, and propagating it to all linked documents.
5263
+ function makeChange(doc, change, ignoreReadOnly) {
5264
+ if (doc.cm) {
5265
+ if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
5266
+ if (doc.cm.state.suppressEdits) { return }
5267
  }
5268
 
5269
+ if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
5270
+ change = filterChange(doc, change, true);
5271
+ if (!change) { return }
5272
+ }
5273
 
5274
+ // Possibly split or suppress the update based on the presence
5275
+ // of read-only spans in its range.
5276
+ var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
5277
+ if (split) {
5278
+ for (var i = split.length - 1; i >= 0; --i)
5279
+ { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5280
  } else {
5281
+ makeChangeInner(doc, change);
 
 
 
 
 
5282
  }
 
 
5283
  }
5284
 
5285
+ function makeChangeInner(doc, change) {
5286
+ if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
5287
+ var selAfter = computeSelAfterChange(doc, change);
5288
+ addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
 
 
 
 
 
 
 
 
5289
 
5290
+ makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
5291
+ var rebased = [];
 
 
 
 
 
 
 
5292
 
5293
+ linkedDocs(doc, function (doc, sharedHist) {
5294
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
5295
+ rebaseHist(doc.history, change);
5296
+ rebased.push(doc.history);
 
 
 
 
 
5297
  }
5298
+ makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
5299
+ });
5300
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5301
 
5302
+ // Revert a change stored in a document's history.
5303
+ function makeChangeFromHistory(doc, type, allowSelectionOnly) {
5304
+ var suppress = doc.cm && doc.cm.state.suppressEdits;
5305
+ if (suppress && !allowSelectionOnly) { return }
5306
+
5307
+ var hist = doc.history, event, selAfter = doc.sel;
5308
+ var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
5309
+
5310
+ // Verify that there is a useable event (so that ctrl-z won't
5311
+ // needlessly clear selection events)
5312
+ var i = 0;
5313
+ for (; i < source.length; i++) {
5314
+ event = source[i];
5315
+ if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
5316
+ { break }
5317
  }
5318
+ if (i == source.length) { return }
5319
+ hist.lastOrigin = hist.lastSelOrigin = null;
 
 
5320
 
5321
+ for (;;) {
5322
+ event = source.pop();
5323
+ if (event.ranges) {
5324
+ pushSelectionToHistory(event, dest);
5325
+ if (allowSelectionOnly && !event.equals(doc.sel)) {
5326
+ setSelection(doc, event, {clearRedo: false});
5327
+ return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5328
  }
5329
+ selAfter = event;
5330
+ } else if (suppress) {
5331
+ source.push(event);
5332
+ return
5333
+ } else { break }
 
 
 
 
 
 
 
 
 
5334
  }
 
5335
 
5336
+ // Build up a reverse change object to add to the opposite history
5337
+ // stack (redo when undoing, and vice versa).
5338
+ var antiChanges = [];
5339
+ pushSelectionToHistory(selAfter, dest);
5340
+ dest.push({changes: antiChanges, generation: hist.generation});
5341
+ hist.generation = event.generation || ++hist.maxGeneration;
5342
 
5343
+ var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
 
 
 
 
 
 
 
 
 
 
5344
 
5345
+ var loop = function ( i ) {
5346
+ var change = event.changes[i];
5347
+ change.origin = type;
5348
+ if (filter && !filterChange(doc, change, false)) {
5349
+ source.length = 0;
5350
+ return {}
5351
+ }
5352
 
5353
+ antiChanges.push(historyChangeFromChange(doc, change));
 
 
 
 
 
 
 
 
 
5354
 
5355
+ var after = i ? computeSelAfterChange(doc, change) : lst(source);
5356
+ makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
5357
+ if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); }
5358
+ var rebased = [];
 
 
 
5359
 
5360
+ // Propagate to the linked documents
5361
+ linkedDocs(doc, function (doc, sharedHist) {
5362
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
5363
+ rebaseHist(doc.history, change);
5364
+ rebased.push(doc.history);
5365
+ }
5366
+ makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
5367
+ });
5368
+ };
5369
 
5370
+ for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
5371
+ var returned = loop( i$1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5372
 
5373
+ if ( returned ) return returned.v;
5374
+ }
5375
+ }
5376
 
5377
+ // Sub-views need their line numbers shifted when text is added
5378
+ // above or below them in the parent document.
5379
+ function shiftDoc(doc, distance) {
5380
+ if (distance == 0) { return }
5381
+ doc.first += distance;
5382
+ doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
5383
+ Pos(range.anchor.line + distance, range.anchor.ch),
5384
+ Pos(range.head.line + distance, range.head.ch)
5385
+ ); }), doc.sel.primIndex);
5386
+ if (doc.cm) {
5387
+ regChange(doc.cm, doc.first, doc.first - distance, distance);
5388
+ for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
5389
+ { regLineChange(doc.cm, l, "gutter"); }
5390
+ }
5391
+ }
5392
 
5393
+ // More lower-level change function, handling only a single document
5394
+ // (not linked ones).
5395
+ function makeChangeSingleDoc(doc, change, selAfter, spans) {
5396
+ if (doc.cm && !doc.cm.curOp)
5397
+ { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
5398
 
5399
+ if (change.to.line < doc.first) {
5400
+ shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
5401
+ return
5402
+ }
5403
+ if (change.from.line > doc.lastLine()) { return }
5404
 
5405
+ // Clip the change to the size of this doc
5406
+ if (change.from.line < doc.first) {
5407
+ var shift = change.text.length - 1 - (doc.first - change.from.line);
5408
+ shiftDoc(doc, shift);
5409
+ change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
5410
+ text: [lst(change.text)], origin: change.origin};
5411
+ }
5412
+ var last = doc.lastLine();
5413
+ if (change.to.line > last) {
5414
+ change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
5415
+ text: [change.text[0]], origin: change.origin};
5416
+ }
5417
 
5418
+ change.removed = getBetween(doc, change.from, change.to);
 
 
 
 
 
 
 
 
 
5419
 
5420
+ if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }
5421
+ if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
5422
+ else { updateDoc(doc, change, spans); }
5423
+ setSelectionNoUndo(doc, selAfter, sel_dontScroll);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5424
 
5425
+ if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0)))
5426
+ { doc.cantEdit = false; }
5427
+ }
5428
+
5429
+ // Handle the interaction of a change to a document with the editor
5430
+ // that this document is part of.
5431
+ function makeChangeSingleDocInEditor(cm, change, spans) {
5432
+ var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
5433
+
5434
+ var recomputeMaxLength = false, checkWidthStart = from.line;
5435
+ if (!cm.options.lineWrapping) {
5436
+ checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
5437
+ doc.iter(checkWidthStart, to.line + 1, function (line) {
5438
+ if (line == display.maxLine) {
5439
+ recomputeMaxLength = true;
5440
+ return true
5441
+ }
5442
+ });
5443
+ }
5444
+
5445
+ if (doc.sel.contains(change.from, change.to) > -1)
5446
+ { signalCursorActivity(cm); }
5447
+
5448
+ updateDoc(doc, change, spans, estimateHeight(cm));
5449
+
5450
+ if (!cm.options.lineWrapping) {
5451
+ doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
5452
+ var len = lineLength(line);
5453
+ if (len > display.maxLineLength) {
5454
+ display.maxLine = line;
5455
+ display.maxLineLength = len;
5456
+ display.maxLineChanged = true;
5457
+ recomputeMaxLength = false;
5458
+ }
5459
+ });
5460
+ if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; }
5461
+ }
5462
+
5463
+ retreatFrontier(doc, from.line);
5464
+ startWorker(cm, 400);
5465
+
5466
+ var lendiff = change.text.length - (to.line - from.line) - 1;
5467
+ // Remember that these lines changed, for updating the display
5468
+ if (change.full)
5469
+ { regChange(cm); }
5470
+ else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
5471
+ { regLineChange(cm, from.line, "text"); }
5472
+ else
5473
+ { regChange(cm, from.line, to.line + 1, lendiff); }
5474
+
5475
+ var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
5476
+ if (changeHandler || changesHandler) {
5477
+ var obj = {
5478
+ from: from, to: to,
5479
+ text: change.text,
5480
+ removed: change.removed,
5481
+ origin: change.origin
5482
+ };
5483
+ if (changeHandler) { signalLater(cm, "change", cm, obj); }
5484
+ if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); }
5485
+ }
5486
+ cm.display.selForContextMenu = null;
5487
+ }
5488
+
5489
+ function replaceRange(doc, code, from, to, origin) {
5490
+ var assign;
5491
+
5492
+ if (!to) { to = from; }
5493
+ if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); }
5494
+ if (typeof code == "string") { code = doc.splitLines(code); }
5495
+ makeChange(doc, {from: from, to: to, text: code, origin: origin});
5496
+ }
5497
+
5498
+ // Rebasing/resetting history to deal with externally-sourced changes
5499
+
5500
+ function rebaseHistSelSingle(pos, from, to, diff) {
5501
+ if (to < pos.line) {
5502
+ pos.line += diff;
5503
+ } else if (from < pos.line) {
5504
+ pos.line = from;
5505
+ pos.ch = 0;
5506
+ }
5507
+ }
5508
+
5509
+ // Tries to rebase an array of history events given a change in the
5510
+ // document. If the change touches the same lines as the event, the
5511
+ // event, and everything 'behind' it, is discarded. If the change is
5512
+ // before the event, the event's positions are updated. Uses a
5513
+ // copy-on-write scheme for the positions, to avoid having to
5514
+ // reallocate them all on every rebase, but also avoid problems with
5515
+ // shared position objects being unsafely updated.
5516
+ function rebaseHistArray(array, from, to, diff) {
5517
+ for (var i = 0; i < array.length; ++i) {
5518
+ var sub = array[i], ok = true;
5519
+ if (sub.ranges) {
5520
+ if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
5521
+ for (var j = 0; j < sub.ranges.length; j++) {
5522
+ rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
5523
+ rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
5524
+ }
5525
+ continue
5526
  }
5527
+ for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
5528
+ var cur = sub.changes[j$1];
5529
+ if (to < cur.from.line) {
5530
+ cur.from = Pos(cur.from.line + diff, cur.from.ch);
5531
+ cur.to = Pos(cur.to.line + diff, cur.to.ch);
5532
+ } else if (from <= cur.to.line) {
5533
+ ok = false;
5534
+ break
5535
+ }
5536
  }
5537
+ if (!ok) {
5538
+ array.splice(0, i + 1);
5539
+ i = 0;
 
 
 
 
 
 
 
 
 
 
5540
  }
5541
+ }
5542
+ }
 
 
 
 
 
 
 
 
5543
 
5544
+ function rebaseHist(hist, change) {
5545
+ var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
5546
+ rebaseHistArray(hist.done, from, to, diff);
5547
+ rebaseHistArray(hist.undone, from, to, diff);
5548
+ }
5549
 
5550
+ // Utility for applying a change to a line by handle or number,
5551
+ // returning the number and optionally registering the line as
5552
+ // changed.
5553
+ function changeLine(doc, handle, changeType, op) {
5554
+ var no = handle, line = handle;
5555
+ if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); }
5556
+ else { no = lineNo(handle); }
5557
+ if (no == null) { return null }
5558
+ if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); }
5559
+ return line
5560
+ }
5561
 
5562
+ // The document is represented as a BTree consisting of leaves, with
5563
+ // chunk of lines in them, and branches, with up to ten leaves or
5564
+ // other branch nodes below them. The top node is always a branch
5565
+ // node, and is the document object itself (meaning it has
5566
+ // additional methods and properties).
5567
+ //
5568
+ // All nodes have parent links. The tree is used both to go from
5569
+ // line numbers to line objects, and to go from objects to numbers.
5570
+ // It also indexes by height, and is used to convert between height
5571
+ // and line object, and to find the total height of the document.
5572
+ //
5573
+ // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
5574
+
5575
+ function LeafChunk(lines) {
5576
+ var this$1 = this;
5577
+
5578
+ this.lines = lines;
5579
+ this.parent = null;
5580
+ var height = 0;
5581
+ for (var i = 0; i < lines.length; ++i) {
5582
+ lines[i].parent = this$1;
5583
+ height += lines[i].height;
5584
+ }
5585
+ this.height = height;
5586
+ }
5587
+
5588
+ LeafChunk.prototype = {
5589
+ chunkSize: function() { return this.lines.length },
5590
+
5591
+ // Remove the n lines at offset 'at'.
5592
+ removeInner: function(at, n) {
5593
+ var this$1 = this;
5594
+
5595
+ for (var i = at, e = at + n; i < e; ++i) {
5596
+ var line = this$1.lines[i];
5597
+ this$1.height -= line.height;
5598
+ cleanUpLine(line);
5599
+ signalLater(line, "delete");
5600
+ }
5601
+ this.lines.splice(at, n);
5602
  },
5603
 
5604
+ // Helper used to collapse a small branch into a single leaf.
5605
+ collapse: function(lines) {
5606
+ lines.push.apply(lines, this.lines);
5607
  },
5608
+
5609
+ // Insert the given array of lines at offset 'at', count them as
5610
+ // having the given height.
5611
+ insertInner: function(at, lines, height) {
5612
+ var this$1 = this;
5613
+
5614
+ this.height += height;
5615
+ this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
5616
+ for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1; }
5617
  },
5618
 
5619
+ // Used to iterate over a part of the tree.
5620
+ iterN: function(at, n, op) {
5621
+ var this$1 = this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5622
 
5623
+ for (var e = at + n; at < e; ++at)
5624
+ { if (op(this$1.lines[at])) { return true } }
5625
+ }
5626
+ };
5627
+
5628
+ function BranchChunk(children) {
5629
+ var this$1 = this;
5630
+
5631
+ this.children = children;
5632
+ var size = 0, height = 0;
5633
+ for (var i = 0; i < children.length; ++i) {
5634
+ var ch = children[i];
5635
+ size += ch.chunkSize(); height += ch.height;
5636
+ ch.parent = this$1;
5637
+ }
5638
+ this.size = size;
5639
+ this.height = height;
5640
+ this.parent = null;
5641
+ }
5642
+
5643
+ BranchChunk.prototype = {
5644
+ chunkSize: function() { return this.size },
5645
+
5646
+ removeInner: function(at, n) {
5647
+ var this$1 = this;
5648
+
5649
+ this.size -= n;
5650
+ for (var i = 0; i < this.children.length; ++i) {
5651
+ var child = this$1.children[i], sz = child.chunkSize();
5652
+ if (at < sz) {
5653
+ var rm = Math.min(n, sz - at), oldHeight = child.height;
5654
+ child.removeInner(at, rm);
5655
+ this$1.height -= oldHeight - child.height;
5656
+ if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null; }
5657
+ if ((n -= rm) == 0) { break }
5658
+ at = 0;
5659
+ } else { at -= sz; }
5660
+ }
5661
+ // If the result is smaller than 25 lines, ensure that it is a
5662
+ // single leaf node.
5663
+ if (this.size - n < 25 &&
5664
+ (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
5665
+ var lines = [];
5666
+ this.collapse(lines);
5667
+ this.children = [new LeafChunk(lines)];
5668
+ this.children[0].parent = this;
5669
+ }
5670
  },
5671
+
5672
+ collapse: function(lines) {
5673
+ var this$1 = this;
5674
+
5675
+ for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines); }
 
5676
  },
5677
+
5678
+ insertInner: function(at, lines, height) {
5679
+ var this$1 = this;
5680
+
5681
+ this.size += lines.length;
5682
+ this.height += height;
5683
+ for (var i = 0; i < this.children.length; ++i) {
5684
+ var child = this$1.children[i], sz = child.chunkSize();
5685
+ if (at <= sz) {
5686
+ child.insertInner(at, lines, height);
5687
+ if (child.lines && child.lines.length > 50) {
5688
+ // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
5689
+ // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
5690
+ var remaining = child.lines.length % 25 + 25;
5691
+ for (var pos = remaining; pos < child.lines.length;) {
5692
+ var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
5693
+ child.height -= leaf.height;
5694
+ this$1.children.splice(++i, 0, leaf);
5695
+ leaf.parent = this$1;
5696
+ }
5697
+ child.lines = child.lines.slice(0, remaining);
5698
+ this$1.maybeSpill();
5699
+ }
5700
+ break
5701
+ }
5702
+ at -= sz;
5703
  }
 
5704
  },
5705
+
5706
+ // When a node has grown, check whether it should be split.
5707
+ maybeSpill: function() {
5708
+ if (this.children.length <= 10) { return }
5709
+ var me = this;
5710
+ do {
5711
+ var spilled = me.children.splice(me.children.length - 5, 5);
5712
+ var sibling = new BranchChunk(spilled);
5713
+ if (!me.parent) { // Become the parent node
5714
+ var copy = new BranchChunk(me.children);
5715
+ copy.parent = me;
5716
+ me.children = [copy, sibling];
5717
+ me = copy;
5718
+ } else {
5719
+ me.size -= sibling.size;
5720
+ me.height -= sibling.height;
5721
+ var myIndex = indexOf(me.parent.children, me);
5722
+ me.parent.children.splice(myIndex + 1, 0, sibling);
5723
  }
5724
+ sibling.parent = me.parent;
5725
+ } while (me.children.length > 10)
5726
+ me.parent.maybeSpill();
5727
  },
5728
+
5729
+ iterN: function(at, n, op) {
5730
+ var this$1 = this;
5731
+
5732
+ for (var i = 0; i < this.children.length; ++i) {
5733
+ var child = this$1.children[i], sz = child.chunkSize();
5734
+ if (at < sz) {
5735
+ var used = Math.min(n, sz - at);
5736
+ if (child.iterN(at, used, op)) { return true }
5737
+ if ((n -= used) == 0) { break }
5738
+ at = 0;
5739
+ } else { at -= sz; }
5740
+ }
5741
+ }
5742
+ };
5743
+
5744
+ // Line widgets are block elements displayed above or below a line.
5745
+
5746
+ var LineWidget = function(doc, node, options) {
5747
+ var this$1 = this;
5748
+
5749
+ if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
5750
+ { this$1[opt] = options[opt]; } } }
5751
+ this.doc = doc;
5752
+ this.node = node;
5753
+ };
5754
+
5755
+ LineWidget.prototype.clear = function () {
5756
+ var this$1 = this;
5757
+
5758
+ var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
5759
+ if (no == null || !ws) { return }
5760
+ for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1); } }
5761
+ if (!ws.length) { line.widgets = null; }
5762
+ var height = widgetHeight(this);
5763
+ updateLineHeight(line, Math.max(0, line.height - height));
5764
+ if (cm) {
5765
+ runInOp(cm, function () {
5766
+ adjustScrollWhenAboveVisible(cm, line, -height);
5767
+ regLineChange(cm, no, "widget");
5768
  });
5769
+ signalLater(cm, "lineWidgetCleared", cm, this, no);
5770
+ }
5771
+ };
5772
+
5773
+ LineWidget.prototype.changed = function () {
5774
+ var this$1 = this;
5775
+
5776
+ var oldH = this.height, cm = this.doc.cm, line = this.line;
5777
+ this.height = null;
5778
+ var diff = widgetHeight(this) - oldH;
5779
+ if (!diff) { return }
5780
+ if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); }
5781
+ if (cm) {
5782
+ runInOp(cm, function () {
5783
+ cm.curOp.forceUpdate = true;
5784
+ adjustScrollWhenAboveVisible(cm, line, diff);
5785
+ signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
5786
+ });
5787
+ }
5788
+ };
5789
+ eventMixin(LineWidget);
5790
+
5791
+ function adjustScrollWhenAboveVisible(cm, line, diff) {
5792
+ if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
5793
+ { addToScrollTop(cm, diff); }
5794
+ }
5795
+
5796
+ function addLineWidget(doc, handle, node, options) {
5797
+ var widget = new LineWidget(doc, node, options);
5798
+ var cm = doc.cm;
5799
+ if (cm && widget.noHScroll) { cm.display.alignWidgets = true; }
5800
+ changeLine(doc, handle, "widget", function (line) {
5801
+ var widgets = line.widgets || (line.widgets = []);
5802
+ if (widget.insertAt == null) { widgets.push(widget); }
5803
+ else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
5804
+ widget.line = line;
5805
+ if (cm && !lineIsHidden(doc, line)) {
5806
+ var aboveVisible = heightAtLine(line) < doc.scrollTop;
5807
+ updateLineHeight(line, line.height + widgetHeight(widget));
5808
+ if (aboveVisible) { addToScrollTop(cm, widget.height); }
5809
+ cm.curOp.forceUpdate = true;
5810
+ }
5811
+ return true
5812
+ });
5813
+ if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); }
5814
+ return widget
5815
+ }
5816
+
5817
+ // TEXTMARKERS
5818
+
5819
+ // Created with markText and setBookmark methods. A TextMarker is a
5820
+ // handle that can be used to clear or find a marked position in the
5821
+ // document. Line objects hold arrays (markedSpans) containing
5822
+ // {from, to, marker} object pointing to such marker objects, and
5823
+ // indicating that such a marker is present on that line. Multiple
5824
+ // lines may point to the same marker when it spans across lines.
5825
+ // The spans will have null for their from/to properties when the
5826
+ // marker continues beyond the start/end of the line. Markers have
5827
+ // links back to the lines they currently touch.
5828
+
5829
+ // Collapsed markers have unique ids, in order to be able to order
5830
+ // them, which is needed for uniquely determining an outer marker
5831
+ // when they overlap (they may nest, but not partially overlap).
5832
+ var nextMarkerId = 0;
5833
+
5834
+ var TextMarker = function(doc, type) {
5835
+ this.lines = [];
5836
+ this.type = type;
5837
+ this.doc = doc;
5838
+ this.id = ++nextMarkerId;
5839
+ };
5840
+
5841
+ // Clear the marker.
5842
+ TextMarker.prototype.clear = function () {
5843
+ var this$1 = this;
5844
+
5845
+ if (this.explicitlyCleared) { return }
5846
+ var cm = this.doc.cm, withOp = cm && !cm.curOp;
5847
+ if (withOp) { startOperation(cm); }
5848
+ if (hasHandler(this, "clear")) {
5849
+ var found = this.find();
5850
+ if (found) { signalLater(this, "clear", found.from, found.to); }
5851
+ }
5852
+ var min = null, max = null;
5853
+ for (var i = 0; i < this.lines.length; ++i) {
5854
+ var line = this$1.lines[i];
5855
+ var span = getMarkedSpanFor(line.markedSpans, this$1);
5856
+ if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text"); }
5857
+ else if (cm) {
5858
+ if (span.to != null) { max = lineNo(line); }
5859
+ if (span.from != null) { min = lineNo(line); }
5860
+ }
5861
+ line.markedSpans = removeMarkedSpan(line.markedSpans, span);
5862
+ if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
5863
+ { updateLineHeight(line, textHeight(cm.display)); }
5864
+ }
5865
+ if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
5866
+ var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual);
5867
+ if (len > cm.display.maxLineLength) {
5868
+ cm.display.maxLine = visual;
5869
+ cm.display.maxLineLength = len;
5870
+ cm.display.maxLineChanged = true;
5871
+ }
5872
+ } }
5873
+
5874
+ if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); }
5875
+ this.lines.length = 0;
5876
+ this.explicitlyCleared = true;
5877
+ if (this.atomic && this.doc.cantEdit) {
5878
+ this.doc.cantEdit = false;
5879
+ if (cm) { reCheckSelection(cm.doc); }
5880
+ }
5881
+ if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); }
5882
+ if (withOp) { endOperation(cm); }
5883
+ if (this.parent) { this.parent.clear(); }
5884
+ };
5885
+
5886
+ // Find the position of the marker in the document. Returns a {from,
5887
+ // to} object by default. Side can be passed to get a specific side
5888
+ // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
5889
+ // Pos objects returned contain a line object, rather than a line
5890
+ // number (used to prevent looking up the same line twice).
5891
+ TextMarker.prototype.find = function (side, lineObj) {
5892
+ var this$1 = this;
5893
+
5894
+ if (side == null && this.type == "bookmark") { side = 1; }
5895
+ var from, to;
5896
+ for (var i = 0; i < this.lines.length; ++i) {
5897
+ var line = this$1.lines[i];
5898
+ var span = getMarkedSpanFor(line.markedSpans, this$1);
5899
+ if (span.from != null) {
5900
+ from = Pos(lineObj ? line : lineNo(line), span.from);
5901
+ if (side == -1) { return from }
5902
+ }
5903
+ if (span.to != null) {
5904
+ to = Pos(lineObj ? line : lineNo(line), span.to);
5905
+ if (side == 1) { return to }
5906
+ }
5907
+ }
5908
+ return from && {from: from, to: to}
5909
+ };
5910
+
5911
+ // Signals that the marker's widget changed, and surrounding layout
5912
+ // should be recomputed.
5913
+ TextMarker.prototype.changed = function () {
5914
+ var this$1 = this;
5915
+
5916
+ var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
5917
+ if (!pos || !cm) { return }
5918
+ runInOp(cm, function () {
5919
+ var line = pos.line, lineN = lineNo(pos.line);
5920
+ var view = findViewForLine(cm, lineN);
5921
+ if (view) {
5922
+ clearLineMeasurementCacheFor(view);
5923
+ cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
5924
+ }
5925
+ cm.curOp.updateMaxLine = true;
5926
+ if (!lineIsHidden(widget.doc, line) && widget.height != null) {
5927
+ var oldHeight = widget.height;
5928
+ widget.height = null;
5929
+ var dHeight = widgetHeight(widget) - oldHeight;
5930
+ if (dHeight)
5931
+ { updateLineHeight(line, line.height + dHeight); }
5932
+ }
5933
+ signalLater(cm, "markerChanged", cm, this$1);
5934
+ });
5935
+ };
5936
+
5937
+ TextMarker.prototype.attachLine = function (line) {
5938
+ if (!this.lines.length && this.doc.cm) {
5939
+ var op = this.doc.cm.curOp;
5940
+ if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
5941
+ { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); }
5942
+ }
5943
+ this.lines.push(line);
5944
+ };
5945
+
5946
+ TextMarker.prototype.detachLine = function (line) {
5947
+ this.lines.splice(indexOf(this.lines, line), 1);
5948
+ if (!this.lines.length && this.doc.cm) {
5949
+ var op = this.doc.cm.curOp
5950
+ ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
5951
+ }
5952
+ };
5953
+ eventMixin(TextMarker);
5954
+
5955
+ // Create a marker, wire it up to the right lines, and
5956
+ function markText(doc, from, to, options, type) {
5957
+ // Shared markers (across linked documents) are handled separately
5958
+ // (markTextShared will call out to this again, once per
5959
+ // document).
5960
+ if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
5961
+ // Ensure we are in an operation.
5962
+ if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
5963
+
5964
+ var marker = new TextMarker(doc, type), diff = cmp(from, to);
5965
+ if (options) { copyObj(options, marker, false); }
5966
+ // Don't connect empty markers unless clearWhenEmpty is false
5967
+ if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
5968
+ { return marker }
5969
+ if (marker.replacedWith) {
5970
+ // Showing up as a widget implies collapsed (widget replaces text)
5971
+ marker.collapsed = true;
5972
+ marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
5973
+ if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); }
5974
+ if (options.insertLeft) { marker.widgetNode.insertLeft = true; }
5975
+ }
5976
+ if (marker.collapsed) {
5977
+ if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
5978
+ from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
5979
+ { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
5980
+ seeCollapsedSpans();
5981
+ }
5982
+
5983
+ if (marker.addToHistory)
5984
+ { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); }
5985
+
5986
+ var curLine = from.line, cm = doc.cm, updateMaxLine;
5987
+ doc.iter(curLine, to.line + 1, function (line) {
5988
+ if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
5989
+ { updateMaxLine = true; }
5990
+ if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
5991
+ addMarkedSpan(line, new MarkedSpan(marker,
5992
+ curLine == from.line ? from.ch : null,
5993
+ curLine == to.line ? to.ch : null));
5994
+ ++curLine;
5995
+ });
5996
+ // lineIsHidden depends on the presence of the spans, so needs a second pass
5997
+ if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
5998
+ if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); }
5999
+ }); }
6000
+
6001
+ if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); }
6002
+
6003
+ if (marker.readOnly) {
6004
+ seeReadOnlySpans();
6005
+ if (doc.history.done.length || doc.history.undone.length)
6006
+ { doc.clearHistory(); }
6007
+ }
6008
+ if (marker.collapsed) {
6009
+ marker.id = ++nextMarkerId;
6010
+ marker.atomic = true;
6011
+ }
6012
+ if (cm) {
6013
+ // Sync editor state
6014
+ if (updateMaxLine) { cm.curOp.updateMaxLine = true; }
6015
+ if (marker.collapsed)
6016
+ { regChange(cm, from.line, to.line + 1); }
6017
+ else if (marker.className || marker.startStyle || marker.endStyle || marker.css ||
6018
+ marker.attributes || marker.title)
6019
+ { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } }
6020
+ if (marker.atomic) { reCheckSelection(cm.doc); }
6021
+ signalLater(cm, "markerAdded", cm, marker);
6022
+ }
6023
+ return marker
6024
+ }
6025
+
6026
+ // SHARED TEXTMARKERS
6027
+
6028
+ // A shared marker spans multiple linked documents. It is
6029
+ // implemented as a meta-marker-object controlling multiple normal
6030
+ // markers.
6031
+ var SharedTextMarker = function(markers, primary) {
6032
+ var this$1 = this;
6033
+
6034
+ this.markers = markers;
6035
+ this.primary = primary;
6036
+ for (var i = 0; i < markers.length; ++i)
6037
+ { markers[i].parent = this$1; }
6038
+ };
6039
+
6040
+ SharedTextMarker.prototype.clear = function () {
6041
+ var this$1 = this;
6042
+
6043
+ if (this.explicitlyCleared) { return }
6044
+ this.explicitlyCleared = true;
6045
+ for (var i = 0; i < this.markers.length; ++i)
6046
+ { this$1.markers[i].clear(); }
6047
+ signalLater(this, "clear");
6048
+ };
6049
+
6050
+ SharedTextMarker.prototype.find = function (side, lineObj) {
6051
+ return this.primary.find(side, lineObj)
6052
+ };
6053
+ eventMixin(SharedTextMarker);
6054
+
6055
+ function markTextShared(doc, from, to, options, type) {
6056
+ options = copyObj(options);
6057
+ options.shared = false;
6058
+ var markers = [markText(doc, from, to, options, type)], primary = markers[0];
6059
+ var widget = options.widgetNode;
6060
+ linkedDocs(doc, function (doc) {
6061
+ if (widget) { options.widgetNode = widget.cloneNode(true); }
6062
+ markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
6063
+ for (var i = 0; i < doc.linked.length; ++i)
6064
+ { if (doc.linked[i].isParent) { return } }
6065
+ primary = lst(markers);
6066
+ });
6067
+ return new SharedTextMarker(markers, primary)
6068
+ }
6069
+
6070
+ function findSharedMarkers(doc) {
6071
+ return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
6072
+ }
6073
+
6074
+ function copySharedMarkers(doc, markers) {
6075
+ for (var i = 0; i < markers.length; i++) {
6076
+ var marker = markers[i], pos = marker.find();
6077
+ var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
6078
+ if (cmp(mFrom, mTo)) {
6079
+ var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
6080
+ marker.markers.push(subMark);
6081
+ subMark.parent = marker;
6082
+ }
6083
+ }
6084
+ }
6085
+
6086
+ function detachSharedMarkers(markers) {
6087
+ var loop = function ( i ) {
6088
+ var marker = markers[i], linked = [marker.primary.doc];
6089
+ linkedDocs(marker.primary.doc, function (d) { return linked.push(d); });
6090
+ for (var j = 0; j < marker.markers.length; j++) {
6091
+ var subMarker = marker.markers[j];
6092
+ if (indexOf(linked, subMarker.doc) == -1) {
6093
+ subMarker.parent = null;
6094
+ marker.markers.splice(j--, 1);
6095
+ }
6096
+ }
6097
+ };
6098
+
6099
+ for (var i = 0; i < markers.length; i++) loop( i );
6100
+ }
6101
+
6102
+ var nextDocId = 0;
6103
+ var Doc = function(text, mode, firstLine, lineSep, direction) {
6104
+ if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
6105
+ if (firstLine == null) { firstLine = 0; }
6106
+
6107
+ BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
6108
+ this.first = firstLine;
6109
+ this.scrollTop = this.scrollLeft = 0;
6110
+ this.cantEdit = false;
6111
+ this.cleanGeneration = 1;
6112
+ this.modeFrontier = this.highlightFrontier = firstLine;
6113
+ var start = Pos(firstLine, 0);
6114
+ this.sel = simpleSelection(start);
6115
+ this.history = new History(null);
6116
+ this.id = ++nextDocId;
6117
+ this.modeOption = mode;
6118
+ this.lineSep = lineSep;
6119
+ this.direction = (direction == "rtl") ? "rtl" : "ltr";
6120
+ this.extend = false;
6121
+
6122
+ if (typeof text == "string") { text = this.splitLines(text); }
6123
+ updateDoc(this, {from: start, to: start, text: text});
6124
+ setSelection(this, simpleSelection(start), sel_dontScroll);
6125
+ };
6126
+
6127
+ Doc.prototype = createObj(BranchChunk.prototype, {
6128
+ constructor: Doc,
6129
+ // Iterate over the document. Supports two forms -- with only one
6130
+ // argument, it calls that for each line in the document. With
6131
+ // three, it iterates over the range given by the first two (with
6132
+ // the second being non-inclusive).
6133
+ iter: function(from, to, op) {
6134
+ if (op) { this.iterN(from - this.first, to - from, op); }
6135
+ else { this.iterN(this.first, this.first + this.size, from); }
6136
+ },
6137
+
6138
+ // Non-public interface for adding and removing lines.
6139
+ insert: function(at, lines) {
6140
+ var height = 0;
6141
+ for (var i = 0; i < lines.length; ++i) { height += lines[i].height; }
6142
+ this.insertInner(at - this.first, lines, height);
6143
+ },
6144
+ remove: function(at, n) { this.removeInner(at - this.first, n); },
6145
+
6146
+ // From here, the methods are part of the public interface. Most
6147
+ // are also available from CodeMirror (editor) instances.
6148
+
6149
+ getValue: function(lineSep) {
6150
+ var lines = getLines(this, this.first, this.first + this.size);
6151
+ if (lineSep === false) { return lines }
6152
+ return lines.join(lineSep || this.lineSeparator())
6153
+ },
6154
+ setValue: docMethodOp(function(code) {
6155
+ var top = Pos(this.first, 0), last = this.first + this.size - 1;
6156
+ makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
6157
+ text: this.splitLines(code), origin: "setValue", full: true}, true);
6158
+ if (this.cm) { scrollToCoords(this.cm, 0, 0); }
6159
+ setSelection(this, simpleSelection(top), sel_dontScroll);
6160
+ }),
6161
+ replaceRange: function(code, from, to, origin) {
6162
+ from = clipPos(this, from);
6163
+ to = to ? clipPos(this, to) : from;
6164
+ replaceRange(this, code, from, to, origin);
6165
+ },
6166
+ getRange: function(from, to, lineSep) {
6167
+ var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
6168
+ if (lineSep === false) { return lines }
6169
+ return lines.join(lineSep || this.lineSeparator())
6170
+ },
6171
+
6172
+ getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
6173
+
6174
+ getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
6175
+ getLineNumber: function(line) {return lineNo(line)},
6176
+
6177
+ getLineHandleVisualStart: function(line) {
6178
+ if (typeof line == "number") { line = getLine(this, line); }
6179
+ return visualLine(line)
6180
+ },
6181
+
6182
+ lineCount: function() {return this.size},
6183
+ firstLine: function() {return this.first},
6184
+ lastLine: function() {return this.first + this.size - 1},
6185
+
6186
+ clipPos: function(pos) {return clipPos(this, pos)},
6187
+
6188
+ getCursor: function(start) {
6189
+ var range$$1 = this.sel.primary(), pos;
6190
+ if (start == null || start == "head") { pos = range$$1.head; }
6191
+ else if (start == "anchor") { pos = range$$1.anchor; }
6192
+ else if (start == "end" || start == "to" || start === false) { pos = range$$1.to(); }
6193
+ else { pos = range$$1.from(); }
6194
+ return pos
6195
+ },
6196
+ listSelections: function() { return this.sel.ranges },
6197
+ somethingSelected: function() {return this.sel.somethingSelected()},
6198
+
6199
+ setCursor: docMethodOp(function(line, ch, options) {
6200
+ setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
6201
+ }),
6202
+ setSelection: docMethodOp(function(anchor, head, options) {
6203
+ setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
6204
+ }),
6205
+ extendSelection: docMethodOp(function(head, other, options) {
6206
+ extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
6207
+ }),
6208
+ extendSelections: docMethodOp(function(heads, options) {
6209
+ extendSelections(this, clipPosArray(this, heads), options);
6210
+ }),
6211
+ extendSelectionsBy: docMethodOp(function(f, options) {
6212
+ var heads = map(this.sel.ranges, f);
6213
+ extendSelections(this, clipPosArray(this, heads), options);
6214
+ }),
6215
+ setSelections: docMethodOp(function(ranges, primary, options) {
6216
+ var this$1 = this;
6217
+
6218
+ if (!ranges.length) { return }
6219
+ var out = [];
6220
+ for (var i = 0; i < ranges.length; i++)
6221
+ { out[i] = new Range(clipPos(this$1, ranges[i].anchor),
6222
+ clipPos(this$1, ranges[i].head)); }
6223
+ if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
6224
+ setSelection(this, normalizeSelection(this.cm, out, primary), options);
6225
+ }),
6226
+ addSelection: docMethodOp(function(anchor, head, options) {
6227
+ var ranges = this.sel.ranges.slice(0);
6228
+ ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
6229
+ setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options);
6230
+ }),
6231
+
6232
+ getSelection: function(lineSep) {
6233
+ var this$1 = this;
6234
+
6235
+ var ranges = this.sel.ranges, lines;
6236
+ for (var i = 0; i < ranges.length; i++) {
6237
+ var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
6238
+ lines = lines ? lines.concat(sel) : sel;
6239
+ }
6240
+ if (lineSep === false) { return lines }
6241
+ else { return lines.join(lineSep || this.lineSeparator()) }
6242
+ },
6243
+ getSelections: function(lineSep) {
6244
+ var this$1 = this;
6245
+
6246
+ var parts = [], ranges = this.sel.ranges;
6247
+ for (var i = 0; i < ranges.length; i++) {
6248
+ var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
6249
+ if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()); }
6250
+ parts[i] = sel;
6251
+ }
6252
+ return parts
6253
+ },
6254
+ replaceSelection: function(code, collapse, origin) {
6255
+ var dup = [];
6256
+ for (var i = 0; i < this.sel.ranges.length; i++)
6257
+ { dup[i] = code; }
6258
+ this.replaceSelections(dup, collapse, origin || "+input");
6259
+ },
6260
+ replaceSelections: docMethodOp(function(code, collapse, origin) {
6261
+ var this$1 = this;
6262
+
6263
+ var changes = [], sel = this.sel;
6264
+ for (var i = 0; i < sel.ranges.length; i++) {
6265
+ var range$$1 = sel.ranges[i];
6266
+ changes[i] = {from: range$$1.from(), to: range$$1.to(), text: this$1.splitLines(code[i]), origin: origin};
6267
+ }
6268
+ var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
6269
+ for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
6270
+ { makeChange(this$1, changes[i$1]); }
6271
+ if (newSel) { setSelectionReplaceHistory(this, newSel); }
6272
+ else if (this.cm) { ensureCursorVisible(this.cm); }
6273
+ }),
6274
+ undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
6275
+ redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
6276
+ undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
6277
+ redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
6278
+
6279
+ setExtending: function(val) {this.extend = val;},
6280
+ getExtending: function() {return this.extend},
6281
+
6282
+ historySize: function() {
6283
+ var hist = this.history, done = 0, undone = 0;
6284
+ for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } }
6285
+ for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
6286
+ return {undo: done, redo: undone}
6287
+ },
6288
+ clearHistory: function() {this.history = new History(this.history.maxGeneration);},
6289
+
6290
+ markClean: function() {
6291
+ this.cleanGeneration = this.changeGeneration(true);
6292
+ },
6293
+ changeGeneration: function(forceSplit) {
6294
+ if (forceSplit)
6295
+ { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; }
6296
+ return this.history.generation
6297
+ },
6298
+ isClean: function (gen) {
6299
+ return this.history.generation == (gen || this.cleanGeneration)
6300
+ },
6301
+
6302
+ getHistory: function() {
6303
+ return {done: copyHistoryArray(this.history.done),
6304
+ undone: copyHistoryArray(this.history.undone)}
6305
+ },
6306
+ setHistory: function(histData) {
6307
+ var hist = this.history = new History(this.history.maxGeneration);
6308
+ hist.done = copyHistoryArray(histData.done.slice(0), null, true);
6309
+ hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
6310
+ },
6311
+
6312
+ setGutterMarker: docMethodOp(function(line, gutterID, value) {
6313
+ return changeLine(this, line, "gutter", function (line) {
6314
+ var markers = line.gutterMarkers || (line.gutterMarkers = {});
6315
+ markers[gutterID] = value;
6316
+ if (!value && isEmpty(markers)) { line.gutterMarkers = null; }
6317
+ return true
6318
+ })
6319
+ }),
6320
+
6321
+ clearGutter: docMethodOp(function(gutterID) {
6322
+ var this$1 = this;
6323
+
6324
+ this.iter(function (line) {
6325
+ if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
6326
+ changeLine(this$1, line, "gutter", function () {
6327
+ line.gutterMarkers[gutterID] = null;
6328
+ if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; }
6329
+ return true
6330
+ });
6331
+ }
6332
+ });
6333
+ }),
6334
+
6335
+ lineInfo: function(line) {
6336
+ var n;
6337
+ if (typeof line == "number") {
6338
+ if (!isLine(this, line)) { return null }
6339
+ n = line;
6340
+ line = getLine(this, line);
6341
+ if (!line) { return null }
6342
+ } else {
6343
+ n = lineNo(line);
6344
+ if (n == null) { return null }
6345
+ }
6346
+ return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
6347
+ textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
6348
+ widgets: line.widgets}
6349
+ },
6350
+
6351
+ addLineClass: docMethodOp(function(handle, where, cls) {
6352
+ return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
6353
+ var prop = where == "text" ? "textClass"
6354
+ : where == "background" ? "bgClass"
6355
+ : where == "gutter" ? "gutterClass" : "wrapClass";
6356
+ if (!line[prop]) { line[prop] = cls; }
6357
+ else if (classTest(cls).test(line[prop])) { return false }
6358
+ else { line[prop] += " " + cls; }
6359
+ return true
6360
+ })
6361
+ }),
6362
+ removeLineClass: docMethodOp(function(handle, where, cls) {
6363
+ return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
6364
+ var prop = where == "text" ? "textClass"
6365
+ : where == "background" ? "bgClass"
6366
+ : where == "gutter" ? "gutterClass" : "wrapClass";
6367
+ var cur = line[prop];
6368
+ if (!cur) { return false }
6369
+ else if (cls == null) { line[prop] = null; }
6370
+ else {
6371
+ var found = cur.match(classTest(cls));
6372
+ if (!found) { return false }
6373
+ var end = found.index + found[0].length;
6374
+ line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
6375
+ }
6376
+ return true
6377
+ })
6378
+ }),
6379
+
6380
+ addLineWidget: docMethodOp(function(handle, node, options) {
6381
+ return addLineWidget(this, handle, node, options)
6382
+ }),
6383
+ removeLineWidget: function(widget) { widget.clear(); },
6384
+
6385
+ markText: function(from, to, options) {
6386
+ return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
6387
+ },
6388
+ setBookmark: function(pos, options) {
6389
+ var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
6390
+ insertLeft: options && options.insertLeft,
6391
+ clearWhenEmpty: false, shared: options && options.shared,
6392
+ handleMouseEvents: options && options.handleMouseEvents};
6393
+ pos = clipPos(this, pos);
6394
+ return markText(this, pos, pos, realOpts, "bookmark")
6395
+ },
6396
+ findMarksAt: function(pos) {
6397
+ pos = clipPos(this, pos);
6398
+ var markers = [], spans = getLine(this, pos.line).markedSpans;
6399
+ if (spans) { for (var i = 0; i < spans.length; ++i) {
6400
+ var span = spans[i];
6401
+ if ((span.from == null || span.from <= pos.ch) &&
6402
+ (span.to == null || span.to >= pos.ch))
6403
+ { markers.push(span.marker.parent || span.marker); }
6404
+ } }
6405
+ return markers
6406
+ },
6407
+ findMarks: function(from, to, filter) {
6408
+ from = clipPos(this, from); to = clipPos(this, to);
6409
+ var found = [], lineNo$$1 = from.line;
6410
+ this.iter(from.line, to.line + 1, function (line) {
6411
+ var spans = line.markedSpans;
6412
+ if (spans) { for (var i = 0; i < spans.length; i++) {
6413
+ var span = spans[i];
6414
+ if (!(span.to != null && lineNo$$1 == from.line && from.ch >= span.to ||
6415
+ span.from == null && lineNo$$1 != from.line ||
6416
+ span.from != null && lineNo$$1 == to.line && span.from >= to.ch) &&
6417
+ (!filter || filter(span.marker)))
6418
+ { found.push(span.marker.parent || span.marker); }
6419
+ } }
6420
+ ++lineNo$$1;
6421
+ });
6422
+ return found
6423
+ },
6424
+ getAllMarks: function() {
6425
+ var markers = [];
6426
+ this.iter(function (line) {
6427
+ var sps = line.markedSpans;
6428
+ if (sps) { for (var i = 0; i < sps.length; ++i)
6429
+ { if (sps[i].from != null) { markers.push(sps[i].marker); } } }
6430
+ });
6431
+ return markers
6432
+ },
6433
+
6434
+ posFromIndex: function(off) {
6435
+ var ch, lineNo$$1 = this.first, sepSize = this.lineSeparator().length;
6436
+ this.iter(function (line) {
6437
+ var sz = line.text.length + sepSize;
6438
+ if (sz > off) { ch = off; return true }
6439
+ off -= sz;
6440
+ ++lineNo$$1;
6441
+ });
6442
+ return clipPos(this, Pos(lineNo$$1, ch))
6443
+ },
6444
+ indexFromPos: function (coords) {
6445
+ coords = clipPos(this, coords);
6446
+ var index = coords.ch;
6447
+ if (coords.line < this.first || coords.ch < 0) { return 0 }
6448
+ var sepSize = this.lineSeparator().length;
6449
+ this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
6450
+ index += line.text.length + sepSize;
6451
+ });
6452
+ return index
6453
+ },
6454
+
6455
+ copy: function(copyHistory) {
6456
+ var doc = new Doc(getLines(this, this.first, this.first + this.size),
6457
+ this.modeOption, this.first, this.lineSep, this.direction);
6458
+ doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
6459
+ doc.sel = this.sel;
6460
+ doc.extend = false;
6461
+ if (copyHistory) {
6462
+ doc.history.undoDepth = this.history.undoDepth;
6463
+ doc.setHistory(this.getHistory());
6464
+ }
6465
+ return doc
6466
+ },
6467
+
6468
+ linkedDoc: function(options) {
6469
+ if (!options) { options = {}; }
6470
+ var from = this.first, to = this.first + this.size;
6471
+ if (options.from != null && options.from > from) { from = options.from; }
6472
+ if (options.to != null && options.to < to) { to = options.to; }
6473
+ var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
6474
+ if (options.sharedHist) { copy.history = this.history
6475
+ ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
6476
+ copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
6477
+ copySharedMarkers(copy, findSharedMarkers(this));
6478
+ return copy
6479
+ },
6480
+ unlinkDoc: function(other) {
6481
+ var this$1 = this;
6482
+
6483
+ if (other instanceof CodeMirror) { other = other.doc; }
6484
+ if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
6485
+ var link = this$1.linked[i];
6486
+ if (link.doc != other) { continue }
6487
+ this$1.linked.splice(i, 1);
6488
+ other.unlinkDoc(this$1);
6489
+ detachSharedMarkers(findSharedMarkers(this$1));
6490
+ break
6491
+ } }
6492
+ // If the histories were shared, split them again
6493
+ if (other.history == this.history) {
6494
+ var splitIds = [other.id];
6495
+ linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true);
6496
+ other.history = new History(null);
6497
+ other.history.done = copyHistoryArray(this.history.done, splitIds);
6498
+ other.history.undone = copyHistoryArray(this.history.undone, splitIds);
6499
+ }
6500
+ },
6501
+ iterLinkedDocs: function(f) {linkedDocs(this, f);},
6502
+
6503
+ getMode: function() {return this.mode},
6504
+ getEditor: function() {return this.cm},
6505
+
6506
+ splitLines: function(str) {
6507
+ if (this.lineSep) { return str.split(this.lineSep) }
6508
+ return splitLinesAuto(str)
6509
+ },
6510
+ lineSeparator: function() { return this.lineSep || "\n" },
6511
+
6512
+ setDirection: docMethodOp(function (dir) {
6513
+ if (dir != "rtl") { dir = "ltr"; }
6514
+ if (dir == this.direction) { return }
6515
+ this.direction = dir;
6516
+ this.iter(function (line) { return line.order = null; });
6517
+ if (this.cm) { directionChanged(this.cm); }
6518
+ })
6519
+ });
6520
+
6521
+ // Public alias.
6522
+ Doc.prototype.eachLine = Doc.prototype.iter;
6523
+
6524
+ // Kludge to work around strange IE behavior where it'll sometimes
6525
+ // re-fire a series of drag-related events right after the drop (#1551)
6526
+ var lastDrop = 0;
6527
+
6528
+ function onDrop(e) {
6529
+ var cm = this;
6530
+ clearDragCursor(cm);
6531
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
6532
+ { return }
6533
+ e_preventDefault(e);
6534
+ if (ie) { lastDrop = +new Date; }
6535
+ var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
6536
+ if (!pos || cm.isReadOnly()) { return }
6537
+ // Might be a file drop, in which case we simply extract the text
6538
+ // and insert it.
6539
+ if (files && files.length && window.FileReader && window.File) {
6540
+ var n = files.length, text = Array(n), read = 0;
6541
+ var loadFile = function (file, i) {
6542
+ if (cm.options.allowDropFileTypes &&
6543
+ indexOf(cm.options.allowDropFileTypes, file.type) == -1)
6544
+ { return }
6545
+
6546
+ var reader = new FileReader;
6547
+ reader.onload = operation(cm, function () {
6548
+ var content = reader.result;
6549
+ if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; }
6550
+ text[i] = content;
6551
+ if (++read == n) {
6552
+ pos = clipPos(cm.doc, pos);
6553
+ var change = {from: pos, to: pos,
6554
+ text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
6555
+ origin: "paste"};
6556
+ makeChange(cm.doc, change);
6557
+ setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
6558
+ }
6559
+ });
6560
+ reader.readAsText(file);
6561
+ };
6562
+ for (var i = 0; i < n; ++i) { loadFile(files[i], i); }
6563
+ } else { // Normal drop
6564
+ // Don't do a replace if the drop happened inside of the selected text.
6565
+ if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
6566
+ cm.state.draggingText(e);
6567
+ // Ensure the editor is re-focused
6568
+ setTimeout(function () { return cm.display.input.focus(); }, 20);
6569
+ return
6570
+ }
6571
+ try {
6572
+ var text$1 = e.dataTransfer.getData("Text");
6573
+ if (text$1) {
6574
+ var selected;
6575
+ if (cm.state.draggingText && !cm.state.draggingText.copy)
6576
+ { selected = cm.listSelections(); }
6577
+ setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
6578
+ if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
6579
+ { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } }
6580
+ cm.replaceSelection(text$1, "around", "paste");
6581
+ cm.display.input.focus();
6582
+ }
6583
+ }
6584
+ catch(e){}
6585
+ }
6586
+ }
6587
+
6588
+ function onDragStart(cm, e) {
6589
+ if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
6590
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
6591
+
6592
+ e.dataTransfer.setData("Text", cm.getSelection());
6593
+ e.dataTransfer.effectAllowed = "copyMove";
6594
+
6595
+ // Use dummy image instead of default browsers image.
6596
+ // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
6597
+ if (e.dataTransfer.setDragImage && !safari) {
6598
+ var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
6599
+ img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
6600
+ if (presto) {
6601
+ img.width = img.height = 1;
6602
+ cm.display.wrapper.appendChild(img);
6603
+ // Force a relayout, or Opera won't use our image for some obscure reason
6604
+ img._top = img.offsetTop;
6605
+ }
6606
+ e.dataTransfer.setDragImage(img, 0, 0);
6607
+ if (presto) { img.parentNode.removeChild(img); }
6608
+ }
6609
+ }
6610
+
6611
+ function onDragOver(cm, e) {
6612
+ var pos = posFromMouse(cm, e);
6613
+ if (!pos) { return }
6614
+ var frag = document.createDocumentFragment();
6615
+ drawSelectionCursor(cm, pos, frag);
6616
+ if (!cm.display.dragCursor) {
6617
+ cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
6618
+ cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
6619
+ }
6620
+ removeChildrenAndAdd(cm.display.dragCursor, frag);
6621
+ }
6622
+
6623
+ function clearDragCursor(cm) {
6624
+ if (cm.display.dragCursor) {
6625
+ cm.display.lineSpace.removeChild(cm.display.dragCursor);
6626
+ cm.display.dragCursor = null;
6627
+ }
6628
+ }
6629
+
6630
+ // These must be handled carefully, because naively registering a
6631
+ // handler for each editor will cause the editors to never be
6632
+ // garbage collected.
6633
+
6634
+ function forEachCodeMirror(f) {
6635
+ if (!document.getElementsByClassName) { return }
6636
+ var byClass = document.getElementsByClassName("CodeMirror"), editors = [];
6637
+ for (var i = 0; i < byClass.length; i++) {
6638
+ var cm = byClass[i].CodeMirror;
6639
+ if (cm) { editors.push(cm); }
6640
+ }
6641
+ if (editors.length) { editors[0].operation(function () {
6642
+ for (var i = 0; i < editors.length; i++) { f(editors[i]); }
6643
+ }); }
6644
+ }
6645
+
6646
+ var globalsRegistered = false;
6647
+ function ensureGlobalHandlers() {
6648
+ if (globalsRegistered) { return }
6649
+ registerGlobalHandlers();
6650
+ globalsRegistered = true;
6651
+ }
6652
+ function registerGlobalHandlers() {
6653
+ // When the window resizes, we need to refresh active editors.
6654
+ var resizeTimer;
6655
+ on(window, "resize", function () {
6656
+ if (resizeTimer == null) { resizeTimer = setTimeout(function () {
6657
+ resizeTimer = null;
6658
+ forEachCodeMirror(onResize);
6659
+ }, 100); }
6660
+ });
6661
+ // When the window loses focus, we want to show the editor as blurred
6662
+ on(window, "blur", function () { return forEachCodeMirror(onBlur); });
6663
+ }
6664
+ // Called when the window resizes
6665
+ function onResize(cm) {
6666
+ var d = cm.display;
6667
+ // Might be a text scaling operation, clear size caches.
6668
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
6669
+ d.scrollbarsClipped = false;
6670
+ cm.setSize();
6671
+ }
6672
+
6673
+ var keyNames = {
6674
+ 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
6675
+ 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
6676
+ 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
6677
+ 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
6678
+ 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock",
6679
+ 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
6680
+ 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
6681
+ 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
6682
+ };
6683
+
6684
+ // Number keys
6685
+ for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); }
6686
+ // Alphabetic keys
6687
+ for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); }
6688
+ // Function keys
6689
+ for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; }
6690
+
6691
+ var keyMap = {};
6692
+
6693
+ keyMap.basic = {
6694
+ "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
6695
+ "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
6696
+ "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
6697
+ "Tab": "defaultTab", "Shift-Tab": "indentAuto",
6698
+ "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
6699
+ "Esc": "singleSelection"
6700
+ };
6701
+ // Note that the save and find-related commands aren't defined by
6702
+ // default. User code or addons can define them. Unknown commands
6703
+ // are simply ignored.
6704
+ keyMap.pcDefault = {
6705
+ "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
6706
+ "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
6707
+ "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
6708
+ "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
6709
+ "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
6710
+ "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
6711
+ "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
6712
+ "fallthrough": "basic"
6713
+ };
6714
+ // Very basic readline/emacs-style bindings, which are standard on Mac.
6715
+ keyMap.emacsy = {
6716
+ "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
6717
+ "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
6718
+ "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
6719
+ "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
6720
+ "Ctrl-O": "openLine"
6721
+ };
6722
+ keyMap.macDefault = {
6723
+ "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
6724
+ "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
6725
+ "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
6726
+ "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
6727
+ "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
6728
+ "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
6729
+ "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
6730
+ "fallthrough": ["basic", "emacsy"]
6731
+ };
6732
+ keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
6733
+
6734
+ // KEYMAP DISPATCH
6735
+
6736
+ function normalizeKeyName(name) {
6737
+ var parts = name.split(/-(?!$)/);
6738
+ name = parts[parts.length - 1];
6739
+ var alt, ctrl, shift, cmd;
6740
+ for (var i = 0; i < parts.length - 1; i++) {
6741
+ var mod = parts[i];
6742
+ if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }
6743
+ else if (/^a(lt)?$/i.test(mod)) { alt = true; }
6744
+ else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }
6745
+ else if (/^s(hift)?$/i.test(mod)) { shift = true; }
6746
+ else { throw new Error("Unrecognized modifier name: " + mod) }
6747
+ }
6748
+ if (alt) { name = "Alt-" + name; }
6749
+ if (ctrl) { name = "Ctrl-" + name; }
6750
+ if (cmd) { name = "Cmd-" + name; }
6751
+ if (shift) { name = "Shift-" + name; }
6752
+ return name
6753
+ }
6754
+
6755
+ // This is a kludge to keep keymaps mostly working as raw objects
6756
+ // (backwards compatibility) while at the same time support features
6757
+ // like normalization and multi-stroke key bindings. It compiles a
6758
+ // new normalized keymap, and then updates the old object to reflect
6759
+ // this.
6760
+ function normalizeKeyMap(keymap) {
6761
+ var copy = {};
6762
+ for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
6763
+ var value = keymap[keyname];
6764
+ if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
6765
+ if (value == "...") { delete keymap[keyname]; continue }
6766
+
6767
+ var keys = map(keyname.split(" "), normalizeKeyName);
6768
+ for (var i = 0; i < keys.length; i++) {
6769
+ var val = (void 0), name = (void 0);
6770
+ if (i == keys.length - 1) {
6771
+ name = keys.join(" ");
6772
+ val = value;
6773
+ } else {
6774
+ name = keys.slice(0, i + 1).join(" ");
6775
+ val = "...";
6776
+ }
6777
+ var prev = copy[name];
6778
+ if (!prev) { copy[name] = val; }
6779
+ else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
6780
+ }
6781
+ delete keymap[keyname];
6782
+ } }
6783
+ for (var prop in copy) { keymap[prop] = copy[prop]; }
6784
+ return keymap
6785
+ }
6786
+
6787
+ function lookupKey(key, map$$1, handle, context) {
6788
+ map$$1 = getKeyMap(map$$1);
6789
+ var found = map$$1.call ? map$$1.call(key, context) : map$$1[key];
6790
+ if (found === false) { return "nothing" }
6791
+ if (found === "...") { return "multi" }
6792
+ if (found != null && handle(found)) { return "handled" }
6793
+
6794
+ if (map$$1.fallthrough) {
6795
+ if (Object.prototype.toString.call(map$$1.fallthrough) != "[object Array]")
6796
+ { return lookupKey(key, map$$1.fallthrough, handle, context) }
6797
+ for (var i = 0; i < map$$1.fallthrough.length; i++) {
6798
+ var result = lookupKey(key, map$$1.fallthrough[i], handle, context);
6799
+ if (result) { return result }
6800
+ }
6801
+ }
6802
+ }
6803
+
6804
+ // Modifier key presses don't count as 'real' key presses for the
6805
+ // purpose of keymap fallthrough.
6806
+ function isModifierKey(value) {
6807
+ var name = typeof value == "string" ? value : keyNames[value.keyCode];
6808
+ return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
6809
+ }
6810
+
6811
+ function addModifierNames(name, event, noShift) {
6812
+ var base = name;
6813
+ if (event.altKey && base != "Alt") { name = "Alt-" + name; }
6814
+ if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
6815
+ if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; }
6816
+ if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
6817
+ return name
6818
+ }
6819
+
6820
+ // Look up the name of a key as indicated by an event object.
6821
+ function keyName(event, noShift) {
6822
+ if (presto && event.keyCode == 34 && event["char"]) { return false }
6823
+ var name = keyNames[event.keyCode];
6824
+ if (name == null || event.altGraphKey) { return false }
6825
+ // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
6826
+ // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
6827
+ if (event.keyCode == 3 && event.code) { name = event.code; }
6828
+ return addModifierNames(name, event, noShift)
6829
+ }
6830
+
6831
+ function getKeyMap(val) {
6832
+ return typeof val == "string" ? keyMap[val] : val
6833
+ }
6834
+
6835
+ // Helper for deleting text near the selection(s), used to implement
6836
+ // backspace, delete, and similar functionality.
6837
+ function deleteNearSelection(cm, compute) {
6838
+ var ranges = cm.doc.sel.ranges, kill = [];
6839
+ // Build up a set of ranges to kill first, merging overlapping
6840
+ // ranges.
6841
+ for (var i = 0; i < ranges.length; i++) {
6842
+ var toKill = compute(ranges[i]);
6843
+ while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
6844
+ var replaced = kill.pop();
6845
+ if (cmp(replaced.from, toKill.from) < 0) {
6846
+ toKill.from = replaced.from;
6847
+ break
6848
+ }
6849
+ }
6850
+ kill.push(toKill);
6851
+ }
6852
+ // Next, remove those actual ranges.
6853
+ runInOp(cm, function () {
6854
+ for (var i = kill.length - 1; i >= 0; i--)
6855
+ { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); }
6856
+ ensureCursorVisible(cm);
6857
+ });
6858
+ }
6859
+
6860
+ function moveCharLogically(line, ch, dir) {
6861
+ var target = skipExtendingChars(line.text, ch + dir, dir);
6862
+ return target < 0 || target > line.text.length ? null : target
6863
+ }
6864
+
6865
+ function moveLogically(line, start, dir) {
6866
+ var ch = moveCharLogically(line, start.ch, dir);
6867
+ return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
6868
+ }
6869
+
6870
+ function endOfLine(visually, cm, lineObj, lineNo, dir) {
6871
+ if (visually) {
6872
+ var order = getOrder(lineObj, cm.doc.direction);
6873
+ if (order) {
6874
+ var part = dir < 0 ? lst(order) : order[0];
6875
+ var moveInStorageOrder = (dir < 0) == (part.level == 1);
6876
+ var sticky = moveInStorageOrder ? "after" : "before";
6877
+ var ch;
6878
+ // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
6879
+ // it could be that the last bidi part is not on the last visual line,
6880
+ // since visual lines contain content order-consecutive chunks.
6881
+ // Thus, in rtl, we are looking for the first (content-order) character
6882
+ // in the rtl chunk that is on the last line (that is, the same line
6883
+ // as the last (content-order) character).
6884
+ if (part.level > 0 || cm.doc.direction == "rtl") {
6885
+ var prep = prepareMeasureForLine(cm, lineObj);
6886
+ ch = dir < 0 ? lineObj.text.length - 1 : 0;
6887
+ var targetTop = measureCharPrepared(cm, prep, ch).top;
6888
+ ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch);
6889
+ if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); }
6890
+ } else { ch = dir < 0 ? part.to : part.from; }
6891
+ return new Pos(lineNo, ch, sticky)
6892
+ }
6893
+ }
6894
+ return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
6895
+ }
6896
+
6897
+ function moveVisually(cm, line, start, dir) {
6898
+ var bidi = getOrder(line, cm.doc.direction);
6899
+ if (!bidi) { return moveLogically(line, start, dir) }
6900
+ if (start.ch >= line.text.length) {
6901
+ start.ch = line.text.length;
6902
+ start.sticky = "before";
6903
+ } else if (start.ch <= 0) {
6904
+ start.ch = 0;
6905
+ start.sticky = "after";
6906
+ }
6907
+ var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];
6908
+ if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
6909
+ // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
6910
+ // nothing interesting happens.
6911
+ return moveLogically(line, start, dir)
6912
+ }
6913
+
6914
+ var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); };
6915
+ var prep;
6916
+ var getWrappedLineExtent = function (ch) {
6917
+ if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
6918
+ prep = prep || prepareMeasureForLine(cm, line);
6919
+ return wrappedLineExtentChar(cm, line, prep, ch)
6920
+ };
6921
+ var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
6922
+
6923
+ if (cm.doc.direction == "rtl" || part.level == 1) {
6924
+ var moveInStorageOrder = (part.level == 1) == (dir < 0);
6925
+ var ch = mv(start, moveInStorageOrder ? 1 : -1);
6926
+ if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
6927
+ // Case 2: We move within an rtl part or in an rtl editor on the same visual line
6928
+ var sticky = moveInStorageOrder ? "before" : "after";
6929
+ return new Pos(start.line, ch, sticky)
6930
+ }
6931
+ }
6932
+
6933
+ // Case 3: Could not move within this bidi part in this visual line, so leave
6934
+ // the current bidi part
6935
+
6936
+ var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
6937
+ var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
6938
+ ? new Pos(start.line, mv(ch, 1), "before")
6939
+ : new Pos(start.line, ch, "after"); };
6940
+
6941
+ for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
6942
+ var part = bidi[partPos];
6943
+ var moveInStorageOrder = (dir > 0) == (part.level != 1);
6944
+ var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);
6945
+ if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
6946
+ ch = moveInStorageOrder ? part.from : mv(part.to, -1);
6947
+ if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
6948
+ }
6949
+ };
6950
+
6951
+ // Case 3a: Look for other bidi parts on the same visual line
6952
+ var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);
6953
+ if (res) { return res }
6954
+
6955
+ // Case 3b: Look for other bidi parts on the next visual line
6956
+ var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);
6957
+ if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
6958
+ res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
6959
+ if (res) { return res }
6960
+ }
6961
+
6962
+ // Case 4: Nowhere to move
6963
+ return null
6964
+ }
6965
+
6966
+ // Commands are parameter-less actions that can be performed on an
6967
+ // editor, mostly used for keybindings.
6968
+ var commands = {
6969
+ selectAll: selectAll,
6970
+ singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
6971
+ killLine: function (cm) { return deleteNearSelection(cm, function (range) {
6972
+ if (range.empty()) {
6973
+ var len = getLine(cm.doc, range.head.line).text.length;
6974
+ if (range.head.ch == len && range.head.line < cm.lastLine())
6975
+ { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
6976
+ else
6977
+ { return {from: range.head, to: Pos(range.head.line, len)} }
6978
+ } else {
6979
+ return {from: range.from(), to: range.to()}
6980
+ }
6981
+ }); },
6982
+ deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
6983
+ from: Pos(range.from().line, 0),
6984
+ to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
6985
+ }); }); },
6986
+ delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
6987
+ from: Pos(range.from().line, 0), to: range.from()
6988
+ }); }); },
6989
+ delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
6990
+ var top = cm.charCoords(range.head, "div").top + 5;
6991
+ var leftPos = cm.coordsChar({left: 0, top: top}, "div");
6992
+ return {from: leftPos, to: range.from()}
6993
+ }); },
6994
+ delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
6995
+ var top = cm.charCoords(range.head, "div").top + 5;
6996
+ var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
6997
+ return {from: range.from(), to: rightPos }
6998
+ }); },
6999
+ undo: function (cm) { return cm.undo(); },
7000
+ redo: function (cm) { return cm.redo(); },
7001
+ undoSelection: function (cm) { return cm.undoSelection(); },
7002
+ redoSelection: function (cm) { return cm.redoSelection(); },
7003
+ goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
7004
+ goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
7005
+ goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
7006
+ {origin: "+move", bias: 1}
7007
+ ); },
7008
+ goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
7009
+ {origin: "+move", bias: 1}
7010
+ ); },
7011
+ goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
7012
+ {origin: "+move", bias: -1}
7013
+ ); },
7014
+ goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
7015
+ var top = cm.cursorCoords(range.head, "div").top + 5;
7016
+ return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
7017
+ }, sel_move); },
7018
+ goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
7019
+ var top = cm.cursorCoords(range.head, "div").top + 5;
7020
+ return cm.coordsChar({left: 0, top: top}, "div")
7021
+ }, sel_move); },
7022
+ goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
7023
+ var top = cm.cursorCoords(range.head, "div").top + 5;
7024
+ var pos = cm.coordsChar({left: 0, top: top}, "div");
7025
+ if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
7026
+ return pos
7027
+ }, sel_move); },
7028
+ goLineUp: function (cm) { return cm.moveV(-1, "line"); },
7029
+ goLineDown: function (cm) { return cm.moveV(1, "line"); },
7030
+ goPageUp: function (cm) { return cm.moveV(-1, "page"); },
7031
+ goPageDown: function (cm) { return cm.moveV(1, "page"); },
7032
+ goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
7033
+ goCharRight: function (cm) { return cm.moveH(1, "char"); },
7034
+ goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
7035
+ goColumnRight: function (cm) { return cm.moveH(1, "column"); },
7036
+ goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
7037
+ goGroupRight: function (cm) { return cm.moveH(1, "group"); },
7038
+ goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
7039
+ goWordRight: function (cm) { return cm.moveH(1, "word"); },
7040
+ delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
7041
+ delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
7042
+ delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
7043
+ delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
7044
+ delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
7045
+ delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
7046
+ indentAuto: function (cm) { return cm.indentSelection("smart"); },
7047
+ indentMore: function (cm) { return cm.indentSelection("add"); },
7048
+ indentLess: function (cm) { return cm.indentSelection("subtract"); },
7049
+ insertTab: function (cm) { return cm.replaceSelection("\t"); },
7050
+ insertSoftTab: function (cm) {
7051
+ var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
7052
+ for (var i = 0; i < ranges.length; i++) {
7053
+ var pos = ranges[i].from();
7054
+ var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
7055
+ spaces.push(spaceStr(tabSize - col % tabSize));
7056
+ }
7057
+ cm.replaceSelections(spaces);
7058
+ },
7059
+ defaultTab: function (cm) {
7060
+ if (cm.somethingSelected()) { cm.indentSelection("add"); }
7061
+ else { cm.execCommand("insertTab"); }
7062
+ },
7063
+ // Swap the two chars left and right of each selection's head.
7064
+ // Move cursor behind the two swapped characters afterwards.
7065
+ //
7066
+ // Doesn't consider line feeds a character.
7067
+ // Doesn't scan more than one line above to find a character.
7068
+ // Doesn't do anything on an empty line.
7069
+ // Doesn't do anything with non-empty selections.
7070
+ transposeChars: function (cm) { return runInOp(cm, function () {
7071
+ var ranges = cm.listSelections(), newSel = [];
7072
+ for (var i = 0; i < ranges.length; i++) {
7073
+ if (!ranges[i].empty()) { continue }
7074
+ var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
7075
+ if (line) {
7076
+ if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }
7077
+ if (cur.ch > 0) {
7078
+ cur = new Pos(cur.line, cur.ch + 1);
7079
+ cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
7080
+ Pos(cur.line, cur.ch - 2), cur, "+transpose");
7081
+ } else if (cur.line > cm.doc.first) {
7082
+ var prev = getLine(cm.doc, cur.line - 1).text;
7083
+ if (prev) {
7084
+ cur = new Pos(cur.line, 1);
7085
+ cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
7086
+ prev.charAt(prev.length - 1),
7087
+ Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
7088
+ }
7089
+ }
7090
+ }
7091
+ newSel.push(new Range(cur, cur));
7092
+ }
7093
+ cm.setSelections(newSel);
7094
+ }); },
7095
+ newlineAndIndent: function (cm) { return runInOp(cm, function () {
7096
+ var sels = cm.listSelections();
7097
+ for (var i = sels.length - 1; i >= 0; i--)
7098
+ { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); }
7099
+ sels = cm.listSelections();
7100
+ for (var i$1 = 0; i$1 < sels.length; i$1++)
7101
+ { cm.indentLine(sels[i$1].from().line, null, true); }
7102
+ ensureCursorVisible(cm);
7103
+ }); },
7104
+ openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
7105
+ toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
7106
+ };
7107
+
7108
+
7109
+ function lineStart(cm, lineN) {
7110
+ var line = getLine(cm.doc, lineN);
7111
+ var visual = visualLine(line);
7112
+ if (visual != line) { lineN = lineNo(visual); }
7113
+ return endOfLine(true, cm, visual, lineN, 1)
7114
+ }
7115
+ function lineEnd(cm, lineN) {
7116
+ var line = getLine(cm.doc, lineN);
7117
+ var visual = visualLineEnd(line);
7118
+ if (visual != line) { lineN = lineNo(visual); }
7119
+ return endOfLine(true, cm, line, lineN, -1)
7120
+ }
7121
+ function lineStartSmart(cm, pos) {
7122
+ var start = lineStart(cm, pos.line);
7123
+ var line = getLine(cm.doc, start.line);
7124
+ var order = getOrder(line, cm.doc.direction);
7125
+ if (!order || order[0].level == 0) {
7126
+ var firstNonWS = Math.max(0, line.text.search(/\S/));
7127
+ var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
7128
+ return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
7129
+ }
7130
+ return start
7131
+ }
7132
+
7133
+ // Run a handler that was bound to a key.
7134
+ function doHandleBinding(cm, bound, dropShift) {
7135
+ if (typeof bound == "string") {
7136
+ bound = commands[bound];
7137
+ if (!bound) { return false }
7138
+ }
7139
+ // Ensure previous input has been read, so that the handler sees a
7140
+ // consistent view of the document
7141
+ cm.display.input.ensurePolled();
7142
+ var prevShift = cm.display.shift, done = false;
7143
+ try {
7144
+ if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
7145
+ if (dropShift) { cm.display.shift = false; }
7146
+ done = bound(cm) != Pass;
7147
+ } finally {
7148
+ cm.display.shift = prevShift;
7149
+ cm.state.suppressEdits = false;
7150
+ }
7151
+ return done
7152
+ }
7153
+
7154
+ function lookupKeyForEditor(cm, name, handle) {
7155
+ for (var i = 0; i < cm.state.keyMaps.length; i++) {
7156
+ var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
7157
+ if (result) { return result }
7158
+ }
7159
+ return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
7160
+ || lookupKey(name, cm.options.keyMap, handle, cm)
7161
+ }
7162
+
7163
+ // Note that, despite the name, this function is also used to check
7164
+ // for bound mouse clicks.
7165
+
7166
+ var stopSeq = new Delayed;
7167
+
7168
+ function dispatchKey(cm, name, e, handle) {
7169
+ var seq = cm.state.keySeq;
7170
+ if (seq) {
7171
+ if (isModifierKey(name)) { return "handled" }
7172
+ if (/\'$/.test(name))
7173
+ { cm.state.keySeq = null; }
7174
+ else
7175
+ { stopSeq.set(50, function () {
7176
+ if (cm.state.keySeq == seq) {
7177
+ cm.state.keySeq = null;
7178
+ cm.display.input.reset();
7179
+ }
7180
+ }); }
7181
+ if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true }
7182
+ }
7183
+ return dispatchKeyInner(cm, name, e, handle)
7184
+ }
7185
+
7186
+ function dispatchKeyInner(cm, name, e, handle) {
7187
+ var result = lookupKeyForEditor(cm, name, handle);
7188
+
7189
+ if (result == "multi")
7190
+ { cm.state.keySeq = name; }
7191
+ if (result == "handled")
7192
+ { signalLater(cm, "keyHandled", cm, name, e); }
7193
+
7194
+ if (result == "handled" || result == "multi") {
7195
+ e_preventDefault(e);
7196
+ restartBlink(cm);
7197
+ }
7198
+
7199
+ return !!result
7200
+ }
7201
+
7202
+ // Handle a key from the keydown event.
7203
+ function handleKeyBinding(cm, e) {
7204
+ var name = keyName(e, true);
7205
+ if (!name) { return false }
7206
+
7207
+ if (e.shiftKey && !cm.state.keySeq) {
7208
+ // First try to resolve full name (including 'Shift-'). Failing
7209
+ // that, see if there is a cursor-motion command (starting with
7210
+ // 'go') bound to the keyname without 'Shift-'.
7211
+ return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
7212
+ || dispatchKey(cm, name, e, function (b) {
7213
+ if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
7214
+ { return doHandleBinding(cm, b) }
7215
+ })
7216
+ } else {
7217
+ return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
7218
+ }
7219
+ }
7220
+
7221
+ // Handle a key from the keypress event
7222
+ function handleCharBinding(cm, e, ch) {
7223
+ return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
7224
+ }
7225
+
7226
+ var lastStoppedKey = null;
7227
+ function onKeyDown(e) {
7228
+ var cm = this;
7229
+ cm.curOp.focus = activeElt();
7230
+ if (signalDOMEvent(cm, e)) { return }
7231
+ // IE does strange things with escape.
7232
+ if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
7233
+ var code = e.keyCode;
7234
+ cm.display.shift = code == 16 || e.shiftKey;
7235
+ var handled = handleKeyBinding(cm, e);
7236
+ if (presto) {
7237
+ lastStoppedKey = handled ? code : null;
7238
+ // Opera has no cut event... we try to at least catch the key combo
7239
+ if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
7240
+ { cm.replaceSelection("", null, "cut"); }
7241
+ }
7242
+
7243
+ // Turn mouse into crosshair when Alt is held on Mac.
7244
+ if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
7245
+ { showCrossHair(cm); }
7246
+ }
7247
+
7248
+ function showCrossHair(cm) {
7249
+ var lineDiv = cm.display.lineDiv;
7250
+ addClass(lineDiv, "CodeMirror-crosshair");
7251
+
7252
+ function up(e) {
7253
+ if (e.keyCode == 18 || !e.altKey) {
7254
+ rmClass(lineDiv, "CodeMirror-crosshair");
7255
+ off(document, "keyup", up);
7256
+ off(document, "mouseover", up);
7257
+ }
7258
+ }
7259
+ on(document, "keyup", up);
7260
+ on(document, "mouseover", up);
7261
+ }
7262
+
7263
+ function onKeyUp(e) {
7264
+ if (e.keyCode == 16) { this.doc.sel.shift = false; }
7265
+ signalDOMEvent(this, e);
7266
+ }
7267
+
7268
+ function onKeyPress(e) {
7269
+ var cm = this;
7270
+ if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
7271
+ var keyCode = e.keyCode, charCode = e.charCode;
7272
+ if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
7273
+ if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
7274
+ var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
7275
+ // Some browsers fire keypress events for backspace
7276
+ if (ch == "\x08") { return }
7277
+ if (handleCharBinding(cm, e, ch)) { return }
7278
+ cm.display.input.onKeyPress(e);
7279
+ }
7280
+
7281
+ var DOUBLECLICK_DELAY = 400;
7282
+
7283
+ var PastClick = function(time, pos, button) {
7284
+ this.time = time;
7285
+ this.pos = pos;
7286
+ this.button = button;
7287
+ };
7288
+
7289
+ PastClick.prototype.compare = function (time, pos, button) {
7290
+ return this.time + DOUBLECLICK_DELAY > time &&
7291
+ cmp(pos, this.pos) == 0 && button == this.button
7292
+ };
7293
+
7294
+ var lastClick, lastDoubleClick;
7295
+ function clickRepeat(pos, button) {
7296
+ var now = +new Date;
7297
+ if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
7298
+ lastClick = lastDoubleClick = null;
7299
+ return "triple"
7300
+ } else if (lastClick && lastClick.compare(now, pos, button)) {
7301
+ lastDoubleClick = new PastClick(now, pos, button);
7302
+ lastClick = null;
7303
+ return "double"
7304
+ } else {
7305
+ lastClick = new PastClick(now, pos, button);
7306
+ lastDoubleClick = null;
7307
+ return "single"
7308
+ }
7309
+ }
7310
+
7311
+ // A mouse down can be a single click, double click, triple click,
7312
+ // start of selection drag, start of text drag, new cursor
7313
+ // (ctrl-click), rectangle drag (alt-drag), or xwin
7314
+ // middle-click-paste. Or it might be a click on something we should
7315
+ // not interfere with, such as a scrollbar or widget.
7316
+ function onMouseDown(e) {
7317
+ var cm = this, display = cm.display;
7318
+ if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
7319
+ display.input.ensurePolled();
7320
+ display.shift = e.shiftKey;
7321
+
7322
+ if (eventInWidget(display, e)) {
7323
+ if (!webkit) {
7324
+ // Briefly turn off draggability, to allow widgets to do
7325
+ // normal dragging things.
7326
+ display.scroller.draggable = false;
7327
+ setTimeout(function () { return display.scroller.draggable = true; }, 100);
7328
+ }
7329
+ return
7330
+ }
7331
+ if (clickInGutter(cm, e)) { return }
7332
+ var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
7333
+ window.focus();
7334
+
7335
+ // #3261: make sure, that we're not starting a second selection
7336
+ if (button == 1 && cm.state.selectingText)
7337
+ { cm.state.selectingText(e); }
7338
+
7339
+ if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }
7340
+
7341
+ if (button == 1) {
7342
+ if (pos) { leftButtonDown(cm, pos, repeat, e); }
7343
+ else if (e_target(e) == display.scroller) { e_preventDefault(e); }
7344
+ } else if (button == 2) {
7345
+ if (pos) { extendSelection(cm.doc, pos); }
7346
+ setTimeout(function () { return display.input.focus(); }, 20);
7347
+ } else if (button == 3) {
7348
+ if (captureRightClick) { cm.display.input.onContextMenu(e); }
7349
+ else { delayBlurEvent(cm); }
7350
+ }
7351
+ }
7352
+
7353
+ function handleMappedButton(cm, button, pos, repeat, event) {
7354
+ var name = "Click";
7355
+ if (repeat == "double") { name = "Double" + name; }
7356
+ else if (repeat == "triple") { name = "Triple" + name; }
7357
+ name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
7358
+
7359
+ return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
7360
+ if (typeof bound == "string") { bound = commands[bound]; }
7361
+ if (!bound) { return false }
7362
+ var done = false;
7363
+ try {
7364
+ if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
7365
+ done = bound(cm, pos) != Pass;
7366
+ } finally {
7367
+ cm.state.suppressEdits = false;
7368
+ }
7369
+ return done
7370
+ })
7371
+ }
7372
+
7373
+ function configureMouse(cm, repeat, event) {
7374
+ var option = cm.getOption("configureMouse");
7375
+ var value = option ? option(cm, repeat, event) : {};
7376
+ if (value.unit == null) {
7377
+ var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
7378
+ value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
7379
+ }
7380
+ if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; }
7381
+ if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; }
7382
+ if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); }
7383
+ return value
7384
+ }
7385
+
7386
+ function leftButtonDown(cm, pos, repeat, event) {
7387
+ if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
7388
+ else { cm.curOp.focus = activeElt(); }
7389
+
7390
+ var behavior = configureMouse(cm, repeat, event);
7391
+
7392
+ var sel = cm.doc.sel, contained;
7393
+ if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
7394
+ repeat == "single" && (contained = sel.contains(pos)) > -1 &&
7395
+ (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
7396
+ (cmp(contained.to(), pos) > 0 || pos.xRel < 0))
7397
+ { leftButtonStartDrag(cm, event, pos, behavior); }
7398
+ else
7399
+ { leftButtonSelect(cm, event, pos, behavior); }
7400
+ }
7401
+
7402
+ // Start a text drag. When it ends, see if any dragging actually
7403
+ // happen, and treat as a click if it didn't.
7404
+ function leftButtonStartDrag(cm, event, pos, behavior) {
7405
+ var display = cm.display, moved = false;
7406
+ var dragEnd = operation(cm, function (e) {
7407
+ if (webkit) { display.scroller.draggable = false; }
7408
+ cm.state.draggingText = false;
7409
+ off(display.wrapper.ownerDocument, "mouseup", dragEnd);
7410
+ off(display.wrapper.ownerDocument, "mousemove", mouseMove);
7411
+ off(display.scroller, "dragstart", dragStart);
7412
+ off(display.scroller, "drop", dragEnd);
7413
+ if (!moved) {
7414
+ e_preventDefault(e);
7415
+ if (!behavior.addNew)
7416
+ { extendSelection(cm.doc, pos, null, null, behavior.extend); }
7417
+ // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
7418
+ if (webkit || ie && ie_version == 9)
7419
+ { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }
7420
+ else
7421
+ { display.input.focus(); }
7422
+ }
7423
+ });
7424
+ var mouseMove = function(e2) {
7425
+ moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
7426
+ };
7427
+ var dragStart = function () { return moved = true; };
7428
+ // Let the drag handler handle this.
7429
+ if (webkit) { display.scroller.draggable = true; }
7430
+ cm.state.draggingText = dragEnd;
7431
+ dragEnd.copy = !behavior.moveOnDrag;
7432
+ // IE's approach to draggable
7433
+ if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
7434
+ on(display.wrapper.ownerDocument, "mouseup", dragEnd);
7435
+ on(display.wrapper.ownerDocument, "mousemove", mouseMove);
7436
+ on(display.scroller, "dragstart", dragStart);
7437
+ on(display.scroller, "drop", dragEnd);
7438
+
7439
+ delayBlurEvent(cm);
7440
+ setTimeout(function () { return display.input.focus(); }, 20);
7441
+ }
7442
+
7443
+ function rangeForUnit(cm, pos, unit) {
7444
+ if (unit == "char") { return new Range(pos, pos) }
7445
+ if (unit == "word") { return cm.findWordAt(pos) }
7446
+ if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
7447
+ var result = unit(cm, pos);
7448
+ return new Range(result.from, result.to)
7449
+ }
7450
+
7451
+ // Normal selection, as opposed to text dragging.
7452
+ function leftButtonSelect(cm, event, start, behavior) {
7453
+ var display = cm.display, doc = cm.doc;
7454
+ e_preventDefault(event);
7455
+
7456
+ var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
7457
+ if (behavior.addNew && !behavior.extend) {
7458
+ ourIndex = doc.sel.contains(start);
7459
+ if (ourIndex > -1)
7460
+ { ourRange = ranges[ourIndex]; }
7461
+ else
7462
+ { ourRange = new Range(start, start); }
7463
+ } else {
7464
+ ourRange = doc.sel.primary();
7465
+ ourIndex = doc.sel.primIndex;
7466
+ }
7467
+
7468
+ if (behavior.unit == "rectangle") {
7469
+ if (!behavior.addNew) { ourRange = new Range(start, start); }
7470
+ start = posFromMouse(cm, event, true, true);
7471
+ ourIndex = -1;
7472
+ } else {
7473
+ var range$$1 = rangeForUnit(cm, start, behavior.unit);
7474
+ if (behavior.extend)
7475
+ { ourRange = extendRange(ourRange, range$$1.anchor, range$$1.head, behavior.extend); }
7476
+ else
7477
+ { ourRange = range$$1; }
7478
+ }
7479
+
7480
+ if (!behavior.addNew) {
7481
+ ourIndex = 0;
7482
+ setSelection(doc, new Selection([ourRange], 0), sel_mouse);
7483
+ startSel = doc.sel;
7484
+ } else if (ourIndex == -1) {
7485
+ ourIndex = ranges.length;
7486
+ setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
7487
+ {scroll: false, origin: "*mouse"});
7488
+ } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
7489
+ setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
7490
+ {scroll: false, origin: "*mouse"});
7491
+ startSel = doc.sel;
7492
+ } else {
7493
+ replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
7494
+ }
7495
+
7496
+ var lastPos = start;
7497
+ function extendTo(pos) {
7498
+ if (cmp(lastPos, pos) == 0) { return }
7499
+ lastPos = pos;
7500
+
7501
+ if (behavior.unit == "rectangle") {
7502
+ var ranges = [], tabSize = cm.options.tabSize;
7503
+ var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
7504
+ var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
7505
+ var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
7506
+ for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
7507
+ line <= end; line++) {
7508
+ var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
7509
+ if (left == right)
7510
+ { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
7511
+ else if (text.length > leftPos)
7512
+ { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
7513
+ }
7514
+ if (!ranges.length) { ranges.push(new Range(start, start)); }
7515
+ setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
7516
+ {origin: "*mouse", scroll: false});
7517
+ cm.scrollIntoView(pos);
7518
+ } else {
7519
+ var oldRange = ourRange;
7520
+ var range$$1 = rangeForUnit(cm, pos, behavior.unit);
7521
+ var anchor = oldRange.anchor, head;
7522
+ if (cmp(range$$1.anchor, anchor) > 0) {
7523
+ head = range$$1.head;
7524
+ anchor = minPos(oldRange.from(), range$$1.anchor);
7525
+ } else {
7526
+ head = range$$1.anchor;
7527
+ anchor = maxPos(oldRange.to(), range$$1.head);
7528
+ }
7529
+ var ranges$1 = startSel.ranges.slice(0);
7530
+ ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
7531
+ setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
7532
+ }
7533
+ }
7534
+
7535
+ var editorSize = display.wrapper.getBoundingClientRect();
7536
+ // Used to ensure timeout re-tries don't fire when another extend
7537
+ // happened in the meantime (clearTimeout isn't reliable -- at
7538
+ // least on Chrome, the timeouts still happen even when cleared,
7539
+ // if the clear happens after their scheduled firing time).
7540
+ var counter = 0;
7541
+
7542
+ function extend(e) {
7543
+ var curCount = ++counter;
7544
+ var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
7545
+ if (!cur) { return }
7546
+ if (cmp(cur, lastPos) != 0) {
7547
+ cm.curOp.focus = activeElt();
7548
+ extendTo(cur);
7549
+ var visible = visibleLines(display, doc);
7550
+ if (cur.line >= visible.to || cur.line < visible.from)
7551
+ { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
7552
+ } else {
7553
+ var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
7554
+ if (outside) { setTimeout(operation(cm, function () {
7555
+ if (counter != curCount) { return }
7556
+ display.scroller.scrollTop += outside;
7557
+ extend(e);
7558
+ }), 50); }
7559
+ }
7560
+ }
7561
+
7562
+ function done(e) {
7563
+ cm.state.selectingText = false;
7564
+ counter = Infinity;
7565
+ // If e is null or undefined we interpret this as someone trying
7566
+ // to explicitly cancel the selection rather than the user
7567
+ // letting go of the mouse button.
7568
+ if (e) {
7569
+ e_preventDefault(e);
7570
+ display.input.focus();
7571
+ }
7572
+ off(display.wrapper.ownerDocument, "mousemove", move);
7573
+ off(display.wrapper.ownerDocument, "mouseup", up);
7574
+ doc.history.lastSelOrigin = null;
7575
+ }
7576
+
7577
+ var move = operation(cm, function (e) {
7578
+ if (e.buttons === 0 || !e_button(e)) { done(e); }
7579
+ else { extend(e); }
7580
+ });
7581
+ var up = operation(cm, done);
7582
+ cm.state.selectingText = up;
7583
+ on(display.wrapper.ownerDocument, "mousemove", move);
7584
+ on(display.wrapper.ownerDocument, "mouseup", up);
7585
+ }
7586
+
7587
+ // Used when mouse-selecting to adjust the anchor to the proper side
7588
+ // of a bidi jump depending on the visual position of the head.
7589
+ function bidiSimplify(cm, range$$1) {
7590
+ var anchor = range$$1.anchor;
7591
+ var head = range$$1.head;
7592
+ var anchorLine = getLine(cm.doc, anchor.line);
7593
+ if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range$$1 }
7594
+ var order = getOrder(anchorLine);
7595
+ if (!order) { return range$$1 }
7596
+ var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];
7597
+ if (part.from != anchor.ch && part.to != anchor.ch) { return range$$1 }
7598
+ var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1);
7599
+ if (boundary == 0 || boundary == order.length) { return range$$1 }
7600
+
7601
+ // Compute the relative visual position of the head compared to the
7602
+ // anchor (<0 is to the left, >0 to the right)
7603
+ var leftSide;
7604
+ if (head.line != anchor.line) {
7605
+ leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
7606
+ } else {
7607
+ var headIndex = getBidiPartAt(order, head.ch, head.sticky);
7608
+ var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
7609
+ if (headIndex == boundary - 1 || headIndex == boundary)
7610
+ { leftSide = dir < 0; }
7611
+ else
7612
+ { leftSide = dir > 0; }
7613
+ }
7614
+
7615
+ var usePart = order[boundary + (leftSide ? -1 : 0)];
7616
+ var from = leftSide == (usePart.level == 1);
7617
+ var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before";
7618
+ return anchor.ch == ch && anchor.sticky == sticky ? range$$1 : new Range(new Pos(anchor.line, ch, sticky), head)
7619
+ }
7620
+
7621
+
7622
+ // Determines whether an event happened in the gutter, and fires the
7623
+ // handlers for the corresponding event.
7624
+ function gutterEvent(cm, e, type, prevent) {
7625
+ var mX, mY;
7626
+ if (e.touches) {
7627
+ mX = e.touches[0].clientX;
7628
+ mY = e.touches[0].clientY;
7629
+ } else {
7630
+ try { mX = e.clientX; mY = e.clientY; }
7631
+ catch(e) { return false }
7632
+ }
7633
+ if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
7634
+ if (prevent) { e_preventDefault(e); }
7635
+
7636
+ var display = cm.display;
7637
+ var lineBox = display.lineDiv.getBoundingClientRect();
7638
+
7639
+ if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
7640
+ mY -= lineBox.top - display.viewOffset;
7641
+
7642
+ for (var i = 0; i < cm.display.gutterSpecs.length; ++i) {
7643
+ var g = display.gutters.childNodes[i];
7644
+ if (g && g.getBoundingClientRect().right >= mX) {
7645
+ var line = lineAtHeight(cm.doc, mY);
7646
+ var gutter = cm.display.gutterSpecs[i];
7647
+ signal(cm, type, cm, line, gutter.className, e);
7648
+ return e_defaultPrevented(e)
7649
+ }
7650
+ }
7651
+ }
7652
+
7653
+ function clickInGutter(cm, e) {
7654
+ return gutterEvent(cm, e, "gutterClick", true)
7655
+ }
7656
+
7657
+ // CONTEXT MENU HANDLING
7658
+
7659
+ // To make the context menu work, we need to briefly unhide the
7660
+ // textarea (making it as unobtrusive as possible) to let the
7661
+ // right-click take effect on it.
7662
+ function onContextMenu(cm, e) {
7663
+ if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
7664
+ if (signalDOMEvent(cm, e, "contextmenu")) { return }
7665
+ if (!captureRightClick) { cm.display.input.onContextMenu(e); }
7666
+ }
7667
+
7668
+ function contextMenuInGutter(cm, e) {
7669
+ if (!hasHandler(cm, "gutterContextMenu")) { return false }
7670
+ return gutterEvent(cm, e, "gutterContextMenu", false)
7671
+ }
7672
+
7673
+ function themeChanged(cm) {
7674
+ cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
7675
+ cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
7676
+ clearCaches(cm);
7677
+ }
7678
+
7679
+ var Init = {toString: function(){return "CodeMirror.Init"}};
7680
+
7681
+ var defaults = {};
7682
+ var optionHandlers = {};
7683
+
7684
+ function defineOptions(CodeMirror) {
7685
+ var optionHandlers = CodeMirror.optionHandlers;
7686
+
7687
+ function option(name, deflt, handle, notOnInit) {
7688
+ CodeMirror.defaults[name] = deflt;
7689
+ if (handle) { optionHandlers[name] =
7690
+ notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; }
7691
+ }
7692
+
7693
+ CodeMirror.defineOption = option;
7694
+
7695
+ // Passed to option handlers when there is no old value.
7696
+ CodeMirror.Init = Init;
7697
+
7698
+ // These two are, on init, called from the constructor because they
7699
+ // have to be initialized before the editor can start at all.
7700
+ option("value", "", function (cm, val) { return cm.setValue(val); }, true);
7701
+ option("mode", null, function (cm, val) {
7702
+ cm.doc.modeOption = val;
7703
+ loadMode(cm);
7704
+ }, true);
7705
+
7706
+ option("indentUnit", 2, loadMode, true);
7707
+ option("indentWithTabs", false);
7708
+ option("smartIndent", true);
7709
+ option("tabSize", 4, function (cm) {
7710
+ resetModeState(cm);
7711
+ clearCaches(cm);
7712
+ regChange(cm);
7713
+ }, true);
7714
+
7715
+ option("lineSeparator", null, function (cm, val) {
7716
+ cm.doc.lineSep = val;
7717
+ if (!val) { return }
7718
+ var newBreaks = [], lineNo = cm.doc.first;
7719
+ cm.doc.iter(function (line) {
7720
+ for (var pos = 0;;) {
7721
+ var found = line.text.indexOf(val, pos);
7722
+ if (found == -1) { break }
7723
+ pos = found + val.length;
7724
+ newBreaks.push(Pos(lineNo, found));
7725
+ }
7726
+ lineNo++;
7727
+ });
7728
+ for (var i = newBreaks.length - 1; i >= 0; i--)
7729
+ { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
7730
+ });
7731
+ option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
7732
+ cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
7733
+ if (old != Init) { cm.refresh(); }
7734
+ });
7735
+ option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);
7736
+ option("electricChars", true);
7737
+ option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
7738
+ throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
7739
+ }, true);
7740
+ option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);
7741
+ option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true);
7742
+ option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true);
7743
+ option("rtlMoveVisually", !windows);
7744
+ option("wholeLineUpdateBefore", true);
7745
+
7746
+ option("theme", "default", function (cm) {
7747
+ themeChanged(cm);
7748
+ updateGutters(cm);
7749
+ }, true);
7750
+ option("keyMap", "default", function (cm, val, old) {
7751
+ var next = getKeyMap(val);
7752
+ var prev = old != Init && getKeyMap(old);
7753
+ if (prev && prev.detach) { prev.detach(cm, next); }
7754
+ if (next.attach) { next.attach(cm, prev || null); }
7755
+ });
7756
+ option("extraKeys", null);
7757
+ option("configureMouse", null);
7758
+
7759
+ option("lineWrapping", false, wrappingChanged, true);
7760
+ option("gutters", [], function (cm, val) {
7761
+ cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers);
7762
+ updateGutters(cm);
7763
+ }, true);
7764
+ option("fixedGutter", true, function (cm, val) {
7765
+ cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
7766
+ cm.refresh();
7767
+ }, true);
7768
+ option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true);
7769
+ option("scrollbarStyle", "native", function (cm) {
7770
+ initScrollbars(cm);
7771
+ updateScrollbars(cm);
7772
+ cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
7773
+ cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
7774
+ }, true);
7775
+ option("lineNumbers", false, function (cm, val) {
7776
+ cm.display.gutterSpecs = getGutters(cm.options.gutters, val);
7777
+ updateGutters(cm);
7778
+ }, true);
7779
+ option("firstLineNumber", 1, updateGutters, true);
7780
+ option("lineNumberFormatter", function (integer) { return integer; }, updateGutters, true);
7781
+ option("showCursorWhenSelecting", false, updateSelection, true);
7782
+
7783
+ option("resetSelectionOnContextMenu", true);
7784
+ option("lineWiseCopyCut", true);
7785
+ option("pasteLinesPerSelection", true);
7786
+ option("selectionsMayTouch", false);
7787
+
7788
+ option("readOnly", false, function (cm, val) {
7789
+ if (val == "nocursor") {
7790
+ onBlur(cm);
7791
+ cm.display.input.blur();
7792
+ }
7793
+ cm.display.input.readOnlyChanged(val);
7794
+ });
7795
+ option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
7796
+ option("dragDrop", true, dragDropChanged);
7797
+ option("allowDropFileTypes", null);
7798
+
7799
+ option("cursorBlinkRate", 530);
7800
+ option("cursorScrollMargin", 0);
7801
+ option("cursorHeight", 1, updateSelection, true);
7802
+ option("singleCursorHeightPerLine", true, updateSelection, true);
7803
+ option("workTime", 100);
7804
+ option("workDelay", 100);
7805
+ option("flattenSpans", true, resetModeState, true);
7806
+ option("addModeClass", false, resetModeState, true);
7807
+ option("pollInterval", 100);
7808
+ option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; });
7809
+ option("historyEventDelay", 1250);
7810
+ option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true);
7811
+ option("maxHighlightLength", 10000, resetModeState, true);
7812
+ option("moveInputWithCursor", true, function (cm, val) {
7813
+ if (!val) { cm.display.input.resetPosition(); }
7814
+ });
7815
+
7816
+ option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; });
7817
+ option("autofocus", null);
7818
+ option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true);
7819
+ option("phrases", null);
7820
+ }
7821
+
7822
+ function dragDropChanged(cm, value, old) {
7823
+ var wasOn = old && old != Init;
7824
+ if (!value != !wasOn) {
7825
+ var funcs = cm.display.dragFunctions;
7826
+ var toggle = value ? on : off;
7827
+ toggle(cm.display.scroller, "dragstart", funcs.start);
7828
+ toggle(cm.display.scroller, "dragenter", funcs.enter);
7829
+ toggle(cm.display.scroller, "dragover", funcs.over);
7830
+ toggle(cm.display.scroller, "dragleave", funcs.leave);
7831
+ toggle(cm.display.scroller, "drop", funcs.drop);
7832
+ }
7833
+ }
7834
+
7835
+ function wrappingChanged(cm) {
7836
+ if (cm.options.lineWrapping) {
7837
+ addClass(cm.display.wrapper, "CodeMirror-wrap");
7838
+ cm.display.sizer.style.minWidth = "";
7839
+ cm.display.sizerWidth = null;
7840
+ } else {
7841
+ rmClass(cm.display.wrapper, "CodeMirror-wrap");
7842
+ findMaxLine(cm);
7843
+ }
7844
+ estimateLineHeights(cm);
7845
+ regChange(cm);
7846
+ clearCaches(cm);
7847
+ setTimeout(function () { return updateScrollbars(cm); }, 100);
7848
+ }
7849
+
7850
+ // A CodeMirror instance represents an editor. This is the object
7851
+ // that user code is usually dealing with.
7852
+
7853
+ function CodeMirror(place, options) {
7854
+ var this$1 = this;
7855
+
7856
+ if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
7857
+
7858
+ this.options = options = options ? copyObj(options) : {};
7859
+ // Determine effective options based on given values and defaults.
7860
+ copyObj(defaults, options, false);
7861
+
7862
+ var doc = options.value;
7863
+ if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); }
7864
+ else if (options.mode) { doc.modeOption = options.mode; }
7865
+ this.doc = doc;
7866
+
7867
+ var input = new CodeMirror.inputStyles[options.inputStyle](this);
7868
+ var display = this.display = new Display(place, doc, input, options);
7869
+ display.wrapper.CodeMirror = this;
7870
+ themeChanged(this);
7871
+ if (options.lineWrapping)
7872
+ { this.display.wrapper.className += " CodeMirror-wrap"; }
7873
+ initScrollbars(this);
7874
+
7875
+ this.state = {
7876
+ keyMaps: [], // stores maps added by addKeyMap
7877
+ overlays: [], // highlighting overlays, as added by addOverlay
7878
+ modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
7879
+ overwrite: false,
7880
+ delayingBlurEvent: false,
7881
+ focused: false,
7882
+ suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
7883
+ pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll
7884
+ selectingText: false,
7885
+ draggingText: false,
7886
+ highlight: new Delayed(), // stores highlight worker timeout
7887
+ keySeq: null, // Unfinished key sequence
7888
+ specialChars: null
7889
+ };
7890
+
7891
+ if (options.autofocus && !mobile) { display.input.focus(); }
7892
+
7893
+ // Override magic textarea content restore that IE sometimes does
7894
+ // on our hidden textarea on reload
7895
+ if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); }
7896
+
7897
+ registerEventHandlers(this);
7898
+ ensureGlobalHandlers();
7899
+
7900
+ startOperation(this);
7901
+ this.curOp.forceUpdate = true;
7902
+ attachDoc(this, doc);
7903
+
7904
+ if ((options.autofocus && !mobile) || this.hasFocus())
7905
+ { setTimeout(bind(onFocus, this), 20); }
7906
+ else
7907
+ { onBlur(this); }
7908
 
7909
+ for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
7910
+ { optionHandlers[opt](this$1, options[opt], Init); } }
7911
+ maybeUpdateLineNumberWidth(this);
7912
+ if (options.finishInit) { options.finishInit(this); }
7913
+ for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1); }
7914
+ endOperation(this);
7915
+ // Suppress optimizelegibility in Webkit, since it breaks text
7916
+ // measuring on line wrapping boundaries.
7917
+ if (webkit && options.lineWrapping &&
7918
+ getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
7919
+ { display.lineDiv.style.textRendering = "auto"; }
7920
+ }
 
 
 
 
 
 
 
7921
 
7922
+ // The default configuration options.
7923
+ CodeMirror.defaults = defaults;
7924
+ // Functions to run when options are changed.
7925
+ CodeMirror.optionHandlers = optionHandlers;
7926
+
7927
+ // Attach the necessary event handlers when initializing the editor
7928
+ function registerEventHandlers(cm) {
7929
+ var d = cm.display;
7930
+ on(d.scroller, "mousedown", operation(cm, onMouseDown));
7931
+ // Older IE's will not fire a second mousedown for a double click
7932
+ if (ie && ie_version < 11)
7933
+ { on(d.scroller, "dblclick", operation(cm, function (e) {
7934
+ if (signalDOMEvent(cm, e)) { return }
7935
+ var pos = posFromMouse(cm, e);
7936
+ if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
7937
+ e_preventDefault(e);
7938
+ var word = cm.findWordAt(pos);
7939
+ extendSelection(cm.doc, word.anchor, word.head);
7940
+ })); }
7941
+ else
7942
+ { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); }
7943
+ // Some browsers fire contextmenu *after* opening the menu, at
7944
+ // which point we can't mess with it anymore. Context menu is
7945
+ // handled in onMouseDown for these browsers.
7946
+ on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); });
7947
+
7948
+ // Used to suppress mouse event handling when a touch happens
7949
+ var touchFinished, prevTouch = {end: 0};
7950
+ function finishTouch() {
7951
+ if (d.activeTouch) {
7952
+ touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000);
7953
+ prevTouch = d.activeTouch;
7954
+ prevTouch.end = +new Date;
7955
+ }
7956
+ }
7957
+ function isMouseLikeTouchEvent(e) {
7958
+ if (e.touches.length != 1) { return false }
7959
+ var touch = e.touches[0];
7960
+ return touch.radiusX <= 1 && touch.radiusY <= 1
7961
+ }
7962
+ function farAway(touch, other) {
7963
+ if (other.left == null) { return true }
7964
+ var dx = other.left - touch.left, dy = other.top - touch.top;
7965
+ return dx * dx + dy * dy > 20 * 20
7966
+ }
7967
+ on(d.scroller, "touchstart", function (e) {
7968
+ if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
7969
+ d.input.ensurePolled();
7970
+ clearTimeout(touchFinished);
7971
+ var now = +new Date;
7972
+ d.activeTouch = {start: now, moved: false,
7973
+ prev: now - prevTouch.end <= 300 ? prevTouch : null};
7974
+ if (e.touches.length == 1) {
7975
+ d.activeTouch.left = e.touches[0].pageX;
7976
+ d.activeTouch.top = e.touches[0].pageY;
7977
+ }
7978
  }
7979
+ });
7980
+ on(d.scroller, "touchmove", function () {
7981
+ if (d.activeTouch) { d.activeTouch.moved = true; }
7982
+ });
7983
+ on(d.scroller, "touchend", function (e) {
7984
+ var touch = d.activeTouch;
7985
+ if (touch && !eventInWidget(d, e) && touch.left != null &&
7986
+ !touch.moved && new Date - touch.start < 300) {
7987
+ var pos = cm.coordsChar(d.activeTouch, "page"), range;
7988
+ if (!touch.prev || farAway(touch, touch.prev)) // Single tap
7989
+ { range = new Range(pos, pos); }
7990
+ else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
7991
+ { range = cm.findWordAt(pos); }
7992
+ else // Triple tap
7993
+ { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); }
7994
+ cm.setSelection(range.anchor, range.head);
7995
+ cm.focus();
7996
+ e_preventDefault(e);
7997
+ }
7998
+ finishTouch();
7999
+ });
8000
+ on(d.scroller, "touchcancel", finishTouch);
8001
 
8002
+ // Sync scrolling between fake scrollbars and real scrollable
8003
+ // area, ensure viewport is updated when scrolling.
8004
+ on(d.scroller, "scroll", function () {
8005
+ if (d.scroller.clientHeight) {
8006
+ updateScrollTop(cm, d.scroller.scrollTop);
8007
+ setScrollLeft(cm, d.scroller.scrollLeft, true);
8008
+ signal(cm, "scroll", cm);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8009
  }
8010
+ });
8011
+
8012
+ // Listen to wheel events in order to try and update the viewport on time.
8013
+ on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); });
8014
+ on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); });
8015
+
8016
+ // Prevent wrapper from ever scrolling
8017
+ on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
8018
+
8019
+ d.dragFunctions = {
8020
+ enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }},
8021
+ over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
8022
+ start: function (e) { return onDragStart(cm, e); },
8023
+ drop: operation(cm, onDrop),
8024
+ leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
8025
+ };
8026
+
8027
+ var inp = d.input.getField();
8028
+ on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); });
8029
+ on(inp, "keydown", operation(cm, onKeyDown));
8030
+ on(inp, "keypress", operation(cm, onKeyPress));
8031
+ on(inp, "focus", function (e) { return onFocus(cm, e); });
8032
+ on(inp, "blur", function (e) { return onBlur(cm, e); });
8033
+ }
8034
+
8035
+ var initHooks = [];
8036
+ CodeMirror.defineInitHook = function (f) { return initHooks.push(f); };
8037
+
8038
+ // Indent the given line. The how parameter can be "smart",
8039
+ // "add"/null, "subtract", or "prev". When aggressive is false
8040
+ // (typically set to true for forced single-line indents), empty
8041
+ // lines are not indented, and places where the mode returns Pass
8042
+ // are left alone.
8043
+ function indentLine(cm, n, how, aggressive) {
8044
+ var doc = cm.doc, state;
8045
+ if (how == null) { how = "add"; }
8046
+ if (how == "smart") {
8047
+ // Fall back to "prev" when the mode doesn't have an indentation
8048
+ // method.
8049
+ if (!doc.mode.indent) { how = "prev"; }
8050
+ else { state = getContextBefore(cm, n).state; }
8051
+ }
8052
+
8053
+ var tabSize = cm.options.tabSize;
8054
+ var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
8055
+ if (line.stateAfter) { line.stateAfter = null; }
8056
+ var curSpaceString = line.text.match(/^\s*/)[0], indentation;
8057
+ if (!aggressive && !/\S/.test(line.text)) {
8058
+ indentation = 0;
8059
+ how = "not";
8060
+ } else if (how == "smart") {
8061
+ indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
8062
+ if (indentation == Pass || indentation > 150) {
8063
+ if (!aggressive) { return }
8064
+ how = "prev";
8065
  }
8066
+ }
8067
+ if (how == "prev") {
8068
+ if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); }
8069
+ else { indentation = 0; }
8070
+ } else if (how == "add") {
8071
+ indentation = curSpace + cm.options.indentUnit;
8072
+ } else if (how == "subtract") {
8073
+ indentation = curSpace - cm.options.indentUnit;
8074
+ } else if (typeof how == "number") {
8075
+ indentation = curSpace + how;
8076
+ }
8077
+ indentation = Math.max(0, indentation);
8078
 
8079
+ var indentString = "", pos = 0;
8080
+ if (cm.options.indentWithTabs)
8081
+ { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} }
8082
+ if (pos < indentation) { indentString += spaceStr(indentation - pos); }
8083
 
8084
+ if (indentString != curSpaceString) {
8085
+ replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
8086
+ line.stateAfter = null;
8087
+ return true
8088
+ } else {
8089
+ // Ensure that, if the cursor was in the whitespace at the start
8090
+ // of the line, it is moved to the end of that space.
8091
+ for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
8092
+ var range = doc.sel.ranges[i$1];
8093
+ if (range.head.line == n && range.head.ch < curSpaceString.length) {
8094
+ var pos$1 = Pos(n, curSpaceString.length);
8095
+ replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
8096
+ break
8097
+ }
8098
+ }
8099
+ }
8100
+ }
8101
 
8102
+ // This will be set to a {lineWise: bool, text: [string]} object, so
8103
+ // that, when pasting, we know what kind of selections the copied
8104
+ // text was made out of.
8105
+ var lastCopied = null;
 
 
8106
 
8107
+ function setLastCopied(newLastCopied) {
8108
+ lastCopied = newLastCopied;
8109
+ }
8110
 
8111
+ function applyTextInput(cm, inserted, deleted, sel, origin) {
8112
+ var doc = cm.doc;
8113
+ cm.display.shift = false;
8114
+ if (!sel) { sel = doc.sel; }
8115
+
8116
+ var recent = +new Date - 200;
8117
+ var paste = origin == "paste" || cm.state.pasteIncoming > recent;
8118
+ var textLines = splitLinesAuto(inserted), multiPaste = null;
8119
+ // When pasting N lines into N selections, insert one line per selection
8120
+ if (paste && sel.ranges.length > 1) {
8121
+ if (lastCopied && lastCopied.text.join("\n") == inserted) {
8122
+ if (sel.ranges.length % lastCopied.text.length == 0) {
8123
+ multiPaste = [];
8124
+ for (var i = 0; i < lastCopied.text.length; i++)
8125
+ { multiPaste.push(doc.splitLines(lastCopied.text[i])); }
8126
+ }
8127
+ } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
8128
+ multiPaste = map(textLines, function (l) { return [l]; });
8129
  }
8130
  }
8131
+
8132
+ var updateInput = cm.curOp.updateInput;
8133
+ // Normal behavior is to insert the new text into every selection
8134
+ for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
8135
+ var range$$1 = sel.ranges[i$1];
8136
+ var from = range$$1.from(), to = range$$1.to();
8137
+ if (range$$1.empty()) {
8138
+ if (deleted && deleted > 0) // Handle deletion
8139
+ { from = Pos(from.line, from.ch - deleted); }
8140
+ else if (cm.state.overwrite && !paste) // Handle overwrite
8141
+ { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
8142
+ else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
8143
+ { from = to = Pos(from.line, 0); }
8144
+ }
8145
+ var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
8146
+ origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")};
8147
+ makeChange(cm.doc, changeEvent);
8148
+ signalLater(cm, "inputRead", cm, changeEvent);
8149
+ }
8150
+ if (inserted && !paste)
8151
+ { triggerElectric(cm, inserted); }
8152
+
8153
+ ensureCursorVisible(cm);
8154
+ if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; }
8155
+ cm.curOp.typing = true;
8156
+ cm.state.pasteIncoming = cm.state.cutIncoming = -1;
8157
  }
8158
 
8159
+ function handlePaste(e, cm) {
8160
+ var pasted = e.clipboardData && e.clipboardData.getData("Text");
8161
+ if (pasted) {
8162
+ e.preventDefault();
8163
+ if (!cm.isReadOnly() && !cm.options.disableInput)
8164
+ { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
8165
+ return true
8166
+ }
 
 
8167
  }
8168
 
8169
+ function triggerElectric(cm, inserted) {
8170
+ // When an 'electric' character is inserted, immediately trigger a reindent
8171
+ if (!cm.options.electricChars || !cm.options.smartIndent) { return }
8172
+ var sel = cm.doc.sel;
8173
 
8174
+ for (var i = sel.ranges.length - 1; i >= 0; i--) {
8175
+ var range$$1 = sel.ranges[i];
8176
+ if (range$$1.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range$$1.head.line)) { continue }
8177
+ var mode = cm.getModeAt(range$$1.head);
8178
+ var indented = false;
8179
+ if (mode.electricChars) {
8180
+ for (var j = 0; j < mode.electricChars.length; j++)
8181
+ { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
8182
+ indented = indentLine(cm, range$$1.head.line, "smart");
8183
+ break
8184
+ } }
8185
+ } else if (mode.electricInput) {
8186
+ if (mode.electricInput.test(getLine(cm.doc, range$$1.head.line).text.slice(0, range$$1.head.ch)))
8187
+ { indented = indentLine(cm, range$$1.head.line, "smart"); }
8188
  }
8189
+ if (indented) { signalLater(cm, "electricInput", cm, range$$1.head.line); }
8190
  }
 
8191
  }
8192
 
8193
+ function copyableRanges(cm) {
8194
+ var text = [], ranges = [];
8195
+ for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
8196
+ var line = cm.doc.sel.ranges[i].head.line;
8197
+ var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
8198
+ ranges.push(lineRange);
8199
+ text.push(cm.getRange(lineRange.anchor, lineRange.head));
8200
+ }
8201
+ return {text: text, ranges: ranges}
 
 
 
8202
  }
8203
+
8204
+ function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {
8205
+ field.setAttribute("autocorrect", autocorrect ? "" : "off");
8206
+ field.setAttribute("autocapitalize", autocapitalize ? "" : "off");
8207
+ field.setAttribute("spellcheck", !!spellcheck);
8208
  }
8209
 
8210
+ function hiddenTextarea() {
8211
+ var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
8212
+ var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
8213
+ // The textarea is kept positioned near the cursor to prevent the
8214
+ // fact that it'll be scrolled into view on input from scrolling
8215
+ // our fake cursor out of view. On webkit, when wrap=off, paste is
8216
+ // very slow. So make the area wide instead.
8217
+ if (webkit) { te.style.width = "1000px"; }
8218
+ else { te.setAttribute("wrap", "off"); }
8219
+ // If border: 0; -- iOS fails to open keyboard (issue #1287)
8220
+ if (ios) { te.style.border = "1px solid black"; }
8221
+ disableBrowserMagic(te);
8222
+ return div
8223
  }
8224
 
8225
+ // The publicly visible API. Note that methodOp(f) means
8226
+ // 'wrap f in an operation, performed on its `this` parameter'.
8227
+
8228
+ // This is not the complete set of editor methods. Most of the
8229
+ // methods defined on the Doc type are also injected into
8230
+ // CodeMirror.prototype, for backwards compatibility and
8231
+ // convenience.
8232
+
8233
+ function addEditorMethods(CodeMirror) {
8234
+ var optionHandlers = CodeMirror.optionHandlers;
8235
+
8236
+ var helpers = CodeMirror.helpers = {};
8237
+
8238
+ CodeMirror.prototype = {
8239
+ constructor: CodeMirror,
8240
+ focus: function(){window.focus(); this.display.input.focus();},
8241
+
8242
+ setOption: function(option, value) {
8243
+ var options = this.options, old = options[option];
8244
+ if (options[option] == value && option != "mode") { return }
8245
+ options[option] = value;
8246
+ if (optionHandlers.hasOwnProperty(option))
8247
+ { operation(this, optionHandlers[option])(this, value, old); }
8248
+ signal(this, "optionChange", this, option);
8249
+ },
8250
+
8251
+ getOption: function(option) {return this.options[option]},
8252
+ getDoc: function() {return this.doc},
8253
+
8254
+ addKeyMap: function(map$$1, bottom) {
8255
+ this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$$1));
8256
+ },
8257
+ removeKeyMap: function(map$$1) {
8258
+ var maps = this.state.keyMaps;
8259
+ for (var i = 0; i < maps.length; ++i)
8260
+ { if (maps[i] == map$$1 || maps[i].name == map$$1) {
8261
+ maps.splice(i, 1);
8262
+ return true
8263
+ } }
8264
+ },
8265
+
8266
+ addOverlay: methodOp(function(spec, options) {
8267
+ var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
8268
+ if (mode.startState) { throw new Error("Overlays may not be stateful.") }
8269
+ insertSorted(this.state.overlays,
8270
+ {mode: mode, modeSpec: spec, opaque: options && options.opaque,
8271
+ priority: (options && options.priority) || 0},
8272
+ function (overlay) { return overlay.priority; });
8273
+ this.state.modeGen++;
8274
+ regChange(this);
8275
+ }),
8276
+ removeOverlay: methodOp(function(spec) {
8277
+ var this$1 = this;
8278
+
8279
+ var overlays = this.state.overlays;
8280
+ for (var i = 0; i < overlays.length; ++i) {
8281
+ var cur = overlays[i].modeSpec;
8282
+ if (cur == spec || typeof spec == "string" && cur.name == spec) {
8283
+ overlays.splice(i, 1);
8284
+ this$1.state.modeGen++;
8285
+ regChange(this$1);
8286
+ return
8287
+ }
8288
+ }
8289
+ }),
8290
+
8291
+ indentLine: methodOp(function(n, dir, aggressive) {
8292
+ if (typeof dir != "string" && typeof dir != "number") {
8293
+ if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; }
8294
+ else { dir = dir ? "add" : "subtract"; }
8295
+ }
8296
+ if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); }
8297
+ }),
8298
+ indentSelection: methodOp(function(how) {
8299
+ var this$1 = this;
8300
+
8301
+ var ranges = this.doc.sel.ranges, end = -1;
8302
+ for (var i = 0; i < ranges.length; i++) {
8303
+ var range$$1 = ranges[i];
8304
+ if (!range$$1.empty()) {
8305
+ var from = range$$1.from(), to = range$$1.to();
8306
+ var start = Math.max(end, from.line);
8307
+ end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
8308
+ for (var j = start; j < end; ++j)
8309
+ { indentLine(this$1, j, how); }
8310
+ var newRanges = this$1.doc.sel.ranges;
8311
+ if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
8312
+ { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); }
8313
+ } else if (range$$1.head.line > end) {
8314
+ indentLine(this$1, range$$1.head.line, how, true);
8315
+ end = range$$1.head.line;
8316
+ if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1); }
8317
+ }
8318
+ }
8319
+ }),
8320
+
8321
+ // Fetch the parser token for a given character. Useful for hacks
8322
+ // that want to inspect the mode state (say, for completion).
8323
+ getTokenAt: function(pos, precise) {
8324
+ return takeToken(this, pos, precise)
8325
+ },
8326
+
8327
+ getLineTokens: function(line, precise) {
8328
+ return takeToken(this, Pos(line), precise, true)
8329
+ },
8330
+
8331
+ getTokenTypeAt: function(pos) {
8332
+ pos = clipPos(this.doc, pos);
8333
+ var styles = getLineStyles(this, getLine(this.doc, pos.line));
8334
+ var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
8335
+ var type;
8336
+ if (ch == 0) { type = styles[2]; }
8337
+ else { for (;;) {
8338
+ var mid = (before + after) >> 1;
8339
+ if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; }
8340
+ else if (styles[mid * 2 + 1] < ch) { before = mid + 1; }
8341
+ else { type = styles[mid * 2 + 2]; break }
8342
+ } }
8343
+ var cut = type ? type.indexOf("overlay ") : -1;
8344
+ return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
8345
+ },
8346
+
8347
+ getModeAt: function(pos) {
8348
+ var mode = this.doc.mode;
8349
+ if (!mode.innerMode) { return mode }
8350
+ return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
8351
+ },
8352
+
8353
+ getHelper: function(pos, type) {
8354
+ return this.getHelpers(pos, type)[0]
8355
+ },
8356
+
8357
+ getHelpers: function(pos, type) {
8358
+ var this$1 = this;
8359
+
8360
+ var found = [];
8361
+ if (!helpers.hasOwnProperty(type)) { return found }
8362
+ var help = helpers[type], mode = this.getModeAt(pos);
8363
+ if (typeof mode[type] == "string") {
8364
+ if (help[mode[type]]) { found.push(help[mode[type]]); }
8365
+ } else if (mode[type]) {
8366
+ for (var i = 0; i < mode[type].length; i++) {
8367
+ var val = help[mode[type][i]];
8368
+ if (val) { found.push(val); }
8369
+ }
8370
+ } else if (mode.helperType && help[mode.helperType]) {
8371
+ found.push(help[mode.helperType]);
8372
+ } else if (help[mode.name]) {
8373
+ found.push(help[mode.name]);
8374
+ }
8375
+ for (var i$1 = 0; i$1 < help._global.length; i$1++) {
8376
+ var cur = help._global[i$1];
8377
+ if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
8378
+ { found.push(cur.val); }
8379
+ }
8380
+ return found
8381
+ },
8382
+
8383
+ getStateAfter: function(line, precise) {
8384
+ var doc = this.doc;
8385
+ line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
8386
+ return getContextBefore(this, line + 1, precise).state
8387
+ },
8388
+
8389
+ cursorCoords: function(start, mode) {
8390
+ var pos, range$$1 = this.doc.sel.primary();
8391
+ if (start == null) { pos = range$$1.head; }
8392
+ else if (typeof start == "object") { pos = clipPos(this.doc, start); }
8393
+ else { pos = start ? range$$1.from() : range$$1.to(); }
8394
+ return cursorCoords(this, pos, mode || "page")
8395
+ },
8396
+
8397
+ charCoords: function(pos, mode) {
8398
+ return charCoords(this, clipPos(this.doc, pos), mode || "page")
8399
+ },
8400
+
8401
+ coordsChar: function(coords, mode) {
8402
+ coords = fromCoordSystem(this, coords, mode || "page");
8403
+ return coordsChar(this, coords.left, coords.top)
8404
+ },
8405
+
8406
+ lineAtHeight: function(height, mode) {
8407
+ height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
8408
+ return lineAtHeight(this.doc, height + this.display.viewOffset)
8409
+ },
8410
+ heightAtLine: function(line, mode, includeWidgets) {
8411
+ var end = false, lineObj;
8412
+ if (typeof line == "number") {
8413
+ var last = this.doc.first + this.doc.size - 1;
8414
+ if (line < this.doc.first) { line = this.doc.first; }
8415
+ else if (line > last) { line = last; end = true; }
8416
+ lineObj = getLine(this.doc, line);
8417
+ } else {
8418
+ lineObj = line;
8419
+ }
8420
+ return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
8421
+ (end ? this.doc.height - heightAtLine(lineObj) : 0)
8422
+ },
8423
+
8424
+ defaultTextHeight: function() { return textHeight(this.display) },
8425
+ defaultCharWidth: function() { return charWidth(this.display) },
8426
+
8427
+ getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
8428
+
8429
+ addWidget: function(pos, node, scroll, vert, horiz) {
8430
+ var display = this.display;
8431
+ pos = cursorCoords(this, clipPos(this.doc, pos));
8432
+ var top = pos.bottom, left = pos.left;
8433
+ node.style.position = "absolute";
8434
+ node.setAttribute("cm-ignore-events", "true");
8435
+ this.display.input.setUneditable(node);
8436
+ display.sizer.appendChild(node);
8437
+ if (vert == "over") {
8438
+ top = pos.top;
8439
+ } else if (vert == "above" || vert == "near") {
8440
+ var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
8441
+ hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
8442
+ // Default to positioning above (if specified and possible); otherwise default to positioning below
8443
+ if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
8444
+ { top = pos.top - node.offsetHeight; }
8445
+ else if (pos.bottom + node.offsetHeight <= vspace)
8446
+ { top = pos.bottom; }
8447
+ if (left + node.offsetWidth > hspace)
8448
+ { left = hspace - node.offsetWidth; }
8449
+ }
8450
+ node.style.top = top + "px";
8451
+ node.style.left = node.style.right = "";
8452
+ if (horiz == "right") {
8453
+ left = display.sizer.clientWidth - node.offsetWidth;
8454
+ node.style.right = "0px";
8455
+ } else {
8456
+ if (horiz == "left") { left = 0; }
8457
+ else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; }
8458
+ node.style.left = left + "px";
8459
+ }
8460
+ if (scroll)
8461
+ { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); }
8462
+ },
8463
+
8464
+ triggerOnKeyDown: methodOp(onKeyDown),
8465
+ triggerOnKeyPress: methodOp(onKeyPress),
8466
+ triggerOnKeyUp: onKeyUp,
8467
+ triggerOnMouseDown: methodOp(onMouseDown),
8468
+
8469
+ execCommand: function(cmd) {
8470
+ if (commands.hasOwnProperty(cmd))
8471
+ { return commands[cmd].call(null, this) }
8472
+ },
8473
+
8474
+ triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
8475
+
8476
+ findPosH: function(from, amount, unit, visually) {
8477
+ var this$1 = this;
8478
+
8479
+ var dir = 1;
8480
+ if (amount < 0) { dir = -1; amount = -amount; }
8481
+ var cur = clipPos(this.doc, from);
8482
+ for (var i = 0; i < amount; ++i) {
8483
+ cur = findPosH(this$1.doc, cur, dir, unit, visually);
8484
+ if (cur.hitSide) { break }
8485
+ }
8486
+ return cur
8487
+ },
8488
+
8489
+ moveH: methodOp(function(dir, unit) {
8490
+ var this$1 = this;
8491
+
8492
+ this.extendSelectionsBy(function (range$$1) {
8493
+ if (this$1.display.shift || this$1.doc.extend || range$$1.empty())
8494
+ { return findPosH(this$1.doc, range$$1.head, dir, unit, this$1.options.rtlMoveVisually) }
8495
+ else
8496
+ { return dir < 0 ? range$$1.from() : range$$1.to() }
8497
+ }, sel_move);
8498
+ }),
8499
+
8500
+ deleteH: methodOp(function(dir, unit) {
8501
+ var sel = this.doc.sel, doc = this.doc;
8502
+ if (sel.somethingSelected())
8503
+ { doc.replaceSelection("", null, "+delete"); }
8504
+ else
8505
+ { deleteNearSelection(this, function (range$$1) {
8506
+ var other = findPosH(doc, range$$1.head, dir, unit, false);
8507
+ return dir < 0 ? {from: other, to: range$$1.head} : {from: range$$1.head, to: other}
8508
+ }); }
8509
+ }),
8510
+
8511
+ findPosV: function(from, amount, unit, goalColumn) {
8512
+ var this$1 = this;
8513
+
8514
+ var dir = 1, x = goalColumn;
8515
+ if (amount < 0) { dir = -1; amount = -amount; }
8516
+ var cur = clipPos(this.doc, from);
8517
+ for (var i = 0; i < amount; ++i) {
8518
+ var coords = cursorCoords(this$1, cur, "div");
8519
+ if (x == null) { x = coords.left; }
8520
+ else { coords.left = x; }
8521
+ cur = findPosV(this$1, coords, dir, unit);
8522
+ if (cur.hitSide) { break }
8523
+ }
8524
+ return cur
8525
+ },
8526
+
8527
+ moveV: methodOp(function(dir, unit) {
8528
+ var this$1 = this;
8529
+
8530
+ var doc = this.doc, goals = [];
8531
+ var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();
8532
+ doc.extendSelectionsBy(function (range$$1) {
8533
+ if (collapse)
8534
+ { return dir < 0 ? range$$1.from() : range$$1.to() }
8535
+ var headPos = cursorCoords(this$1, range$$1.head, "div");
8536
+ if (range$$1.goalColumn != null) { headPos.left = range$$1.goalColumn; }
8537
+ goals.push(headPos.left);
8538
+ var pos = findPosV(this$1, headPos, dir, unit);
8539
+ if (unit == "page" && range$$1 == doc.sel.primary())
8540
+ { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); }
8541
+ return pos
8542
+ }, sel_move);
8543
+ if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
8544
+ { doc.sel.ranges[i].goalColumn = goals[i]; } }
8545
+ }),
8546
+
8547
+ // Find the word at the given position (as returned by coordsChar).
8548
+ findWordAt: function(pos) {
8549
+ var doc = this.doc, line = getLine(doc, pos.line).text;
8550
+ var start = pos.ch, end = pos.ch;
8551
+ if (line) {
8552
+ var helper = this.getHelper(pos, "wordChars");
8553
+ if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; }
8554
+ var startChar = line.charAt(start);
8555
+ var check = isWordChar(startChar, helper)
8556
+ ? function (ch) { return isWordChar(ch, helper); }
8557
+ : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
8558
+ : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); };
8559
+ while (start > 0 && check(line.charAt(start - 1))) { --start; }
8560
+ while (end < line.length && check(line.charAt(end))) { ++end; }
8561
+ }
8562
+ return new Range(Pos(pos.line, start), Pos(pos.line, end))
8563
+ },
8564
+
8565
+ toggleOverwrite: function(value) {
8566
+ if (value != null && value == this.state.overwrite) { return }
8567
+ if (this.state.overwrite = !this.state.overwrite)
8568
+ { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
8569
+ else
8570
+ { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
8571
+
8572
+ signal(this, "overwriteToggle", this, this.state.overwrite);
8573
+ },
8574
+ hasFocus: function() { return this.display.input.getField() == activeElt() },
8575
+ isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
8576
+
8577
+ scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
8578
+ getScrollInfo: function() {
8579
+ var scroller = this.display.scroller;
8580
+ return {left: scroller.scrollLeft, top: scroller.scrollTop,
8581
+ height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
8582
+ width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
8583
+ clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
8584
+ },
8585
+
8586
+ scrollIntoView: methodOp(function(range$$1, margin) {
8587
+ if (range$$1 == null) {
8588
+ range$$1 = {from: this.doc.sel.primary().head, to: null};
8589
+ if (margin == null) { margin = this.options.cursorScrollMargin; }
8590
+ } else if (typeof range$$1 == "number") {
8591
+ range$$1 = {from: Pos(range$$1, 0), to: null};
8592
+ } else if (range$$1.from == null) {
8593
+ range$$1 = {from: range$$1, to: null};
8594
+ }
8595
+ if (!range$$1.to) { range$$1.to = range$$1.from; }
8596
+ range$$1.margin = margin || 0;
8597
+
8598
+ if (range$$1.from.line != null) {
8599
+ scrollToRange(this, range$$1);
8600
+ } else {
8601
+ scrollToCoordsRange(this, range$$1.from, range$$1.to, range$$1.margin);
8602
+ }
8603
+ }),
8604
+
8605
+ setSize: methodOp(function(width, height) {
8606
+ var this$1 = this;
8607
+
8608
+ var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; };
8609
+ if (width != null) { this.display.wrapper.style.width = interpret(width); }
8610
+ if (height != null) { this.display.wrapper.style.height = interpret(height); }
8611
+ if (this.options.lineWrapping) { clearLineMeasurementCache(this); }
8612
+ var lineNo$$1 = this.display.viewFrom;
8613
+ this.doc.iter(lineNo$$1, this.display.viewTo, function (line) {
8614
+ if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
8615
+ { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo$$1, "widget"); break } } }
8616
+ ++lineNo$$1;
8617
+ });
8618
+ this.curOp.forceUpdate = true;
8619
+ signal(this, "refresh", this);
8620
+ }),
8621
+
8622
+ operation: function(f){return runInOp(this, f)},
8623
+ startOperation: function(){return startOperation(this)},
8624
+ endOperation: function(){return endOperation(this)},
8625
+
8626
+ refresh: methodOp(function() {
8627
+ var oldHeight = this.display.cachedTextHeight;
8628
+ regChange(this);
8629
+ this.curOp.forceUpdate = true;
8630
+ clearCaches(this);
8631
+ scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
8632
+ updateGutterSpace(this.display);
8633
+ if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
8634
+ { estimateLineHeights(this); }
8635
+ signal(this, "refresh", this);
8636
+ }),
8637
+
8638
+ swapDoc: methodOp(function(doc) {
8639
+ var old = this.doc;
8640
+ old.cm = null;
8641
+ // Cancel the current text selection if any (#5821)
8642
+ if (this.state.selectingText) { this.state.selectingText(); }
8643
+ attachDoc(this, doc);
8644
+ clearCaches(this);
8645
+ this.display.input.reset();
8646
+ scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
8647
+ this.curOp.forceScroll = true;
8648
+ signalLater(this, "swapDoc", this, old);
8649
+ return old
8650
+ }),
8651
+
8652
+ phrase: function(phraseText) {
8653
+ var phrases = this.options.phrases;
8654
+ return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText
8655
+ },
8656
+
8657
+ getInputField: function(){return this.display.input.getField()},
8658
+ getWrapperElement: function(){return this.display.wrapper},
8659
+ getScrollerElement: function(){return this.display.scroller},
8660
+ getGutterElement: function(){return this.display.gutters}
8661
+ };
8662
+ eventMixin(CodeMirror);
8663
+
8664
+ CodeMirror.registerHelper = function(type, name, value) {
8665
+ if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; }
8666
+ helpers[type][name] = value;
8667
+ };
8668
+ CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
8669
+ CodeMirror.registerHelper(type, name, value);
8670
+ helpers[type]._global.push({pred: predicate, val: value});
8671
+ };
8672
+ }
8673
+
8674
+ // Used for horizontal relative motion. Dir is -1 or 1 (left or
8675
+ // right), unit can be "char", "column" (like char, but doesn't
8676
+ // cross line boundaries), "word" (across next word), or "group" (to
8677
+ // the start of next group of word or non-word-non-whitespace
8678
+ // chars). The visually param controls whether, in right-to-left
8679
+ // text, direction 1 means to move towards the next index in the
8680
+ // string, or towards the character to the right of the current
8681
+ // position. The resulting position will have a hitSide=true
8682
+ // property if it reached the end of the document.
8683
+ function findPosH(doc, pos, dir, unit, visually) {
8684
+ var oldPos = pos;
8685
+ var origDir = dir;
8686
+ var lineObj = getLine(doc, pos.line);
8687
+ function findNextLine() {
8688
+ var l = pos.line + dir;
8689
+ if (l < doc.first || l >= doc.first + doc.size) { return false }
8690
+ pos = new Pos(l, pos.ch, pos.sticky);
8691
+ return lineObj = getLine(doc, l)
8692
+ }
8693
+ function moveOnce(boundToLine) {
8694
+ var next;
8695
+ if (visually) {
8696
+ next = moveVisually(doc.cm, lineObj, pos, dir);
8697
+ } else {
8698
+ next = moveLogically(lineObj, pos, dir);
8699
+ }
8700
+ if (next == null) {
8701
+ if (!boundToLine && findNextLine())
8702
+ { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }
8703
+ else
8704
+ { return false }
8705
+ } else {
8706
+ pos = next;
8707
  }
8708
+ return true
8709
  }
 
 
8710
 
8711
+ if (unit == "char") {
8712
+ moveOnce();
8713
+ } else if (unit == "column") {
8714
+ moveOnce(true);
8715
+ } else if (unit == "word" || unit == "group") {
8716
+ var sawType = null, group = unit == "group";
8717
+ var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
8718
+ for (var first = true;; first = false) {
8719
+ if (dir < 0 && !moveOnce(!first)) { break }
8720
+ var cur = lineObj.text.charAt(pos.ch) || "\n";
8721
+ var type = isWordChar(cur, helper) ? "w"
8722
+ : group && cur == "\n" ? "n"
8723
+ : !group || /\s/.test(cur) ? null
8724
+ : "p";
8725
+ if (group && !first && !type) { type = "s"; }
8726
+ if (sawType && sawType != type) {
8727
+ if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";}
8728
+ break
8729
+ }
8730
+
8731
+ if (type) { sawType = type; }
8732
+ if (dir > 0 && !moveOnce(!first)) { break }
8733
  }
 
 
 
 
 
 
8734
  }
8735
+ var result = skipAtomic(doc, pos, oldPos, origDir, true);
8736
+ if (equalCursorPos(oldPos, result)) { result.hitSide = true; }
8737
+ return result
8738
  }
8739
 
8740
+ // For relative vertical movement. Dir may be -1 or 1. Unit can be
8741
+ // "page" or "line". The resulting position will have a hitSide=true
8742
+ // property if it reached the end of the document.
8743
+ function findPosV(cm, pos, dir, unit) {
8744
+ var doc = cm.doc, x = pos.left, y;
8745
+ if (unit == "page") {
8746
+ var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
8747
+ var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
8748
+ y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
8749
 
8750
+ } else if (unit == "line") {
8751
+ y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
 
 
 
 
 
 
 
8752
  }
8753
+ var target;
8754
+ for (;;) {
8755
+ target = coordsChar(cm, x, y);
8756
+ if (!target.outside) { break }
8757
+ if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
8758
+ y += dir * 5;
8759
  }
8760
+ return target
8761
  }
8762
 
8763
+ // CONTENTEDITABLE INPUT STYLE
 
 
 
 
 
 
 
8764
 
8765
+ var ContentEditableInput = function(cm) {
8766
+ this.cm = cm;
8767
+ this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
8768
+ this.polling = new Delayed();
8769
+ this.composing = null;
8770
+ this.gracePeriod = false;
8771
+ this.readDOMTimeout = null;
8772
+ };
8773
 
8774
+ ContentEditableInput.prototype.init = function (display) {
8775
+ var this$1 = this;
 
 
 
 
 
 
 
 
 
 
 
 
8776
 
8777
+ var input = this, cm = input.cm;
8778
+ var div = input.div = display.lineDiv;
8779
+ disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
 
 
 
 
 
8780
 
8781
+ on(div, "paste", function (e) {
8782
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
8783
+ // IE doesn't fire input events, so we schedule a read for the pasted content in this way
8784
+ if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
8785
+ });
 
 
 
 
8786
 
8787
+ on(div, "compositionstart", function (e) {
8788
+ this$1.composing = {data: e.data, done: false};
8789
+ });
8790
+ on(div, "compositionupdate", function (e) {
8791
+ if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; }
8792
+ });
8793
+ on(div, "compositionend", function (e) {
8794
+ if (this$1.composing) {
8795
+ if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); }
8796
+ this$1.composing.done = true;
8797
+ }
8798
+ });
 
8799
 
8800
+ on(div, "touchstart", function () { return input.forceCompositionEnd(); });
 
 
 
 
 
 
8801
 
8802
+ on(div, "input", function () {
8803
+ if (!this$1.composing) { this$1.readFromDOMSoon(); }
8804
+ });
8805
+
8806
+ function onCopyCut(e) {
8807
+ if (signalDOMEvent(cm, e)) { return }
8808
+ if (cm.somethingSelected()) {
8809
+ setLastCopied({lineWise: false, text: cm.getSelections()});
8810
+ if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
8811
+ } else if (!cm.options.lineWiseCopyCut) {
8812
+ return
8813
  } else {
8814
+ var ranges = copyableRanges(cm);
8815
+ setLastCopied({lineWise: true, text: ranges.text});
8816
+ if (e.type == "cut") {
8817
+ cm.operation(function () {
8818
+ cm.setSelections(ranges.ranges, 0, sel_dontScroll);
8819
+ cm.replaceSelection("", null, "cut");
8820
+ });
8821
+ }
8822
  }
8823
+ if (e.clipboardData) {
8824
+ e.clipboardData.clearData();
8825
+ var content = lastCopied.text.join("\n");
8826
+ // iOS exposes the clipboard API, but seems to discard content inserted into it
8827
+ e.clipboardData.setData("Text", content);
8828
+ if (e.clipboardData.getData("Text") == content) {
8829
+ e.preventDefault();
8830
+ return
8831
+ }
 
 
8832
  }
8833
+ // Old-fashioned briefly-focus-a-textarea hack
8834
+ var kludge = hiddenTextarea(), te = kludge.firstChild;
8835
+ cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
8836
+ te.value = lastCopied.text.join("\n");
8837
+ var hadFocus = document.activeElement;
8838
+ selectInput(te);
8839
+ setTimeout(function () {
8840
+ cm.display.lineSpace.removeChild(kludge);
8841
+ hadFocus.focus();
8842
+ if (hadFocus == div) { input.showPrimarySelection(); }
8843
+ }, 50);
8844
+ }
8845
+ on(div, "copy", onCopyCut);
8846
+ on(div, "cut", onCopyCut);
8847
+ };
 
 
 
 
 
 
 
 
 
 
8848
 
8849
+ ContentEditableInput.prototype.prepareSelection = function () {
8850
+ var result = prepareSelection(this.cm, false);
8851
+ result.focus = this.cm.state.focused;
8852
+ return result
8853
+ };
 
 
 
 
 
 
8854
 
8855
+ ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
8856
+ if (!info || !this.cm.display.view.length) { return }
8857
+ if (info.focus || takeFocus) { this.showPrimarySelection(); }
8858
+ this.showMultipleSelections(info);
8859
+ };
 
8860
 
8861
+ ContentEditableInput.prototype.getSelection = function () {
8862
+ return this.cm.display.wrapper.ownerDocument.getSelection()
8863
+ };
 
 
8864
 
8865
+ ContentEditableInput.prototype.showPrimarySelection = function () {
8866
+ var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();
8867
+ var from = prim.from(), to = prim.to();
 
 
 
 
 
 
8868
 
8869
+ if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
8870
+ sel.removeAllRanges();
8871
+ return
 
 
 
 
8872
  }
 
 
8873
 
8874
+ var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
8875
+ var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
8876
+ if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
8877
+ cmp(minPos(curAnchor, curFocus), from) == 0 &&
8878
+ cmp(maxPos(curAnchor, curFocus), to) == 0)
8879
+ { return }
 
 
8880
 
8881
+ var view = cm.display.view;
8882
+ var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
8883
+ {node: view[0].measure.map[2], offset: 0};
8884
+ var end = to.line < cm.display.viewTo && posToDOM(cm, to);
8885
+ if (!end) {
8886
+ var measure = view[view.length - 1].measure;
8887
+ var map$$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
8888
+ end = {node: map$$1[map$$1.length - 1], offset: map$$1[map$$1.length - 2] - map$$1[map$$1.length - 3]};
8889
+ }
8890
+
8891
+ if (!start || !end) {
8892
+ sel.removeAllRanges();
8893
+ return
8894
+ }
8895
+
8896
+ var old = sel.rangeCount && sel.getRangeAt(0), rng;
8897
+ try { rng = range(start.node, start.offset, end.offset, end.node); }
8898
+ catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
8899
+ if (rng) {
8900
+ if (!gecko && cm.state.focused) {
8901
+ sel.collapse(start.node, start.offset);
8902
+ if (!rng.collapsed) {
8903
+ sel.removeAllRanges();
8904
+ sel.addRange(rng);
8905
  }
8906
+ } else {
8907
+ sel.removeAllRanges();
8908
+ sel.addRange(rng);
8909
  }
8910
+ if (old && sel.anchorNode == null) { sel.addRange(old); }
8911
+ else if (gecko) { this.startGracePeriod(); }
8912
  }
8913
+ this.rememberSelection();
8914
+ };
8915
 
8916
+ ContentEditableInput.prototype.startGracePeriod = function () {
8917
+ var this$1 = this;
8918
 
8919
+ clearTimeout(this.gracePeriod);
8920
+ this.gracePeriod = setTimeout(function () {
8921
+ this$1.gracePeriod = false;
8922
+ if (this$1.selectionChanged())
8923
+ { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); }
8924
+ }, 20);
8925
+ };
 
8926
 
8927
+ ContentEditableInput.prototype.showMultipleSelections = function (info) {
8928
+ removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
8929
+ removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
8930
+ };
8931
+
8932
+ ContentEditableInput.prototype.rememberSelection = function () {
8933
+ var sel = this.getSelection();
8934
+ this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
8935
+ this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
8936
+ };
8937
+
8938
+ ContentEditableInput.prototype.selectionInEditor = function () {
8939
+ var sel = this.getSelection();
8940
+ if (!sel.rangeCount) { return false }
8941
+ var node = sel.getRangeAt(0).commonAncestorContainer;
8942
+ return contains(this.div, node)
8943
+ };
8944
+
8945
+ ContentEditableInput.prototype.focus = function () {
8946
+ if (this.cm.options.readOnly != "nocursor") {
8947
+ if (!this.selectionInEditor())
8948
+ { this.showSelection(this.prepareSelection(), true); }
8949
+ this.div.focus();
 
 
 
 
 
 
 
 
 
8950
  }
8951
+ };
8952
+ ContentEditableInput.prototype.blur = function () { this.div.blur(); };
8953
+ ContentEditableInput.prototype.getField = function () { return this.div };
8954
 
8955
+ ContentEditableInput.prototype.supportsTouch = function () { return true };
 
 
 
 
8956
 
8957
+ ContentEditableInput.prototype.receivedFocus = function () {
8958
+ var input = this;
8959
+ if (this.selectionInEditor())
8960
+ { this.pollSelection(); }
8961
+ else
8962
+ { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
8963
 
8964
+ function poll() {
8965
+ if (input.cm.state.focused) {
8966
+ input.pollSelection();
8967
+ input.polling.set(input.cm.options.pollInterval, poll);
8968
+ }
8969
+ }
8970
+ this.polling.set(this.cm.options.pollInterval, poll);
8971
+ };
8972
 
8973
+ ContentEditableInput.prototype.selectionChanged = function () {
8974
+ var sel = this.getSelection();
8975
+ return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
8976
+ sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
8977
  };
8978
+
8979
+ ContentEditableInput.prototype.pollSelection = function () {
8980
+ if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
8981
+ var sel = this.getSelection(), cm = this.cm;
8982
+ // On Android Chrome (version 56, at least), backspacing into an
8983
+ // uneditable block element will put the cursor in that element,
8984
+ // and then, because it's not editable, hide the virtual keyboard.
8985
+ // Because Android doesn't allow us to actually detect backspace
8986
+ // presses in a sane way, this code checks for when that happens
8987
+ // and simulates a backspace press in this case.
8988
+ if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) {
8989
+ this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs});
8990
+ this.blur();
8991
+ this.focus();
8992
+ return
8993
+ }
8994
+ if (this.composing) { return }
8995
+ this.rememberSelection();
8996
+ var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
8997
+ var head = domToPos(cm, sel.focusNode, sel.focusOffset);
8998
+ if (anchor && head) { runInOp(cm, function () {
8999
+ setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
9000
+ if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; }
9001
+ }); }
9002
  };
 
 
 
 
9003
 
9004
+ ContentEditableInput.prototype.pollContent = function () {
9005
+ if (this.readDOMTimeout != null) {
9006
+ clearTimeout(this.readDOMTimeout);
9007
+ this.readDOMTimeout = null;
 
 
 
9008
  }
 
 
 
9009
 
9010
+ var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
9011
+ var from = sel.from(), to = sel.to();
9012
+ if (from.ch == 0 && from.line > cm.firstLine())
9013
+ { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }
9014
+ if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
9015
+ { to = Pos(to.line + 1, 0); }
9016
+ if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
9017
+
9018
+ var fromIndex, fromLine, fromNode;
9019
+ if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
9020
+ fromLine = lineNo(display.view[0].line);
9021
+ fromNode = display.view[0].node;
9022
+ } else {
9023
+ fromLine = lineNo(display.view[fromIndex].line);
9024
+ fromNode = display.view[fromIndex - 1].node.nextSibling;
9025
+ }
9026
+ var toIndex = findViewIndex(cm, to.line);
9027
+ var toLine, toNode;
9028
+ if (toIndex == display.view.length - 1) {
9029
+ toLine = display.viewTo - 1;
9030
+ toNode = display.lineDiv.lastChild;
9031
+ } else {
9032
+ toLine = lineNo(display.view[toIndex + 1].line) - 1;
9033
+ toNode = display.view[toIndex + 1].node.previousSibling;
9034
+ }
9035
+
9036
+ if (!fromNode) { return false }
9037
+ var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
9038
+ var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
9039
+ while (newText.length > 1 && oldText.length > 1) {
9040
+ if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
9041
+ else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
9042
+ else { break }
9043
+ }
9044
+
9045
+ var cutFront = 0, cutEnd = 0;
9046
+ var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
9047
+ while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
9048
+ { ++cutFront; }
9049
+ var newBot = lst(newText), oldBot = lst(oldText);
9050
+ var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
9051
+ oldBot.length - (oldText.length == 1 ? cutFront : 0));
9052
+ while (cutEnd < maxCutEnd &&
9053
+ newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
9054
+ { ++cutEnd; }
9055
+ // Try to move start of change to start of selection if ambiguous
9056
+ if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
9057
+ while (cutFront && cutFront > from.ch &&
9058
+ newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
9059
+ cutFront--;
9060
+ cutEnd++;
9061
+ }
9062
+ }
9063
+
9064
+ newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
9065
+ newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
9066
+
9067
+ var chFrom = Pos(fromLine, cutFront);
9068
+ var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
9069
+ if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
9070
+ replaceRange(cm.doc, newText, chFrom, chTo, "+input");
9071
+ return true
9072
+ }
9073
+ };
9074
+
9075
+ ContentEditableInput.prototype.ensurePolled = function () {
9076
+ this.forceCompositionEnd();
9077
+ };
9078
+ ContentEditableInput.prototype.reset = function () {
9079
+ this.forceCompositionEnd();
9080
+ };
9081
+ ContentEditableInput.prototype.forceCompositionEnd = function () {
9082
+ if (!this.composing) { return }
9083
+ clearTimeout(this.readDOMTimeout);
9084
+ this.composing = null;
9085
+ this.updateFromDOM();
9086
+ this.div.blur();
9087
+ this.div.focus();
9088
+ };
9089
+ ContentEditableInput.prototype.readFromDOMSoon = function () {
9090
+ var this$1 = this;
9091
+
9092
+ if (this.readDOMTimeout != null) { return }
9093
+ this.readDOMTimeout = setTimeout(function () {
9094
+ this$1.readDOMTimeout = null;
9095
+ if (this$1.composing) {
9096
+ if (this$1.composing.done) { this$1.composing = null; }
9097
+ else { return }
9098
+ }
9099
+ this$1.updateFromDOM();
9100
+ }, 80);
9101
+ };
9102
 
9103
+ ContentEditableInput.prototype.updateFromDOM = function () {
9104
+ var this$1 = this;
9105
 
9106
+ if (this.cm.isReadOnly() || !this.pollContent())
9107
+ { runInOp(this.cm, function () { return regChange(this$1.cm); }); }
 
 
 
 
 
 
 
 
9108
  };
9109
 
9110
+ ContentEditableInput.prototype.setUneditable = function (node) {
9111
+ node.contentEditable = "false";
 
 
 
 
 
 
 
 
 
9112
  };
9113
 
9114
+ ContentEditableInput.prototype.onKeyPress = function (e) {
9115
+ if (e.charCode == 0 || this.composing) { return }
9116
+ e.preventDefault();
9117
+ if (!this.cm.isReadOnly())
9118
+ { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); }
9119
  };
9120
 
9121
+ ContentEditableInput.prototype.readOnlyChanged = function (val) {
9122
+ this.div.contentEditable = String(val != "nocursor");
9123
+ };
9124
 
9125
+ ContentEditableInput.prototype.onContextMenu = function () {};
9126
+ ContentEditableInput.prototype.resetPosition = function () {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9127
 
9128
+ ContentEditableInput.prototype.needsContentAttribute = true;
 
 
 
 
9129
 
9130
+ function posToDOM(cm, pos) {
9131
+ var view = findViewForLine(cm, pos.line);
9132
+ if (!view || view.hidden) { return null }
9133
+ var line = getLine(cm.doc, pos.line);
9134
+ var info = mapFromLineView(view, line, pos.line);
 
 
9135
 
9136
+ var order = getOrder(line, cm.doc.direction), side = "left";
9137
+ if (order) {
9138
+ var partPos = getBidiPartAt(order, pos.ch);
9139
+ side = partPos % 2 ? "right" : "left";
9140
+ }
9141
+ var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
9142
+ result.offset = result.collapse == "right" ? result.end : result.start;
9143
+ return result
9144
  }
9145
 
9146
+ function isInGutter(node) {
9147
+ for (var scan = node; scan; scan = scan.parentNode)
9148
+ { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
9149
+ return false
9150
  }
9151
 
9152
+ function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
 
 
 
 
 
9153
 
9154
+ function domTextBetween(cm, from, to, fromLine, toLine) {
9155
+ var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false;
9156
+ function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
9157
+ function close() {
9158
+ if (closing) {
9159
+ text += lineSep;
9160
+ if (extraLinebreak) { text += lineSep; }
9161
+ closing = extraLinebreak = false;
9162
+ }
9163
+ }
9164
+ function addText(str) {
9165
+ if (str) {
9166
+ close();
9167
+ text += str;
9168
+ }
9169
+ }
9170
+ function walk(node) {
9171
+ if (node.nodeType == 1) {
9172
+ var cmText = node.getAttribute("cm-text");
9173
+ if (cmText) {
9174
+ addText(cmText);
9175
+ return
9176
+ }
9177
+ var markerID = node.getAttribute("cm-marker"), range$$1;
9178
+ if (markerID) {
9179
+ var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
9180
+ if (found.length && (range$$1 = found[0].find(0)))
9181
+ { addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep)); }
9182
+ return
9183
+ }
9184
+ if (node.getAttribute("contenteditable") == "false") { return }
9185
+ var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName);
9186
+ if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return }
9187
 
9188
+ if (isBlock) { close(); }
9189
+ for (var i = 0; i < node.childNodes.length; i++)
9190
+ { walk(node.childNodes[i]); }
9191
 
9192
+ if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; }
9193
+ if (isBlock) { closing = true; }
9194
+ } else if (node.nodeType == 3) {
9195
+ addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "));
9196
+ }
9197
+ }
9198
+ for (;;) {
9199
+ walk(from);
9200
+ if (from == to) { break }
9201
+ from = from.nextSibling;
9202
+ extraLinebreak = false;
9203
+ }
9204
+ return text
9205
+ }
9206
 
9207
+ function domToPos(cm, node, offset) {
9208
+ var lineNode;
9209
+ if (node == cm.display.lineDiv) {
9210
+ lineNode = cm.display.lineDiv.childNodes[offset];
9211
+ if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
9212
+ node = null; offset = 0;
9213
+ } else {
9214
+ for (lineNode = node;; lineNode = lineNode.parentNode) {
9215
+ if (!lineNode || lineNode == cm.display.lineDiv) { return null }
9216
+ if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
9217
+ }
9218
+ }
9219
+ for (var i = 0; i < cm.display.view.length; i++) {
9220
+ var lineView = cm.display.view[i];
9221
+ if (lineView.node == lineNode)
9222
+ { return locateNodeInLineView(lineView, node, offset) }
9223
+ }
9224
+ }
9225
 
9226
+ function locateNodeInLineView(lineView, node, offset) {
9227
+ var wrapper = lineView.text.firstChild, bad = false;
9228
+ if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
9229
+ if (node == wrapper) {
9230
+ bad = true;
9231
+ node = wrapper.childNodes[offset];
9232
+ offset = 0;
9233
+ if (!node) {
9234
+ var line = lineView.rest ? lst(lineView.rest) : lineView.line;
9235
+ return badPos(Pos(lineNo(line), line.text.length), bad)
9236
+ }
9237
+ }
9238
 
9239
+ var textNode = node.nodeType == 3 ? node : null, topNode = node;
9240
+ if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
9241
+ textNode = node.firstChild;
9242
+ if (offset) { offset = textNode.nodeValue.length; }
 
 
9243
  }
9244
+ while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; }
9245
+ var measure = lineView.measure, maps = measure.maps;
9246
+
9247
+ function find(textNode, topNode, offset) {
9248
+ for (var i = -1; i < (maps ? maps.length : 0); i++) {
9249
+ var map$$1 = i < 0 ? measure.map : maps[i];
9250
+ for (var j = 0; j < map$$1.length; j += 3) {
9251
+ var curNode = map$$1[j + 2];
9252
+ if (curNode == textNode || curNode == topNode) {
9253
+ var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
9254
+ var ch = map$$1[j] + offset;
9255
+ if (offset < 0 || curNode != textNode) { ch = map$$1[j + (offset ? 1 : 0)]; }
9256
+ return Pos(line, ch)
9257
+ }
9258
+ }
9259
+ }
9260
  }
9261
+ var found = find(textNode, topNode, offset);
9262
+ if (found) { return badPos(found, bad) }
9263
 
9264
+ // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
9265
+ for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
9266
+ found = find(after, after.firstChild, 0);
9267
+ if (found)
9268
+ { return badPos(Pos(found.line, found.ch - dist), bad) }
9269
+ else
9270
+ { dist += after.textContent.length; }
9271
+ }
9272
+ for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
9273
+ found = find(before, before.firstChild, -1);
9274
+ if (found)
9275
+ { return badPos(Pos(found.line, found.ch + dist$1), bad) }
9276
+ else
9277
+ { dist$1 += before.textContent.length; }
9278
  }
9279
  }
9280
 
9281
+ // TEXTAREA INPUT STYLE
 
 
 
 
 
9282
 
9283
+ var TextareaInput = function(cm) {
9284
+ this.cm = cm;
9285
+ // See input.poll and input.reset
9286
+ this.prevInput = "";
9287
 
9288
+ // Flag that indicates whether we expect input to appear real soon
9289
+ // now (after some event like 'keypress' or 'input') and are
9290
+ // polling intensively.
9291
+ this.pollingFast = false;
9292
+ // Self-resetting timeout for the poller
9293
+ this.polling = new Delayed();
9294
+ // Used to work around IE issue with selection being forgotten when focus moves away from textarea
9295
+ this.hasSelection = false;
9296
+ this.composing = null;
9297
+ };
9298
 
9299
+ TextareaInput.prototype.init = function (display) {
9300
+ var this$1 = this;
 
 
 
 
 
 
 
 
 
 
9301
 
9302
+ var input = this, cm = this.cm;
9303
+ this.createField(display);
9304
+ var te = this.textarea;
 
 
 
 
 
 
 
 
 
9305
 
9306
+ display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
 
 
 
 
 
 
9307
 
9308
+ // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
9309
+ if (ios) { te.style.width = "0px"; }
 
 
9310
 
9311
+ on(te, "input", function () {
9312
+ if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; }
9313
+ input.poll();
9314
+ });
 
 
 
 
 
 
9315
 
9316
+ on(te, "paste", function (e) {
9317
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
 
 
9318
 
9319
+ cm.state.pasteIncoming = +new Date;
9320
+ input.fastPoll();
9321
+ });
9322
+
9323
+ function prepareCopyCut(e) {
9324
+ if (signalDOMEvent(cm, e)) { return }
9325
+ if (cm.somethingSelected()) {
9326
+ setLastCopied({lineWise: false, text: cm.getSelections()});
9327
+ } else if (!cm.options.lineWiseCopyCut) {
9328
+ return
9329
+ } else {
9330
+ var ranges = copyableRanges(cm);
9331
+ setLastCopied({lineWise: true, text: ranges.text});
9332
+ if (e.type == "cut") {
9333
+ cm.setSelections(ranges.ranges, null, sel_dontScroll);
9334
+ } else {
9335
+ input.prevInput = "";
9336
+ te.value = ranges.text.join("\n");
9337
+ selectInput(te);
9338
+ }
9339
+ }
9340
+ if (e.type == "cut") { cm.state.cutIncoming = +new Date; }
9341
+ }
9342
+ on(te, "cut", prepareCopyCut);
9343
+ on(te, "copy", prepareCopyCut);
9344
 
9345
+ on(display.scroller, "paste", function (e) {
9346
+ if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
9347
+ if (!te.dispatchEvent) {
9348
+ cm.state.pasteIncoming = +new Date;
9349
+ input.focus();
9350
+ return
9351
+ }
9352
 
9353
+ // Pass the `paste` event to the textarea so it's handled by its event listener.
9354
+ var event = new Event("paste");
9355
+ event.clipboardData = e.clipboardData;
9356
+ te.dispatchEvent(event);
9357
+ });
 
 
 
9358
 
9359
+ // Prevent normal selection in the editor (we handle our own)
9360
+ on(display.lineSpace, "selectstart", function (e) {
9361
+ if (!eventInWidget(display, e)) { e_preventDefault(e); }
9362
+ });
9363
+
9364
+ on(te, "compositionstart", function () {
9365
+ var start = cm.getCursor("from");
9366
+ if (input.composing) { input.composing.range.clear(); }
9367
+ input.composing = {
9368
+ start: start,
9369
+ range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
9370
+ };
9371
+ });
9372
+ on(te, "compositionend", function () {
9373
+ if (input.composing) {
9374
+ input.poll();
9375
+ input.composing.range.clear();
9376
+ input.composing = null;
9377
+ }
9378
+ });
9379
  };
9380
+
9381
+ TextareaInput.prototype.createField = function (_display) {
9382
+ // Wraps and hides input textarea
9383
+ this.wrapper = hiddenTextarea();
9384
+ // The semihidden textarea that is focused when the editor is
9385
+ // focused, and receives input.
9386
+ this.textarea = this.wrapper.firstChild;
9387
  };
9388
 
9389
+ TextareaInput.prototype.prepareSelection = function () {
9390
+ // Redraw the selection and/or cursor
9391
+ var cm = this.cm, display = cm.display, doc = cm.doc;
9392
+ var result = prepareSelection(cm);
 
9393
 
9394
+ // Move the hidden textarea near the cursor to prevent scrolling artifacts
9395
+ if (cm.options.moveInputWithCursor) {
9396
+ var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
9397
+ var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
9398
+ result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
9399
+ headPos.top + lineOff.top - wrapOff.top));
9400
+ result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
9401
+ headPos.left + lineOff.left - wrapOff.left));
9402
+ }
9403
 
9404
+ return result
9405
+ };
 
 
 
 
9406
 
9407
+ TextareaInput.prototype.showSelection = function (drawn) {
9408
+ var cm = this.cm, display = cm.display;
9409
+ removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
9410
+ removeChildrenAndAdd(display.selectionDiv, drawn.selection);
9411
+ if (drawn.teTop != null) {
9412
+ this.wrapper.style.top = drawn.teTop + "px";
9413
+ this.wrapper.style.left = drawn.teLeft + "px";
9414
+ }
9415
  };
9416
 
9417
+ // Reset the input to correspond to the selection (or to be empty,
9418
+ // when not typing and nothing is selected)
9419
+ TextareaInput.prototype.reset = function (typing) {
9420
+ if (this.contextMenuPending || this.composing) { return }
9421
+ var cm = this.cm;
9422
+ if (cm.somethingSelected()) {
9423
+ this.prevInput = "";
9424
+ var content = cm.getSelection();
9425
+ this.textarea.value = content;
9426
+ if (cm.state.focused) { selectInput(this.textarea); }
9427
+ if (ie && ie_version >= 9) { this.hasSelection = content; }
9428
+ } else if (!typing) {
9429
+ this.prevInput = this.textarea.value = "";
9430
+ if (ie && ie_version >= 9) { this.hasSelection = null; }
9431
+ }
9432
+ };
9433
 
9434
+ TextareaInput.prototype.getField = function () { return this.textarea };
9435
 
9436
+ TextareaInput.prototype.supportsTouch = function () { return false };
 
 
9437
 
9438
+ TextareaInput.prototype.focus = function () {
9439
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
9440
+ try { this.textarea.focus(); }
9441
+ catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
 
 
9442
  }
9443
+ };
9444
 
9445
+ TextareaInput.prototype.blur = function () { this.textarea.blur(); };
9446
+
9447
+ TextareaInput.prototype.resetPosition = function () {
9448
+ this.wrapper.style.top = this.wrapper.style.left = 0;
9449
+ };
9450
+
9451
+ TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); };
9452
+
9453
+ // Poll for input changes, using the normal rate of polling. This
9454
+ // runs as long as the editor is focused.
9455
+ TextareaInput.prototype.slowPoll = function () {
9456
+ var this$1 = this;
9457
+
9458
+ if (this.pollingFast) { return }
9459
+ this.polling.set(this.cm.options.pollInterval, function () {
9460
+ this$1.poll();
9461
+ if (this$1.cm.state.focused) { this$1.slowPoll(); }
 
 
9462
  });
9463
+ };
9464
+
9465
+ // When an event has just come in that is likely to add or change
9466
+ // something in the input textarea, we poll faster, to ensure that
9467
+ // the change appears on the screen quickly.
9468
+ TextareaInput.prototype.fastPoll = function () {
9469
+ var missed = false, input = this;
9470
+ input.pollingFast = true;
9471
+ function p() {
9472
+ var changed = input.poll();
9473
+ if (!changed && !missed) {missed = true; input.polling.set(60, p);}
9474
+ else {input.pollingFast = false; input.slowPoll();}
9475
+ }
9476
+ input.polling.set(20, p);
9477
+ };
9478
 
9479
+ // Read input from the textarea, and update the document to match.
9480
+ // When something is selected, it is present in the textarea, and
9481
+ // selected (unless it is huge, in which case a placeholder is
9482
+ // used). When nothing is selected, the cursor sits after previously
9483
+ // seen text (can be empty), which is stored in prevInput (we must
9484
+ // not reset the textarea when typing, because that breaks IME).
9485
+ TextareaInput.prototype.poll = function () {
9486
+ var this$1 = this;
9487
 
9488
+ var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
9489
+ // Since this is called a *lot*, try to bail out as cheaply as
9490
+ // possible when it is clear that nothing happened. hasSelection
9491
+ // will be the case when there is a lot of text in the textarea,
9492
+ // in which case reading its value would be expensive.
9493
+ if (this.contextMenuPending || !cm.state.focused ||
9494
+ (hasSelection(input) && !prevInput && !this.composing) ||
9495
+ cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
9496
+ { return false }
9497
 
9498
+ var text = input.value;
9499
+ // If nothing changed, bail.
9500
+ if (text == prevInput && !cm.somethingSelected()) { return false }
9501
+ // Work around nonsensical selection resetting in IE9/10, and
9502
+ // inexplicable appearance of private area unicode characters on
9503
+ // some key combos in Mac (#2689).
9504
+ if (ie && ie_version >= 9 && this.hasSelection === text ||
9505
+ mac && /[\uf700-\uf7ff]/.test(text)) {
9506
+ cm.display.input.reset();
9507
+ return false
9508
+ }
9509
 
9510
+ if (cm.doc.sel == cm.display.selForContextMenu) {
9511
+ var first = text.charCodeAt(0);
9512
+ if (first == 0x200b && !prevInput) { prevInput = "\u200b"; }
9513
+ if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
 
 
 
9514
  }
9515
+ // Find the part of the input that is actually new
9516
+ var same = 0, l = Math.min(prevInput.length, text.length);
9517
+ while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; }
9518
 
9519
+ runInOp(cm, function () {
9520
+ applyTextInput(cm, text.slice(same), prevInput.length - same,
9521
+ null, this$1.composing ? "*compose" : null);
 
 
 
 
 
 
 
9522
 
9523
+ // Don't leave long text in the textarea, since it makes further polling slow
9524
+ if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; }
9525
+ else { this$1.prevInput = text; }
9526
+
9527
+ if (this$1.composing) {
9528
+ this$1.composing.range.clear();
9529
+ this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
9530
+ {className: "CodeMirror-composing"});
 
 
 
 
 
 
 
9531
  }
9532
+ });
9533
+ return true
9534
+ };
9535
 
9536
+ TextareaInput.prototype.ensurePolled = function () {
9537
+ if (this.pollingFast && this.poll()) { this.pollingFast = false; }
 
 
 
 
 
 
9538
  };
9539
 
9540
+ TextareaInput.prototype.onKeyPress = function () {
9541
+ if (ie && ie_version >= 9) { this.hasSelection = null; }
9542
+ this.fastPoll();
9543
+ };
 
 
9544
 
9545
+ TextareaInput.prototype.onContextMenu = function (e) {
9546
+ var input = this, cm = input.cm, display = cm.display, te = input.textarea;
9547
+ if (input.contextMenuPending) { input.contextMenuPending(); }
9548
+ var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
9549
+ if (!pos || presto) { return } // Opera is difficult.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9550
 
9551
+ // Reset the current text selection only if the click is done outside of the selection
9552
+ // and 'resetSelectionOnContextMenu' option is true.
9553
+ var reset = cm.options.resetSelectionOnContextMenu;
9554
+ if (reset && cm.doc.sel.contains(pos) == -1)
9555
+ { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }
9556
+
9557
+ var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
9558
+ var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect();
9559
+ input.wrapper.style.cssText = "position: static";
9560
+ te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
9561
+ var oldScrollY;
9562
+ if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
9563
+ display.input.focus();
9564
+ if (webkit) { window.scrollTo(null, oldScrollY); }
9565
+ display.input.reset();
9566
+ // Adds "Select all" to context menu in FF
9567
+ if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
9568
+ input.contextMenuPending = rehide;
9569
+ display.selForContextMenu = cm.doc.sel;
9570
+ clearTimeout(display.detectingSelectAll);
9571
 
9572
+ // Select-all will be greyed out if there's nothing to select, so
9573
+ // this adds a zero-width space so that we can later check whether
9574
+ // it got selected.
9575
+ function prepareSelectAllHack() {
9576
+ if (te.selectionStart != null) {
9577
+ var selected = cm.somethingSelected();
9578
+ var extval = "\u200b" + (selected ? te.value : "");
9579
+ te.value = "\u21da"; // Used to catch context-menu undo
9580
+ te.value = extval;
9581
+ input.prevInput = selected ? "" : "\u200b";
9582
+ te.selectionStart = 1; te.selectionEnd = extval.length;
9583
+ // Re-set this, in case some other handler touched the
9584
+ // selection in the meantime.
9585
+ display.selForContextMenu = cm.doc.sel;
9586
  }
9587
  }
9588
+ function rehide() {
9589
+ if (input.contextMenuPending != rehide) { return }
9590
+ input.contextMenuPending = false;
9591
+ input.wrapper.style.cssText = oldWrapperCSS;
9592
+ te.style.cssText = oldCSS;
9593
+ if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); }
 
 
 
 
 
 
9594
 
9595
+ // Try to detect the user choosing select-all
9596
+ if (te.selectionStart != null) {
9597
+ if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); }
9598
+ var i = 0, poll = function () {
9599
+ if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
9600
+ te.selectionEnd > 0 && input.prevInput == "\u200b") {
9601
+ operation(cm, selectAll)(cm);
9602
+ } else if (i++ < 10) {
9603
+ display.detectingSelectAll = setTimeout(poll, 500);
9604
+ } else {
9605
+ display.selForContextMenu = null;
9606
+ display.input.reset();
9607
+ }
9608
+ };
9609
+ display.detectingSelectAll = setTimeout(poll, 200);
9610
+ }
9611
  }
 
 
 
 
9612
 
9613
+ if (ie && ie_version >= 9) { prepareSelectAllHack(); }
9614
+ if (captureRightClick) {
9615
+ e_stop(e);
9616
+ var mouseup = function () {
9617
+ off(window, "mouseup", mouseup);
9618
+ setTimeout(rehide, 20);
9619
+ };
9620
+ on(window, "mouseup", mouseup);
9621
+ } else {
9622
+ setTimeout(rehide, 50);
 
 
 
 
 
 
 
 
 
 
 
 
 
9623
  }
9624
+ };
 
9625
 
9626
+ TextareaInput.prototype.readOnlyChanged = function (val) {
9627
+ if (!val) { this.reset(); }
9628
+ this.textarea.disabled = val == "nocursor";
9629
+ };
 
 
9630
 
9631
+ TextareaInput.prototype.setUneditable = function () {};
 
 
 
 
 
 
 
 
 
9632
 
9633
+ TextareaInput.prototype.needsContentAttribute = false;
9634
+
9635
+ function fromTextArea(textarea, options) {
9636
+ options = options ? copyObj(options) : {};
9637
+ options.value = textarea.value;
9638
+ if (!options.tabindex && textarea.tabIndex)
9639
+ { options.tabindex = textarea.tabIndex; }
9640
+ if (!options.placeholder && textarea.placeholder)
9641
+ { options.placeholder = textarea.placeholder; }
9642
+ // Set autofocus to true if this textarea is focused, or if it has
9643
+ // autofocus and no other element is focused.
9644
+ if (options.autofocus == null) {
9645
+ var hasFocus = activeElt();
9646
+ options.autofocus = hasFocus == textarea ||
9647
+ textarea.getAttribute("autofocus") != null && hasFocus == document.body;
9648
  }
 
9649
 
9650
+ function save() {textarea.value = cm.getValue();}
 
 
 
 
9651
 
9652
+ var realSubmit;
9653
+ if (textarea.form) {
9654
+ on(textarea.form, "submit", save);
9655
+ // Deplorable hack to make the submit method do the right thing.
9656
+ if (!options.leaveSubmitMethodAlone) {
9657
+ var form = textarea.form;
9658
+ realSubmit = form.submit;
9659
+ try {
9660
+ var wrappedSubmit = form.submit = function () {
9661
+ save();
9662
+ form.submit = realSubmit;
9663
+ form.submit();
9664
+ form.submit = wrappedSubmit;
9665
+ };
9666
+ } catch(e) {}
9667
+ }
9668
+ }
9669
 
9670
+ options.finishInit = function (cm) {
9671
+ cm.save = save;
9672
+ cm.getTextArea = function () { return textarea; };
9673
+ cm.toTextArea = function () {
9674
+ cm.toTextArea = isNaN; // Prevent this from being ran twice
9675
+ save();
9676
+ textarea.parentNode.removeChild(cm.getWrapperElement());
9677
+ textarea.style.display = "";
9678
+ if (textarea.form) {
9679
+ off(textarea.form, "submit", save);
9680
+ if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function")
9681
+ { textarea.form.submit = realSubmit; }
9682
+ }
9683
+ };
9684
+ };
9685
 
9686
+ textarea.style.display = "none";
9687
+ var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
9688
+ options);
9689
+ return cm
9690
+ }
9691
+
9692
+ function addLegacyProps(CodeMirror) {
9693
+ CodeMirror.off = off;
9694
+ CodeMirror.on = on;
9695
+ CodeMirror.wheelEventPixels = wheelEventPixels;
9696
+ CodeMirror.Doc = Doc;
9697
+ CodeMirror.splitLines = splitLinesAuto;
9698
+ CodeMirror.countColumn = countColumn;
9699
+ CodeMirror.findColumn = findColumn;
9700
+ CodeMirror.isWordChar = isWordCharBasic;
9701
+ CodeMirror.Pass = Pass;
9702
+ CodeMirror.signal = signal;
9703
+ CodeMirror.Line = Line;
9704
+ CodeMirror.changeEnd = changeEnd;
9705
+ CodeMirror.scrollbarModel = scrollbarModel;
9706
+ CodeMirror.Pos = Pos;
9707
+ CodeMirror.cmpPos = cmp;
9708
+ CodeMirror.modes = modes;
9709
+ CodeMirror.mimeModes = mimeModes;
9710
+ CodeMirror.resolveMode = resolveMode;
9711
+ CodeMirror.getMode = getMode;
9712
+ CodeMirror.modeExtensions = modeExtensions;
9713
+ CodeMirror.extendMode = extendMode;
9714
+ CodeMirror.copyState = copyState;
9715
+ CodeMirror.startState = startState;
9716
+ CodeMirror.innerMode = innerMode;
9717
+ CodeMirror.commands = commands;
9718
+ CodeMirror.keyMap = keyMap;
9719
+ CodeMirror.keyName = keyName;
9720
+ CodeMirror.isModifierKey = isModifierKey;
9721
+ CodeMirror.lookupKey = lookupKey;
9722
+ CodeMirror.normalizeKeyMap = normalizeKeyMap;
9723
+ CodeMirror.StringStream = StringStream;
9724
+ CodeMirror.SharedTextMarker = SharedTextMarker;
9725
+ CodeMirror.TextMarker = TextMarker;
9726
+ CodeMirror.LineWidget = LineWidget;
9727
+ CodeMirror.e_preventDefault = e_preventDefault;
9728
+ CodeMirror.e_stopPropagation = e_stopPropagation;
9729
+ CodeMirror.e_stop = e_stop;
9730
+ CodeMirror.addClass = addClass;
9731
+ CodeMirror.contains = contains;
9732
+ CodeMirror.rmClass = rmClass;
9733
+ CodeMirror.keyNames = keyNames;
9734
+ }
9735
 
9736
+ // EDITOR CONSTRUCTOR
 
 
 
9737
 
9738
+ defineOptions(CodeMirror);
 
 
 
9739
 
9740
+ addEditorMethods(CodeMirror);
 
 
 
 
9741
 
9742
+ // Set up methods on CodeMirror's prototype to redirect to the editor's document.
9743
+ var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
9744
+ for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
9745
+ { CodeMirror.prototype[prop] = (function(method) {
9746
+ return function() {return method.apply(this.doc, arguments)}
9747
+ })(Doc.prototype[prop]); } }
 
 
 
9748
 
9749
+ eventMixin(Doc);
9750
+ CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
 
 
 
 
 
 
 
 
9751
 
9752
+ // Extra arguments are stored as the mode's dependencies, which is
9753
+ // used by (legacy) mechanisms like loadmode.js to automatically
9754
+ // load a mode. (Preferred mechanism is the require/define calls.)
9755
+ CodeMirror.defineMode = function(name/*, mode, …*/) {
9756
+ if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; }
9757
+ defineMode.apply(this, arguments);
9758
+ };
 
 
 
9759
 
9760
+ CodeMirror.defineMIME = defineMIME;
 
 
 
 
 
 
 
 
 
 
 
 
 
9761
 
9762
+ // Minimal default mode.
9763
+ CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
9764
+ CodeMirror.defineMIME("text/plain", "null");
 
 
 
 
 
9765
 
9766
+ // EXTENSIONS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9767
 
9768
+ CodeMirror.defineExtension = function (name, func) {
9769
+ CodeMirror.prototype[name] = func;
9770
+ };
9771
+ CodeMirror.defineDocExtension = function (name, func) {
9772
+ Doc.prototype[name] = func;
9773
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9774
 
9775
+ CodeMirror.fromTextArea = fromTextArea;
 
 
9776
 
9777
+ addLegacyProps(CodeMirror);
9778
 
9779
+ CodeMirror.version = "5.49.2";
9780
 
9781
  return CodeMirror;
9782
+
9783
+ })));
admin/dist/css/admin.css CHANGED
@@ -757,6 +757,97 @@ disabled look for disabled choices in the results dropdown
757
  .alm-pro-listing .item.inactive:hover .state:before {
758
  opacity: 1; }
759
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
  .ajax-load-more .cnkt-sidebar {
761
  width: 33%;
762
  float: right;
@@ -1279,7 +1370,7 @@ a.layout-hover:hover img {
1279
 
1280
  /* Expand/Collapse all rows */
1281
  .ajax-load-more .toggle-all {
1282
- position: absolute;
1283
  top: -16px;
1284
  right: 20px;
1285
  width: auto;
@@ -1294,7 +1385,12 @@ a.layout-hover:hover img {
1294
  border: 1px solid #e1e1e1;
1295
  color: #777;
1296
  cursor: pointer;
1297
- z-index: 20; }
 
 
 
 
 
1298
 
1299
  #alm-container.ajax-load-more .toggle-all {
1300
  display: none; }
@@ -1583,10 +1679,14 @@ a.button-small {
1583
  display: inline-block;
1584
  clear: both;
1585
  border-radius: 3px;
1586
- color: #444;
1587
  -webkit-box-shadow: none;
1588
  box-shadow: none; }
1589
 
 
 
 
 
1590
  .controls button.disabled {
1591
  opacity: 0.5; }
1592
 
@@ -1695,8 +1795,8 @@ a.button-small {
1695
  .ajax-load-more input[type=email]:focus,
1696
  .ajax-load-more textarea:focus {
1697
  border-color: #bbbbbb;
1698
- -webkit-box-shadow: 0 0 6px #ccc;
1699
- box-shadow: 0 0 6px #ccc;
1700
  background: #f7f7f7; }
1701
 
1702
  .checkboxes label {
@@ -1944,10 +2044,11 @@ hr.indented {
1944
  padding-left: 0 !important; }
1945
 
1946
  .ajax-load-more label.template-title {
1947
- padding: 8px 0 10px;
1948
  margin: 0;
1949
- font-size: 13px;
1950
- color: #888; }
 
1951
 
1952
  .ajax-load-more label input._alm_repeater_alias {
1953
  height: auto;
@@ -2398,6 +2499,14 @@ table.highlight {
2398
  -webkit-box-shadow: none;
2399
  box-shadow: none; }
2400
 
 
 
 
 
 
 
 
 
2401
  .ajax-load-more .cnkt-main.full {
2402
  width: 100%;
2403
  float: none; }
@@ -2429,7 +2538,13 @@ table.highlight {
2429
  padding: 15px 0 !important; }
2430
 
2431
  .repeaters .repeater-wrap label {
2432
- cursor: default; }
 
 
 
 
 
 
2433
 
2434
  .repeaters input.save-repeater {
2435
  display: inline-block;
@@ -2950,11 +3065,11 @@ span.cnkt-button.installed i,
2950
  margin-top: 0; }
2951
 
2952
  .ajax-load-more .cnkt-sidebar h3 {
2953
- padding: 14px 20px;
2954
  background: #fff;
2955
  margin: 0;
2956
  display: block;
2957
- font-size: 15px;
2958
  font-weight: 700;
2959
  text-transform: none;
2960
  border-radius: 2px 2px 0 0; }
@@ -3132,93 +3247,6 @@ span.cnkt-button.installed i,
3132
  * CodeMirror Syntax Highlighting
3133
  * @since 2.2.0
3134
  */
3135
- .ajax-load-more .CodeMirror {
3136
- height: auto;
3137
- border-radius: 3px;
3138
- padding: 5px;
3139
- background: #f7f7f7;
3140
- border: 1px solid #e1e1e1;
3141
- color: #999;
3142
- line-height: 1.5; }
3143
- .ajax-load-more .CodeMirror.CodeMirror-focused {
3144
- border-color: #bbbbbb;
3145
- -webkit-box-shadow: 0 0 6px #ccc;
3146
- box-shadow: 0 0 6px #ccc; }
3147
-
3148
- .ajax-load-more .cm-readonly .CodeMirror {
3149
- opacity: 0.8; }
3150
-
3151
- .ajax-load-more .cm-readonly .CodeMirror pre {
3152
- cursor: default !important; }
3153
-
3154
- .ajax-load-more .CodeMirror pre {
3155
- padding: 0 10px; }
3156
-
3157
- .CodeMirror-linenumber {
3158
- padding: 0 10px !important;
3159
- line-height: 1.25 !important;
3160
- color: #999; }
3161
-
3162
- .ajax-load-more .cm-readonly.sm-margin .CodeMirror {
3163
- margin: 0 0 10px; }
3164
-
3165
- .ajax-load-more .cm-readonly p.warning-callout {
3166
- margin: 0 0 10px; }
3167
-
3168
- .ajax-load-more .CodeMirror.loading {
3169
- background: #f7f7f7 url("../../img/loader-unlimited.gif") no-repeat center center;
3170
- opacity: 0.6; }
3171
-
3172
- .ajax-load-more .cm-s-pastel-on-dark.CodeMirror {
3173
- /* Bkg color */
3174
- background: #333; }
3175
-
3176
- .ajax-load-more .CodeMirror-gutters {
3177
- /* Line Number color */
3178
- background: #fff;
3179
- border-right: 1px solid #e1e1e1;
3180
- border-radius: 2px; }
3181
-
3182
- .ajax-load-more .CodeMirror pre {
3183
- font-size: 13px; }
3184
-
3185
- .ajax-load-more .CodeMirror-scroll {
3186
- overflow-y: hidden;
3187
- overflow-x: auto; }
3188
-
3189
- .ajax-load-more .cm-tag {
3190
- /* <li> <h2> html elements */
3191
- color: #0a4b83 !important; }
3192
-
3193
- .ajax-load-more .cm-string {
3194
- /* Elements in " " */
3195
- color: #c75050 !important; }
3196
-
3197
- .ajax-load-more .cm-attribute {
3198
- /* class names */
3199
- color: #008080 !important; }
3200
-
3201
- .ajax-load-more .cm-keyword {
3202
- /* if, array, echo */
3203
- color: #ae5fb3 !important; }
3204
-
3205
- .ajax-load-more span.CodeMirror-matchingbracket {
3206
- color: #ff0000 !important; }
3207
-
3208
- .ajax-load-more .CodeMirror span.cm-meta {
3209
- /* <?php */
3210
- color: #999; }
3211
-
3212
- .ajax-load-more .CodeMirror span.cm-variable {
3213
- /* Function names */
3214
- color: #111;
3215
- font-weight: 500;
3216
- padding: 0 1px; }
3217
-
3218
- .ajax-load-more .CodeMirror span.cm-number {
3219
- /* Numbers */
3220
- color: #009999 !important; }
3221
-
3222
  .shortcode-builder hr {
3223
  margin: 0; }
3224
 
@@ -3377,6 +3405,8 @@ span.cnkt-button.installed i,
3377
  .alm-cache {
3378
  /* Live Search */
3379
  /* Directory Listing */ }
 
 
3380
  .alm-cache .row:first-of-type {
3381
  margin-top: 0 !important; }
3382
  .alm-cache .alm-cache-search-wrap {
@@ -3402,6 +3432,9 @@ span.cnkt-button.installed i,
3402
  overflow: hidden;
3403
  padding: 0;
3404
  margin: 10px 0 0; }
 
 
 
3405
  .alm-cache .alm-dir-listing.theme-repeaters {
3406
  padding: 15px;
3407
  margin: 0; }
@@ -3817,7 +3850,7 @@ p.theme-title {
3817
  .alm-drop-btn.alm-layout-selection {
3818
  display: inline-block;
3819
  float: right;
3820
- margin: 0; }
3821
  @media screen and (max-width: 480px) {
3822
  .alm-drop-btn.alm-layout-selection {
3823
  float: none; } }
@@ -3897,12 +3930,14 @@ p.theme-title {
3897
 
3898
  .alm-drop-btn.alm-layout-selection a.external {
3899
  padding: 0 10px 0 36px;
3900
- font-weight: 600; }
 
 
3901
 
3902
  .alm-drop-btn.alm-layout-selection a.external i {
3903
  color: #999;
3904
  border-color: #ccc;
3905
- top: 50%;
3906
  -webkit-transform: translateY(-50%);
3907
  -ms-transform: translateY(-50%);
3908
  transform: translateY(-50%);
@@ -4015,109 +4050,105 @@ span.dismiss a {
4015
  top: 108%;
4016
  right: -15px;
4017
  z-index: 9; }
4018
-
4019
- .alm-dropdown .alm-drop-inner {
4020
- display: block;
4021
- position: relative;
4022
- background: #fff;
4023
- border-radius: 3px;
4024
- border: 1px solid #ccc;
4025
- -webkit-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
4026
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
4027
- padding: 8px 10px;
4028
- width: 220px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4029
 
4030
  .alm-layout-selection .alm-dropdown .alm-drop-inner {
4031
- width: 250px;
4032
  padding: 10px 10px 6px; }
4033
 
4034
- .alm-drop-inner:after,
4035
- .alm-drop-inner:before {
4036
- bottom: 100%;
4037
- right: 26px;
4038
- border: solid transparent;
4039
- content: " ";
4040
- height: 0;
4041
- width: 0;
4042
- position: absolute;
4043
- pointer-events: none; }
4044
-
4045
- .alm-drop-inner:after {
4046
- border-color: rgba(247, 247, 247, 0);
4047
- border-bottom-color: #fff;
4048
- border-width: 7px;
4049
- margin-left: -7px; }
4050
-
4051
- .alm-drop-inner:before {
4052
- border-color: rgba(204, 204, 204, 0);
4053
- border-bottom-color: #ccc;
4054
- border-width: 8px;
4055
- right: 25px; }
4056
-
4057
- .alm-dropdown.active {
4058
- display: block !important; }
4059
-
4060
  .alm-dropdown ul {
4061
  padding: 0;
4062
  margin: 0;
4063
  overflow: hidden; }
4064
 
4065
- .alm-dropdown ul li {
4066
  margin: 0;
4067
  padding: 2px 0;
4068
  list-style: none;
4069
  clear: both;
4070
- font-size: 12px;
4071
  line-height: 1.2;
4072
  font-weight: 400; }
4073
-
4074
- .alm-dropdown ul li a {
4075
- padding: 0 10px 0 34px;
4076
- line-height: 40px;
4077
- height: 40px;
4078
- display: block;
4079
- text-decoration: none;
4080
- background-position: 4px center;
4081
- color: #666;
4082
- -webkit-box-shadow: none !important;
4083
- box-shadow: none !important;
4084
- position: relative;
4085
- width: 100%;
4086
- white-space: nowrap;
4087
- overflow: hidden;
4088
- text-overflow: ellipsis;
4089
- border-radius: 3px; }
4090
- .alm-dropdown ul li a.layout, .alm-dropdown ul li a.external, .alm-dropdown ul li a.option {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4091
  border: 1px solid #e1e1e1;
4092
- background-color: transparent; }
4093
- .alm-dropdown ul li a.layout:hover, .alm-dropdown ul li a.layout:focus, .alm-dropdown ul li a.external:hover, .alm-dropdown ul li a.external:focus, .alm-dropdown ul li a.option:hover, .alm-dropdown ul li a.option:focus {
4094
- border-color: #ccc;
4095
- background-color: #f1f1f1; }
4096
- .alm-dropdown ul li a.layout:focus, .alm-dropdown ul li a.external:focus, .alm-dropdown ul li a.option:focus {
4097
- background-color: #f1f1f1; }
4098
-
4099
- .alm-dropdown ul li a i {
4100
- margin: 0;
4101
- color: #ccc;
4102
- position: absolute;
4103
- left: 2px;
4104
- top: 50%;
4105
- -webkit-transform: translateY(-50%);
4106
- -ms-transform: translateY(-50%);
4107
- transform: translateY(-50%);
4108
- font-size: 14px;
4109
- width: 32px;
4110
- height: 16px;
4111
- line-height: 16px;
4112
- display: inline-block;
4113
- text-align: center; }
4114
-
4115
- .alm-dropdown ul li a:hover {
4116
- color: #111;
4117
- background-color: #f7f7f7; }
4118
-
4119
- .alm-dropdown ul li a:hover i {
4120
- color: #999; }
4121
 
4122
  /*
4123
  * Mailchimp Sign-up
@@ -4475,13 +4506,13 @@ span.dismiss a {
4475
  list-style: none; }
4476
  .ajax-load-more .alm-toggle-switch li a {
4477
  display: block;
4478
- padding: 15px 22px;
4479
  line-height: 1;
4480
  text-decoration: none;
4481
  border: 1px solid #e1e1e1;
4482
  border-radius: 3px 3px 0 0;
4483
  background: #f7f7f7;
4484
- color: #666; }
4485
  .ajax-load-more .alm-toggle-switch li a:hover {
4486
  color: #222;
4487
  background-color: #fff; }
757
  .alm-pro-listing .item.inactive:hover .state:before {
758
  opacity: 1; }
759
 
760
+ .ajax-load-more .CodeMirror {
761
+ height: auto;
762
+ border-radius: 3px;
763
+ padding: 0;
764
+ background: #f7f7f7;
765
+ border: 1px solid #e1e1e1;
766
+ color: #999;
767
+ line-height: 1.5;
768
+ font-size: 13px; }
769
+ .ajax-load-more .CodeMirror.CodeMirror-focused {
770
+ border-color: #bbbbbb;
771
+ -webkit-box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
772
+ box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05); }
773
+
774
+ .ajax-load-more .cm-readonly .CodeMirror {
775
+ opacity: 0.8; }
776
+
777
+ .ajax-load-more .cm-readonly .CodeMirror pre {
778
+ cursor: default !important; }
779
+
780
+ .ajax-load-more .CodeMirror pre {
781
+ padding: 0 10px; }
782
+
783
+ .CodeMirror-lines {
784
+ padding: 10px !important; }
785
+
786
+ .CodeMirror-linenumber {
787
+ padding: 0 10px !important;
788
+ line-height: 1.25 !important;
789
+ color: #ccc !important; }
790
+
791
+ .CodeMirror-linenumber.CodeMirror-gutter-elt {
792
+ padding: 0 20px 0 0 !important; }
793
+
794
+ .ajax-load-more .cm-readonly.sm-margin .CodeMirror {
795
+ margin: 0 0 10px; }
796
+
797
+ .ajax-load-more .cm-readonly p.warning-callout {
798
+ margin: 0 0 10px; }
799
+
800
+ .ajax-load-more .CodeMirror.loading {
801
+ background: #f7f7f7 url("../../img/loader-unlimited.gif") no-repeat center center;
802
+ opacity: 0.6; }
803
+
804
+ .ajax-load-more .cm-s-pastel-on-dark.CodeMirror {
805
+ /* Bkg color */
806
+ background: #333; }
807
+
808
+ .ajax-load-more .CodeMirror-gutters {
809
+ /* Line Number color */
810
+ background: #fff;
811
+ border-right: 1px solid #e1e1e1;
812
+ border-radius: 2px; }
813
+
814
+ .ajax-load-more .CodeMirror-scroll {
815
+ overflow-y: hidden;
816
+ overflow-x: auto; }
817
+
818
+ .ajax-load-more .cm-tag {
819
+ /* <li> <h2> html elements */
820
+ color: #0a4b83 !important; }
821
+
822
+ .ajax-load-more .cm-string {
823
+ /* Elements in " " */
824
+ color: #c75050 !important; }
825
+
826
+ .ajax-load-more .cm-attribute {
827
+ /* class names */
828
+ color: #008080 !important; }
829
+
830
+ .ajax-load-more .cm-keyword {
831
+ /* if, array, echo */
832
+ color: #ae5fb3 !important; }
833
+
834
+ .ajax-load-more span.CodeMirror-matchingbracket {
835
+ color: #ff0000 !important; }
836
+
837
+ .ajax-load-more .CodeMirror span.cm-meta {
838
+ /* <?php */
839
+ color: #999; }
840
+
841
+ .ajax-load-more .CodeMirror span.cm-variable {
842
+ /* Function names */
843
+ color: #111;
844
+ font-weight: 500;
845
+ padding: 0 1px; }
846
+
847
+ .ajax-load-more .CodeMirror span.cm-number {
848
+ /* Numbers */
849
+ color: #009999 !important; }
850
+
851
  .ajax-load-more .cnkt-sidebar {
852
  width: 33%;
853
  float: right;
1370
 
1371
  /* Expand/Collapse all rows */
1372
  .ajax-load-more .toggle-all {
1373
+ position: static;
1374
  top: -16px;
1375
  right: 20px;
1376
  width: auto;
1385
  border: 1px solid #e1e1e1;
1386
  color: #777;
1387
  cursor: pointer;
1388
+ z-index: 20;
1389
+ margin-bottom: 10px;
1390
+ overflow: hidden; }
1391
+ @media screen and (min-width: 768px) {
1392
+ .ajax-load-more .toggle-all {
1393
+ position: absolute; } }
1394
 
1395
  #alm-container.ajax-load-more .toggle-all {
1396
  display: none; }
1679
  display: inline-block;
1680
  clear: both;
1681
  border-radius: 3px;
1682
+ color: #555;
1683
  -webkit-box-shadow: none;
1684
  box-shadow: none; }
1685
 
1686
+ .ajax-load-more input[type=checkbox],
1687
+ .ajax-load-more input[type=radio] {
1688
+ width: 1rem; }
1689
+
1690
  .controls button.disabled {
1691
  opacity: 0.5; }
1692
 
1795
  .ajax-load-more input[type=email]:focus,
1796
  .ajax-load-more textarea:focus {
1797
  border-color: #bbbbbb;
1798
+ -webkit-box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
1799
+ box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
1800
  background: #f7f7f7; }
1801
 
1802
  .checkboxes label {
2044
  padding-left: 0 !important; }
2045
 
2046
  .ajax-load-more label.template-title {
2047
+ padding: 3px 2px 0;
2048
  margin: 0;
2049
+ display: block; }
2050
+ .ajax-load-more label.template-title.has-margin-btm {
2051
+ margin-bottom: 10px; }
2052
 
2053
  .ajax-load-more label input._alm_repeater_alias {
2054
  height: auto;
2499
  -webkit-box-shadow: none;
2500
  box-shadow: none; }
2501
 
2502
+ .ajax-load-more .cnkt-main .repeater-listing {
2503
+ border-top: 1px solid #e1e1e1;
2504
+ padding-top: 20px;
2505
+ position: relative; }
2506
+ .ajax-load-more .cnkt-main .repeater-listing .toggle-all {
2507
+ right: 0;
2508
+ top: -45px; }
2509
+
2510
  .ajax-load-more .cnkt-main.full {
2511
  width: 100%;
2512
  float: none; }
2538
  padding: 15px 0 !important; }
2539
 
2540
  .repeaters .repeater-wrap label {
2541
+ font-weight: 600; }
2542
+ .repeaters .repeater-wrap label span {
2543
+ display: block;
2544
+ font-weight: 400;
2545
+ color: #999;
2546
+ font-size: 13px;
2547
+ padding-top: 2px; }
2548
 
2549
  .repeaters input.save-repeater {
2550
  display: inline-block;
3065
  margin-top: 0; }
3066
 
3067
  .ajax-load-more .cnkt-sidebar h3 {
3068
+ padding: 10px 20px;
3069
  background: #fff;
3070
  margin: 0;
3071
  display: block;
3072
+ font-size: 14px;
3073
  font-weight: 700;
3074
  text-transform: none;
3075
  border-radius: 2px 2px 0 0; }
3247
  * CodeMirror Syntax Highlighting
3248
  * @since 2.2.0
3249
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3250
  .shortcode-builder hr {
3251
  margin: 0; }
3252
 
3405
  .alm-cache {
3406
  /* Live Search */
3407
  /* Directory Listing */ }
3408
+ .alm-cache .group .row {
3409
+ overflow: visible; }
3410
  .alm-cache .row:first-of-type {
3411
  margin-top: 0 !important; }
3412
  .alm-cache .alm-cache-search-wrap {
3432
  overflow: hidden;
3433
  padding: 0;
3434
  margin: 10px 0 0; }
3435
+ .alm-cache .alm-dir-listing:hover {
3436
+ -webkit-box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
3437
+ box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05); }
3438
  .alm-cache .alm-dir-listing.theme-repeaters {
3439
  padding: 15px;
3440
  margin: 0; }
3850
  .alm-drop-btn.alm-layout-selection {
3851
  display: inline-block;
3852
  float: right;
3853
+ margin: 6px 0 0; }
3854
  @media screen and (max-width: 480px) {
3855
  .alm-drop-btn.alm-layout-selection {
3856
  float: none; } }
3930
 
3931
  .alm-drop-btn.alm-layout-selection a.external {
3932
  padding: 0 10px 0 36px;
3933
+ font-weight: 600;
3934
+ border: 1px solid #e1e1e1;
3935
+ border-radius: 3px; }
3936
 
3937
  .alm-drop-btn.alm-layout-selection a.external i {
3938
  color: #999;
3939
  border-color: #ccc;
3940
+ top: 53%;
3941
  -webkit-transform: translateY(-50%);
3942
  -ms-transform: translateY(-50%);
3943
  transform: translateY(-50%);
4050
  top: 108%;
4051
  right: -15px;
4052
  z-index: 9; }
4053
+ .alm-dropdown .alm-drop-inner {
4054
+ display: block;
4055
+ position: relative;
4056
+ background: #fff;
4057
+ border-radius: 3px;
4058
+ border: 1px solid #ccc;
4059
+ -webkit-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
4060
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
4061
+ padding: 8px 10px;
4062
+ width: 220px; }
4063
+ .alm-dropdown .alm-drop-inner:after,
4064
+ .alm-dropdown .alm-drop-inner:before {
4065
+ bottom: 100%;
4066
+ right: 26px;
4067
+ border: solid transparent;
4068
+ content: " ";
4069
+ height: 0;
4070
+ width: 0;
4071
+ position: absolute;
4072
+ pointer-events: none; }
4073
+ .alm-dropdown .alm-drop-inner:after {
4074
+ border-color: rgba(247, 247, 247, 0);
4075
+ border-bottom-color: #fff;
4076
+ border-width: 7px;
4077
+ margin-left: -7px; }
4078
+ .alm-dropdown .alm-drop-inner:before {
4079
+ border-color: rgba(204, 204, 204, 0);
4080
+ border-bottom-color: #ccc;
4081
+ border-width: 8px;
4082
+ right: 25px; }
4083
+ .alm-dropdown.active {
4084
+ display: block !important; }
4085
 
4086
  .alm-layout-selection .alm-dropdown .alm-drop-inner {
4087
+ width: 270px;
4088
  padding: 10px 10px 6px; }
4089
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4090
  .alm-dropdown ul {
4091
  padding: 0;
4092
  margin: 0;
4093
  overflow: hidden; }
4094
 
4095
+ .alm-dropdown li {
4096
  margin: 0;
4097
  padding: 2px 0;
4098
  list-style: none;
4099
  clear: both;
4100
+ font-size: 13px;
4101
  line-height: 1.2;
4102
  font-weight: 400; }
4103
+ .alm-dropdown li.option {
4104
+ border-radius: 3px; }
4105
+ .alm-dropdown li.option:nth-child(even) {
4106
+ background-color: #f7f7f7; }
4107
+ .alm-dropdown li a:not(.button) {
4108
+ padding: 0 10px 0 32px;
4109
+ line-height: 40px;
4110
+ height: 40px;
4111
+ display: block;
4112
+ text-decoration: none;
4113
+ background-position: 4px center;
4114
+ color: #555;
4115
+ -webkit-box-shadow: none !important;
4116
+ box-shadow: none !important;
4117
+ position: relative;
4118
+ width: 100%;
4119
+ white-space: nowrap;
4120
+ overflow: hidden;
4121
+ text-overflow: ellipsis;
4122
+ border-radius: 3px; }
4123
+ .alm-dropdown li a:not(.button):hover, .alm-dropdown li a:not(.button):focus {
4124
+ color: #333; }
4125
+ .alm-dropdown li a:not(.button):hover i, .alm-dropdown li a:not(.button):focus i {
4126
+ opacity: 0.8; }
4127
+ .alm-dropdown li a:not(.button) i {
4128
+ margin: 0;
4129
+ position: absolute;
4130
+ left: 0px;
4131
+ top: 50%;
4132
+ -webkit-transform: translateY(-50%);
4133
+ -ms-transform: translateY(-50%);
4134
+ transform: translateY(-50%);
4135
+ width: 32px;
4136
+ font-size: 14px;
4137
+ line-height: 1;
4138
+ display: inline-block;
4139
+ text-align: center;
4140
+ opacity: 0.5; }
4141
+ .alm-dropdown li.layout-cta {
4142
  border: 1px solid #e1e1e1;
4143
+ padding: 20px 10px;
4144
+ border-radius: 3px;
4145
+ margin-bottom: 5px;
4146
+ background-color: #fffeed;
4147
+ text-align: center; }
4148
+ .alm-dropdown li.layout-cta span {
4149
+ display: block;
4150
+ padding: 0 0 12px;
4151
+ line-height: 1.5; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4152
 
4153
  /*
4154
  * Mailchimp Sign-up
4506
  list-style: none; }
4507
  .ajax-load-more .alm-toggle-switch li a {
4508
  display: block;
4509
+ padding: 14px 20px;
4510
  line-height: 1;
4511
  text-decoration: none;
4512
  border: 1px solid #e1e1e1;
4513
  border-radius: 3px 3px 0 0;
4514
  background: #f7f7f7;
4515
+ color: #555; }
4516
  .ajax-load-more .alm-toggle-switch li a:hover {
4517
  color: #222;
4518
  background-color: #fff; }
admin/dist/js/admin.js CHANGED
@@ -1301,6 +1301,39 @@ jQuery(document).ready(function ($) {
1301
  });
1302
  }
1303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1304
  /*
1305
  * _alm.saveSettings
1306
  * Setting panel save actions
@@ -1629,9 +1662,10 @@ jQuery(document).ready(function ($) {
1629
  });
1630
 
1631
  /*
1632
- * Get layout value Ajax
1633
- * @since 2.8.7
1634
- */
 
1635
  $(document).on('click', '.alm-layout-selection li a.layout', function (e) {
1636
  e.preventDefault();
1637
  var el = $(this),
@@ -1650,7 +1684,7 @@ jQuery(document).ready(function ($) {
1650
  var eid = '';
1651
  if (name === 'default') {
1652
  // Default Template
1653
- eid = window.editorDefault;
1654
  } else {
1655
  // Repeater Templates
1656
  eid = window['editor_' + name];
1301
  });
1302
  }
1303
 
1304
+ /*
1305
+ * Save Repeater Templates with cmd + s and ctrl + s
1306
+ * @since 5.1
1307
+ */
1308
+ document.addEventListener("keydown", function (e) {
1309
+ if ((window.navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) && e.keyCode == 83) {
1310
+
1311
+ if (e.target.nodeName === 'TEXTAREA' && $(e.target).closest('.repeater-wrap')) {
1312
+ console.log('Saving template...');
1313
+ var btn = $(e.target).closest('.repeater-wrap').find('input.save-repeater');
1314
+ if (btn) {
1315
+ btn.click();
1316
+ }
1317
+ }
1318
+
1319
+ e.preventDefault();
1320
+ }
1321
+ }, false);
1322
+
1323
+ /*
1324
+ * Set focus in code mirror editor
1325
+ * @since 5.1
1326
+ */
1327
+ $('label.trigger-codemirror').on('click', function () {
1328
+ var el = $(this);
1329
+ var id = el.data('id');
1330
+ var cm = window['editor_' + id];
1331
+ if (cm) {
1332
+ cm.focus();
1333
+ cm.setCursor(cm.lineCount(), 0);
1334
+ }
1335
+ });
1336
+
1337
  /*
1338
  * _alm.saveSettings
1339
  * Setting panel save actions
1662
  });
1663
 
1664
  /*
1665
+ * Get layout value Ajax
1666
+ * @since 2.8.7
1667
+ */
1668
+ console.log(window.editorDefault);
1669
  $(document).on('click', '.alm-layout-selection li a.layout', function (e) {
1670
  e.preventDefault();
1671
  var el = $(this),
1684
  var eid = '';
1685
  if (name === 'default') {
1686
  // Default Template
1687
+ eid = window.editor_default;
1688
  } else {
1689
  // Repeater Templates
1690
  eid = window['editor_' + name];
admin/includes/components/layout-list.php CHANGED
@@ -11,17 +11,20 @@
11
  } else { ?>
12
  <li>
13
  <a href="javascript:void(0);" class="layout" data-type="default">
14
- <i class="fa fa-list-alt"></i>
15
  <?php _e('Default Layout', 'ajax-load-more'); ?>
16
  </a>
17
  </li>
18
  <?php
19
 
 
20
  include( ALM_PATH . 'admin/includes/components/custom-layouts.php'); // Custom Layouts
21
- echo '<li><a href="https://connekthq.com/plugins/ajax-load-more/add-ons/layouts/?utm_source=WP%20Admin&utm_medium=Extend&utm_campaign=Layouts" class="add-on" target="_blank">';
22
- echo '<i class="fa fa-key"></i>';
23
- _e('Get predefined responsive layouts with the <strong>Layouts add-on</strong>', 'ajax-load-more');
24
- echo '</a></li>';
 
 
25
  }?>
26
  </ul>
27
  </div>
11
  } else { ?>
12
  <li>
13
  <a href="javascript:void(0);" class="layout" data-type="default">
14
+ <i class="fa fa-file-code-o" aria-hidden="true"></i>
15
  <?php _e('Default Layout', 'ajax-load-more'); ?>
16
  </a>
17
  </li>
18
  <?php
19
 
20
+ $link = 'href="https://connekthq.com/plugins/ajax-load-more/add-ons/layouts/?utm_source=WP%20Admin&utm_medium=Extend&utm_campaign=Layouts';
21
  include( ALM_PATH . 'admin/includes/components/custom-layouts.php'); // Custom Layouts
22
+ echo '<li class="layout-cta">';
23
+ echo '<span>';
24
+ _e('Get predefined responsive layouts with the <strong>Layouts add-on</strong>', 'ajax-load-more');
25
+ echo '</span>';
26
+ echo '<a class="button button-primary" href="'. $link .'">'. __('Get More Layouts', 'ajax-load-more') .'</a>';
27
+ echo '</li>';
28
  }?>
29
  </ul>
30
  </div>
admin/includes/components/repeater-options.php CHANGED
@@ -6,18 +6,18 @@
6
  </a>
7
  <div class="alm-dropdown">
8
  <div class="alm-drop-inner">
9
- <ul>
10
-
11
  <?php if($repeater_options['type'] !== 'theme-repeater'){ ?>
12
- <li class="option-update">
13
  <a href="javascript:void(0);" title="<?php _e('Update Template from Database', 'ajax-load-more'); ?>"><i class="fa fa-pencil"></i> <?php _e('Update from Database', 'ajax-load-more'); ?></a>
14
  </li>
15
  <?php } ?>
16
 
17
- <?php if(isset($repeater_options['path'])){
 
18
  $path = str_replace('/', '_', $repeater_options['path']);
19
- ?>
20
- <li class="download">
21
  <form action="" method="POST" id="<?php echo $path; ?>">
22
  <input type="hidden" name="alm_repeaters_export" value="<?php echo $repeater_options['path']; ?>">
23
  <a href="javascript:void(0);" title="<?php _e('Download Template', 'ajax-load-more'); ?>" class="download-repeater">
@@ -25,9 +25,8 @@
25
  </a>
26
  </form>
27
  </li>
28
- <?php } ?>
29
-
30
- <li class="copy">
31
  <a href="javascript:void(0);" title="<?php _e('Copy Template Data', 'ajax-load-more'); ?>"><i class="fa fa-file"></i> <?php _e('Copy Template Data', 'ajax-load-more'); ?></a>
32
  </li>
33
 
6
  </a>
7
  <div class="alm-dropdown">
8
  <div class="alm-drop-inner">
9
+ <ul>
 
10
  <?php if($repeater_options['type'] !== 'theme-repeater'){ ?>
11
+ <li class="option option-update">
12
  <a href="javascript:void(0);" title="<?php _e('Update Template from Database', 'ajax-load-more'); ?>"><i class="fa fa-pencil"></i> <?php _e('Update from Database', 'ajax-load-more'); ?></a>
13
  </li>
14
  <?php } ?>
15
 
16
+ <?php
17
+ if(isset($repeater_options['path'])){
18
  $path = str_replace('/', '_', $repeater_options['path']);
19
+ ?>
20
+ <li class="option download">
21
  <form action="" method="POST" id="<?php echo $path; ?>">
22
  <input type="hidden" name="alm_repeaters_export" value="<?php echo $repeater_options['path']; ?>">
23
  <a href="javascript:void(0);" title="<?php _e('Download Template', 'ajax-load-more'); ?>" class="download-repeater">
25
  </a>
26
  </form>
27
  </li>
28
+ <?php } ?>
29
+ <li class="option copy">
 
30
  <a href="javascript:void(0);" title="<?php _e('Copy Template Data', 'ajax-load-more'); ?>"><i class="fa fa-file"></i> <?php _e('Copy Template Data', 'ajax-load-more'); ?></a>
31
  </li>
32
 
admin/shortcode-builder/includes/tax-query-options.php CHANGED
@@ -24,6 +24,18 @@
24
  <input class="alm_element" name="tax-operator" id="tax-not-in-radio" value="NOT IN" type="radio">
25
  <label for="tax-not-in-radio">NOT IN</label>
26
  </li>
 
 
 
 
 
 
 
 
 
 
 
 
27
  </ul>
28
  </div>
29
 
@@ -69,6 +81,18 @@
69
  <input class="alm_element" name="tax-operator2" id="tax-not-in-radio2" value="NOT IN" type="radio">
70
  <label for="tax-not-in-radio2">NOT IN</label>
71
  </li>
 
 
 
 
 
 
 
 
 
 
 
 
72
  </ul>
73
  </div>
74
  </div>
@@ -100,6 +124,18 @@
100
  <input class="alm_element" name="tax-operator3" id="tax-not-in-radio3" value="NOT IN" type="radio">
101
  <label for="tax-not-in-radio3">NOT IN</label>
102
  </li>
 
 
 
 
 
 
 
 
 
 
 
 
103
  </ul>
104
  </div>
105
  </div>
24
  <input class="alm_element" name="tax-operator" id="tax-not-in-radio" value="NOT IN" type="radio">
25
  <label for="tax-not-in-radio">NOT IN</label>
26
  </li>
27
+ <li>
28
+ <input class="alm_element" name="tax-operator" id="tax-and-radio" value="AND" type="radio">
29
+ <label for="tax-and-radio">AND</label>
30
+ </li>
31
+ <li>
32
+ <input class="alm_element" name="tax-operator" id="tax-exists-radio" value="EXISTS" type="radio">
33
+ <label for="tax-exists-radio">EXISTS</label>
34
+ </li>
35
+ <li>
36
+ <input class="alm_element" name="tax-operator" id="tax-not-exists-radio" value="NOT EXISTS" type="radio">
37
+ <label for="tax-not-exists-radio">NOT EXISTS</label>
38
+ </li>
39
  </ul>
40
  </div>
41
 
81
  <input class="alm_element" name="tax-operator2" id="tax-not-in-radio2" value="NOT IN" type="radio">
82
  <label for="tax-not-in-radio2">NOT IN</label>
83
  </li>
84
+ <li>
85
+ <input class="alm_element" name="tax-operator2" id="tax-and-radio2" value="AND" type="radio">
86
+ <label for="tax-and-radio2">AND</label>
87
+ </li>
88
+ <li>
89
+ <input class="alm_element" name="tax-operator2" id="tax-exists-radio2" value="EXISTS" type="radio">
90
+ <label for="tax-exists-radio2">EXISTS</label>
91
+ </li>
92
+ <li>
93
+ <input class="alm_element" name="tax-operator2" id="tax-not-exists-radio2" value="NOT EXISTS" type="radio">
94
+ <label for="tax-not-exists-radio2">NOT EXISTS</label>
95
+ </li>
96
  </ul>
97
  </div>
98
  </div>
124
  <input class="alm_element" name="tax-operator3" id="tax-not-in-radio3" value="NOT IN" type="radio">
125
  <label for="tax-not-in-radio3">NOT IN</label>
126
  </li>
127
+ <li>
128
+ <input class="alm_element" name="tax-operator3" id="tax-and-radio3" value="AND" type="radio">
129
+ <label for="tax-and-radio3">AND</label>
130
+ </li>
131
+ <li>
132
+ <input class="alm_element" name="tax-operator3" id="tax-exists-radio3" value="EXISTS" type="radio">
133
+ <label for="tax-exists-radio3">EXISTS</label>
134
+ </li>
135
+ <li>
136
+ <input class="alm_element" name="tax-operator3" id="tax-not-exists-radio3" value="NOT EXISTS" type="radio">
137
+ <label for="tax-not-exists-radio3">NOT EXISTS</label>
138
+ </li>
139
  </ul>
140
  </div>
141
  </div>
admin/shortcode-builder/shortcode-builder.php CHANGED
@@ -1,4 +1,4 @@
1
- <span class="toggle-all" data-id="shortcode-builder-state">
2
  <span class="inner-wrap">
3
  <em class="collapse"><?php _e('Collapse All', 'ajax-load-more'); ?></em>
4
  <em class="expand"><?php _e('Expand All', 'ajax-load-more'); ?></em>
@@ -375,11 +375,12 @@
375
  <div class="scroll_distance">
376
  <div class="section-title">
377
  <h4><?php _e('Scroll Distance', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('Distance is based on the position of the loading button from the bottom of the screen','ajax-load-more'); ?>."></a></h4>
378
- <p><?php _e('The distance from the bottom of the screen to trigger loading of posts. (Default = 100)', 'ajax-load-more'); ?></p>
 
379
  </div>
380
  <div class="wrap">
381
  <div class="inner">
382
- <input type="number" class="alm_element numbers-only" name="scroll-distance" id="scroll-distance" step="10" min="0" value="100">
383
  </div>
384
  </div>
385
  </div>
1
+ <span class="toggle-all" role="button" tabindex="0" data-id="shortcode-builder-state">
2
  <span class="inner-wrap">
3
  <em class="collapse"><?php _e('Collapse All', 'ajax-load-more'); ?></em>
4
  <em class="expand"><?php _e('Expand All', 'ajax-load-more'); ?></em>
375
  <div class="scroll_distance">
376
  <div class="section-title">
377
  <h4><?php _e('Scroll Distance', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('Distance is based on the position of the loading button from the bottom of the screen','ajax-load-more'); ?>."></a></h4>
378
+ <p><?php _e('The distance from the bottom of the screen to trigger loading of posts. (Default = 100)', 'ajax-load-more'); ?>
379
+ <small><strong><?php _e('Pro-tip', 'ajax-load-more'); ?>:</strong> <?php _e('Use a negative number (-200) to trigger a post load before the button is in view', 'ajax-load-more'); ?></small></p></p>
380
  </div>
381
  <div class="wrap">
382
  <div class="inner">
383
+ <input type="number" class="alm_element numbers-only" name="scroll-distance" id="scroll-distance" step="50" min="-100000" value="100">
384
  </div>
385
  </div>
386
  </div>
admin/src/js/admin.js CHANGED
@@ -9,6 +9,7 @@ jQuery(document).ready(function($) {
9
 
10
 
11
 
 
12
  /*
13
  * Test REST API access
14
  *
@@ -31,6 +32,45 @@ jQuery(document).ready(function($) {
31
  });
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
 
36
  /*
@@ -383,13 +423,14 @@ jQuery(document).ready(function($) {
383
  });
384
  }
385
  });
386
-
387
-
388
-
389
- /*
390
  * Get layout value Ajax
391
  * @since 2.8.7
392
  */
 
393
  $(document).on('click', '.alm-layout-selection li a.layout', function(e){
394
  e.preventDefault();
395
  var el = $(this),
@@ -408,7 +449,7 @@ jQuery(document).ready(function($) {
408
  var eid = '';
409
  if(name === 'default'){
410
  // Default Template
411
- eid = window.editorDefault;
412
  }else{
413
  // Repeater Templates
414
  eid = window['editor_'+name];
9
 
10
 
11
 
12
+
13
  /*
14
  * Test REST API access
15
  *
32
  });
33
  }
34
 
35
+
36
+
37
+ /*
38
+ * Save Repeater Templates with cmd + s and ctrl + s
39
+ * @since 5.1
40
+ */
41
+ document.addEventListener("keydown", function(e) {
42
+ if ((window.navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) && e.keyCode == 83) {
43
+
44
+
45
+ if(e.target.nodeName === 'TEXTAREA' && $(e.target).closest('.repeater-wrap')){
46
+ console.log('Saving template...');
47
+ var btn = $(e.target).closest('.repeater-wrap').find('input.save-repeater');
48
+ if(btn){
49
+ btn.click();
50
+ }
51
+ }
52
+
53
+ e.preventDefault();
54
+
55
+ }
56
+ }, false);
57
+
58
+
59
+
60
+ /*
61
+ * Set focus in code mirror editor
62
+ * @since 5.1
63
+ */
64
+ $('label.trigger-codemirror').on('click', function(){
65
+ var el = $(this);
66
+ var id = el.data('id');
67
+ var cm = window['editor_'+id];
68
+ if(cm){
69
+ cm.focus();
70
+ cm.setCursor(cm.lineCount(), 0);
71
+ }
72
+ });
73
+
74
 
75
 
76
  /*
423
  });
424
  }
425
  });
426
+
427
+
428
+
429
+ /*
430
  * Get layout value Ajax
431
  * @since 2.8.7
432
  */
433
+ console.log(window.editorDefault);
434
  $(document).on('click', '.alm-layout-selection li a.layout', function(e){
435
  e.preventDefault();
436
  var el = $(this),
449
  var eid = '';
450
  if(name === 'default'){
451
  // Default Template
452
+ eid = window.editor_default;
453
  }else{
454
  // Repeater Templates
455
  eid = window['editor_'+name];
admin/src/scss/_variables.scss CHANGED
@@ -6,6 +6,7 @@ $green_hover: #57bda4;
6
  $yellow: #ffffe8;
7
  $yellow_dark: #e4e4c8;
8
  $red: #e06464;
 
9
  $border: #e1e1e1;
10
  $border_hover: #ccc;
11
  $radius: 3px;
6
  $yellow: #ffffe8;
7
  $yellow_dark: #e4e4c8;
8
  $red: #e06464;
9
+ $light_grey: #f7f7f7;
10
  $border: #e1e1e1;
11
  $border_hover: #ccc;
12
  $radius: 3px;
admin/src/scss/admin.scss CHANGED
@@ -4,6 +4,7 @@
4
  'variables',
5
  'partials/header',
6
  'partials/pro-listing',
 
7
  'partials/sidebar',
8
  'partials/alm-settings-feedback',
9
  'partials/select2';
@@ -389,7 +390,7 @@ a.layout-hover{
389
 
390
  /* Expand/Collapse all rows */
391
  .ajax-load-more .toggle-all{
392
- position: absolute;
393
  top: -16px;
394
  right: 20px;
395
  width: auto;
@@ -405,6 +406,11 @@ a.layout-hover{
405
  color: #777;
406
  cursor: pointer;
407
  z-index: 20;
 
 
 
 
 
408
  }
409
  #alm-container.ajax-load-more .toggle-all{
410
  display: none;
@@ -718,11 +724,15 @@ a.button-small{
718
  display: inline-block;
719
  clear: both;
720
  border-radius: 3px;
721
- color: #444;
722
  -webkit-box-shadow: none;
723
  -moz-box-shadow: none;
724
  box-shadow: none;
725
  }
 
 
 
 
726
 
727
  .controls button.disabled{
728
  opacity: 0.5;
@@ -844,7 +854,7 @@ a.button-small{
844
  .ajax-load-more input[type=email]:focus,
845
  .ajax-load-more textarea:focus{
846
  border-color: #bbbbbb;
847
- box-shadow: 0 0 6px #ccc;
848
  background: #f7f7f7;
849
  }
850
 
@@ -1139,10 +1149,12 @@ hr.indented{ // Indented as fake padding in shortcode builder
1139
  padding-left: 0 !important;
1140
  }
1141
  .ajax-load-more label.template-title{
1142
- padding: 8px 0 10px;
1143
  margin: 0;
1144
- font-size: 13px;
1145
- color: #888;
 
 
1146
  }
1147
 
1148
  .ajax-load-more label input._alm_repeater_alias{
@@ -1637,6 +1649,17 @@ table.highlight{
1637
  box-shadow: none;
1638
  }
1639
  }
 
 
 
 
 
 
 
 
 
 
 
1640
  .ajax-load-more .cnkt-main.full{
1641
  width: 100%;
1642
  float: none;
@@ -1674,7 +1697,14 @@ table.highlight{
1674
  padding: 15px 0 !important;
1675
  }
1676
  .repeater-wrap label{
1677
- cursor: default;
 
 
 
 
 
 
 
1678
  }
1679
  input.save-repeater{
1680
  display: inline-block;
@@ -2220,11 +2250,11 @@ table.highlight{
2220
  margin-top: 0;
2221
  }
2222
  .ajax-load-more .cnkt-sidebar h3{
2223
- padding: 14px 20px;
2224
  background: #fff;
2225
  margin: 0;
2226
  display: block;
2227
- font-size: 15px;
2228
  font-weight: 700;
2229
  text-transform: none;
2230
  border-radius: 2px 2px 0 0;
@@ -2421,85 +2451,7 @@ table.highlight{
2421
  * @since 2.2.0
2422
  */
2423
 
2424
- .ajax-load-more .CodeMirror {
2425
- height: auto;
2426
- border-radius: $radius;
2427
- padding: 5px;
2428
- background: #f7f7f7;
2429
- border: 1px solid #e1e1e1;
2430
- color: #999;
2431
- line-height: 1.5;
2432
- &.CodeMirror-focused{
2433
- border-color: #bbbbbb;
2434
- box-shadow: 0 0 6px #ccc;
2435
- }
2436
- }
2437
- .ajax-load-more .cm-readonly .CodeMirror{
2438
- opacity: 0.8;
2439
- }
2440
- .ajax-load-more .cm-readonly .CodeMirror pre{
2441
- cursor: default !important;
2442
- }
2443
- .ajax-load-more .CodeMirror pre{
2444
- padding: 0 10px;
2445
- }
2446
- .CodeMirror-linenumber{
2447
- padding: 0 10px !important;
2448
- line-height: 1.25 !important;
2449
- color: #999;
2450
- }
2451
- .ajax-load-more .cm-readonly.sm-margin .CodeMirror{
2452
- margin: 0 0 10px;
2453
- }
2454
- .ajax-load-more .cm-readonly p.warning-callout{
2455
- margin: 0 0 10px;
2456
- }
2457
- .ajax-load-more .CodeMirror.loading {
2458
- background: #f7f7f7 url("../../img/loader-unlimited.gif") no-repeat center center;
2459
- opacity: 0.6;
2460
- }
2461
- .ajax-load-more .cm-s-pastel-on-dark.CodeMirror{ /* Bkg color */
2462
- background: #333;
2463
- }
2464
- .ajax-load-more .CodeMirror-gutters{ /* Line Number color */
2465
- background: #fff;
2466
- border-right: 1px solid #e1e1e1;
2467
- border-radius: 2px;
2468
- }
2469
- .ajax-load-more .CodeMirror pre{
2470
- font-size: 13px;
2471
- }
2472
- .ajax-load-more .CodeMirror-scroll {
2473
- overflow-y: hidden;
2474
- overflow-x: auto;
2475
- }
2476
 
2477
- .ajax-load-more .cm-tag{ /* <li> <h2> html elements */
2478
- color: #0a4b83 !important;
2479
- }
2480
- .ajax-load-more .cm-string{ /* Elements in " " */
2481
- color: #c75050 !important;
2482
- }
2483
- .ajax-load-more .cm-attribute{ /* class names */
2484
- color: #008080 !important;
2485
- }
2486
- .ajax-load-more .cm-keyword{ /* if, array, echo */
2487
- color: #ae5fb3 !important;
2488
- }
2489
- .ajax-load-more span.CodeMirror-matchingbracket{
2490
- color: #ff0000 !important;
2491
- }
2492
- .ajax-load-more .CodeMirror span.cm-meta{ /* <?php */
2493
- color: #999;
2494
- }
2495
- .ajax-load-more .CodeMirror span.cm-variable{ /* Function names */
2496
- color: #111;
2497
- font-weight: 500;
2498
- padding: 0 1px;
2499
- }
2500
- .ajax-load-more .CodeMirror span.cm-number{ /* Numbers */
2501
- color: #009999 !important;
2502
- }
2503
 
2504
 
2505
 
@@ -2668,6 +2620,9 @@ table.highlight{
2668
  */
2669
 
2670
  .alm-cache{
 
 
 
2671
  .row{
2672
  &:first-of-type{
2673
  margin-top: 0 !important;
@@ -2703,6 +2658,9 @@ table.highlight{
2703
  overflow: hidden;
2704
  padding: 0;
2705
  margin: 10px 0 0;
 
 
 
2706
  &.theme-repeaters{
2707
  padding: 15px;
2708
  margin: 0;
@@ -3171,7 +3129,7 @@ p.theme-title{
3171
  .alm-drop-btn.alm-layout-selection{
3172
  display: inline-block;
3173
  float: right;
3174
- margin: 0;
3175
  @media screen and (max-width: 480px){
3176
  float: none;
3177
  }
@@ -3257,11 +3215,13 @@ p.theme-title{
3257
  .alm-drop-btn.alm-layout-selection a.external{
3258
  padding: 0 10px 0 36px;
3259
  font-weight: 600;
 
 
3260
  }
3261
  .alm-drop-btn.alm-layout-selection a.external i{
3262
  color: #999;
3263
  border-color: #ccc;
3264
- top: 50%;
3265
  transform: translateY(-50%);
3266
  width: 38px;
3267
  }
@@ -3369,82 +3329,92 @@ p.theme-title{
3369
  text-decoration: none;
3370
  }
3371
 
3372
- /* Dropwbown */
3373
- .alm-drop-btn{
 
 
 
 
 
 
 
 
 
 
 
 
 
3374
  position: relative;
3375
- width: auto;
 
 
 
 
 
3376
  }
3377
- .alm-dropdown{
3378
- display: none;
3379
- position: absolute;
3380
- top: 108%;
3381
- right: -15px;
3382
- z-index: 9;
 
 
 
 
3383
  }
3384
- .alm-dropdown .alm-drop-inner{
3385
- display: block;
3386
- position: relative;
3387
- background: #fff;
3388
- border-radius: $radius;
3389
- border: 1px solid #ccc;
3390
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
3391
- padding: 8px 10px;
3392
- width: 220px;
3393
- }
3394
- .alm-layout-selection .alm-dropdown .alm-drop-inner{
3395
- width: 250px;
3396
- padding: 10px 10px 6px;
3397
- }
3398
- .alm-drop-inner:after,
3399
- .alm-drop-inner:before {
3400
- bottom:100%;
3401
- right: 26px;
3402
- border:solid transparent;
3403
- content:" ";
3404
- height:0;
3405
- width:0;
3406
- position:absolute;
3407
- pointer-events:none;
3408
- }
3409
-
3410
- .alm-drop-inner:after {
3411
- border-color:rgba(247,247,247,0);
3412
- border-bottom-color:#fff;
3413
- border-width:7px;
3414
- margin-left:-7px;
3415
- }
3416
- .alm-drop-inner:before {
3417
- border-color:rgba(204,204,204,0);
3418
- border-bottom-color:#ccc;
3419
- border-width:8px;
3420
- right: 25px;
3421
- }
3422
 
3423
- .alm-dropdown.active{
3424
- display: block !important;
 
 
 
 
 
 
 
 
 
3425
  }
3426
- .alm-dropdown ul{
 
 
 
 
 
 
 
 
 
 
 
 
3427
  padding:0;
3428
  margin:0;
3429
  overflow: hidden;
3430
  }
3431
- .alm-dropdown ul li{
3432
  margin: 0;
3433
  padding: 2px 0;
3434
  list-style: none;
3435
  clear: both;
3436
- font-size: 12px;
3437
  line-height: 1.2;
3438
  font-weight: 400;
3439
- }
3440
- .alm-dropdown ul li a{
3441
- padding: 0 10px 0 34px;
 
 
 
 
 
3442
  line-height: 40px;
3443
  height: 40px;
3444
  display: block;
3445
  text-decoration: none;
3446
  background-position: 4px center;
3447
- color: #666;
3448
  box-shadow: none !important;
3449
  position: relative;
3450
  width: 100%;
@@ -3452,43 +3422,43 @@ p.theme-title{
3452
  overflow: hidden;
3453
  text-overflow: ellipsis;
3454
  border-radius: $radius;
3455
- &.layout,
3456
- &.external,
3457
- &.option{
3458
- border: 1px solid $border;
3459
- background-color: transparent;
3460
- &:hover,
3461
- &:focus{
3462
- border-color: $border_hover;
3463
- background-color: #f1f1f1;
3464
  }
3465
- &:focus{
3466
- background-color: #f1f1f1;
3467
- }
 
 
 
 
 
 
 
 
 
 
3468
  }
3469
  }
3470
-
3471
- .alm-dropdown ul li a i{
3472
- margin: 0;
3473
- color: #ccc;
3474
- position: absolute;
3475
- left: 2px;
3476
- top: 50%;
3477
- transform: translateY(-50%);
3478
- font-size: 14px;
3479
- width: 32px;
3480
- height: 16px;
3481
- line-height: 16px;
3482
- display: inline-block;
3483
- text-align: center;
3484
- }
3485
- .alm-dropdown ul li a:hover{
3486
- color: #111;
3487
- background-color: #f7f7f7;
3488
- }
3489
- .alm-dropdown ul li a:hover i{
3490
- color: #999;
3491
- }
3492
 
3493
 
3494
  /*
@@ -3905,13 +3875,13 @@ p.theme-title{
3905
  }
3906
  li a{
3907
  display: block;
3908
- padding: 15px 22px;
3909
  line-height: 1;
3910
  text-decoration: none;
3911
- border: 1px solid #e1e1e1;
3912
  border-radius: $radius $radius 0 0;
3913
  background: #f7f7f7;
3914
- color: #666;
3915
  }
3916
  li a:hover{
3917
  color: #222;
4
  'variables',
5
  'partials/header',
6
  'partials/pro-listing',
7
+ 'partials/codemirror',
8
  'partials/sidebar',
9
  'partials/alm-settings-feedback',
10
  'partials/select2';
390
 
391
  /* Expand/Collapse all rows */
392
  .ajax-load-more .toggle-all{
393
+ position: static;
394
  top: -16px;
395
  right: 20px;
396
  width: auto;
406
  color: #777;
407
  cursor: pointer;
408
  z-index: 20;
409
+ margin-bottom: 10px;
410
+ overflow: hidden;
411
+ @media screen and (min-width: 768px){
412
+ position: absolute;
413
+ }
414
  }
415
  #alm-container.ajax-load-more .toggle-all{
416
  display: none;
724
  display: inline-block;
725
  clear: both;
726
  border-radius: 3px;
727
+ color: $grey;
728
  -webkit-box-shadow: none;
729
  -moz-box-shadow: none;
730
  box-shadow: none;
731
  }
732
+ .ajax-load-more input[type=checkbox],
733
+ .ajax-load-more input[type=radio]{
734
+ width: 1rem;
735
+ }
736
 
737
  .controls button.disabled{
738
  opacity: 0.5;
854
  .ajax-load-more input[type=email]:focus,
855
  .ajax-load-more textarea:focus{
856
  border-color: #bbbbbb;
857
+ box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
858
  background: #f7f7f7;
859
  }
860
 
1149
  padding-left: 0 !important;
1150
  }
1151
  .ajax-load-more label.template-title{
1152
+ padding: 3px 2px 0;
1153
  margin: 0;
1154
+ display: block;
1155
+ &.has-margin-btm{
1156
+ margin-bottom: 10px;
1157
+ }
1158
  }
1159
 
1160
  .ajax-load-more label input._alm_repeater_alias{
1649
  box-shadow: none;
1650
  }
1651
  }
1652
+
1653
+ .ajax-load-more .cnkt-main .repeater-listing{
1654
+ border-top: 1px solid $border;
1655
+ padding-top: 20px;
1656
+ position: relative;
1657
+ .toggle-all{
1658
+ right: 0;
1659
+ top: -45px;
1660
+ }
1661
+ }
1662
+
1663
  .ajax-load-more .cnkt-main.full{
1664
  width: 100%;
1665
  float: none;
1697
  padding: 15px 0 !important;
1698
  }
1699
  .repeater-wrap label{
1700
+ font-weight: 600;
1701
+ span{
1702
+ display: block;
1703
+ font-weight: 400;
1704
+ color: #999;
1705
+ font-size: 13px;
1706
+ padding-top: 2px;
1707
+ }
1708
  }
1709
  input.save-repeater{
1710
  display: inline-block;
2250
  margin-top: 0;
2251
  }
2252
  .ajax-load-more .cnkt-sidebar h3{
2253
+ padding: 10px 20px;
2254
  background: #fff;
2255
  margin: 0;
2256
  display: block;
2257
+ font-size: 14px;
2258
  font-weight: 700;
2259
  text-transform: none;
2260
  border-radius: 2px 2px 0 0;
2451
  * @since 2.2.0
2452
  */
2453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2454
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2455
 
2456
 
2457
 
2620
  */
2621
 
2622
  .alm-cache{
2623
+ .group .row{
2624
+ overflow: visible;
2625
+ }
2626
  .row{
2627
  &:first-of-type{
2628
  margin-top: 0 !important;
2658
  overflow: hidden;
2659
  padding: 0;
2660
  margin: 10px 0 0;
2661
+ &:hover{
2662
+ box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
2663
+ }
2664
  &.theme-repeaters{
2665
  padding: 15px;
2666
  margin: 0;
3129
  .alm-drop-btn.alm-layout-selection{
3130
  display: inline-block;
3131
  float: right;
3132
+ margin: 6px 0 0;
3133
  @media screen and (max-width: 480px){
3134
  float: none;
3135
  }
3215
  .alm-drop-btn.alm-layout-selection a.external{
3216
  padding: 0 10px 0 36px;
3217
  font-weight: 600;
3218
+ border: 1px solid $border;
3219
+ border-radius: $radius;
3220
  }
3221
  .alm-drop-btn.alm-layout-selection a.external i{
3222
  color: #999;
3223
  border-color: #ccc;
3224
+ top: 53%;
3225
  transform: translateY(-50%);
3226
  width: 38px;
3227
  }
3329
  text-decoration: none;
3330
  }
3331
 
3332
+ /* Dropwbown */
3333
+
3334
+ .alm-drop-btn{
3335
+ position: relative;
3336
+ width: auto;
3337
+ }
3338
+
3339
+ .alm-dropdown{
3340
+ display: none;
3341
+ position: absolute;
3342
+ top: 108%;
3343
+ right: -15px;
3344
+ z-index: 9;
3345
+ .alm-drop-inner{
3346
+ display: block;
3347
  position: relative;
3348
+ background: #fff;
3349
+ border-radius: $radius;
3350
+ border: 1px solid #ccc;
3351
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
3352
+ padding: 8px 10px;
3353
+ width: 220px;
3354
  }
3355
+ .alm-drop-inner:after,
3356
+ .alm-drop-inner:before {
3357
+ bottom:100%;
3358
+ right: 26px;
3359
+ border:solid transparent;
3360
+ content:" ";
3361
+ height:0;
3362
+ width:0;
3363
+ position:absolute;
3364
+ pointer-events:none;
3365
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3366
 
3367
+ .alm-drop-inner:after {
3368
+ border-color:rgba(247,247,247,0);
3369
+ border-bottom-color:#fff;
3370
+ border-width:7px;
3371
+ margin-left:-7px;
3372
+ }
3373
+ .alm-drop-inner:before {
3374
+ border-color:rgba(204,204,204,0);
3375
+ border-bottom-color:#ccc;
3376
+ border-width:8px;
3377
+ right: 25px;
3378
  }
3379
+
3380
+ &.active{
3381
+ display: block !important;
3382
+ }
3383
+ }
3384
+
3385
+ .alm-layout-selection .alm-dropdown .alm-drop-inner{
3386
+ width: 270px;
3387
+ padding: 10px 10px 6px;
3388
+ }
3389
+
3390
+ .alm-dropdown {
3391
+ ul{
3392
  padding:0;
3393
  margin:0;
3394
  overflow: hidden;
3395
  }
3396
+ li{
3397
  margin: 0;
3398
  padding: 2px 0;
3399
  list-style: none;
3400
  clear: both;
3401
+ font-size: 13px;
3402
  line-height: 1.2;
3403
  font-weight: 400;
3404
+ &.option{
3405
+ border-radius: $radius;
3406
+ &:nth-child(even){
3407
+ background-color: $light_grey;
3408
+ }
3409
+ }
3410
+ a:not(.button){
3411
+ padding: 0 10px 0 32px;
3412
  line-height: 40px;
3413
  height: 40px;
3414
  display: block;
3415
  text-decoration: none;
3416
  background-position: 4px center;
3417
+ color: $grey;
3418
  box-shadow: none !important;
3419
  position: relative;
3420
  width: 100%;
3422
  overflow: hidden;
3423
  text-overflow: ellipsis;
3424
  border-radius: $radius;
3425
+ &:hover,
3426
+ &:focus{
3427
+ color: #333;
3428
+ i{
3429
+ opacity: 0.8;
 
 
 
 
3430
  }
3431
+ }
3432
+ i{
3433
+ margin: 0;
3434
+ position: absolute;
3435
+ left: 0px;
3436
+ top: 50%;
3437
+ transform: translateY(-50%);
3438
+ width: 32px;
3439
+ font-size: 14px;
3440
+ line-height: 1;
3441
+ display: inline-block;
3442
+ text-align: center;
3443
+ opacity: 0.5;
3444
  }
3445
  }
3446
+ &.layout-cta{
3447
+ border: 1px solid $border;
3448
+ padding: 20px 10px;
3449
+ border-radius: $radius;
3450
+ margin-bottom: 5px;
3451
+ background-color: #fffeed;
3452
+ text-align: center;
3453
+ span{
3454
+ display: block;
3455
+ padding: 0 0 12px;
3456
+ line-height: 1.5;
3457
+ }
3458
+ }
3459
+ }
3460
+ }
3461
+
 
 
 
 
 
 
3462
 
3463
 
3464
  /*
3875
  }
3876
  li a{
3877
  display: block;
3878
+ padding: 14px 20px;
3879
  line-height: 1;
3880
  text-decoration: none;
3881
+ border: 1px solid $border;
3882
  border-radius: $radius $radius 0 0;
3883
  background: #f7f7f7;
3884
+ color: $grey;
3885
  }
3886
  li a:hover{
3887
  color: #222;
admin/src/scss/partials/_alm-block.scss ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ajax-load-more{
2
+
3
+ .alm-block{
4
+ &--wrap{
5
+ border: 1px solid $border;
6
+ border-top: none;
7
+ }
8
+ &--row{
9
+ display: flex;
10
+ flex-wrap: nowrap;
11
+ border-top: 1px solid $border;
12
+ &_title{
13
+ width: 100%;
14
+ flex: 1;
15
+ padding: 20px;
16
+ h3{
17
+ font-weight: 700;
18
+ margin: 0;
19
+ padding: 0;
20
+ }
21
+ }
22
+ &_label,
23
+ &_detail{
24
+ padding: 20px;
25
+ }
26
+ &_label{
27
+ background-color: #f7f7f7;
28
+ font-weight: 600;
29
+ width: 20%;
30
+ border-right: 1px solid $border;
31
+ }
32
+ &_detail{
33
+ background-color: #fff;
34
+ flex: 1;
35
+ }
36
+ }
37
+
38
+ label{
39
+ font-size: 14px;
40
+ .small{
41
+ font-weight: 400;
42
+ font-size: 12px;
43
+ line-height: 1.35;
44
+ opacity: 0.8;
45
+ }
46
+ }
47
+ }
48
+
49
+ }
admin/src/scss/partials/_codemirror.scss ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ajax-load-more .CodeMirror {
2
+ height: auto;
3
+ border-radius: $radius;
4
+ padding: 0;
5
+ background: $light_grey;
6
+ border: 1px solid $border;
7
+ color: #999;
8
+ line-height: 1.5;
9
+ font-size: 13px;
10
+ &.CodeMirror-focused{
11
+ border-color: #bbbbbb;
12
+ box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
13
+ }
14
+ }
15
+ .ajax-load-more .cm-readonly .CodeMirror{
16
+ opacity: 0.8;
17
+ }
18
+ .ajax-load-more .cm-readonly .CodeMirror pre{
19
+ cursor: default !important;
20
+ }
21
+ .ajax-load-more .CodeMirror pre{
22
+ padding: 0 10px;
23
+ }
24
+ .CodeMirror-lines{
25
+ padding: 10px !important;
26
+ }
27
+ .CodeMirror-linenumber{
28
+ padding: 0 10px !important;
29
+ line-height: 1.25 !important;
30
+ color: #ccc !important;
31
+ }
32
+ .CodeMirror-linenumber.CodeMirror-gutter-elt {
33
+ padding: 0 20px 0 0 !important;
34
+ }
35
+ .ajax-load-more .cm-readonly.sm-margin .CodeMirror{
36
+ margin: 0 0 10px;
37
+ }
38
+ .ajax-load-more .cm-readonly p.warning-callout{
39
+ margin: 0 0 10px;
40
+ }
41
+ .ajax-load-more .CodeMirror.loading {
42
+ background: $light_grey url("../../img/loader-unlimited.gif") no-repeat center center;
43
+ opacity: 0.6;
44
+ }
45
+ .ajax-load-more .cm-s-pastel-on-dark.CodeMirror{ /* Bkg color */
46
+ background: #333;
47
+ }
48
+ .ajax-load-more .CodeMirror-gutters{ /* Line Number color */
49
+ background: #fff;
50
+ border-right: 1px solid $border;
51
+ border-radius: 2px;
52
+ }
53
+ .ajax-load-more .CodeMirror-scroll {
54
+ overflow-y: hidden;
55
+ overflow-x: auto;
56
+ }
57
+
58
+ .ajax-load-more .cm-tag{ /* <li> <h2> html elements */
59
+ color: #0a4b83 !important;
60
+ }
61
+ .ajax-load-more .cm-string{ /* Elements in " " */
62
+ color: #c75050 !important;
63
+ }
64
+ .ajax-load-more .cm-attribute{ /* class names */
65
+ color: #008080 !important;
66
+ }
67
+ .ajax-load-more .cm-keyword{ /* if, array, echo */
68
+ color: #ae5fb3 !important;
69
+ }
70
+ .ajax-load-more span.CodeMirror-matchingbracket{
71
+ color: #ff0000 !important;
72
+ }
73
+ .ajax-load-more .CodeMirror span.cm-meta{ /* <?php */
74
+ color: #999;
75
+ }
76
+ .ajax-load-more .CodeMirror span.cm-variable{ /* Function names */
77
+ color: #111;
78
+ font-weight: 500;
79
+ padding: 0 1px;
80
+ }
81
+ .ajax-load-more .CodeMirror span.cm-number{ /* Numbers */
82
+ color: #009999 !important;
83
+ }
admin/views/licenses.php CHANGED
@@ -9,63 +9,63 @@
9
  <?php echo ALM_TITLE; ?>: <strong><?php echo $pg_title; ?></strong>
10
  <em><?php echo $pg_desc; ?>.</em>
11
  </h1>
12
- <?php alm_render_transient_notification(); ?>
13
  </header>
14
-
15
  <div class="ajax-load-more-inner-wrapper">
16
-
17
  <div class="cnkt-main">
18
-
19
- <h3><?php
20
  if(has_action('alm_pro_installed')){
21
- _e('License Key', 'ajax-load-more');
22
  } else {
23
- _e('License Keys', 'ajax-load-more');
24
  }
25
  ?></h3>
26
 
27
  <p>
28
- <?php
29
  if(has_action('alm_pro_installed')){
30
- _e('Enter your Ajax Load More Pro license key to receive plugin update notifications directly within the <a href="plugins.php">WP Plugins dashboard</a>.', 'ajax-load-more');
31
  } else {
32
- _e('Enter a key for each of your Ajax Load More add-ons to receive plugin update notifications directly within the <a href="plugins.php">WP Plugins dashboard</a>.', 'ajax-load-more');
33
  }
34
  ?>
35
- </p>
36
-
37
- <?php
38
-
39
- $addons = (has_action('alm_pro_installed')) ? alm_get_pro_addon() : alm_get_addons();
40
  $addon_count = 0;
41
-
42
- foreach($addons as $addon){
43
-
44
  $name = $addon['name'];
45
  $intro = $addon['intro'];
46
  $desc = $addon['desc'];
47
  $action = $addon['action'];
48
  $key = $addon['key'];
49
- $license = get_option($key);
50
  $status = $addon['status'];
51
  $settings_field = $addon['settings_field'];
52
  $url = $addon['url'];
53
- $img = $addon['img'];
54
  $item_id = $addon['item_id'];
55
-
56
-
57
  // If installed
58
  if(!has_action($action)){
59
- continue;
60
  }
61
-
62
- $addon_count++;
63
-
64
  // Check license
65
  $license_status = alm_license_check($item_id, $license, $status);
66
-
67
- ?>
68
-
69
  <div class="license" id="license-<?php echo sanitize_title_with_dashes($name); ?>">
70
  <div class="license-title">
71
  <div class="status <?php echo ($license_status === 'valid') ? 'valid' : 'invalid'; ?> "></div>
@@ -73,7 +73,7 @@
73
  </div>
74
  <div class="license-wrap">
75
  <form method="post" action="options.php">
76
-
77
  <?php if( $license_status !== false && $license_status == 'valid' ) { ?>
78
  <!-- nothing -->
79
  <?php } else { ?>
@@ -81,10 +81,10 @@
81
  <h4><?php _e('Don\'t have a license?', 'ajax-load-more'); ?></h4>
82
  <p><?php _e('A valid license is required to activate and receive plugin updates directly in your WordPress dashboard', 'ajax-load-more'); ?> &rarr; <a href="<?php echo $url; ?>?utm_source=WP%20Admin&utm_medium=Licenses&utm_campaign=<?php echo $name; ?>" target="blank"><strong><?php _e('Purchase Now', 'ajax-load-more'); ?>!</strong></a></p>
83
  </div>
84
- <?php } ?>
85
-
86
- <?php settings_fields($settings_field); ?>
87
-
88
  <label class="description offscreen" for="<?php echo $key; ?>"><?php _e('Enter License Key', 'ajax-load-more'); ?></label>
89
  <div class="license-key-field">
90
  <input id="<?php echo $key; ?>" name="<?php echo $key; ?>" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" placeholder="<?php _e('Enter License Key', 'ajax-load-more'); ?>" />
@@ -94,38 +94,38 @@
94
  </span>
95
  <?php } else { ?>
96
  <span class="status inactive">
97
- <?php
98
  if($license_status === 'expired'){
99
- _e('Expired', 'ajax-load-more');
100
  }else{
101
- _e('Inactive', 'ajax-load-more');
102
  }
103
  ?>
104
  </span>
105
  <?php } ?>
106
- </div>
107
-
108
- <?php
109
- $nonce = 'alm_'. $item_id .'_license_nonce';
110
- wp_nonce_field( $nonce, $nonce );
111
  ?>
112
-
113
  <div class="license-btn-wrap"
114
  data-name="<?php echo $item_id; ?>"
115
  data-url="<?php echo ALM_STORE_URL; ?>"
116
  data-option-status="<?php echo $status; ?>"
117
  data-option-key="<?php echo $key; ?>"
118
  data-upgrade-url="<?php echo $url; ?>">
119
- <button type="button" class="activate license-btn <?php if($license_status === 'valid'){ echo 'hide'; } ?> button-primary" data-type="activate">
120
  <?php _e('Activate License', 'ajax-load-more'); ?>
121
  </button>
122
- <button type="button" class="deactivate license-btn <?php if($license_status !== 'valid'){ echo 'hide'; } ?> button-secondary" data-type="deactivate">
123
  <?php _e('Deactivate License', 'ajax-load-more'); ?>
124
  </button>
125
- <button type="button" class="check-licence license-btn <?php if($license_status !== 'valid'){ echo 'hide'; } ?> button-secondary" data-type="check">
126
  <i class="fa fa-refresh" aria-hidden="true"></i> <?php _e('Refresh Status', 'ajax-load-more'); ?>
127
  </button>
128
- <?php if($license_status === 'expired'){
129
  if(isset($license) && !empty($license)){
130
  $store = ALM_STORE_URL;
131
  $url = "{$store}/checkout/?edd_license_key={$license}&download_id={$item_id}";
@@ -134,25 +134,25 @@
134
  <a class="button renew-btn" href="<?php echo $url; ?>" target="_blank">
135
  <?php _e('Renew License', 'ajax-load-more'); ?></a>
136
  <?php } ?>
137
- </div>
138
  </form>
139
  </div>
140
  <div class="loading"></div>
141
- </div>
142
  <?php } unset($addons); ?>
143
-
144
- <?php
145
- // No add-ons installed
146
- if($addon_count == 0) :
147
  ?>
148
  <div class="spacer"></div>
149
  <div class="license-no-addons">
150
  <p><?php _e('You do not have any Ajax Load More add-ons installed', 'ajax-load-more'); ?> | <a href="admin.php?page=ajax-load-more-add-ons"><strong><?php _e('Browse Add-ons', 'ajax-load-more'); ?></strong></a> | <a href="https://connekthq.com/plugins/ajax-load-more/pro/" target="_blank"><strong><?php _e('Go Pro', 'ajax-load-more'); ?></strong></a></p>
151
  </div>
152
- <?php endif; ?>
153
-
154
  </div>
155
-
156
  <aside class="cnkt-sidebar">
157
  <div id="cnkt-sticky-wrapper">
158
  <div id="cnkt-sticky">
@@ -176,8 +176,8 @@
176
  </div>
177
  </div>
178
  </div>
179
-
180
- <div class="clear"></div>
181
  </aside>
182
 
183
  </div>
9
  <?php echo ALM_TITLE; ?>: <strong><?php echo $pg_title; ?></strong>
10
  <em><?php echo $pg_desc; ?>.</em>
11
  </h1>
12
+ <?php alm_render_transient_notification(); ?>
13
  </header>
14
+
15
  <div class="ajax-load-more-inner-wrapper">
16
+
17
  <div class="cnkt-main">
18
+
19
+ <h3><?php
20
  if(has_action('alm_pro_installed')){
21
+ _e('License Key', 'ajax-load-more');
22
  } else {
23
+ _e('License Keys', 'ajax-load-more');
24
  }
25
  ?></h3>
26
 
27
  <p>
28
+ <?php
29
  if(has_action('alm_pro_installed')){
30
+ _e('Enter your Ajax Load More Pro license key to receive plugin update notifications directly within the <a href="plugins.php">WP Plugins dashboard</a>.', 'ajax-load-more');
31
  } else {
32
+ _e('Enter a key for each of your Ajax Load More add-ons to receive plugin update notifications directly within the <a href="plugins.php">WP Plugins dashboard</a>.', 'ajax-load-more');
33
  }
34
  ?>
35
+ </p>
36
+
37
+ <?php
38
+
39
+ $addons = (has_action('alm_pro_installed')) ? alm_get_pro_addon() : alm_get_addons();
40
  $addon_count = 0;
41
+
42
+ foreach($addons as $addon){
43
+
44
  $name = $addon['name'];
45
  $intro = $addon['intro'];
46
  $desc = $addon['desc'];
47
  $action = $addon['action'];
48
  $key = $addon['key'];
49
+ $license = get_option($key);
50
  $status = $addon['status'];
51
  $settings_field = $addon['settings_field'];
52
  $url = $addon['url'];
53
+ $img = $addon['img'];
54
  $item_id = $addon['item_id'];
55
+
56
+
57
  // If installed
58
  if(!has_action($action)){
59
+ continue;
60
  }
61
+
62
+ $addon_count++;
63
+
64
  // Check license
65
  $license_status = alm_license_check($item_id, $license, $status);
66
+
67
+ ?>
68
+
69
  <div class="license" id="license-<?php echo sanitize_title_with_dashes($name); ?>">
70
  <div class="license-title">
71
  <div class="status <?php echo ($license_status === 'valid') ? 'valid' : 'invalid'; ?> "></div>
73
  </div>
74
  <div class="license-wrap">
75
  <form method="post" action="options.php">
76
+
77
  <?php if( $license_status !== false && $license_status == 'valid' ) { ?>
78
  <!-- nothing -->
79
  <?php } else { ?>
81
  <h4><?php _e('Don\'t have a license?', 'ajax-load-more'); ?></h4>
82
  <p><?php _e('A valid license is required to activate and receive plugin updates directly in your WordPress dashboard', 'ajax-load-more'); ?> &rarr; <a href="<?php echo $url; ?>?utm_source=WP%20Admin&utm_medium=Licenses&utm_campaign=<?php echo $name; ?>" target="blank"><strong><?php _e('Purchase Now', 'ajax-load-more'); ?>!</strong></a></p>
83
  </div>
84
+ <?php } ?>
85
+
86
+ <?php settings_fields($settings_field); ?>
87
+
88
  <label class="description offscreen" for="<?php echo $key; ?>"><?php _e('Enter License Key', 'ajax-load-more'); ?></label>
89
  <div class="license-key-field">
90
  <input id="<?php echo $key; ?>" name="<?php echo $key; ?>" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" placeholder="<?php _e('Enter License Key', 'ajax-load-more'); ?>" />
94
  </span>
95
  <?php } else { ?>
96
  <span class="status inactive">
97
+ <?php
98
  if($license_status === 'expired'){
99
+ _e('Expired', 'ajax-load-more');
100
  }else{
101
+ _e('Inactive', 'ajax-load-more');
102
  }
103
  ?>
104
  </span>
105
  <?php } ?>
106
+ </div>
107
+
108
+ <?php
109
+ $nonce = 'alm_'. $item_id .'_license_nonce';
110
+ wp_nonce_field( $nonce, $nonce );
111
  ?>
112
+
113
  <div class="license-btn-wrap"
114
  data-name="<?php echo $item_id; ?>"
115
  data-url="<?php echo ALM_STORE_URL; ?>"
116
  data-option-status="<?php echo $status; ?>"
117
  data-option-key="<?php echo $key; ?>"
118
  data-upgrade-url="<?php echo $url; ?>">
119
+ <button type="button" class="activate license-btn <?php if($license_status === 'valid'){ echo 'hide'; } ?> button button-primary" data-type="activate">
120
  <?php _e('Activate License', 'ajax-load-more'); ?>
121
  </button>
122
+ <button type="button" class="deactivate license-btn <?php if($license_status !== 'valid'){ echo 'hide'; } ?> button button-secondary" data-type="deactivate">
123
  <?php _e('Deactivate License', 'ajax-load-more'); ?>
124
  </button>
125
+ <button type="button" class="check-licence license-btn <?php if($license_status !== 'valid'){ echo 'hide'; } ?> button button-secondary" data-type="check">
126
  <i class="fa fa-refresh" aria-hidden="true"></i> <?php _e('Refresh Status', 'ajax-load-more'); ?>
127
  </button>
128
+ <?php if($license_status === 'expired'){
129
  if(isset($license) && !empty($license)){
130
  $store = ALM_STORE_URL;
131
  $url = "{$store}/checkout/?edd_license_key={$license}&download_id={$item_id}";
134
  <a class="button renew-btn" href="<?php echo $url; ?>" target="_blank">
135
  <?php _e('Renew License', 'ajax-load-more'); ?></a>
136
  <?php } ?>
137
+ </div>
138
  </form>
139
  </div>
140
  <div class="loading"></div>
141
+ </div>
142
  <?php } unset($addons); ?>
143
+
144
+ <?php
145
+ // No add-ons installed
146
+ if($addon_count == 0) :
147
  ?>
148
  <div class="spacer"></div>
149
  <div class="license-no-addons">
150
  <p><?php _e('You do not have any Ajax Load More add-ons installed', 'ajax-load-more'); ?> | <a href="admin.php?page=ajax-load-more-add-ons"><strong><?php _e('Browse Add-ons', 'ajax-load-more'); ?></strong></a> | <a href="https://connekthq.com/plugins/ajax-load-more/pro/" target="_blank"><strong><?php _e('Go Pro', 'ajax-load-more'); ?></strong></a></p>
151
  </div>
152
+ <?php endif; ?>
153
+
154
  </div>
155
+
156
  <aside class="cnkt-sidebar">
157
  <div id="cnkt-sticky-wrapper">
158
  <div id="cnkt-sticky">
176
  </div>
177
  </div>
178
  </div>
179
+
180
+ <div class="clear"></div>
181
  </aside>
182
 
183
  </div>
admin/views/repeater-templates.php CHANGED
@@ -28,13 +28,12 @@
28
  </ul>
29
  <?php } ?>
30
 
31
-
32
  <?php
33
 
34
  // Theme Repeaters
35
 
36
  if($theme_repeaters){ ?>
37
- <div class="group no-shadow">
38
 
39
  <?php
40
 
@@ -80,14 +79,15 @@
80
  ?>
81
  <textarea rows="10" id="template-tr-<?php echo $id; ?>" class="_alm_repeater"><?php echo $tr_contents; ?></textarea>
82
  <script>
83
- var editorDefault = CodeMirror.fromTextArea(document.getElementById("template-tr-<?php echo $id; ?>"), {
84
  mode: "application/x-httpd-php",
85
  lineNumbers: true,
86
  lineWrapping: true,
87
  indentUnit: 0,
88
  matchBrackets: true,
89
  readOnly: true,
90
- viewportMargin: Infinity,
 
91
  extraKeys: {"Ctrl-Space": "autocomplete"},
92
  });
93
  </script>
@@ -122,7 +122,7 @@
122
  }
123
 
124
  if($count > 1){?>
125
- <span class="toggle-all">
126
  <span class="inner-wrap">
127
  <em class="collapse"><?php _e('Collapse All', 'ajax-load-more'); ?></em>
128
  <em class="expand"><?php _e('Expand All', 'ajax-load-more'); ?></em>
@@ -148,11 +148,11 @@
148
  <?php } else { ?>
149
 
150
  <!-- Repeaters -->
151
- <div class="group no-shadow">
152
 
153
  <?php
154
  if (has_action('alm_custom_repeaters') || has_action('alm_unlimited_repeaters')){ ?>
155
- <span class="toggle-all">
156
  <span class="inner-wrap">
157
  <em class="collapse"><?php _e('Collapse All', 'ajax-load-more'); ?></em>
158
  <em class="expand"><?php _e('Expand All', 'ajax-load-more'); ?></em>
@@ -200,9 +200,10 @@
200
  echo '<div class="alm-row alm-row--margin-btm">';
201
  echo '<div class="column column--two-third">';
202
  // Add Label
203
- echo '<label class="template-title" for="template-default">';
204
- _e('Enter the HTML and PHP code for the default template', 'ajax-load-more');
205
- echo ':</label>';
 
206
  echo '</div>';
207
  echo '<div class="column column--one-third">';
208
  do_action('alm_get_layouts'); // Layouts - Template Selection
@@ -214,14 +215,15 @@
214
  <div class="column">
215
  <textarea rows="10" id="template-default" class="_alm_repeater"><?php echo $contents; ?></textarea>
216
  <script>
217
- var editorDefault = CodeMirror.fromTextArea(document.getElementById("template-default"), {
218
  mode: "application/x-httpd-php",
219
  lineNumbers: true,
220
  lineWrapping: true,
221
  indentUnit: 0,
222
  matchBrackets: true,
223
  readOnly: <?php echo $readOnly; ?>,
224
- viewportMargin: Infinity,
 
225
  extraKeys: {"Ctrl-Space": "autocomplete"},
226
  });
227
  </script>
@@ -325,7 +327,7 @@
325
  var id = editorId.replace('template-', ''); // Editor ID
326
 
327
  if(id === 'default'){ // Default Template
328
- value = editorDefault.getValue();
329
  }else{ // Repeater Templates
330
  var eid = window['editor_'+id]; // Set editor ID
331
  value = eid.getValue();
@@ -424,7 +426,7 @@
424
  },
425
  success: function(response) {
426
  if(id === 'default'){ // Default Template
427
- editorDefault.setValue(response);
428
  }else{ // Repeater Templates
429
  var eid = window['editor_'+id]; // Set editor ID
430
  eid.setValue(response);
28
  </ul>
29
  <?php } ?>
30
 
 
31
  <?php
32
 
33
  // Theme Repeaters
34
 
35
  if($theme_repeaters){ ?>
36
+ <div class="repeater-listing">
37
 
38
  <?php
39
 
79
  ?>
80
  <textarea rows="10" id="template-tr-<?php echo $id; ?>" class="_alm_repeater"><?php echo $tr_contents; ?></textarea>
81
  <script>
82
+ var editor_default = CodeMirror.fromTextArea(document.getElementById("template-tr-<?php echo $id; ?>"), {
83
  mode: "application/x-httpd-php",
84
  lineNumbers: true,
85
  lineWrapping: true,
86
  indentUnit: 0,
87
  matchBrackets: true,
88
  readOnly: true,
89
+ viewportMargin: Infinity,foldGutter: true,
90
+ gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
91
  extraKeys: {"Ctrl-Space": "autocomplete"},
92
  });
93
  </script>
122
  }
123
 
124
  if($count > 1){?>
125
+ <span class="toggle-all" role="button" tabindex="0">
126
  <span class="inner-wrap">
127
  <em class="collapse"><?php _e('Collapse All', 'ajax-load-more'); ?></em>
128
  <em class="expand"><?php _e('Expand All', 'ajax-load-more'); ?></em>
148
  <?php } else { ?>
149
 
150
  <!-- Repeaters -->
151
+ <div class="<?php if(has_action('alm_get_theme_repeater')){ echo 'repeater-listing'; } ?>">
152
 
153
  <?php
154
  if (has_action('alm_custom_repeaters') || has_action('alm_unlimited_repeaters')){ ?>
155
+ <span class="toggle-all" role="button" tabindex="0">
156
  <span class="inner-wrap">
157
  <em class="collapse"><?php _e('Collapse All', 'ajax-load-more'); ?></em>
158
  <em class="expand"><?php _e('Expand All', 'ajax-load-more'); ?></em>
200
  echo '<div class="alm-row alm-row--margin-btm">';
201
  echo '<div class="column column--two-third">';
202
  // Add Label
203
+ echo '<label class="template-title trigger-codemirror" data-id="default" for="template-default">';
204
+ _e('Template Code:', 'ajax-load-more');
205
+ echo '<span>'. __('Enter the PHP and HTML markup for this template.', 'ajax-load-more') .'</span>';
206
+ echo '</label>';
207
  echo '</div>';
208
  echo '<div class="column column--one-third">';
209
  do_action('alm_get_layouts'); // Layouts - Template Selection
215
  <div class="column">
216
  <textarea rows="10" id="template-default" class="_alm_repeater"><?php echo $contents; ?></textarea>
217
  <script>
218
+ var editor_default = CodeMirror.fromTextArea(document.getElementById("template-default"), {
219
  mode: "application/x-httpd-php",
220
  lineNumbers: true,
221
  lineWrapping: true,
222
  indentUnit: 0,
223
  matchBrackets: true,
224
  readOnly: <?php echo $readOnly; ?>,
225
+ viewportMargin: Infinity,foldGutter: true,
226
+ gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
227
  extraKeys: {"Ctrl-Space": "autocomplete"},
228
  });
229
  </script>
327
  var id = editorId.replace('template-', ''); // Editor ID
328
 
329
  if(id === 'default'){ // Default Template
330
+ value = editor_default.getValue();
331
  }else{ // Repeater Templates
332
  var eid = window['editor_'+id]; // Set editor ID
333
  value = eid.getValue();
426
  },
427
  success: function(response) {
428
  if(id === 'default'){ // Default Template
429
+ editor_default.setValue(response);
430
  }else{ // Repeater Templates
431
  var eid = window['editor_'+id]; // Set editor ID
432
  eid.setValue(response);
ajax-load-more.php CHANGED
@@ -7,14 +7,14 @@ Text Domain: ajax-load-more
7
  Author: Darren Cooney
8
  Twitter: @KaptonKaos
9
  Author URI: https://connekthq.com
10
- Version: 5.1.6.1
11
  License: GPL
12
  Copyright: Darren Cooney & Connekt Media
13
  */
14
 
15
 
16
- define('ALM_VERSION', '5.1.6.1');
17
- define('ALM_RELEASE', 'November 18, 2019');
18
  define('ALM_STORE_URL', 'https://connekthq.com');
19
 
20
 
@@ -304,7 +304,8 @@ if( !class_exists('AjaxLoadMore') ):
304
  */
305
 
306
  public function alm_action_links( $links ) {
307
- $links[] = '<a href="'. get_admin_url(null, 'admin.php?page=ajax-load-more') .'">'.__('Settings', 'ajax-load-more').'</a>';
 
308
  return $links;
309
  }
310
 
7
  Author: Darren Cooney
8
  Twitter: @KaptonKaos
9
  Author URI: https://connekthq.com
10
+ Version: 5.1.7.1
11
  License: GPL
12
  Copyright: Darren Cooney & Connekt Media
13
  */
14
 
15
 
16
+ define('ALM_VERSION', '5.1.7.1');
17
+ define('ALM_RELEASE', 'December 9, 2019');
18
  define('ALM_STORE_URL', 'https://connekthq.com');
19
 
20
 
304
  */
305
 
306
  public function alm_action_links( $links ) {
307
+ $settings = '<a href="'. get_admin_url(null, 'admin.php?page=ajax-load-more') .'">'.__('Settings', 'ajax-load-more').'</a>';
308
+ array_unshift( $links, $settings );
309
  return $links;
310
  }
311
 
core/classes/class.alm-shortcode.php CHANGED
@@ -118,20 +118,20 @@ if( !class_exists('ALM_SHORTCODE') ):
118
  'comments_style' => 'ol',
119
  'comments_template' => 'none',
120
  'comments_callback' => '',
121
- 'comments_post_id' => 'null',
122
  'nextpage' => false,
123
- 'nextpage_post_id' => 'null',
124
  'nextpage_urls' => 'true',
125
  'nextpage_scroll' => 'true:30',
126
  'nextpage_pageviews' => 'true',
127
  'nextpage_start' => 1,
128
  'previous_post' => false,
129
- 'previous_post_id' => 'null',
130
  'previous_post_order' => 'previous',
131
  'previous_post_taxonomy' => '',
132
  'previous_post_excluded_terms' => '',
133
  'single_post' => false,
134
- 'single_post_id' => 'null',
135
  'single_post_order' => 'previous',
136
  'single_post_taxonomy' => '',
137
  'single_post_excluded_terms' => '',
@@ -214,11 +214,23 @@ if( !class_exists('ALM_SHORTCODE') ):
214
  'id' => '',
215
  'primary' => false,
216
  'woocommerce' => false,
 
217
  'no_results_text' => '',
218
  'placeholder' => ''
219
- ), $atts));
220
 
221
 
 
 
 
 
 
 
 
 
 
 
 
222
  // Backwards compat
223
  // If $previous_post_ is true, set the $single_post_{value} params
224
  if($previous_post === 'true'){
@@ -226,7 +238,7 @@ if( !class_exists('ALM_SHORTCODE') ):
226
  $single_post_id = $previous_post_id;
227
  $single_post_order = $previous_post_order;
228
  $single_post_taxonomy = $previous_post_taxonomy;
229
- $single_post_excluded_terms = $previous_post_excluded_terms;
230
  }
231
 
232
 
@@ -365,8 +377,8 @@ if( !class_exists('ALM_SHORTCODE') ):
365
  // Previous Post
366
  if($single_post){
367
  $posts_per_page = 1;
368
- $container_element = 'div';
369
- $seo = false;
370
  }
371
 
372
  // Users
@@ -783,7 +795,14 @@ if( !class_exists('ALM_SHORTCODE') ):
783
 
784
 
785
  // Single Posts Add-on
786
- if(has_action('alm_single_post_installed') && $single_post){
 
 
 
 
 
 
 
787
  $single_post_return = apply_filters(
788
  'alm_single_post_shortcode',
789
  $single_post_id,
@@ -799,6 +818,13 @@ if( !class_exists('ALM_SHORTCODE') ):
799
 
800
  // Nextpage Post Add-on
801
  if(has_action('alm_nextpage_installed') && $nextpage){
 
 
 
 
 
 
 
802
  $nextpage_return = apply_filters(
803
  'alm_nextpage_shortcode',
804
  $nextpage_urls,
118
  'comments_style' => 'ol',
119
  'comments_template' => 'none',
120
  'comments_callback' => '',
121
+ 'comments_post_id' => '',
122
  'nextpage' => false,
123
+ 'nextpage_post_id' => '',
124
  'nextpage_urls' => 'true',
125
  'nextpage_scroll' => 'true:30',
126
  'nextpage_pageviews' => 'true',
127
  'nextpage_start' => 1,
128
  'previous_post' => false,
129
+ 'previous_post_id' => '',
130
  'previous_post_order' => 'previous',
131
  'previous_post_taxonomy' => '',
132
  'previous_post_excluded_terms' => '',
133
  'single_post' => false,
134
+ 'single_post_id' => '',
135
  'single_post_order' => 'previous',
136
  'single_post_taxonomy' => '',
137
  'single_post_excluded_terms' => '',
214
  'id' => '',
215
  'primary' => false,
216
  'woocommerce' => false,
217
+ 'elementor' => false,
218
  'no_results_text' => '',
219
  'placeholder' => ''
220
+ ), $atts));
221
 
222
 
223
+ // Elementor
224
+ if($elementor === 'true'){
225
+ // If Elementor && not on a singular page, exit ALM.
226
+ if(!is_singular($post_type)){
227
+ return false;
228
+ }
229
+ $container_element = 'div';
230
+ $offset = '1';
231
+ }
232
+
233
+
234
  // Backwards compat
235
  // If $previous_post_ is true, set the $single_post_{value} params
236
  if($previous_post === 'true'){
238
  $single_post_id = $previous_post_id;
239
  $single_post_order = $previous_post_order;
240
  $single_post_taxonomy = $previous_post_taxonomy;
241
+ $single_post_excluded_terms = $previous_post_excluded_terms;
242
  }
243
 
244
 
377
  // Previous Post
378
  if($single_post){
379
  $posts_per_page = 1;
380
+ $container_element = 'div';
381
+ $seo = false;
382
  }
383
 
384
  // Users
795
 
796
 
797
  // Single Posts Add-on
798
+ if(has_action('alm_single_post_installed') && $single_post){
799
+
800
+ // Get post ID if null
801
+ if(!$single_post_id){
802
+ global $post;
803
+ $single_post_id = $post->ID;
804
+ }
805
+
806
  $single_post_return = apply_filters(
807
  'alm_single_post_shortcode',
808
  $single_post_id,
818
 
819
  // Nextpage Post Add-on
820
  if(has_action('alm_nextpage_installed') && $nextpage){
821
+
822
+ // Get post ID if null
823
+ if(!$nextpage_post_id){
824
+ global $post;
825
+ $nextpage_post_id = $post->ID;
826
+ }
827
+
828
  $nextpage_return = apply_filters(
829
  'alm_nextpage_shortcode',
830
  $nextpage_urls,
core/classes/includes/preloaded.php CHANGED
@@ -48,7 +48,7 @@ $type = alm_get_repeater_type($repeater);
48
 
49
 
50
  // Tabs
51
- if($tabs === 'true'){
52
 
53
  /*
54
  * alm_tabs_preloaded
48
 
49
 
50
  // Tabs
51
+ if($tabs){
52
 
53
  /*
54
  * alm_tabs_preloaded
core/dist/js/ajax-load-more.js CHANGED
@@ -274,7 +274,11 @@ var alm_is_filtering = false;
274
  alm.loading = true;
275
  alm.finished = false;
276
  alm.timer = null;
277
- alm.ua = window.navigator.userAgent ? window.navigator.userAgent : ''; // User agent
 
 
 
 
278
  alm.main = el;
279
  alm.master_id = el.dataset.id ? 'ajax-load-more-' + el.dataset.id : el.id; // The defined or generated ID of the ALM instance
280
  el.classList.add('alm-' + e); // Add unique classname
@@ -464,16 +468,22 @@ var alm_is_filtering = false;
464
  if (alm.addons.tabs === 'true') {
465
  alm.addons.tabs = true;
466
  alm.addons.tab_template = alm.listing.dataset.tabTemplate ? alm.listing.dataset.tabTemplate : '';
 
 
467
 
468
- // Set current template
469
- setTimeout(function () {
470
- //window.almTabsOnLoad(alm);
471
- }, 500);
472
- if (typeof almTabsOnLoad === 'function' && window.location.hash) {
473
- //alm.addons.tab_template = window.almTabsOnLoad(alm);
 
 
 
 
 
 
474
  }
475
-
476
- alm.addons.tabs_resturl = alm.listing.dataset.tabsRestUrl ? alm.listing.dataset.tabsRestUrl : '';
477
  } else {
478
  alm.addons.tabs = false;
479
  }
@@ -615,7 +625,7 @@ var alm_is_filtering = false;
615
  alm.max_pages = alm.max_pages === undefined || alm.max_pages === 0 ? 10000 : alm.max_pages;
616
 
617
  /* Scroll Distance */
618
- alm.scroll_distance = alm.scroll_distance === undefined ? 150 : alm.scroll_distance;
619
 
620
  /* Scroll Container */
621
  alm.scroll_container = alm.scroll_container === undefined ? '' : alm.scroll_container;
@@ -630,6 +640,11 @@ var alm_is_filtering = false;
630
  alm.is_masonry_preloaded = false;
631
  if (alm.transition === 'masonry') {
632
  alm.masonry_init = true;
 
 
 
 
 
633
  alm.masonry_selector = alm.listing.dataset.masonrySelector;
634
  alm.masonry_columnwidth = alm.listing.dataset.masonryColumnwidth;
635
  alm.masonry_animation = alm.listing.dataset.masonryAnimation;
@@ -839,14 +854,15 @@ var alm_is_filtering = false;
839
  // REST API
840
  if (alm.extensions.restapi) {
841
  alm.AjaxLoadMore.restapi(alm, action, queryType);
842
- } else if (alm.addons.tabs) {
843
- alm.AjaxLoadMore.tabs(alm);
844
  }
845
-
846
- // Standard ALM
847
- else {
848
- alm.AjaxLoadMore.adminajax(alm, action, queryType);
849
  }
 
 
 
 
850
  };
851
 
852
  /**
@@ -1391,27 +1407,14 @@ var alm_is_filtering = false;
1391
  }
1392
  }
1393
 
1394
- // *****
1395
  // TABS - Trigger almTabsSetHeight callback in Tabs add-on
1396
- // *****
1397
- if (typeof almTabsSetHeight === 'function') {
1398
- if (alm.images_loaded === 'true') {
1399
- imagesLoaded(reveal, function () {
1400
- setTimeout(function () {
1401
- (0, _fadeIn2.default)(alm.listing, alm.speed);
1402
- setTimeout(function () {
1403
- window.almTabsSetHeight(alm);
1404
- }, alm.speed);
1405
- }, alm.speed + 1);
1406
- });
1407
- } else {
1408
  setTimeout(function () {
1409
- (0, _fadeIn2.default)(alm.listing, alm.speed);
1410
- setTimeout(function () {
1411
- window.almTabsSetHeight(alm);
1412
- }, alm.speed);
1413
- }, alm.speed + 1);
1414
- }
1415
  }
1416
  } else {
1417
 
@@ -1450,8 +1453,7 @@ var alm_is_filtering = false;
1450
  }
1451
  } else {
1452
 
1453
- // almMasonry(alm, alm.init, alm_is_filtering);
1454
-
1455
  setTimeout(function () {
1456
  alm.main.classList.remove('alm-loading');
1457
  alm.AjaxLoadMore.triggerAddons(alm);
@@ -1462,9 +1464,11 @@ var alm_is_filtering = false;
1462
 
1463
  // almFiltersOnload [Filters Add-on hook]
1464
  if (typeof almFiltersOnload === 'function' && alm.init) {
1465
- setTimeout(function () {
 
1466
  window.almFiltersOnload(alm);
1467
- }, parseInt(alm.speed) + 25);
 
1468
  }
1469
 
1470
  // ALM Complete / Nested
@@ -1529,27 +1533,10 @@ var alm_is_filtering = false;
1529
  }
1530
 
1531
  // Set Focus for A11y
1532
- if (alm.transition_container && total > 0) {
1533
- if (alm.addons.paging) {
1534
- // Paging
1535
- (0, _setFocus2.default)(alm.init, alm.addons.preloaded, alm.listing, alm_is_filtering);
1536
- } else if (alm.addons.single_post || alm.addons.nextpage) {
1537
- // Single Posts OR Next Page, set `init` to false to trigger focus
1538
- (0, _setFocus2.default)(false, alm.addons.preloaded, reveal, alm_is_filtering);
1539
- } else {
1540
- // Standard ALM
1541
- (0, _setFocus2.default)(alm.init, alm.addons.preloaded, reveal, alm_is_filtering);
1542
- }
1543
- } else if (!alm.transition_container && alm.container_type === 'table') {
1544
-
1545
- // Table Layout
1546
- (0, _setFocus2.default)(alm.init, alm.addons.preloaded, reveal[0], alm_is_filtering);
1547
- }
1548
 
1549
  // Comment Reply Fix
1550
- if (alm.addons.comments === 'true') {
1551
- (0, _commentReplyFix2.default)(alm.listing);
1552
- }
1553
 
1554
  // Remove filtering class
1555
  if (alm.main.classList.contains('alm-is-filtering')) {
@@ -1785,6 +1772,7 @@ var alm_is_filtering = false;
1785
  // Delay done until animations complete
1786
  setTimeout(function () {
1787
  window.almDone(alm);
 
1788
  }, alm.speed + 10);
1789
  }
1790
  };
@@ -2466,8 +2454,7 @@ var getOffset = function getOffset() {
2466
  exports.getOffset = getOffset;
2467
 
2468
  /**
2469
- * almScroll
2470
- * Scroll window to position (global function)
2471
  *
2472
  * @since 5.0
2473
  * @param {*} position
@@ -2645,31 +2632,40 @@ var almGetCacheUrl = function almGetCacheUrl(alm) {
2645
  var cache_url = '';
2646
  var ext = '.html';
2647
 
 
2648
  if (alm.init && alm.addons.seo && alm.isPaged) {
2649
- // SEO Add-on
2650
  // If the request is a paged URL (/page/3/)
2651
  var firstpage = '1';
2652
  cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + firstpage + '-' + alm.start_page + ext;
2653
- } else if (alm.addons.nextpage) {
2654
- // Nextpage add-on
2655
- var nextpage_cache_url = void 0;
2656
- if (alm.addons.paging) {
2657
- nextpage_cache_url = parseInt(alm.page) + 1;
2658
- } else {
2659
- nextpage_cache_url = parseInt(alm.page) + 2;
2660
- if (alm.isPaged) {
2661
- // If the request a paged URL (/page/3/)
2662
- nextpage_cache_url = parseInt(alm.page) + parseInt(alm.addons.nextpage_startpage) + 1;
 
 
 
 
2663
  }
 
2664
  }
2665
- cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + nextpage_cache_url + ext;
2666
- } else if (alm.addons.single_post) {
2667
- // Previous Post
2668
- cache_url = alm.addons.cache_path + alm.addons.cache_id + '/' + alm.addons.single_post_id + ext;
2669
- } else {
2670
- // Standard URL request
2671
- cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + (alm.page + 1) + ext;
2672
- }
 
 
 
 
2673
 
2674
  return cache_url;
2675
  };
@@ -2730,32 +2726,34 @@ Object.defineProperty(exports, "__esModule", {
2730
  * commentReplyFix
2731
  * Hotfix for Reply links not working in WordPress 5.1+
2732
  *
 
2733
  * @param listing object
2734
  * @since 5.1
2735
  */
2736
  var commentReplyFix = function commentReplyFix() {
2737
- var listing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
 
 
 
 
 
 
2738
 
2739
  // Get all `Reply` links.
2740
  var replyLinks = listing.querySelectorAll('.comment-reply-link');
2741
  if (!replyLinks) {
2742
  return false;
2743
  }
2744
-
2745
  // Loop links
2746
  replyLinks.forEach(function (link) {
2747
-
2748
  // Add custom click handler
2749
  link.onclick = function (e) {
2750
-
2751
  e.preventDefault();
2752
-
2753
  var commId = link.dataset.belowelement,
2754
  parentId = link.dataset.commentid,
2755
  respondId = link.dataset.respondelement,
2756
  postId = link.dataset.postid,
2757
  follow = void 0;
2758
-
2759
  if (!commId || !parentId || !respondId || !postId) {
2760
  /*
2761
  * Theme or plugin defines own link via custom `wp_list_comments()` callback
@@ -4036,8 +4034,6 @@ var imagesLoaded = __webpack_require__(/*! imagesloaded */ "./node_modules/image
4036
  * @since 3.1
4037
  * @updated 5.0.2
4038
  */
4039
-
4040
- var msnry = '';
4041
  var almMasonry = function almMasonry(alm, init, filtering) {
4042
 
4043
  var container = alm.listing;
@@ -4121,7 +4117,7 @@ var almMasonry = function almMasonry(alm, init, filtering) {
4121
 
4122
  // Init Masonry, delay to allow time for items to be added to the page
4123
  setTimeout(function () {
4124
- msnry = new Masonry(container, defaults);
4125
  // Fade In
4126
  (0, _fadeIn2.default)(container.parentNode, speed);
4127
  }, 100);
@@ -4144,14 +4140,13 @@ var almMasonry = function almMasonry(alm, init, filtering) {
4144
 
4145
  // Confirm imagesLoaded & append
4146
  imagesLoaded(container, function () {
4147
- msnry.appended(data);
4148
  });
4149
  }
4150
  }
4151
  } else {
4152
 
4153
- // Reset
4154
- msnry.destroy(); // destroy masonry
4155
  container.parentNode.style.opacity = 0;
4156
  almMasonry(alm, true, false);
4157
  }
@@ -4407,19 +4402,58 @@ Object.defineProperty(exports, "__esModule", {
4407
  * setFocus
4408
  * Set user focus to improve accessibility after load events
4409
  *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4410
  * @param {Boolean} init
4411
  * @param {String} preloaded
4412
  * @param {HTMLElement} element
4413
- * @param {Boolean} alm_is_filtering
 
4414
  * @since 5.1
4415
  */
4416
- var setFocus = function setFocus() {
 
4417
  var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4418
  var preloaded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'false';
4419
  var element = arguments[2];
4420
- var alm_is_filtering = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
 
4421
 
4422
- if (!alm_is_filtering) {
4423
  if ((init || !element) && preloaded !== 'true') {
4424
  return false; // Exit if first run
4425
  }
@@ -4459,11 +4493,15 @@ var setFocus = function setFocus() {
4459
  else {
4460
  var x = window.scrollX;
4461
  var y = window.scrollY;
 
 
 
 
 
4462
  element.focus();
4463
  window.scrollTo(x, y);
4464
  }
4465
  };
4466
- exports.default = setFocus;
4467
 
4468
  /***/ }),
4469
 
274
  alm.loading = true;
275
  alm.finished = false;
276
  alm.timer = null;
277
+
278
+ alm.ua = window.navigator.userAgent ? window.navigator.userAgent : ''; // Browser User Agent
279
+ alm.vendor = window.navigator.vendor ? window.navigator.vendor : ''; // Browser Vendor
280
+ alm.isSafari = /Safari/i.test(alm.ua) && /Apple Computer/.test(alm.vendor) && !/Mobi|Android/i.test(alm.ua);
281
+
282
  alm.main = el;
283
  alm.master_id = el.dataset.id ? 'ajax-load-more-' + el.dataset.id : el.id; // The defined or generated ID of the ALM instance
284
  el.classList.add('alm-' + e); // Add unique classname
468
  if (alm.addons.tabs === 'true') {
469
  alm.addons.tabs = true;
470
  alm.addons.tab_template = alm.listing.dataset.tabTemplate ? alm.listing.dataset.tabTemplate : '';
471
+ alm.addons.tab_onload = alm.listing.dataset.tabOnload ? alm.listing.dataset.tabOnload : '';
472
+ alm.addons.tabs_resturl = alm.listing.dataset.tabsRestUrl ? alm.listing.dataset.tabsRestUrl : '';
473
 
474
+ // Locate active template (deeplinks)
475
+ if (alm.addons.tab_onload !== '') {
476
+ var tabNav = document.querySelector('.alm-tab-nav li [data-tab-url=' + alm.addons.tab_onload + ']');
477
+ alm.addons.tab_template = tabNav ? tabNav.dataset.tabTemplate : alm.addons.tab_template;
478
+ alm.listing.dataset.tabOnload = '';
479
+ // Set selected tab
480
+ if (tabNav) {
481
+ var activeTab = document.querySelector('.alm-tab-nav li .active');
482
+ if (activeTab) {
483
+ activeTab.classList.remove('active');
484
+ }
485
+ }
486
  }
 
 
487
  } else {
488
  alm.addons.tabs = false;
489
  }
625
  alm.max_pages = alm.max_pages === undefined || alm.max_pages === 0 ? 10000 : alm.max_pages;
626
 
627
  /* Scroll Distance */
628
+ alm.scroll_distance = alm.scroll_distance === undefined ? 100 : alm.scroll_distance;
629
 
630
  /* Scroll Container */
631
  alm.scroll_container = alm.scroll_container === undefined ? '' : alm.scroll_container;
640
  alm.is_masonry_preloaded = false;
641
  if (alm.transition === 'masonry') {
642
  alm.masonry_init = true;
643
+ if (alm.msnry) {
644
+ alm.msnry.destroy(); // destroy masonry if currently exists
645
+ } else {
646
+ alm.msnry = '';
647
+ }
648
  alm.masonry_selector = alm.listing.dataset.masonrySelector;
649
  alm.masonry_columnwidth = alm.listing.dataset.masonryColumnwidth;
650
  alm.masonry_animation = alm.listing.dataset.masonryAnimation;
854
  // REST API
855
  if (alm.extensions.restapi) {
856
  alm.AjaxLoadMore.restapi(alm, action, queryType);
 
 
857
  }
858
+ // Tabs
859
+ else if (alm.addons.tabs) {
860
+ alm.AjaxLoadMore.tabs(alm);
 
861
  }
862
+ // Standard ALM
863
+ else {
864
+ alm.AjaxLoadMore.adminajax(alm, action, queryType);
865
+ }
866
  };
867
 
868
  /**
1407
  }
1408
  }
1409
 
 
1410
  // TABS - Trigger almTabsSetHeight callback in Tabs add-on
1411
+ if (alm.addons.tabs && typeof almTabsSetHeight === 'function') {
1412
+ imagesLoaded(reveal, function () {
1413
+ (0, _fadeIn2.default)(alm.listing, alm.speed);
 
 
 
 
 
 
 
 
 
1414
  setTimeout(function () {
1415
+ window.almTabsSetHeight(alm);
1416
+ }, alm.speed);
1417
+ });
 
 
 
1418
  }
1419
  } else {
1420
 
1453
  }
1454
  } else {
1455
 
1456
+ // almMasonry(alm, alm.init, alm_is_filtering);
 
1457
  setTimeout(function () {
1458
  alm.main.classList.remove('alm-loading');
1459
  alm.AjaxLoadMore.triggerAddons(alm);
1464
 
1465
  // almFiltersOnload [Filters Add-on hook]
1466
  if (typeof almFiltersOnload === 'function' && alm.init) {
1467
+ imagesLoaded(reveal, function () {
1468
+ //setTimeout(function(){
1469
  window.almFiltersOnload(alm);
1470
+ //}, parseInt(alm.speed) + 25);
1471
+ });
1472
  }
1473
 
1474
  // ALM Complete / Nested
1533
  }
1534
 
1535
  // Set Focus for A11y
1536
+ (0, _setFocus2.default)(alm, reveal, total, alm_is_filtering);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1537
 
1538
  // Comment Reply Fix
1539
+ (0, _commentReplyFix2.default)(alm.addons.comments, alm.listing);
 
 
1540
 
1541
  // Remove filtering class
1542
  if (alm.main.classList.contains('alm-is-filtering')) {
1772
  // Delay done until animations complete
1773
  setTimeout(function () {
1774
  window.almDone(alm);
1775
+ (0, _placeholder.hidePlaceholder)(alm);
1776
  }, alm.speed + 10);
1777
  }
1778
  };
2454
  exports.getOffset = getOffset;
2455
 
2456
  /**
2457
+ * render
 
2458
  *
2459
  * @since 5.0
2460
  * @param {*} position
2632
  var cache_url = '';
2633
  var ext = '.html';
2634
 
2635
+ // SEO Add-on
2636
  if (alm.init && alm.addons.seo && alm.isPaged) {
 
2637
  // If the request is a paged URL (/page/3/)
2638
  var firstpage = '1';
2639
  cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + firstpage + '-' + alm.start_page + ext;
2640
+ }
2641
+
2642
+ // Nextpage add-on
2643
+ else if (alm.addons.nextpage) {
2644
+
2645
+ var nextpage_cache_url = void 0;
2646
+ if (alm.addons.paging) {
2647
+ nextpage_cache_url = parseInt(alm.page) + 1;
2648
+ } else {
2649
+ nextpage_cache_url = parseInt(alm.page) + 2;
2650
+ if (alm.isPaged) {
2651
+ // If the request a paged URL (/page/3/)
2652
+ nextpage_cache_url = parseInt(alm.page) + parseInt(alm.addons.nextpage_startpage) + 1;
2653
+ }
2654
  }
2655
+ cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + nextpage_cache_url + ext;
2656
  }
2657
+ // Single Post
2658
+ else if (alm.addons.single_post) {
2659
+ cache_url = alm.addons.cache_path + alm.addons.cache_id + '/' + alm.addons.single_post_id + ext;
2660
+ }
2661
+
2662
+ // Filters
2663
+ else if (alm.addons.filters) {
2664
+ console.log(alm);
2665
+ } else {
2666
+ // Standard URL request
2667
+ cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + (alm.page + 1) + ext;
2668
+ }
2669
 
2670
  return cache_url;
2671
  };
2726
  * commentReplyFix
2727
  * Hotfix for Reply links not working in WordPress 5.1+
2728
  *
2729
+ * @param comments string
2730
  * @param listing object
2731
  * @since 5.1
2732
  */
2733
  var commentReplyFix = function commentReplyFix() {
2734
+ var comments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2735
+ var listing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2736
+
2737
+ if (comments !== 'true') {
2738
+ // Exit if not comments
2739
+ return false;
2740
+ }
2741
 
2742
  // Get all `Reply` links.
2743
  var replyLinks = listing.querySelectorAll('.comment-reply-link');
2744
  if (!replyLinks) {
2745
  return false;
2746
  }
 
2747
  // Loop links
2748
  replyLinks.forEach(function (link) {
 
2749
  // Add custom click handler
2750
  link.onclick = function (e) {
 
2751
  e.preventDefault();
 
2752
  var commId = link.dataset.belowelement,
2753
  parentId = link.dataset.commentid,
2754
  respondId = link.dataset.respondelement,
2755
  postId = link.dataset.postid,
2756
  follow = void 0;
 
2757
  if (!commId || !parentId || !respondId || !postId) {
2758
  /*
2759
  * Theme or plugin defines own link via custom `wp_list_comments()` callback
4034
  * @since 3.1
4035
  * @updated 5.0.2
4036
  */
 
 
4037
  var almMasonry = function almMasonry(alm, init, filtering) {
4038
 
4039
  var container = alm.listing;
4117
 
4118
  // Init Masonry, delay to allow time for items to be added to the page
4119
  setTimeout(function () {
4120
+ alm.msnry = new Masonry(container, defaults);
4121
  // Fade In
4122
  (0, _fadeIn2.default)(container.parentNode, speed);
4123
  }, 100);
4140
 
4141
  // Confirm imagesLoaded & append
4142
  imagesLoaded(container, function () {
4143
+ alm.msnry.appended(data);
4144
  });
4145
  }
4146
  }
4147
  } else {
4148
 
4149
+ // Reset
 
4150
  container.parentNode.style.opacity = 0;
4151
  almMasonry(alm, true, false);
4152
  }
4402
  * setFocus
4403
  * Set user focus to improve accessibility after load events
4404
  *
4405
+ * @param {Object} alm
4406
+ * @param {HTMLElement} preloaded
4407
+ * @param {Number} total
4408
+ * @param {Boolean} is_filtering
4409
+ * @since 5.1
4410
+ */
4411
+
4412
+ var setFocus = function setFocus(alm) {
4413
+ var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
4414
+ var total = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
4415
+ var is_filtering = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
4416
+
4417
+ // If has total
4418
+ if (alm.transition_container && total > 0) {
4419
+ if (alm.addons.paging) {
4420
+ // Paging
4421
+ moveFocus(alm.init, alm.addons.preloaded, alm.listing, is_filtering, alm.isSafari);
4422
+ } else if (alm.addons.single_post || alm.addons.nextpage) {
4423
+ // Single Posts OR Next Page, set `init` to false to trigger focus
4424
+ moveFocus(false, alm.addons.preloaded, element, is_filtering, alm.isSafari);
4425
+ } else {
4426
+ // Standard ALM
4427
+ moveFocus(alm.init, alm.addons.preloaded, element, is_filtering, alm.isSafari);
4428
+ }
4429
+ } else if (!alm.transition_container && alm.container_type === 'table') {
4430
+
4431
+ // Table Layout
4432
+ moveFocus(alm.init, alm.addons.preloaded, element[0], is_filtering, alm.isSafari);
4433
+ }
4434
+ };
4435
+ exports.default = setFocus;
4436
+
4437
+ /**
4438
+ * moveFocus
4439
+ * Move user focus to alm-reveal div
4440
+ *
4441
  * @param {Boolean} init
4442
  * @param {String} preloaded
4443
  * @param {HTMLElement} element
4444
+ * @param {Boolean} is_filtering
4445
+ * @param {Boolean} isSafari
4446
  * @since 5.1
4447
  */
4448
+
4449
+ var moveFocus = function moveFocus() {
4450
  var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4451
  var preloaded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'false';
4452
  var element = arguments[2];
4453
+ var is_filtering = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
4454
+ var isSafari = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
4455
 
4456
+ if (!is_filtering) {
4457
  if ((init || !element) && preloaded !== 'true') {
4458
  return false; // Exit if first run
4459
  }
4493
  else {
4494
  var x = window.scrollX;
4495
  var y = window.scrollY;
4496
+ // Safari fix for window movement if Y = 0
4497
+ if (isSafari) {
4498
+ window.scrollTo(x, y);
4499
+ y = y === 0 ? 1 : y;
4500
+ }
4501
  element.focus();
4502
  window.scrollTo(x, y);
4503
  }
4504
  };
 
4505
 
4506
  /***/ }),
4507
 
core/dist/js/ajax-load-more.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://ajaxloadmore/webpack/bootstrap","webpack://ajaxloadmore/./core/src/js/ajax-load-more.js","webpack://ajaxloadmore/./core/src/js/helpers/almAppendChild.js","webpack://ajaxloadmore/./core/src/js/helpers/almAppendChildren.js","webpack://ajaxloadmore/./core/src/js/helpers/almDomParser.js","webpack://ajaxloadmore/./core/src/js/helpers/almGetCacheUrl.js","webpack://ajaxloadmore/./core/src/js/helpers/almTableWrap.js","webpack://ajaxloadmore/./core/src/js/helpers/commentReplyFix.js","webpack://ajaxloadmore/./core/src/js/helpers/getParameterByName.js","webpack://ajaxloadmore/./core/src/js/helpers/helpers.js","webpack://ajaxloadmore/./core/src/js/helpers/polyfills.js","webpack://ajaxloadmore/./core/src/js/helpers/queryParams.js","webpack://ajaxloadmore/./core/src/js/helpers/srcsetPolyfill.js","webpack://ajaxloadmore/./core/src/js/helpers/stripEmptyNodes.js","webpack://ajaxloadmore/./core/src/js/modules/almDebug.js","webpack://ajaxloadmore/./core/src/js/modules/fadeIn.js","webpack://ajaxloadmore/./core/src/js/modules/fadeOut.js","webpack://ajaxloadmore/./core/src/js/modules/filtering.js","webpack://ajaxloadmore/./core/src/js/modules/insertScript.js","webpack://ajaxloadmore/./core/src/js/modules/masonry.js","webpack://ajaxloadmore/./core/src/js/modules/noResults.js","webpack://ajaxloadmore/./core/src/js/modules/placeholder.js","webpack://ajaxloadmore/./core/src/js/modules/resultsText.js","webpack://ajaxloadmore/./core/src/js/modules/setFocus.js","webpack://ajaxloadmore/./core/src/js/modules/setLocalizedVars.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/lib/noConflict.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/noConflict.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/es6/index.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/array/includes.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/object/entries.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/object/get-own-property-descriptors.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/object/values.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/promise/finally.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/string/pad-end.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/string/pad-start.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/fn/symbol/async-iterator.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_a-function.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_a-number-value.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_add-to-unscopables.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_advance-string-index.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_an-instance.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_an-object.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-copy-within.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-fill.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-includes.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-methods.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-reduce.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-species-constructor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_array-species-create.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_bind.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_classof.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_cof.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_collection-strong.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_collection-weak.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_collection.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_core.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_create-property.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_ctx.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_date-to-iso-string.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_date-to-primitive.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_defined.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_descriptors.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_dom-create.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_enum-bug-keys.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_enum-keys.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_export.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_fails-is-regexp.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_fails.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_fix-re-wks.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_flags.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_for-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_function-to-string.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_global.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_has.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_hide.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_html.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_ie8-dom-define.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_inherit-if-required.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_invoke.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iobject.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_is-array-iter.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_is-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_is-integer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_is-object.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_is-regexp.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iter-call.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iter-create.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iter-define.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iter-detect.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iter-step.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_iterators.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_library.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_math-expm1.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_math-fround.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_math-log1p.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_math-sign.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_meta.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_microtask.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_new-promise-capability.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-assign.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-create.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-dp.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-dps.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-gopd.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-gopn-ext.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-gopn.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-gops.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-gpo.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-keys-internal.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-keys.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-pie.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-sap.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_object-to-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_own-keys.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_parse-float.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_parse-int.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_perform.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_promise-resolve.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_property-desc.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_redefine-all.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_redefine.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_regexp-exec-abstract.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_regexp-exec.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_same-value.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_set-proto.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_set-species.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_set-to-string-tag.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_shared-key.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_shared.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_species-constructor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_strict-method.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-at.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-context.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-html.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-pad.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-repeat.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-trim.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_string-ws.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_task.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-absolute-index.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-index.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-integer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-iobject.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-length.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-object.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_to-primitive.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_typed-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_typed-buffer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_typed.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_uid.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_user-agent.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_validate-collection.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_wks-define.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_wks-ext.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/_wks.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/core.get-iterator-method.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.copy-within.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.every.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.fill.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.filter.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.find-index.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.find.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.for-each.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.from.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.index-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.is-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.iterator.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.join.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.last-index-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.map.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.reduce-right.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.reduce.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.slice.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.some.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.sort.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.array.species.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.date.now.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.date.to-iso-string.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.date.to-json.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.date.to-primitive.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.date.to-string.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.function.bind.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.function.has-instance.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.function.name.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.map.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.acosh.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.asinh.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.atanh.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.cbrt.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.clz32.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.cosh.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.expm1.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.fround.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.hypot.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.imul.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.log10.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.log1p.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.log2.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.sign.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.sinh.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.tanh.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.math.trunc.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.constructor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.epsilon.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.is-finite.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.is-integer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.is-nan.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.is-safe-integer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.max-safe-integer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.min-safe-integer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.parse-float.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.parse-int.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.to-fixed.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.number.to-precision.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.assign.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.create.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.define-properties.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.define-property.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.freeze.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.get-own-property-descriptor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.get-own-property-names.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.get-prototype-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.is-extensible.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.is-frozen.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.is-sealed.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.is.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.keys.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.prevent-extensions.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.seal.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.set-prototype-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.object.to-string.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.parse-float.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.parse-int.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.promise.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.apply.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.construct.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.define-property.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.delete-property.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.enumerate.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.get-own-property-descriptor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.get-prototype-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.get.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.has.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.is-extensible.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.own-keys.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.prevent-extensions.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.set-prototype-of.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.reflect.set.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.constructor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.exec.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.flags.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.match.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.replace.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.search.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.split.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.regexp.to-string.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.set.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.anchor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.big.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.blink.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.bold.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.code-point-at.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.ends-with.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.fixed.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.fontcolor.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.fontsize.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.from-code-point.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.includes.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.italics.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.iterator.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.link.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.raw.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.repeat.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.small.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.starts-with.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.strike.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.sub.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.sup.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.string.trim.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.symbol.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.array-buffer.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.data-view.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.float32-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.float64-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.int16-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.int32-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.int8-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.uint16-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.uint32-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.uint8-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.typed.uint8-clamped-array.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.weak-map.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es6.weak-set.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.array.includes.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.object.entries.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.object.get-own-property-descriptors.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.object.values.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.promise.finally.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.string.pad-end.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.string.pad-start.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/es7.symbol.async-iterator.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/web.dom.iterable.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/web.immediate.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/modules/web.timers.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/core-js/web/index.js","webpack://ajaxloadmore/./node_modules/@babel/polyfill/node_modules/regenerator-runtime/runtime.js","webpack://ajaxloadmore/./node_modules/axios/index.js","webpack://ajaxloadmore/./node_modules/axios/lib/adapters/xhr.js","webpack://ajaxloadmore/./node_modules/axios/lib/axios.js","webpack://ajaxloadmore/./node_modules/axios/lib/cancel/Cancel.js","webpack://ajaxloadmore/./node_modules/axios/lib/cancel/CancelToken.js","webpack://ajaxloadmore/./node_modules/axios/lib/cancel/isCancel.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/Axios.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/InterceptorManager.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/createError.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/dispatchRequest.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/enhanceError.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/settle.js","webpack://ajaxloadmore/./node_modules/axios/lib/core/transformData.js","webpack://ajaxloadmore/./node_modules/axios/lib/defaults.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/bind.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/btoa.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/buildURL.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/combineURLs.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/cookies.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/isAbsoluteURL.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/isURLSameOrigin.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/normalizeHeaderName.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/parseHeaders.js","webpack://ajaxloadmore/./node_modules/axios/lib/helpers/spread.js","webpack://ajaxloadmore/./node_modules/axios/lib/utils.js","webpack://ajaxloadmore/./node_modules/ev-emitter/ev-emitter.js","webpack://ajaxloadmore/./node_modules/imagesloaded/imagesloaded.js","webpack://ajaxloadmore/./node_modules/is-buffer/index.js","webpack://ajaxloadmore/./node_modules/process/browser.js","webpack://ajaxloadmore/./node_modules/qs/lib/formats.js","webpack://ajaxloadmore/./node_modules/qs/lib/index.js","webpack://ajaxloadmore/./node_modules/qs/lib/parse.js","webpack://ajaxloadmore/./node_modules/qs/lib/stringify.js","webpack://ajaxloadmore/./node_modules/qs/lib/utils.js","webpack://ajaxloadmore/./node_modules/smoothscroll-polyfill/dist/smoothscroll.js"],"names":["queryParams","resultsText","require","qs","imagesLoaded","smoothscroll","alm_is_filtering","ajaxloadmore","alm_localize","window","alm","el","alm_no_results","Array","parseInt","page","setTimeout","almChildren","almChildArray","btnWrap","element","container","document","cache_page","axios","response","action","acf_parent_field_name","nextpage_startpage","single_post_slug","comments_callback","usersOrderby","cta_theme_repeater","config","arrayFormat","encode","ajaxURL","params","data","queryType","alm_rest_url","post_id","template","tab_template","results","html","obj","alm_rest_template","wp","meta","postcount","totalposts","i","result","console","isPaged","reveal","pagingContent","total","pagenum","querystring","seo_class","filters_class","preloaded_class","return_data","container_array","posts_per_page","pages","Math","k","p","alm_reveal","p2","insertScript","currentPage","classes","content","loader","styles","pTop","pBtm","h","nested","id","initial_id","order","taxonomy","excluded_terms","post_type","init","location","error","button","e","resize","clearTimeout","trigger","btnPos","scrollTrigger","scrollInstance","scrollHeight","scrollPosition","direction","code","name","value","query","vars","pair","decodeURIComponent","alm_nextpage_pages","alm_nextpage_total","target","alm_instances","filter","transition","speed","tab","url","tracking","gtag","path","ga","__gaTracker","start","almScroll","top","behavior","getOffset","rect","scrollLeft","scrollTop","left","render","options","nodeNameArray","almAppendChild","almAppendChildren","array","almDomParser","type","parser","almGetCacheUrl","cache_url","ext","firstpage","nextpage_cache_url","almTableWrap","table_reveal","table_reveal_array","commentReplyFix","listing","replyLinks","link","commId","parentId","respondId","postId","follow","event","getParameterByName","regex","Object","ownProps","resArray","toStr","isCallable","toInteger","number","Number","isNaN","isFinite","maxSafeInteger","toLength","len","C","items","arrayLike","mapFn","arguments","T","A","kValue","NodeList","thisArg","callback","arr","item","configurable","enumerable","writable","Element","CharacterData","DocumentType","Function","aArgs","fToBind","FNOP","fBound","ObjectProto","defineGetter","defineSetter","lookupGetter","lookupSetter","hasOwnProp","prop","descriptor","getter","setter","props","propDescriptor","get","that","attributes","attsLength","toUpperCase","n0","HTML5_DOMStringMap","attribute","attrVal","attrName","propName","set","almGetAjaxParams","almGetRestParams","slug","canonical_url","encodeURIComponent","offset","repeater","seo_start_page","start_page","post_format","category","category__not_in","tag","tag__not_in","taxonomy_terms","taxonomy_operator","taxonomy_relation","meta_key","meta_value","meta_compare","meta_relation","meta_type","author","year","month","day","post_status","orderby","post__in","post__not_in","search","s","custom_args","lang","preloaded","preloaded_amount","srcsetPolyfill","ua","imgs","img","stripEmptyNodes","nodes","node","almDebug","almFadeIn","op","timer","clearInterval","almFadeOut","fadeEffect","almFilter","almFilterTransition","new_el","almCompleteFilterTransition","paging","almSetFilters","key","almFilterComplete","almFiltersAddonComplete","almTabsComplete","children","replace","isScript","clone","script","msnry","almMasonry","selector","columnWidth","animation","horizontalOrder","masonry_init","duration","hidden","visible","defaults","itemSelector","transitionDuration","hiddenStyle","transform","opacity","visibleStyle","alm_masonry_vars","almNoResults","showPlaceholder","hidePlaceholder","almResultsText","almGetResultsText","almInitResultsText","resultsType","current","almRenderResultsText","text","setFocus","parent","scrollContainer","x","y","setLocalizedVars"],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;;;;;;ACjEA;;;;A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;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,yCAAyC;AACzC,qBAAqB;AACrB,0BAA0B;AAC1B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;;;;;;;;;;;;AC/Ia;AACb,kBAAkB,mBAAO,CAAC,qGAAiB;AAC3C,cAAc,mBAAO,CAAC,qFAAS;AAC/B,eAAe,mBAAO,CAAC,+FAAc;AACrC,eAAe,mBAAO,CAAC,+FAAc;AACrC,iBAAiB,mBAAO,CAAC,mGAAgB;AACzC,YAAY,mBAAO,CAAC,yFAAW;AAC/B,wBAAwB,mBAAO,CAAC,uGAAkB;AAClD,WAAW,mBAAO,CAAC,mFAAQ;AAC3B,eAAe,mBAAO,CAAC,mHAAwB;AAC/C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,qBAAqB;AACrB,0BAA0B;AAC1B;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;;;;;;;;;;;;ACpFa;AACb,aAAa,mBAAO,CAAC,yFAAW;AAChC,cAAc,mBAAO,CAAC,yFAAW;AACjC,eAAe,mBAAO,C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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,uCAAuC,sBAAsB,EAAE;AAC/D;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;;;;;;;;;;;;ACpEa;AACb;AACA,gBAAgB,mBAAO,CAAC,iGAAe;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;;ACjBa;AACb;AACA,cAAc,mBAAO,CAAC,mGAAgB;AACtC,WAAW,mBAAO,CAAC,mGAAgB;AACnC,UAAU,mBAAO,CAAC,iGAAe;AACjC,eAAe,mBAAO,CAAC,+FAAc;AACrC,cAAc,mBAAO,CAAC,2FAAY;AAClC;;AAEA;AACA,6BAA6B,mBAAO,CAAC,uFAAU;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,UAAU,EAAE;AAChD,mBAAmB,sCAAsC;AACzD,CAAC,qCAAqC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;;;;;;;;;;;ACjCD;AACA,eAAe,mBAAO,CAAC,+FAAc;AACrC,UAAU,mBAAO,CAAC,iGAAe;AACjC,kBAAkB,mBAAO,CAAC,uGAAkB;AAC5C,eAAe,mBAAO,CAAC,iGAAe;AACtC,yBAAyB;AACzB;;AAEA;AACA;AACA;AACA,eAAe,mBAAO,CAAC,iGAAe;AACtC;AACA;AACA;AACA;AACA;AACA,EAAE,mBAAO,CAAC,qFAAS;AACnB,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AAC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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,mBAAO,CAAC,mFAAQ;AACtB;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACnFA,gBAAgB,mBAAO,CAAC,iGAAe;AACvC;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACNA;AACA,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,eAAe,mBAAO,CAAC,+FAAc;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACLA;AACA,cAAc,mBAAO,CAAC,2FAAY;AAClC,cAAc,mBAAO,CAAC,2FAAY;AAClC;AACA;AACA;;;;;;;;;;;;ACLA;AACA,gBAAgB,mBAAO,CAAC,iGAAe;AACvC;AACA;AACA,2DAA2D;AAC3D;;;;;;;;;;;;ACLA;AACA,cAAc,mBAAO,CAAC,2FAAY;AAClC;AACA;AACA;;;;;;;;;;;;ACJA;AACA,eAAe,mBAAO,CAAC,+FAAc;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACXa;AACb,IAAI,mBAAO,CAAC,mGAAgB;AAC5B,gBAAgB,mBAAO,CAAC,2FAAY;AACpC,eAAe,mBAAO,CAAC,yFAAW;AAClC,cAAc,mBAAO,CAAC,uFAAU;AAChC,gBAAgB,mBAAO,CAAC,yFAAW;AACnC,eAAe,mBAAO,CAAC,uFAAU;AACjC,gBAAgB,mBAAO,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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA,4BAA4B;AAC5B,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,mBAAmB,0BAA0B,EAAE,EAAE;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yDAAyD,gCAAgC;AACzF;AACA,OAAO;AACP;AACA;AACA,6EAA6E,YAAY;AACzF;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yDAAyD,6CAA6C,EAAE;;AAExG;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL,mDAAmD;AACnD;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL,oCAAoC;AACpC;AACA,KAAK;AACL,wEAAwE;AACxE;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL,8DAA8D;AAC9D;AACA,KAAK;AACL,wEAAwE;AACxE;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH,yBAAyB,sBAAsB,EAAE,EAAE;AACnD;AACA;AACA;AACA;;AAEA,4CAA4C;AAC5C;AACA;AACA;AACA;AACA;AACA,8BAA8B,aAAa;AAC3C;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,sBAAsB,0BAA0B;AAChD,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL,yBAAyB;AACzB,KAAK;AACL,uBAAuB;AACvB,2BAA2B;AAC3B,0BAA0B;AAC1B,2BAA2B;AAC3B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,aAAa;AACvC,OAAO;AACP;;AAEA;;AAEA;;AAEA;AACA;AACA,KAAK;;AAEL,uDAAuD,6BAA6B,EAAE;AACtF;AACA;AACA,KAAK;;AAEL;;AAEA;;AAEA;;AAEA,uDAAuD,YAAY;;AAEnE;;AAEA;;AAEA;AACA;AACA,KAAK,UAAU,gBAAgB;;AAE/B;AACA;AACA,KAAK;AACL;AACA,KAAK,WAAW,kCAAkC;;AAElD;AACA;AACA;AACA,CAAC,oCAAoC;;;;;;;;;;;;;AC/dxB;AACb,aAAa,mBAAO,CAAC,yFAAW;AAChC,kBAAkB,mBAAO,CAAC,mGAAgB;AAC1C,cAAc,mBAAO,CAAC,2FAAY;AAClC,aAAa,mBAAO,CAAC,uFAAU;AAC/B,WAAW,mBAAO,CAAC,qFAAS;AAC5B,kBAAkB,mBAAO,CAAC,qGAAiB;AAC3C,YAAY,mBAAO,CAAC,uFAAU;AAC9B,iBAAiB,mBAAO,CAAC,mGAAgB;AACzC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,eAAe,mBAAO,CAAC,+FAAc;AACrC,cAAc,mBAAO,CAAC,6FAAa;AACnC,WAAW,mBAAO,CAAC,mGAAgB;AACnC,SAAS,mBAAO,CAAC,+FAAc;AAC/B,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,qBAAqB,mBAAO,CAAC,+GAAsB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,QAAQ,WAAW;AACnB;AACA;AACA,QAAQ,UAAU;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,WAAW;AACnB;AACA;AACA;AACA,QAAQ,WAAW;AACnB;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yBAAyB,mBAAmB,uBAAuB,EAAE,EAAE;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,WAAW;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG;AACH,CAAC;AACD;AACA;AACA,GAAG;AACH,yBAAyB;AACzB,GAAG;AACH,uBAAuB;AACvB,0BAA0B;AAC1B,0BAA0B;AAC1B;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,iDAAiD,iBAAiB;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACnRA,aAAa,mBAAO,CAAC,yFAAW;AAChC,WAAW,mBAAO,CAAC,qFAAS;AAC5B,UAAU,mBAAO,CAAC,mFAAQ;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;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;AAEA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;ACTD;AACA,cAAc,mBAAO,CAAC,yFAAW;;AAEjC,8BAA8B,qCAAqC;;;;;;;;;;;;ACHnE;AACA,cAAc,mBAAO,CAAC,yFAAW;;AAEjC,8BAA8B,sCAAsC;;;;;;;;;;;;ACHpE,cAAc,mBAAO,CAAC,yFAAW;AACjC,kBAAkB,mBAAO,CAAC,mGAAgB;AAC1C;AACA,+EAA+E,0BAA0B;;;;;;;;;;;;ACHzG,cAAc,mBAAO,CAAC,yFAAW;AACjC,gBAAgB,mBAAO,CAAC,+FAAc;AACtC;AACA,2EAA2E,sBAAsB;;;;;;;;;;;;;ACHpF;AACb,cAAc,mBAAO,CAAC,yFAAW;AACjC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,mBAAmB,mBAAO,CAAC,yGAAmB;AAC9C,aAAa,mBAAO,CAAC,uGAAkB;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM,mBAAO,CAAC,uFAAU;AACxB;AACA,kBAAkB;AAClB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA,CAAC;;;;;;;;;;;;;ACjHY;AACb,cAAc,mBAAO,CAAC,yFAAW;AACjC,aAAa,m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AAO,CAAC,2FAAY;AAClC,aAAa,mBAAO,CAAC,yFAAW;AAChC,UAAU,mBAAO,CAAC,mFAAQ;AAC1B,cAAc,mBAAO,CAAC,2FAAY;AAClC,cAAc,mBAAO,CAAC,yFAAW;AACjC,eAAe,mBAAO,CAAC,+FAAc;AACrC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,iBAAiB,mBAAO,CAAC,mGAAgB;AACzC,YAAY,mBAAO,CAAC,yFAAW;AAC/B,yBAAyB,mBAAO,CAAC,mHAAwB;AACzD,WAAW,mBAAO,CAAC,qFAAS;AAC5B,gBAAgB,mBAAO,CAAC,+FAAc;AACtC,iCAAiC,mBAAO,CAAC,yHAA2B;AACpE,cAAc,mBAAO,CAAC,2FAAY;AAClC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,qBAAqB,mBAAO,CAAC,2GAAoB;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA,+CAA+C,EAAE,mBAAO,CAAC,mFAAQ;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,YAAY;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,WAAW;AACX,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,6CAA6C;AAC7C;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,mBAAmB,kCAAkC;AACrD,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,eAAe,uCAAuC;AACtD;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA,uBAAuB,0BAA0B;AACjD;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA;AACA,GAAG;AACH,kBAAkB,yBAAyB,KAAK;AAChD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,wBAAwB;AACxB,gBAAgB;AAChB,oBAAoB;AACpB,wBAAwB;AACxB,gBAAgB;AAChB,oBAAoB;AACpB;AACA,uBAAuB,mBAAO,CAAC,qGAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,0DAA0D,oBAAoB;AAC9E,mBAAO,CAAC,+GAAsB;AAC9B,mBAAO,CAAC,mGAAgB;AACxB,UAAU,mBAAO,CAAC,qFAAS;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,gDAAgD,mBAAO,CAAC,mGAAgB;AACxE;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA,CAAC;;;;;;;;;;;;AC7RD;AACA,cAAc,mBAAO,CAAC,yFAAW;AACjC,gBAAgB,mBAA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EA,mBAAO,CAAC,mGAAgB;;;;;;;;;;;;;AC1CX;AACb,iBAAiB,mBAAO,CAAC,mGAAgB;AACzC,mBAAO,CAAC,yFAAW;AACnB;AACA;AACA;AACA,CAAC;AACD;AACA,CAAC;;;;;;;;;;;;ACRD;AACA,IAAI,mBAAO,CAAC,mGAAgB,wBAAwB,mBAAO,CAAC,+FAAc;AAC1E;AACA,OAAO,mBAAO,CAAC,uFAAU;AACzB,CAAC;;;;;;;;;;;;;ACJY;;AAEb,eAAe,mBAAO,CAAC,+FAAc;AACrC,eAAe,mBAAO,CAAC,+FAAc;AACrC,yBAAyB,mBAAO,CAAC,qHAAyB;AAC1D,iBAAiB,mBAAO,CAAC,qHAAyB;;AAElD;AACA,mBAAO,CAAC,iGAAe;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;;ACvCY;;AAEb,eAAe,mBAAO,CAAC,+FAAc;AACrC,eAAe,mBAAO,CAAC,+FAAc;AACrC,eAAe,mBAAO,CAAC,+FAAc;AACrC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,yBAAyB,mBAAO,CAAC,qHAAyB;AAC1D,iBAAiB,mBAAO,CAAC,qHAAyB;AAClD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,mBAAO,CAAC,iGAAe;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,oBAAoB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,mBAAmB;AAC1C;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,CAAC;;;;;;;;;;;;;ACrHY;;AAEb,eAAe,mBAAO,CAAC,+FAAc;AACrC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,iBAAiB,mBAAO,CAAC,qHAAyB;;AAElD;AACA,mBAAO,CAAC,iGAAe;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;;AC9BY;;AAEb,eAAe,mBAAO,CAAC,+FAAc;AACrC,eAAe,mBAAO,CAAC,+FAAc;AACrC,yBAAyB,mBAAO,CAAC,mHAAwB;AACzD,yBAAyB,mBAAO,CAAC,qHAAyB;AAC1D,eAAe,mBAAO,CAAC,+FAAc;AACrC,qBAAqB,mBAAO,CAAC,qHAAyB;AACtD,iBAAiB,mBAAO,CAAC,mGAAgB;AACzC,YAAY,mBAAO,CAAC,uFAAU;AAC9B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qCAAqC,yBAAyB,EAAE;;AAEhE;AACA,mBAAO,CAAC,iGAAe;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mFAAmF;AACnF;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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B;AACnD,UAAU,mBAAO,CAAC,mFAAQ;AAC1B,UAAU,mBAAO,CAAC,mFAAQ;AAC1B,aAAa,mBAAO,CAAC,2FAAY;AACjC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,eAAe,mBAAO,CAAC,+FAAc;AACrC,cAAc,mBAAO,CAAC,6FAAa;AACnC,eAAe,mBAAO,CAAC,+FAAc;AACrC,eAAe,mBAAO,CAAC,+FAAc;AACrC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC,kBAAkB,mBAAO,CAAC,qGAAiB;AAC3C,iBAAiB,mBAAO,CAAC,uGAAkB;AAC3C,cAAc,mBAAO,CAAC,uGAAkB;AACxC,cAAc,mBAAO,CAAC,2GAAoB;AAC1C,YAAY,mBAAO,CAAC,mGAAgB;AACpC,UAAU,mBAAO,CAAC,+FAAc;AAChC,YAAY,mBAAO,CAAC,mGAAgB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB;AACtB,sBAAsB,uBAAuB,WAAW,IAAI;AAC5D,GAAG;AACH,CAAC;AACD;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D;AAC3D;AACA,KAAK;AACL;AACA,sBAAsB,mCAAmC;AACzD,KAAK;AACL,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE,gCAAgC;A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AAChC,cAAc,mBAAO,CAAC,yFAAW;AACjC,gBAAgB,mBAAO,CAAC,iGAAe;AACvC;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;ACnBD,mBAAO,CAAC,wGAAuB;AAC/B,mBAAO,CAAC,8GAA0B;AAClC,mBAAO,CAAC,oHAA6B;AACrC,iBAAiB,mBAAO,CAAC,8FAAkB;;;;;;;;;;;;ACH3C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,KAAK;AACL,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yDAAyD;AACzD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,WAAW;AACX;;AAEA;AACA;AACA,wCAAwC,WAAW;AACnD;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,SAAS;AACT;AACA;AACA;AACA;;AAEA;;AAEA,SAAS;AACT;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oCAAoC,cAAc;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,iCAAiC,kBAAkB;AACnD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB;;AAEjB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,YAAY;AACZ;AACA;;AAEA;AACA,YAAY;AACZ;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,8CAA8C,QAAQ;AACtD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA,WAAW;AACX;AACA;AACA;;AAEA,WAAW;AACX;AACA;AACA;;AAEA,WAAW;AACX;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,8CAA8C,QAAQ;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,KAAK;;AAEL;AACA,8CAA8C,QAAQ;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,8CAA8C,QAAQ;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;AChtBA,iBAAiB,mBAAO,CAAC,sDAAa,E;;;;;;;;;;;;ACAzB;;AAEb,YAAY,mBAAO,CAAC,qDAAY;AAChC,aAAa,mBAAO,CAAC,iEAAkB;AACvC,eAAe,mBAAO,CAAC,2EAAuB;AAC9C,mBAAmB,mBAAO,CAAC,mFAA2B;AACtD,sBAAsB,mBAAO,CAAC,yFAA8B;AAC5D,kBAAkB,mBAAO,CAAC,yEAAqB;AAC/C,yFAAyF,mBAAO,CAAC,mEAAmB;;AAEpH;AACA;AACA;AACA;;AAEA;AACA,4CAA4C;AAC5C;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAQ,KAA+B;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oBAAoB,mBAAO,CAAC,yEAAsB;;AAElD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AAC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AC,iFAAsB;AACvD,sBAAsB,mBAAO,CAAC,2EAAmB;;AAEjD;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA,kCAAkC,cAAc;AAChD;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA,KAAK;AACL;AACA,CAAC;;AAED;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA,KAAK;AACL;AACA,CAAC;;AAED;;;;;;;;;;;;;AC9Ea;;AAEb,YAAY,mBAAO,CAAC,qDAAY;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;;;;;;;;;;;;;ACnDa;;AAEb,mBAAmB,mBAAO,CAAC,qEAAgB;;AAE3C;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACjBa;;AAEb,YAAY,mBAAO,CAAC,qDAAY;AAChC,oBAAoB,mBAAO,CAAC,uEAAiB;AAC7C,eAAe,mBAAO,CAAC,uEAAoB;AAC3C,eAAe,mBAAO,CAAC,yDAAa;AACpC,oBAAoB,mBAAO,CAAC,qFAA4B;AACxD,kBAAkB,mBAAO,CAAC,iFAA0B;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,+BAA+B;AAC/B,uCAAuC;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;;;;;;;;;;;;;ACrFa;;AAEb;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACpBa;;AAEb,kBAAkB,mBAAO,CAAC,mEAAe;;AAEzC;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACzBa;;AAEb,YAAY,mBAAO,CAAC,qDAAY;;AAEhC;AACA;AACA;AACA,WAAW,cAAc;AACzB,WAAW,MAAM;AACjB,WAAW,eAAe;AAC1B,aAAa,EAAE;AACf;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;;;;;;;;;;;;ACnBA,+CAAa;;AAEb,YAAY,mBAAO,CAAC,kDAAS;AAC7B,0BAA0B,mBAAO,CAAC,8FAA+B;;AAEjE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc,mBAAO,CAAC,gEAAgB;AACtC,GAAG;AACH;AACA,cAAc,mBAAO,CAAC,iEAAiB;AACvC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wEAAwE;AACxE;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,OAAO,YAAY;AACnB;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA,CAAC;;AAED;;;;;;;;;;;;;;AC/Fa;;AAEb;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACVa;;AAEb;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACnCa;;AAEb,YAAY,mBAAO,CAAC,qDAAY;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACjEa;;AAEb;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACba;;AAEb,YAAY,mBAAO,CAAC,qDAAY;;AAEhC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,wCAAwC;AACxC,OAAO;;AAEP;AACA,0DAA0D,wBAAwB;AAClF;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,gCAAgC;AAChC,6BAA6B,aAAa,EAAE;AAC5C;AACA;AACA,GAAG;AACH;;;;;;;;;;;;;ACpDa;;AAEb;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACba;;AAEb,YAAY,mBAAO,CAAC,qDAAY;;AAEhC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc,OAAO;AACrB,gBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,cAAc,OAAO;AACrB,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;;ACnEa;;AAEb,YAAY,mBAAO,CAAC,mDAAU;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;;ACXa;;AAEb,YAAY,mBAAO,CAAC,qDAAY;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,eAAe;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,GAAG;;AAEH;AACA;;;;;;;;;;;;;ACpDa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA,WAAW,SAAS;AACpB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;AC1Ba;;AAEb,WAAW,mBAAO,CAAC,gEAAgB;AACnC,eAAe,mBAAO,CAAC,oDAAW;;AAElC;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mCAAmC,OAAO;AAC1C;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C,2BAA2B;AAC3B;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA,uCAAuC,OAAO;AAC9C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC9SA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,OAAO,IAAyC;AAChD;AACA,IAAI,oCAAQ,OAAO;AAAA;AAAA;AAAA;AAAA,oGAAE;AACrB,GAAG,MAAM,EAMN;;AAEH,CAAC;;AAED;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB,sBAAsB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA,CAAC;;;;;;;;;;;;AC/GD;AACA;AACA;AACA;AACA;;AAEA,+BAA+B;AAC/B;;AAEA;;AAEA,OAAO,IAAyC;AAChD;AACA,IAAI,iCAAQ;AACZ,MAAM,2FAAuB;AAC7B,KAAK,mCAAE;AACP;AACA,KAAK;AAAA,oGAAC;AACN,GAAG,MAAM,EAYN;;AAEH,CAAC;;AAED;;AAEA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,WAAW,iCAAiC;AAC5C,WAAW,mBAAmB;AAC9B,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,sBAAsB;AACtC;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc,qBAAqB;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,WAAW,MAAM;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,CAAC;;;;;;;;;;;;ACxXD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;ACpBA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,qCAAqC;;AAErC;AACA;AACA;;AAEA,2BAA2B;AAC3B;AACA;AACA;AACA,4BAA4B,UAAU;;;;;;;;;;;;;ACvLzB;;AAEb;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;;;;;;;;;;;;ACjBa;;AAEb,gBAAgB,mBAAO,CAAC,uDAAa;AACrC,YAAY,mBAAO,CAAC,+CAAS;AAC7B,cAAc,mBAAO,CAAC,mDAAW;;AAEjC;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACVa;;AAEb,YAAY,mBAAO,CAAC,+CAAS;;AAE7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gCAAgC;AAChC;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,wCAAwC,gCAAgC;;AAExE;AACA,uCAAuC;;AAEvC;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;;AAEA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;;AAEA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,kCAAkC,QAAQ;AAC1C;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,uBAAuB;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,wCAAwC;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACjOa;;AAEb,YAAY,mBAAO,CAAC,+CAAS;AAC7B,cAAc,mBAAO,CAAC,mDAAW;;AAEjC;AACA,yCAAyC;AACzC;AACA,KAAK;AACL,4CAA4C;AAC5C;AACA,KAAK;AACL,qCAAqC;AACrC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAiD;AACjD;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA,mBAAmB,oBAAoB;AACvC;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,wCAAwC;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB,oBAAoB;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,2CAA2C;AAC3C;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACjPa;;AAEb;;AAEA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;;AAEA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;AACA;;AAEA,2BAA2B,gBAAgB;AAC3C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,iDAAiD,EAAE;AACnD;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,kDAAkD,EAAE;AACpD;AACA,SAAS;AACT;;AAEA;AACA,mBAAmB,mBAAmB;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,kBAAkB,OAAO,WAAW,aAAa;AACjD;;AAEA,mBAAmB,kBAAkB;AACrC;AACA;;AAEA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA,4BAA4B,sBAAsB;AAClD;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACnOA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,cAAc;AAC7B,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,KAAK;AACpB,iBAAiB,KAAK;AACtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA,OAAO;;AAEP;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,YAAY;AAC3B,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA,MAAM,IAA4D;AAClE;AACA,sBAAsB;AACtB,GAAG,MAAM,EAGN;;AAEH,CAAC","file":"js/ajax-load-more.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./core/src/js/ajax-load-more.js\");\n","/*\n * Ajax Load More\n * https://connekthq.com/plugins/ajax-load-more/\n * Author: Darren Cooney\n * Twitter: @KaptonKaos, @ajaxloadmore, @connekthq \n * Copyright Connekt Media - https://connekthq.com\n */\n\n\n// Polyfills\nrequire(\"@babel/polyfill/noConflict\");\nrequire('./helpers/polyfills.js');\n\n\n// External Modules\nlet qs = require('qs');\nlet imagesLoaded = require('imagesloaded');\nimport axios from 'axios';\nimport smoothscroll from 'smoothscroll-polyfill'; // Smooth scrolling polyfill\nsmoothscroll.polyfill();\n\n\n// ALM Modules\nimport './helpers/helpers';\nimport commentReplyFix from './helpers/commentReplyFix';\nimport getParameterByName from './helpers/getParameterByName';\nimport almAppendChildren from './helpers/almAppendChildren';\nimport almTableWrap from './helpers/almTableWrap';\nimport almGetCacheUrl from './helpers/almGetCacheUrl';\nimport almDomParser from './helpers/almDomParser';\nimport stripEmptyNodes from './helpers/stripEmptyNodes'; \nimport * as queryParams from './helpers/queryParams';\nimport * as resultsText from './modules/resultsText';\nimport setLocalizedVars from './modules/setLocalizedVars';\nimport insertScript from './modules/insertScript';\nimport setFocus from './modules/setFocus';\nimport almMasonry from './modules/masonry';\nimport almFadeIn from './modules/fadeIn';\nimport almFadeOut from './modules/fadeOut';\nimport almFilter from './modules/filtering';\nimport almNoResults from './modules/noResults';\nimport almDebug from './modules/almDebug';\nimport srcsetPolyfill from './helpers/srcsetPolyfill';\nimport { showPlaceholder, hidePlaceholder } from './modules/placeholder';\n\n\n// Global filtering var\nlet alm_is_filtering = false;\n\n\n// Start ALM\n(function() {\n \"use strict\";\n\n /**\n * ajaxloadmore\n * Init Ajax Load More\n *\n * @param {*} el\n * @param {*} e\n */\n let ajaxloadmore = function(el, e) {\n\n\n // Move user to top of page to prevent loading of unnessasry posts\n if (alm_localize && alm_localize.scrolltop === 'true') {\n window.scrollTo(0, 0);\n }\n\n\n //Set ALM Variables\n let alm = this;\n alm.AjaxLoadMore = {};\n alm.addons = {};\n alm.extensions = {};\n alm.window = window;\n alm.page = 0;\n alm.posts = 0;\n alm.totalposts = 0;\n alm.proceed = false;\n alm.disable_ajax = false;\n alm.init = true;\n alm.loading = true;\n alm.finished = false;\n alm.timer = null;\n alm.ua = (window.navigator.userAgent) ? window.navigator.userAgent : ''; // User agent\n alm.main = el;\n alm.master_id = (el.dataset.id) ? `ajax-load-more-${el.dataset.id}` : el.id; // The defined or generated ID of the ALM instance \n el.classList.add('alm-' + e); // Add unique classname\n el.setAttribute('data-alm-id', e); // Add unique data id\n\n\n // Get localized <script/> variables\n alm.master_id = alm.master_id.replace(/-/g, '_'); // Convert dashes to underscores for the var name\n alm.localize = window[alm.master_id + '_vars']; // Get localize vars\n\n\n // Main ALM Containers\n alm.main = el; // Top level DOM element\n alm.listing = el.querySelector('.alm-listing') || el.querySelector('.alm-comments');\n alm.content = alm.listing;\n alm.el = alm.content;\n alm.ajax = el.querySelector('.alm-ajax');\n alm.container_type = alm.listing.dataset.containerType;\n\n\n // Instance Params\n alm.canonical_url = el.dataset.canonicalUrl;\n alm.nested = (el.dataset.nested) ? el.dataset.nested : null;\n alm.is_search = el.dataset.search;\n alm.slug = el.dataset.slug;\n alm.post_id = el.dataset.postId;\n alm.id = (el.dataset.id) ? el.dataset.id : '';\n \n // No results template\n let alm_no_results = el.querySelector('.alm-no-results');\n alm.no_results = (alm_no_results) ? alm_no_results.innerHTML : '';\n\n // Shortcode Params \n alm.repeater = alm.listing.dataset.repeater; // Repeaters\n alm.theme_repeater = alm.listing.dataset.themeRepeater;\n\n alm.post_type = (alm.listing.dataset.postType) ? alm.listing.dataset.postType : 'post';\n alm.sticky_posts = (alm.listing.dataset.stickyPosts) ? alm.listing.dataset.stickyPosts : null;\n\n alm.btnWrap = el.querySelectorAll('.alm-btn-wrap'); // Get all `.alm-button-wrap` divs\n alm.btnWrap = Array.prototype.slice.call(alm.btnWrap); // Convert NodeList to array\n alm.btnWrap[alm.btnWrap.length - 1].style.visibility = 'visible'; // Get last element (used for nesting)\n alm.trigger = alm.btnWrap[alm.btnWrap.length - 1];\n\n alm.button_label = alm.listing.dataset.buttonLabel;\n alm.button_loading_label = alm.listing.dataset.buttonLoadingLabel;\n alm.placeholder = alm.main.querySelector('.alm-placeholder');\n\n alm.scroll_distance = alm.listing.dataset.scrollDistance;\n alm.scroll_distance = (alm.scroll_distance) ? parseInt(alm.scroll_distance) : 100;\n alm.scroll_container = alm.listing.dataset.scrollContainer;\n alm.max_pages = (alm.listing.dataset.maxPages) ? parseInt(alm.listing.dataset.maxPages) : 0;\n alm.pause_override = alm.listing.dataset.pauseOverride; // true | false\n alm.pause = alm.listing.dataset.pause; // true | false\n alm.transition = alm.listing.dataset.transition; // Transition\n alm.transition_container = alm.listing.dataset.transitionContainer; // Transition Container\n alm.tcc = alm.listing.dataset.transitionContainerClasses; // Transition Container Classes\n alm.speed = (alm_localize.speed) ? parseInt(alm_localize.speed) : 200;\n alm.images_loaded = (alm.listing.dataset.imagesLoaded) ? alm.listing.dataset.imagesLoaded : false;\n alm.destroy_after = (alm.listing.dataset.destroyAfter) ? alm.listing.dataset.destroyAfter : '';\n alm.orginal_posts_per_page = parseInt(alm.listing.dataset.postsPerPage); // Used for paging add-on\n alm.posts_per_page = alm.listing.dataset.postsPerPage;\n alm.offset = (alm.listing.dataset.offset) ? parseInt(alm.listing.dataset.offset) : 0;\n\n\n // Addon Shortcode Params\n alm.addons.cache = alm.listing.dataset.cache; // Cache add-on\n alm.addons.cache = (alm.addons.cache === undefined) ? false : alm.addons.cache;\n alm.addons.cache_id = alm.listing.dataset.cacheId;\n alm.addons.cache_path = alm.listing.dataset.cachePath;\n alm.addons.cache_logged_in = alm.listing.dataset.cacheLoggedIn;\n alm.addons.cache_logged_in = (alm.addons.cache_logged_in === undefined) ? false : alm.addons.cache_logged_in;\n\n alm.addons.cta = alm.listing.dataset.cta; // CTA add-on\n alm.addons.cta_position = alm.listing.dataset.ctaPosition;\n alm.addons.cta_repeater = alm.listing.dataset.ctaRepeater;\n alm.addons.cta_theme_repeater = alm.listing.dataset.ctaThemeRepeater;\n\n alm.addons.nextpage = alm.listing.dataset.nextpage; // Nextpage add-on\n alm.addons.nextpage_urls = alm.listing.dataset.nextpageUrls;\n alm.addons.nextpage_scroll = alm.listing.dataset.nextpageScroll;\n alm.addons.nextpage_pageviews = alm.listing.dataset.nextpagePageviews;\n alm.addons.nextpage_post_id = alm.listing.dataset.nextpagePostId;\n alm.addons.nextpage_startpage = alm.listing.dataset.nextpageStartpage;\n\n alm.addons.single_post = alm.listing.dataset.singlePost; // Previous Post add-on\n alm.addons.single_post_id = alm.listing.dataset.singlePostId;\n alm.addons.single_post_order = alm.listing.dataset.singlePostOrder;\n alm.addons.single_post_init_id = alm.listing.dataset.singlePostId;\n alm.addons.single_post_taxonomy = alm.listing.dataset.singlePostTaxonomy;\n alm.addons.single_post_excluded_terms = alm.listing.dataset.singlePostExcludedTerms;\n alm.addons.single_post_progress_bar = alm.listing.dataset.singlePostProgressBar;\n\n alm.addons.comments = alm.listing.dataset.comments; // Comments add-on \n alm.addons.comments_post_id = alm.listing.dataset.comments_post_id; // current post id\n alm.addons.comments_per_page = alm.listing.dataset.comments_per_page;\n alm.addons.comments_per_page = (alm.addons.comments_per_page === undefined) ? '5' : alm.addons.comments_per_page;\n alm.addons.comments_type = alm.listing.dataset.comments_type;\n alm.addons.comments_style = alm.listing.dataset.comments_style;\n alm.addons.comments_template = alm.listing.dataset.comments_template;\n alm.addons.comments_callback = alm.listing.dataset.comments_callback;\n\n alm.addons.tabs = alm.listing.dataset.tabs;\n \n alm.addons.filters = alm.listing.dataset.filters;\n\n alm.addons.seo = alm.listing.dataset.seo; // SEO add-on\n\n alm.addons.preloaded = alm.listing.dataset.preloaded; // Preloaded add-on\n alm.addons.preloaded_amount = (alm.listing.dataset.preloadedAmount) ? alm.listing.dataset.preloadedAmount : 0;\n alm.is_preloaded = (alm.listing.dataset.isPreloaded === 'true') ? true : false;\n\n alm.addons.paging = alm.listing.dataset.paging; // Paging add-on \n\n alm.addons.users = (alm.listing.dataset.users === 'true') ? true : false; // Users add-on\n if (alm.addons.users) { // Override paging params for users\n alm.orginal_posts_per_page = alm.listing.dataset.usersPerPage;\n alm.posts_per_page = alm.listing.dataset.usersPerPage;\n }\n\n // Extension Shortcode Params\n alm.extensions.restapi = alm.listing.dataset.restapi; // REST API\n alm.extensions.restapi_base_url = alm.listing.dataset.restapiBaseUrl;\n alm.extensions.restapi_namespace = alm.listing.dataset.restapiNamespace;\n alm.extensions.restapi_endpoint = alm.listing.dataset.restapiEndpoint;\n alm.extensions.restapi_template_id = alm.listing.dataset.restapiTemplateId; \n alm.extensions.restapi_debug = alm.listing.dataset.restapiDebug;\n\n alm.extensions.acf = alm.listing.dataset.acf; // ACF\n alm.extensions.acf_field_type = alm.listing.dataset.acfFieldType;\n alm.extensions.acf_field_name = alm.listing.dataset.acfFieldName;\n alm.extensions.acf_parent_field_name = alm.listing.dataset.acfParentFieldName;\n alm.extensions.acf_post_id = alm.listing.dataset.acfPostId;\n alm.extensions.acf = (alm.extensions.acf === 'true') ? true : false;\n // if field type, name or post ID is empty\n if (alm.extensions.acf_field_type === undefined || alm.extensions.acf_field_name === undefined || alm.extensions.acf_post_id === undefined) {\n alm.extensions.acf = false;\n }\n \n\n /* Paging */\n if (alm.addons.paging === 'true') {\n alm.addons.paging = true;\n alm.addons.paging_init = true;\n alm.addons.paging_controls = (alm.listing.dataset.pagingControls === 'true') ? true : false;\n alm.addons.paging_show_at_most = alm.listing.dataset.pagingShowAtMost;\n alm.addons.paging_classes = alm.listing.dataset.pagingClasses;\n alm.addons.paging_show_at_most = (alm.addons.paging_show_at_most === undefined) ? 7 : alm.addons.paging_show_at_most; \n \n alm.addons.paging_first_label = alm.listing.dataset.pagingFirstLabel;\n alm.addons.paging_previous_label = alm.listing.dataset.pagingPreviousLabel;\n alm.addons.paging_next_label = alm.listing.dataset.pagingNextLabel;\n alm.addons.paging_last_label = alm.listing.dataset.pagingLastLabel;\n \n // If preloaded, pause ALM\t\n alm.pause = (alm.addons.preloaded === 'true') ? true : alm.pause;\n } else {\n alm.addons.paging = false;\n }\n /* End Paging */\n\n\n /* Filters */\n if (alm.addons.filters === 'true') {\n alm.addons.filters = true;\n\n alm.addons.filters_url = (alm.listing.dataset.filtersUrl === 'true') ? true : false;\n alm.addons.filters_paging = (alm.listing.dataset.filtersPaging === 'true') ? true : false;\n alm.addons.filters_scroll = (alm.listing.dataset.filtersScroll === 'true') ? true : false;\n alm.addons.filters_scrolltop = (alm.listing.dataset.filtersScrolltop) ? alm.listing.dataset.filtersScrolltop : '30';\n alm.addons.filters_analtyics = alm.listing.dataset.filtersAnalytics;\n alm.addons.filters_debug = alm.listing.dataset.filtersDebug;\n alm.addons.filters_startpage = 0;\n\n // Get Paged Querystring Val\n let page = getParameterByName('pg');\n alm.addons.filters_startpage = (page !== null) ? parseInt(page) : 0;\n \n // If not Paging add-on\n if(!alm.addons.paging && alm.addons.filters_startpage > 0){\n \talm.posts_per_page = alm.posts_per_page * alm.addons.filters_startpage;\n\t\t\t\talm.isPaged = (alm.addons.filters_startpage > 0) ? true : false;\n } \n \n } else {\n alm.addons.filters = false;\n }\n /* End Filters */\n\n\n /* TABS */\n if (alm.addons.tabs === 'true') { \n alm.addons.tabs = true; \n alm.addons.tab_template = (alm.listing.dataset.tabTemplate) ? alm.listing.dataset.tabTemplate : '';\n\t\t\t\n\t\t\t// Set current template\t\t\n\t\t\tsetTimeout(function(){\n\t\t\t\t//window.almTabsOnLoad(alm);\n\t\t\t}, 500);\n if (typeof almTabsOnLoad === 'function' && window.location.hash) {\n\t\t\t //alm.addons.tab_template = window.almTabsOnLoad(alm);\n\t\t\t} \n \n alm.addons.tabs_resturl = (alm.listing.dataset.tabsRestUrl) ? alm.listing.dataset.tabsRestUrl : '';\n } else {\n alm.addons.tabs = false;\n }\n /* End TABS */\n\n\n /* REST API */\n if (alm.extensions.restapi === 'true') {\n alm.extensions.restapi = true;\n alm.extensions.restapi_debug = (alm.extensions.restapi_debug === undefined) ? false : alm.extensions.restapi_debug;\n alm.extensions.restapi = (alm.extensions.restapi_template_id === '') ? false : alm.extensions.restapi;\n } else {\n alm.extensions.restapi = false;\n }\n /* End REST API */\n\n\n /* Preloaded */\n if (alm.addons.preloaded === 'true') {\n // Preloaded Amount\n alm.addons.preloaded_amount = (alm.addons.preloaded_amount === undefined) ? alm.posts_per_page : alm.addons.preloaded_amount;\n // Disable ALM if total_posts is less than or equal to preloaded_amount\n if (alm.localize && alm.localize.total_posts) {\n if (parseInt(alm.localize.total_posts) <= parseInt(alm.addons.preloaded_amount)) {\n alm.addons.preloaded_total_posts = alm.localize.total_posts;\n alm.disable_ajax = true;\n }\n }\n } else {\n alm.addons.preloaded = 'false';\n }\n /* End Preloaded */\n\n\n /* SEO */\n alm.addons.seo = (alm.addons.seo === undefined) ? false : alm.addons.seo;\n alm.addons.seo = (alm.addons.seo === 'true') ? true : alm.addons.seo;\n alm.is_search = (alm.is_search === undefined) ? false : alm.is_search;\n alm.search_value = (alm.is_search === 'true') ? alm.slug : ''; // Convert to value of slug for appending to seo url\n \n alm.addons.seo_permalink = alm.listing.dataset.seoPermalink;\n alm.addons.seo_pageview = alm.listing.dataset.seoPageview;\n alm.addons.seo_trailing_slash = (alm.listing.dataset.seoTrailingSlash === 'false') ? '' : '/';\n alm.addons.seo_leading_slash = (alm.listing.dataset.seoLeadingSlash === 'true') ? '/' : '';\n alm.start_page = alm.listing.dataset.seoStartPage;\n\n if (alm.start_page) {\n alm.addons.seo_scroll = alm.listing.dataset.seoScroll;\n alm.addons.seo_scrolltop = alm.listing.dataset.seoScrolltop;\n alm.addons.seo_controls = alm.listing.dataset.seoControls;\n alm.isPaged = false;\n if (alm.start_page > 1) {\n alm.isPaged = true; // Is this a paged page > 1 ?\n alm.posts_per_page = alm.start_page * alm.posts_per_page;\n }\n if (alm.addons.paging) { // If paging, reset posts_per_page\n alm.posts_per_page = alm.orginal_posts_per_page;\n }\n } else {\n alm.start_page = 1;\n }\n /* End SEO */\n\n\n /* Nextpage */\n if (alm.addons.nextpage === 'true') {\n alm.addons.nextpage = true;\n alm.posts_per_page = 1;\n } else {\n alm.addons.nextpage = false;\n }\n if (alm.addons.nextpage_urls === undefined) {\n alm.addons.nextpage_urls = 'true';\n }\n if (alm.addons.nextpage_scroll === undefined) {\n alm.addons.nextpage_scroll = '250:30';\n }\n if (alm.addons.nextpage_pageviews === undefined) {\n alm.addons.nextpage_pageviews = 'true';\n }\n if (alm.addons.nextpage_post_id === undefined) {\n alm.addons.nextpage = false;\n alm.addons.nextpage_post_id = null;\n }\n if (alm.addons.nextpage_startpage === undefined) {\n alm.addons.nextpage_startpage = 1;\n }\n if (alm.addons.nextpage_startpage > 1) {\n alm.isPaged = true;\n }\n /* End Nextpage */\n\n\n /* Single Post */\n if (alm.addons.single_post === 'true') {\n alm.addons.single_post = true;\n alm.addons.single_post_permalink = '';\n alm.addons.single_post_title = '';\n alm.addons.single_post_slug = '';\n } else {\n alm.addons.single_post = false;\n }\n if (alm.addons.single_post_id === undefined) {\n alm.addons.single_post_id = '';\n alm.addons.single_post_init_id = '';\n }\n alm.addons.single_post_order = (alm.addons.single_post_order === undefined) ? 'previous' : alm.addons.single_post_order;\n alm.addons.single_post_taxonomy = (alm.addons.single_post_taxonomy === undefined) ? '' : alm.addons.single_post_taxonomy;\n alm.addons.single_post_excluded_terms = (alm.addons.single_post_excluded_terms === undefined) ? '' : alm.addons.single_post_excluded_terms;\n alm.addons.single_post_progress_bar = (alm.addons.single_post_progress_bar === undefined) ? '' : alm.addons.single_post_progress_bar;\n alm.addons.single_post_title_template = alm.listing.dataset.singlePostTitleTemplate;\n alm.addons.single_post_siteTitle = alm.listing.dataset.singlePostSiteTitle;\n alm.addons.single_post_siteTagline = alm.listing.dataset.singlePostSiteTagline;\n alm.addons.single_post_pageview = alm.listing.dataset.singlePostPageview;\n alm.addons.single_post_scroll = alm.listing.dataset.singlePostScroll;\n alm.addons.single_post_scroll_speed = alm.listing.dataset.singlePostScrollSpeed;\n alm.addons.single_post_scroll_top = alm.listing.dataset.singlePostScrolltop;\n alm.addons.single_post_controls = alm.listing.dataset.singlePostControls;\n /* End Single Post */\n\n\n /* Pause */\n if (alm.pause === undefined || (alm.addons.seo && alm.start_page > 1)) { // SEO only\n alm.pause = false;\n }\n if (alm.addons.preloaded === 'true' && alm.addons.seo && alm.start_page > 0) { // SEO + Preloaded\n alm.pause = false;\n }\n if (alm.addons.filters && alm.addons.filters_startpage > 0) { // Filters\n alm.pause = false;\n }\n if (alm.addons.preloaded === 'true' && alm.addons.paging) {\n alm.pause = true;\n }\n\n /* Repeater and Theme Repeater */\n alm.repeater = (alm.repeater === undefined) ? 'default' : alm.repeater;\n alm.theme_repeater = (alm.theme_repeater === undefined) ? false : alm.theme_repeater;\n\n /* Max Pages (while scrolling) */\n alm.max_pages = (alm.max_pages === undefined || alm.max_pages === 0) ? 10000 : alm.max_pages;\n\n /* Scroll Distance */\n alm.scroll_distance = (alm.scroll_distance === undefined) ? 150 : alm.scroll_distance;\n\n /* Scroll Container */\n alm.scroll_container = (alm.scroll_container === undefined) ? '' : alm.scroll_container;\n\n /* Transition */\n alm.transition = (alm.transition === undefined) ? 'fade' : alm.transition;\n\n /* Transition Container Class */\n alm.tcc = (alm.tcc === undefined) ? '' : alm.tcc;\n\n /* Masonry */\n alm.is_masonry_preloaded = false;\n if (alm.transition === 'masonry') {\n alm.masonry_init = true;\n alm.masonry_selector = alm.listing.dataset.masonrySelector;\n alm.masonry_columnwidth = alm.listing.dataset.masonryColumnwidth;\n alm.masonry_animation = alm.listing.dataset.masonryAnimation;\n alm.masonry_animation = (alm.masonry_animation === undefined) ? 'standard' : alm.masonry_animation;\n alm.masonry_horizontalorder = alm.listing.dataset.masonryHorizontalorder;\n alm.masonry_horizontalorder = (alm.masonry_horizontalorder === undefined) ? 'true' : alm.masonry_horizontalorder;\n alm.transition_container = false;\n alm.images_loaded = false;\n alm.is_masonry_preloaded = (alm.addons.preloaded === 'true') ? true : alm.is_masonry_preloaded;\n }\n\n /* Scroll */\n if (alm.listing.dataset.scroll === undefined) {\n alm.scroll = true;\n } else if (alm.listing.dataset.scroll === 'false') {\n alm.scroll = false;\n } else {\n alm.scroll = true;\n }\n\n /* Transition Container */\n alm.transition_container = (alm.transition_container === undefined || alm.transition_container === 'true') ? true : false;\n\n /* Button Labels */\n alm.button_label = (alm.button_label === undefined) ? 'Older Posts' : alm.button_label;\n alm.button_loading_label = (alm.button_loading_label === undefined) ? false : alm.button_loading_label;\n\n /* Paging */\n if (alm.addons.paging) {\n alm.main.classList.add('loading'); // add loading class to main container\n } else {\n let almChildren = el.childNodes; // Get child nodes of instance [nodeList]\n if (almChildren) {\n let almChildArray = Array.prototype.slice.call(almChildren); // Convert nodeList to array \n\n // Filter array to find the `.alm-btn-wrap` div\n let btnWrap = almChildArray.filter(function(element) {\n if (!element.classList) { // If not element (#text node)\n return false;\n }\n return element.classList.contains('alm-btn-wrap');\n });\n alm.button = (btnWrap) ? (btnWrap[0]).querySelector('.alm-load-more-btn') : container.querySelector('.alm-btn-wrap .alm-load-more-btn');\n } else {\n alm.button = container.querySelector('.alm-btn-wrap .alm-load-more-btn');\n }\n \n // Reset button state\n alm.button.disabled = false;\n\n }\n\n\n // Results Text\n // Render \"Showing x of y results\" text.\n alm.resultsText = document.querySelector('.alm-results-text');\n if (alm.resultsText) {\n\t alm.resultsText.setAttribute('aria-live', 'polite');\n\t alm.resultsText.setAttribute('aria-atomic', 'true');\n } else {\n alm.resultsText = false;\n }\n\n\n\n /** \n * LoadPosts()\n * The function to get posts via Ajax\n * @since 2.0.0\n */\n\n alm.AjaxLoadMore.loadPosts = function() {\n\t \n\t\t\tif (typeof almOnChange === 'function') {\n\t\t\t window.almOnChange(alm);\n\t\t\t}\n\t\t\t\n\t\t\tshowPlaceholder(alm);\n\t \n if (!alm.disable_ajax) { // Check for ajax blocker\n if (!alm.addons.paging) {\n alm.button.classList.add('loading');\n if (alm.button_loading_label !== false) {\n alm.button.innerHTML = alm.button_loading_label;\n }\n }\n alm.main.classList.add('alm-loading');\n alm.loading = true;\n \n if (alm.addons.cache === 'true' && !alm.addons.cache_logged_in) {\n // Cache \n let cache_page = almGetCacheUrl(alm); \n if(cache_page){ \n \n // Load `.html` page\n axios.get(cache_page)\n .then(response => {\n // Exists\n alm.AjaxLoadMore.success(response.data, true);\n } \n )\n .catch(function (error) { \n // Error || Page does not yet exist\n \t\t\t\t\talm.AjaxLoadMore.ajax('standard');\n \t\t\t\t\t//console.warn(error.message); \t\t\t\t\t\n \t\t\t\t});\n \t\t\t\t\n \t\t\t\t} else {\n \t\t\t\t// Standard ALM query\n \t\t\t\talm.AjaxLoadMore.ajax('standard');\n \t\t\t\t} \n \t\t\t\t \t\n } else { \n // Standard ALM query\n alm.AjaxLoadMore.ajax('standard');\n \n }\n }\n };\n\n\n /* ajax()\n * Ajax Load Moe Ajax function\n *\n * @param queryType The type of Ajax request (standard/totalposts)\n * @since 2.6.0\n */\n\n alm.AjaxLoadMore.ajax = function(queryType) {\n\n // Default ALM action\n let action = 'alm_get_posts';\n\n // ACF Params\n alm.acf_array = '';\n if (alm.extensions.acf) {\n // Custom query for the Repeater / Gallery / Flexible Content field types\n if (alm.extensions.acf_field_type !== 'relationship') {\n action = 'alm_acf';\n }\n alm.acf_array = {\n 'acf': 'true',\n 'post_id': alm.extensions.acf_post_id,\n 'field_type': alm.extensions.acf_field_type,\n 'field_name': alm.extensions.acf_field_name,\n 'parent_field_name': alm.extensions.acf_parent_field_name\n };\n }\n\n // Nextpage Params\n alm.nextpage_array = '';\n if (alm.addons.nextpage) {\n action = 'alm_nextpage';\n alm.nextpage_array = {\n 'nextpage': 'true',\n 'urls': alm.addons.nextpage_urls,\n 'scroll': alm.addons.nextpage_scroll,\n 'pageviews': alm.addons.nextpage_pageviews,\n 'post_id': alm.addons.nextpage_post_id,\n 'startpage': alm.addons.nextpage_startpage\n };\n }\n\n // Previous Post Params\n alm.single_post_array = '';\n if (alm.addons.single_post) {\n alm.single_post_array = {\n 'single_post': 'true',\n 'id': alm.addons.single_post_id,\n 'slug': alm.addons.single_post_slug,\n };\n }\n\n // Comment Params\n alm.comments_array = '';\n if (alm.addons.comments === 'true') {\n action = 'alm_comments';\n alm.posts_per_page = alm.addons.comments_per_page;\n alm.comments_array = {\n 'comments': 'true',\n 'post_id': alm.addons.comments_post_id,\n 'per_page': alm.addons.comments_per_page,\n 'type': alm.addons.comments_type,\n 'style': alm.addons.comments_style,\n 'template': alm.addons.comments_template,\n 'callback': alm.addons.comments_callback,\n };\n }\n\n // Users Params\n alm.users_array = '';\n if (alm.addons.users) {\n action = 'alm_users';\n alm.users_array = {\n 'users': 'true',\n 'role': alm.listing.dataset.usersRole,\n 'include': alm.listing.dataset.usersInclude,\n 'exclude': alm.listing.dataset.usersExclude,\n 'per_page': alm.posts_per_page,\n 'order': alm.listing.dataset.usersOrder,\n 'orderby': alm.listing.dataset.usersOrderby,\n };\n }\n\n // CTA Params\n alm.cta_array = '';\n if (alm.addons.cta === 'true') {\n alm.cta_array = {\n 'cta': 'true',\n 'cta_position': alm.addons.cta_position,\n 'cta_repeater': alm.addons.cta_repeater,\n 'cta_theme_repeater': alm.addons.cta_theme_repeater,\n };\n }\n \n\n // REST API\n if (alm.extensions.restapi) {\n alm.AjaxLoadMore.restapi(alm, action, queryType);\n }\n else if(alm.addons.tabs){\n\t alm.AjaxLoadMore.tabs(alm);\n }\n\n // Standard ALM\n else {\t \n\t alm.AjaxLoadMore.adminajax(alm, action, queryType); \n }\n \n };\n \n \n \n /** \n\t * adminajax\n * Send request to the admin-ajax.php\n *\n * @param {*} alm | ALm object\n * @param {*} action | Ajax action\n * @param {*} queryType\n * @since 5.0.0\n */\n alm.AjaxLoadMore.adminajax = function(alm, action, queryType){\n\t \n\t if (alm.page != 1 && !alm.addons.paging) {\n alm.button.classList.add('loading');\n } \n \n // Axios Interceptor for nested data objects\n\t\t\taxios.interceptors.request.use(config => {\n\t\t\t\tconfig.paramsSerializer = params => {\n\t\t\t\t\t// Qs is already included in the Axios package\n\t\t\t\t\treturn qs.stringify(params, {\n\t\t\t\t\t\tarrayFormat: 'brackets',\n\t\t\t\t\t\tencode: false\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\treturn config; \n\t\t\t});\t\t\t \n \n // Get admin-ajax.php URL \n let ajaxURL = alm_localize.ajaxurl; \n\n\t\t\t// Get data params\n let params = queryParams.almGetAjaxParams(alm, action, queryType); // [./helpers/queryParams.js\n \n // Send HTTP request via Axios\n axios.get(ajaxURL, {params})\n .then(function(response){\n // Success \n let data = response.data; // Get data from response\n \n // Standard Query\n if (queryType === 'standard') {\n alm.AjaxLoadMore.success(data, false);\n \n } else if (queryType === 'totalpages' && alm.addons.paging && alm.addons.nextpage) {\n // Next Page and Paging\n if (typeof almBuildPagination === 'function') {\n window.almBuildPagination(data.totalpages, alm);\n }\n \n } else if (queryType === 'totalposts' && alm.addons.paging) {\n // Paging\n if (typeof almBuildPagination === 'function') {\n window.almBuildPagination(data.totalposts, alm);\n }\n }\n \n })\n .catch(function (error) { \n // Error \n alm.AjaxLoadMore.error(error, 'adminajax'); \n \t\t\t\t\t\n\t\t\t}); \n };\n \n \n \n /** \n\t * tabs\n * Send request to the WP REST API\n *\n * @param {*} alm | ALm object\n * @since 5.2.0\n */\n alm.AjaxLoadMore.tabs = function(alm){\n\t \n let alm_rest_url = `${alm.addons.tabs_resturl}ajaxloadmore/tab`; \n \n let params = {\n\t\t\t\tpost_id : alm.post_id,\n\t\t\t\ttemplate: alm.addons.tab_template\n }\n\n\t\t\t// Axios Interceptor for nested data objects\n\t\t\taxios.interceptors.request.use(config => {\n\t\t\t\tconfig.paramsSerializer = params => {\n\t\t\t\t\t// Qs is already included in the Axios package\n\t\t\t\t\treturn qs.stringify(params, {\n\t\t\t\t\t\tarrayFormat: 'brackets',\n\t\t\t\t\t\tencode: false\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\treturn config;\n\t\t\t}); \n \n // Send Ajax request\n axios.get(alm_rest_url, {params})\n .then(function(response){\n\t \n // Success \n let results = response.data; // Get data from response\n\t\t\t\tlet html = results.html;\n \n // Create object to pass to success()\n let obj = {\n 'html': html,\n 'meta': {\n 'postcount': 1,\n 'totalposts': 1\n },\n };\n alm.AjaxLoadMore.success(obj, false); // Send data\n \n \n // Callback to Tabs add-on\n if (typeof almTabLoaded === 'function') {\n window.almTabLoaded(alm);\n }\n \n \n })\n .catch(function (error) { \n // Error \n alm.AjaxLoadMore.error(error, 'restapi'); \n \t\t\t\t\t\n\t\t\t});\n\t\t\t\n };\n \n \n \n /** \n\t * restapi\n * Send request to the WP REST API\n *\n * @param {*} alm | ALm object\n * @param {*} action | Ajax action\n * @param {*} queryType\n * @since 5.0.0\n */\n alm.AjaxLoadMore.restapi = function(alm, action, queryType){\n\t \n\t let alm_rest_template = wp.template(alm.extensions.restapi_template_id);\n let alm_rest_url = `${alm.extensions.restapi_base_url}/${alm.extensions.restapi_namespace}/${alm.extensions.restapi_endpoint}`; \n let params = queryParams.almGetRestParams(alm); // [./helpers/queryParams.js]\n\n\t\t\t// Axios Interceptor for nested data objects\n\t\t\taxios.interceptors.request.use(config => {\n\t\t\t\tconfig.paramsSerializer = params => {\n\t\t\t\t\t// Qs is already included in the Axios package\n\t\t\t\t\treturn qs.stringify(params, {\n\t\t\t\t\t\tarrayFormat: 'brackets',\n\t\t\t\t\t\tencode: false\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\treturn config;\n\t\t\t}); \n \n // Send Ajax request\n axios.get(alm_rest_url, {params})\n .then(function(response){\n // Success \n let results = response.data; // Get data from response\n\t\t\t\tlet data = '',\n\t\t\t\t\t html = results.html,\n\t\t\t\t\t meta = results.meta,\n\t\t\t\t\t postcount = meta.postcount,\n\t\t\t\t\t totalposts = meta.totalposts;\n \n \n // loop results to get data from each\n for(let i = 0; i < html.length; i++){\n\t let result = html[i];\n if (alm.restapi_debug === 'true') { // If debug\n console.log(result);\n }\n data += alm_rest_template(result);\n }\n \n // Create object to pass to success()\n let obj = {\n 'html': data,\n 'meta': {\n 'postcount': postcount,\n 'totalposts': totalposts\n },\n };\n alm.AjaxLoadMore.success(obj, false); // Send data\n \n })\n .catch(function (error) { \n // Error \n alm.AjaxLoadMore.error(error, 'restapi'); \n \t\t\t\t\t\n\t\t\t});\n\t\t\t\n };\n\n\n\n // If pagination enabled, run totalposts query\n if (alm.addons.paging) {\n if (alm.addons.nextpage) {\n alm.AjaxLoadMore.ajax('totalpages'); // Create paging menu and query for total pages\n } else {\n alm.AjaxLoadMore.ajax('totalposts'); // Create paging menu and query for total posts\n }\n }\n\n\n\n /** \n\t * success\n * Success function after loading data\n *\n * @param data The results of the Ajax request\n * @param is_cache Are results of the Ajax request coming from cache\n * @since 2.6.0\n */\n alm.AjaxLoadMore.success = function(data, is_cache) {\n\n if (alm.addons.single_post) { // Get previous page data\n alm.AjaxLoadMore.getSinglePost();\n }\n\n\t\t\tlet isPaged = false;\n\t\t\t \n // Create `.alm-reveal` element \n //let reveal = document.createElement('div');\n let reveal = (alm.container_type === 'table') ? document.createElement('tbody') : document.createElement('div');\n alm.el = reveal;\n reveal.style.opacity = 0;\n reveal.style.height = 0;\n reveal.style.outline = 'none';\n \n\t\t\t// Paging container\n let pagingContent = alm.listing.querySelector('.alm-paging-content');\n\t\t\t\n var html, meta, total;\n\n if (is_cache) {\n // If Cache, do not look for json data as we won't be querying the DB.\n html = data;\n \n } else {\n // Standard ALM query results\n html = data.html;\n meta = data.meta; \n alm.posts = (alm.addons.paging) ? meta.postcount : alm.posts + meta.postcount;\n total = meta.postcount;\n alm.totalposts = meta.totalposts;\n alm.totalposts = (alm.addons.preloaded === 'true') ? alm.totalposts - alm.addons.preloaded_amount : alm.totalposts;\n alm.debug = (meta.debug) ? meta.debug : '';\n } \n\n\t\t\t// Set alm.html as plain text return\n alm.html = html; \n\n // If cache, get the length of the html object\n total = (is_cache) ? almDomParser(html).length : total;\n\n // First Run Only\n if (alm.init) {\n\t // Set Meta\t\t \n if (meta) {\n alm.main.dataset.totalPosts = (meta.totalposts) ? meta.totalposts : 0;\n } \n // Paging\t \n if (alm.addons.paging && total > 0) { \n\t // Add paging containers and content\n\t\t\t\t\talm.AjaxLoadMore.pagingInit(html, 'alm-reveal');\n }\n // ALM Empty\n if (total === 0) {\n if (alm.addons.paging) {\n if (typeof almPagingEmpty === 'function') {\n window.almPagingEmpty(alm);\n }\n }\n if (typeof almEmpty === 'function') {\t \n window.almEmpty(alm);\n }\n if(alm.no_results){\n\t almNoResults(alm.content, alm.no_results);\n }\n }\n\n // isPaged\n if (alm.isPaged) {\n // Reset the posts_per_page parameter\n alm.posts_per_page = (alm.users) ? alm.listing.dataset.usersPerPage : alm.listing.dataset.postsPerPage;\n // SEO add-on\n alm.page = (alm.start_page) ? alm.start_page - 1 : alm.page; // Set new page #\n // Filters add-on \n if (alm.addons.filters) {\n if (alm.addons.filters_startpage > 0) {\n alm.page = alm.addons.filters_startpage - 1; // Set new page # \n alm.posts_per_page = alm.listing.dataset.postsPerPage; // Reset `filters-startpage` data after the first run\n }\n } \n }\n } \n\t\t\t\n\t\t\t\n\t\t\t/*\n * Display alm_debug results\n */ \n almDebug(alm);\n\n\n /*\n * Set localized variables\n */ \n setLocalizedVars(alm); \n \n \n /*\n * Render results\n */\n \n if (total > 0) {\n\n // We have results! \n\n if (!alm.addons.paging) {\n\t\t\t\t\t\n if (alm.addons.single_post) { \n\t \n\t // Single Posts \n reveal.setAttribute('class', 'alm-reveal alm-single-post post-' + alm.addons.single_post_id + alm.tcc);\n reveal.dataset.url = alm.addons.single_post_permalink;\n reveal.dataset.page = alm.page;\n reveal.dataset.id = alm.addons.single_post_id;\n reveal.dataset.title = alm.addons.single_post_title; \n reveal.innerHTML = alm.html;\n \n } else {\n\n if (!alm.transition_container) { // No transition container\n\t \n\t \talm.el = alm.html; \n reveal = (alm.container_type === 'table') ? almTableWrap(alm.html) : almDomParser(alm.html, 'text/html');\n\n } else { // Standard container\n\n let pagenum;\n let querystring = window.location.search;\n let seo_class = (alm.addons.seo) ? ' alm-seo' : '';\n let filters_class = (alm.addons.filters) ? ' alm-filters' : '';\n let preloaded_class = (alm.is_preloaded) ? ' alm-preloaded' : '';\n\n // SEO and Filter Paged\n if (alm.init && (alm.start_page > 1 || alm.addons.filters_startpage > 0)) {\t \n // loop through items and break into separate .alm-reveal divs for paging \n\n let return_data = [];\n let container_array = [];\n let posts_per_page = parseInt(alm.posts_per_page);\n let pages = Math.ceil(total / posts_per_page);\n isPaged = true;\n \n\n // Call to Actions\n if (alm.addons.cta === 'true') {\n posts_per_page = posts_per_page + 1; // Add 1 to posts_per_page for CTAs\n pages = Math.ceil(total / posts_per_page); // Update pages var with new posts_per_page\n total = pages + total; // Get new total w/ CTAs added\n } \n\n\n // Parse returned HTML and strip empty nodes\n let data = stripEmptyNodes(almDomParser(alm.html, 'text/html') );\n \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t// Slice data array into individual pages (array)\n for (var i = 0; i < total; i += posts_per_page) {\n return_data.push(data.slice(i, posts_per_page + i));\n }\n\n // Loop return_data array to build .alm-reveal containers\n for (var k = 0; k < return_data.length; k++) {\n\n let p = (alm.addons.preloaded === 'true') ? 1 : 0; // Add 1 page if items are preloaded.\n let alm_reveal = document.createElement('div');\n\n if (k > 0 || alm.addons.preloaded === 'true') {\n \n pagenum = (k + 1 + p); // > Paged\n\n\t\t\t\t\t\t\t\t\t\tif(alm.addons.seo){ // SEO\n\t if (alm.addons.seo_permalink === 'default') {\n\t\t\t\t\t\t\t\t\t\t\t\t// Default Permalinks\n\t\t\t\t\t\t\t\t\t\t\t\talm_reveal.setAttribute('class', 'alm-reveal' + seo_class + alm.tcc);\n\t\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.url = alm.canonical_url + querystring + '&paged=' + pagenum;\n\t\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.page = pagenum;\n\t } else {\n\t\t\t\t\t\t\t\t\t\t\t\t// Pretty Permalinks\n\t\t\t\t\t\t\t\t\t\t\t\talm_reveal.setAttribute('class', 'alm-reveal' + seo_class + alm.tcc);\n\t\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.url = alm.canonical_url + alm.addons.seo_leading_slash + 'page/' + pagenum + alm.addons.seo_trailing_slash + querystring;\n\t\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.page = pagenum;\n\t }\n }\n \n if(alm.addons.filters){ // Filters\n \talm_reveal.setAttribute('class', 'alm-reveal' + filters_class + alm.tcc);\n\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.url = alm.canonical_url + alm.AjaxLoadMore.buildFilterURL(querystring, pagenum);\n\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.page = pagenum;\n } \n\n } else {\n\t \t \n // First Page \n if(alm.addons.seo){\n\t // SEO\n\t alm_reveal.setAttribute('class', 'alm-reveal' + seo_class + alm.tcc);\n\t\t alm_reveal.dataset.url = alm.canonical_url + querystring;\n\t\t alm_reveal.dataset.page = '1';\n\t\t \n } \n if(alm.addons.filters){\n\t // Filters\n \talm_reveal.setAttribute('class', 'alm-reveal' + filters_class + preloaded_class + alm.tcc);\n\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.url = alm.canonical_url + alm.AjaxLoadMore.buildFilterURL(querystring, 0);\n\t\t\t\t\t\t\t\t\t\t\talm_reveal.dataset.page = '1';\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n } \n } \n \n \n // Append children to `.alm-reveal` element\n almAppendChildren(alm_reveal, return_data[k]);\n \n // Run srcSet polyfill\n\t\t\t\t\t\t\t\t\tsrcsetPolyfill(alm_reveal, alm.ua);\n \n \n // Push alm_reveal elements into container_array\n container_array.push(alm_reveal);\n \n }\n \n\n // Set opacity and height of .alm-listing div to allow for fadein.\n alm.listing.style.opacity = 0;\n alm.listing.style.height = 0;\n \n\n // Append container_array to `.alm-listing` \n almAppendChildren(alm.listing, container_array);\n \n reveal = alm.listing;\n alm.el = reveal;\n\n }\n // End Init & SEO\n \n else {\n\t \n\t // Preloaded OR SEO (and Paged)\n if (alm.addons.seo && alm.page > 0 || alm.addons.preloaded === 'true') {\n\n let p2 = (alm.addons.preloaded === 'true') ? 1 : 0; // Add 1 page if items are preloaded.\n\n // SEO [Paged]\n pagenum = (alm.page + 1 + p2);\n\n if (alm.addons.seo) {\n // SEO\n if (alm.addons.seo_permalink === 'default') {\n\t // Default Permalinks\n\t reveal.setAttribute('class', 'alm-reveal' + seo_class + alm.tcc);\n\t\t reveal.dataset.url = alm.canonical_url + querystring + '&paged=' + pagenum;\n\t\t reveal.dataset.page = pagenum;\n \n } else {\n\t // Pretty Permalinks\n\t reveal.setAttribute('class', 'alm-reveal' + seo_class + alm.tcc);\n\t\t reveal.dataset.url = alm.canonical_url + alm.addons.seo_leading_slash + 'page/' + pagenum + alm.addons.seo_trailing_slash + querystring;\n\t\t reveal.dataset.page = pagenum;\n \n }\n\n } else if (alm.addons.filters) {\n // Filters \n\t\t\t\t\t\t\t\t\t\treveal.setAttribute('class', 'alm-reveal' + filters_class + alm.tcc);\n\t\t\t\t\t\t\t\t\t\treveal.dataset.url = alm.canonical_url + alm.AjaxLoadMore.buildFilterURL(querystring, pagenum);\n\t\t\t\t\t\t\t\t\t\treveal.dataset.page = pagenum;\n \n } else { \n // Basic ALM\n reveal.setAttribute('class', 'alm-reveal' + alm.tcc);\n \n }\n\n } else if (alm.addons.filters) {\n\t \n // Filters\n\t\t\t\t\t\t\t\t\treveal.setAttribute('class', 'alm-reveal' + filters_class + alm.tcc);\n\t\t\t\t\t\t\t\t\treveal.dataset.url = alm.canonical_url + alm.AjaxLoadMore.buildFilterURL(querystring, parseInt(alm.page) + 1);\n\t\t\t\t\t\t\t\t\treveal.dataset.page = parseInt(alm.page) + 1;\n \n } else {\n\n if (alm.addons.seo) {\n // SEO [Page 1] \n reveal.setAttribute('class', 'alm-reveal' + seo_class + alm.tcc);\n reveal.dataset.url = alm.canonical_url + querystring;\n reveal.dataset.page = '1';\n \n } else {\n // Basic ALM \n reveal.setAttribute('class', 'alm-reveal' + alm.tcc); \n }\n\n }\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\treveal.innerHTML = alm.html;\n \n }\n \n }\n \n }\n \n\n // Append `reveal` div to ALM Listing container\n // Do not append when transtion == masonry OR init and !preloaded\n if (alm.transition !== 'masonry' || (alm.init && !alm.is_masonry_preloaded)) {\n\t \n\t if(!isPaged){ \t \n \t if(!alm.transition_container){ \n\t \t // No transition container \t \n \t if (alm.images_loaded === 'true') {\t \n \t imagesLoaded( reveal, function() {\n \t\t almAppendChildren(alm.listing, reveal);\n \t\t \n \t\t // Run srcSet polyfill\n\t\t\t\t\t\t\t\t\t\tsrcsetPolyfill(alm.listing, alm.ua);\n \t\t }); \t\t \n } else {\n almAppendChildren(alm.listing, reveal);\n \n // Run srcSet polyfill\n\t\t\t\t\t\t\t\t\tsrcsetPolyfill(alm.listing, alm.ua);\n } \t \n \t \n \t } else { \n\t \t // Standard container\t\n \t alm.listing.appendChild(reveal);\n \t \n \t }\t \t \t\n\t }\n\t \n }\n\t\t\t\t\t\n\t\t\t\t\t// *****\n // Transitions\t\n // *****\t\t\t\n\t\t\t\t\t\n\n // Masonry\n if (alm.transition === 'masonry') {\n alm.el = alm.listing;\n almMasonry(alm, alm.init, alm_is_filtering);\n alm.masonry_init = false;\n alm.AjaxLoadMore.transitionEnd();\n\n }\n \n // None\n else if (alm.transition === 'none') { \n if (alm.images_loaded === 'true') {\t \n\t imagesLoaded( reveal, function() {\n\t\t\t\t\t\t\t\talmFadeIn(reveal, 0);\n\t\t\t\t\t\t\t\talm.AjaxLoadMore.transitionEnd();\n\t\t });\n\t\t \n } else {\n almFadeIn(reveal, 0);\n alm.AjaxLoadMore.transitionEnd();\n }\n }\n \n // Fade transition (default)\n else {\n if (alm.images_loaded === 'true') {\t \n\t imagesLoaded( reveal, function() {\n\t\t if (alm.transition_container) {\n almFadeIn(reveal, alm.speed);\n }\n alm.AjaxLoadMore.transitionEnd();\n\t\t });\n\t\t \n } else {\n if (alm.transition_container) {\n almFadeIn(reveal, alm.speed);\n }\n alm.AjaxLoadMore.transitionEnd();\n }\n }\n \n \n // *****\n // TABS - Trigger almTabsSetHeight callback in Tabs add-on\n // *****\n\t\t\t\t\tif (typeof almTabsSetHeight === 'function') {\n\t\t\t\t\t\tif (alm.images_loaded === 'true') {\n \t\t\t\t\t\timagesLoaded( reveal, function() {\n \t\t\t\t\t\tsetTimeout(function(){\t \n almFadeIn(alm.listing, alm.speed);\n setTimeout(function(){ \n\t\t\t\t\t\t window.almTabsSetHeight(alm);\n }, alm.speed);\n\t\t\t\t\t\t }, alm.speed + 1);\n\t\t\t\t\t\t });\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetTimeout(function(){\n almFadeIn(alm.listing, alm.speed);\n setTimeout(function(){ \n\t\t\t\t\t window.almTabsSetHeight(alm);\n }, alm.speed);\n\t\t\t\t\t\t\t}, alm.speed + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\n } else {\n\n // Paging \n if (!alm.init) {\n\t \n\t if(pagingContent){ \n\t\t \n\t\t almFadeOut(pagingContent, alm.speed);\n \t\t\t \n \t\t\t pagingContent.style.outline = 'none'; \n \t\t alm.main.classList.remove('alm-loading');\t\t \n\n\t\t setTimeout(function(){\t\t\n \t\t \t\t\n\t\t\t\t\t\t\t\tpagingContent.style.opacity = 0;\n pagingContent.innerHTML = alm.html;\n \t\t\t\t\t\t\t\t\n\t\t\t imagesLoaded( pagingContent, function() { \t\t\t\t\t\t\t\t\n \t\t\t\t\t\t\t\t\n\t\t // Delay for effect \n\t alm.AjaxLoadMore.triggerAddons(alm);\n\t almFadeIn(pagingContent, alm.speed);\n\t \n\t // Remove opacity on element to fix CSS transition\n\t setTimeout(function(){\t \t \t\n\t\t \tpagingContent.style.opacity = '';\n\t\t }, parseInt(alm.speed) + 25); \n \t\t\t\t\t\t\t\t\n\t\t\t\t // Paging addon\n\t\t if (typeof almOnPagingComplete === 'function') {\n\t\t window.almOnPagingComplete(alm);\n\t\t } \t \n \t \n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\n\t\t }, parseInt(alm.speed) + 25); \n\t }\n\n } else {\n\t \n\t // almMasonry(alm, alm.init, alm_is_filtering);\n \n setTimeout(function(){\n alm.main.classList.remove('alm-loading');\n alm.AjaxLoadMore.triggerAddons(alm);\n }, alm.speed); \n\n }\n // End Paging\n\n }\n \n \n\t\t\t\t// almFiltersOnload [Filters Add-on hook]\n\t\t\t\tif(typeof almFiltersOnload === 'function' && alm.init){\n\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\twindow.almFiltersOnload(alm);\n\t\t\t\t\t}, parseInt(alm.speed) + 25);\n\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\n \n // ALM Complete / Nested\n if (alm.images_loaded === 'true') {\n imagesLoaded( reveal, function() {\n alm.AjaxLoadMore.nested(reveal); // Nested\t\t\t\t\t\t\n\t\t\t\t\t\tinsertScript.init(alm.el); // Run script inserter\n if (typeof almComplete === 'function') {\n \twindow.almComplete(alm);\n }\n });\n \n } else {\n alm.AjaxLoadMore.nested(reveal); // Nested\n\t\t\t\t\tinsertScript.init(alm.el); // Run script inserter\n if (typeof almComplete === 'function') {\n \twindow.almComplete(alm);\n }\n \n }\n // End ALM Complete / Nested\n \n\n // ALM Done\n if (!alm.addons.cache) {\n\t // Not Cache & Previous Post\n if (alm.posts >= alm.totalposts && !alm.addons.single_post) {\n alm.AjaxLoadMore.triggerDone();\n }\n } else { // Cache \n if (total < alm.posts_per_page) {\n alm.AjaxLoadMore.triggerDone();\n }\n }\n // End ALM Done\n\n\n } \n \n \n /*\n * No results from Ajax\n */\n else { \n\n if (!alm.addons.paging) {\n // Add .done class, reset btn text\n setTimeout(function() {\n alm.button.classList.remove('loading');\n alm.button.classList.add('done');\n }, alm.speed);\n alm.AjaxLoadMore.resetBtnText();\n }\n\n alm.AjaxLoadMore.triggerDone(); // ALM Done\n\n } \n\n\n // Destroy After\n if (alm.destroy_after !== undefined && alm.destroy_after !== '') {\n var currentPage = alm.page + 1; // Add 1 because alm.page starts at 0\n currentPage = (alm.addons.preloaded === 'true') ? currentPage++ : currentPage; // Add 1 for preloaded\n if (currentPage == alm.destroy_after) { // Disable ALM if page = alm.destroy_after val\n alm.AjaxLoadMore.destroyed();\n }\n }\n \n\t\t\t\n\t\t\t// Set Focus for A11y\n\t\t\tif(alm.transition_container && total > 0){\n\t\t\t\tif(alm.addons.paging){\n \t\t\t\t// Paging\n\t\t\t \tsetFocus(alm.init, alm.addons.preloaded, alm.listing, alm_is_filtering);\n\t\t\t \t\n\t\t\t } else if(alm.addons.single_post || alm.addons.nextpage){\n \t\t\t // Single Posts OR Next Page, set `init` to false to trigger focus\n\t\t \t setFocus(false, alm.addons.preloaded, reveal, alm_is_filtering);\n\t\t \t \n } else {\n // Standard ALM\n\t\t \t setFocus(alm.init, alm.addons.preloaded, reveal, alm_is_filtering); \n }\n\t\t\t} else if(!alm.transition_container && alm.container_type === 'table'){\n \t\t\t\n \t\t\t// Table Layout\n\t\t \tsetFocus(alm.init, alm.addons.preloaded, reveal[0], alm_is_filtering);\n\t\t\t}\n \n \n // Comment Reply Fix\n if(alm.addons.comments === 'true'){ \n commentReplyFix(alm.listing);\n } \n \n \n // Remove filtering class\n if(alm.main.classList.contains('alm-is-filtering')){\n alm.main.classList.remove('alm-is-filtering');\n } \n \n \n // Set flags\n alm_is_filtering = alm.init = false;\n\n };\n\n\t\t\n\n /**\n\t * pagingPreloadedInit\n * First run for Paging + Preloaded add-ons\n * Moves preloaded content into ajax container\n *\n * @param {data} Results of the Ajax request\n * @since 2.11.3\n */\n alm.AjaxLoadMore.pagingPreloadedInit = function(data) {\n\n data = (data == null) ? '' : data; // Check for null data object\n\n // Add paging containers and content\n\t alm.AjaxLoadMore.pagingInit(data, 'alm-reveal'); \n\n if (data === '') {\n if (typeof almPagingEmpty === 'function') {\n window.almPagingEmpty(alm);\n }\n if (typeof almEmpty === 'function') {\n window.almEmpty(alm);\n }\n if(alm.no_results){\n almNoResults(alm.content, alm.no_results);\n }\n }\n \n };\n\n\n\n /** \n\t * pagingNextpageInit\n * First run for Paging + Next Page add-ons\n * Moves .alm-nextpage content into ajax container\n *\n * @param {data} Results of Ajax request\n * @since 2.14.0\n */\n alm.AjaxLoadMore.pagingNextpageInit = function(data) {\n\t \n\t data = (data == null) ? '' : data; // Check for null data object\n\t \n\t // Add paging containers and content\n\t alm.AjaxLoadMore.pagingInit(data, 'alm-reveal alm-nextpage'); \n\t\t\t\n\t\t\t// Set up Nextpage Vars\n if (typeof almSetNextPageVars === 'function') {\n window.almSetNextPageVars(alm); // Next Page Add-on\n }\n \n };\n \n \n \n /**\n\t * pagingInit\n * First run for Paging + (Preloaded & Next Page) add-ons. Create required containers.\n *\n * @param {data} Ajax results\n * @param {classes} added classes\n * @since 5.0\n */\n alm.AjaxLoadMore.pagingInit = function(data, classes = 'alm-reveal'){\n\t \n\t data = (data == null) ? '' : data; // Check for null data object\n\t \n\t // Create `alm-reveal` container\n\t \tlet reveal = document.createElement('div');\n\t reveal.setAttribute('class', classes);\t \n\t \n\t // Create `alm-paging-loading` container\n\t let content = document.createElement('div');\n\t content.setAttribute('class', 'alm-paging-content' + alm.tcc);\t\n\t content.innerHTML = data; \t \n\t reveal.appendChild(content); \n\t \n\t // Create `alm-paging-content` container\n\t let loader = document.createElement('div');\n\t loader.setAttribute('class', 'alm-paging-loading');\t \t\n\t reveal.appendChild(loader); \n\t \n\t // Add div to container\n\t alm.listing.appendChild(reveal); \n \n // Get/Set height of .alm-listing div\n\t let styles = window.getComputedStyle(alm.listing);\n\t let pTop = parseInt(styles.getPropertyValue('padding-top').replace('px', ''));\n\t let pBtm = parseInt(styles.getPropertyValue('padding-bottom').replace('px', ''));\n\t let h = reveal.offsetHeight;\n\t \n\t // Set initial `.alm-listing` height\n alm.listing.style.height = h + pTop + pBtm + 'px'; \n \n // Reset button text\n alm.AjaxLoadMore.resetBtnText(); \n \n // Delay reveal of paging to avoid positioning issues\n setTimeout(function() {\t \n if (typeof almFadePageControls === 'function') {\n window.almFadePageControls(alm.btnWrap);\n }\n if (typeof almOnWindowResize === 'function') {\n window.almOnWindowResize(alm);\n } \t \n\t\t // Remove loading class from main container\n\t alm.main.classList.remove('loading'); \t\t\t\t\n }, alm.speed);\n \n };\n\n\n /**\n *\tnested\n *\tAutomatically trigger nested ALM instances (Requies `.alm-reveal` container\n *\n * @param {object} instance\n * @since 5.0\n */\n alm.AjaxLoadMore.nested = function(reveal) {\n\t if(!reveal || !alm.transition_container){\n\t\t return false; // Exit if not `transition_container`\n\t }\n let nested = reveal.querySelectorAll('.ajax-load-more-wrap'); // Get all instances from jQuery obj\n if (nested) {\n nested.forEach(function(element) {\n window.almInit(element);\n });\n }\n };\n\n\n\n /**\n\t * fetchingPreviousPost\n\t * Get the previous post ID via ajax\n\t *\n * @since 2.7.4\n */\n\n if (alm.addons.single_post_id) {\n alm.fetchingPreviousPost = false;\n alm.addons.single_post_init = true;\n }\n\n alm.AjaxLoadMore.getSinglePost = function() {\t\n\t \n\t\t\tlet action = 'alm_get_single'; \n\t \n\t if(alm.fetchingPreviousPost){\n\t\t return false;\n\t }\n\t \n alm.fetchingPreviousPost = true;\n \n // Get admin-ajax.php URL \n let ajaxURL = alm_localize.ajaxurl; \n \n\t\t\t// Get data params \n let params = {\n id: alm.addons.single_post_id,\n initial_id: alm.addons.single_post_init_id,\n order: alm.addons.single_post_order,\n taxonomy: alm.addons.single_post_taxonomy,\n excluded_terms: alm.addons.single_post_excluded_terms,\n post_type: alm.post_type,\n init: alm.addons.single_post_init,\n action: action\n };\n \n // Send HTTP request via Axios\n axios.get(ajaxURL, {params})\n .then(function(response){\n // Success\n \n let data = response.data; // Get data from response\n \n if (data.has_previous_post) {\n alm.listing.dataset.singlePostId = data.prev_id; // Update single-post-id on instance\n alm.addons.single_post_id = data.prev_id;\n alm.addons.single_post_permalink = data.prev_permalink;\n alm.addons.single_post_title = data.prev_title;\n alm.addons.single_post_slug = data.prev_slug;\n\n } else {\n if (!data.has_previous_post) {\n alm.AjaxLoadMore.triggerDone();\n }\n }\n if (typeof window.almSetSinglePost === 'function') {\n window.almSetSinglePost(alm, data.current_id, data.permalink, data.title);\n }\n alm.fetchingPreviousPost = false;\n alm.addons.single_post_init = false;\n \n })\n .catch(function (error) { \n // Error\n \n alm.AjaxLoadMore.error(error, 'getSinglePost');\n alm.fetchingPreviousPost = false; \n \t\t\t\t\t\n\t\t\t});\n\n };\n\n\n\n /**\n\t * triggerAddons\n *\n * Triggers various add-on functions (if available) after load complete.\n * @since 2.14.0\n */\n alm.AjaxLoadMore.triggerAddons = function(alm) {\n if (typeof almSEO === \"function\") { // SEO\n window.almSEO(alm, false);\n }\n if (typeof almSetNextPage === 'function') { // Next Page\n window.almSetNextPage(alm);\n } \n };\n\n\n\n /** \n\t * triggerDone\n *\n * Fires the almDone() function (if available).\n * @since 2.11.3\n */\n alm.AjaxLoadMore.triggerDone = function() {\n alm.loading = false;\n alm.finished = true;\n if (!alm.addons.paging) {\n alm.button.classList.add('done');\n alm.button.disabled = true;\n }\n if (typeof almDone === 'function') {\n // Delay done until animations complete\n setTimeout(function() {\n window.almDone(alm);\n }, alm.speed + 10);\n }\n };\n\n\n\n /** \n\t * resetBtnText\n\t * Resets the loading button text after loading has completed\n\t *\n * @since 2.8.4\n */\n alm.AjaxLoadMore.resetBtnText = function() {\n if (alm.button_loading_label !== false && !alm.addons.paging) { // Reset button text\n alm.button.innerHTML = alm.button_label;\n }\n };\n\n\n\n /** \n * Ajax Error\n * Error function after failed data\n * \n * @since 2.6.0\n */\n alm.AjaxLoadMore.error = function(error, location = null) {\n alm.loading = false;\n if (!alm.addons.paging) {\n alm.button.classList.remove('loading');\n alm.AjaxLoadMore.resetBtnText();\n }\n \n console.log('Error: ', error);\n if (error.response) {\n // The request was made and the server responded with a status code\n // that falls out of the range of 2xx\n //console.log(error.response.data);\n //console.log(error.response.status);\n //console.log(error.response.headers);\n console.log('Error Msg: ', error.message);\n } else if (error.request) {\n // The request was made but no response was received\n // `error.request` is an instance of XMLHttpRequest in the browser and an instance of\n // http.ClientRequest in node.js\n console.log(error.request);\n } else {\n // Something happened in setting up the request that triggered an Error\n console.log('Error Msg: ', error.message);\n }\n \n \n if(location){\n console.log('ALM Error started in '+ location);\n }\n\t\t\t\n\t\t\tif(error.config){\n \tconsole.log('ALM Error Debug: ', error.config);\n }\n \n };\n\n\n\n /** \n * click\n * Button click handler to load posts \n * \n * @since 4.2.0\n */\n alm.AjaxLoadMore.click = function(e) {\n let button = e.target || e.currentTarget;\n if (alm.pause === 'true') {\n alm.pause = false;\n alm.pause_override = false;\n alm.AjaxLoadMore.loadPosts();\n }\n if (!alm.loading && !alm.finished && !button.classList.contains('done')) {\n alm.loading = true;\n alm.page++;\n alm.AjaxLoadMore.loadPosts();\n }\n };\n\n\n\n /**\n\t * Button Click Event\n * Load more button click event \n * \n * @since 1.0.0\n */\n\n if (!alm.addons.paging && !alm.fetchingPreviousPost) {\n alm.button.onclick = alm.AjaxLoadMore.click;\n }\n\n\n\n /**\n\t * Window Resize\n * Add resize function for Paging & Tabs add-ons.\n * \n * @since 2.1.2\n * @updated 5.2\n */\n if (alm.addons.paging || alm.addons.tabs) {\n let resize;\n alm.window.onresize = function() {\n clearTimeout(resize);\n resize = setTimeout(function(e) {\n\t if(alm.addons.tabs){ // Tabs\n\t if (typeof almOnTabsWindowResize === 'function') {\n\t window.almOnTabsWindowResize(alm);\n\t }\n }\n\t if(alm.addons.paging){ // Paging\n\t if (typeof almOnWindowResize === 'function') {\n\t window.almOnWindowResize(alm);\n\t }\n }\n }, alm.speed);\n };\n }\n\n\n\n /**\n\t * isVisible\n * Check to see if element is visible before loading posts\n *\n * @since 2.1.2\n */\n\n alm.AjaxLoadMore.isVisible = function() {\n // Check for a width and height to determine visibility \n alm.visible = (alm.main.clientWidth > 0 && alm.main.clientHeight > 0) ? true : false;\n return alm.visible;\n };\n\n\n\n /**\n\t * scroll \n * Load posts as user scrolls the page\n *\n * @since 1.0\n * @updated 4.2.0\n */ \n alm.AjaxLoadMore.scroll = function() {\n\n if (alm.timer) {\n clearTimeout(alm.timer);\n }\n\n alm.timer = setTimeout(function() {\n if (alm.AjaxLoadMore.isVisible() && !alm.fetchingPreviousPost) {\n let trigger = alm.trigger.getBoundingClientRect();\n let btnPos = Math.round(trigger.top - alm.window.innerHeight) + alm.scroll_distance;\n let scrollTrigger = (btnPos <= 0) ? true : false;\n\n // Scroll Container\n if (alm.window !== window) {\n let scrollInstance = alm.window.querySelector('.ajax-load-more-wrap'); // ALM inside the container\n let scrollHeight = scrollInstance.offsetHeight; // ALM height\n let scrollPosition = Math.round(alm.window.scrollTop + alm.window.offsetHeight - alm.scroll_distance); // How far user has scrolled\t\n scrollTrigger = (scrollHeight <= scrollPosition) ? true : false;\n }\n\n // If Pause && Pause Override\n if (!alm.loading && !alm.finished && scrollTrigger && alm.page < (alm.max_pages - 1) && alm.proceed && alm.pause === 'true' && alm.pause_override === 'true') {\n alm.button.click();\n }\n\n // Standard Scroll\n else {\n if (!alm.loading && !alm.finished && scrollTrigger && alm.page < (alm.max_pages - 1) && alm.proceed && alm.pause !== 'true') {\n alm.button.click();\n }\n }\n }\n \n }, 25);\n };\n \n\n // Add scroll eventlisteners, only when needed\n if (alm.scroll && !alm.addons.paging) {\n if (alm.scroll_container !== '') { // Scroll Container \n alm.window = (document.querySelector(alm.scroll_container)) ? document.querySelector(alm.scroll_container) : alm.window;\n }\n alm.window.addEventListener('scroll', alm.AjaxLoadMore.scroll); // Scroll\n alm.window.addEventListener('touchstart', alm.AjaxLoadMore.scroll); // Touch Devices\n alm.window.addEventListener('wheel', function(e) { // Mousewheel\n\t\t\t\tlet direction = Math.sign(e.deltaY);\n\t\t\t\tif(direction > 0){\n\t\t\t\t\talm.AjaxLoadMore.scroll();\n\t\t\t\t}\n\t\t\t});\n\t\t\talm.window.addEventListener('keyup', function(e) { // End, Page Down\n\t\t\t\tlet code = (e.keyCode ? e.keyCode : e.which);\n\t\t\t\tswitch (code) {\n\t\t\t\t\tcase 35 :\n\t\t\t\t\tcase 34 :\n\t\t\t\t\t\talm.AjaxLoadMore.scroll();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n \n \n }\n \n \n \n /** \n\t * destroyed\n * Destroy Ajax Load More functionality\n * \n * @since 3.4.2\n */\n alm.AjaxLoadMore.destroyed = function() {\n alm.disable_ajax = true;\n if (!alm.addons.paging) {\n alm.button.style.display = 'none';\n alm.AjaxLoadMore.triggerDone();\n if (typeof almDestroyed === 'function') {\n window.almDestroyed(alm);\n }\n }\n };\n\n\n\n /** \n\t * transitionEnd\n * Set variables after loading transiton completes\n *\n * @since 3.5 \n */\n alm.AjaxLoadMore.transitionEnd = function() { \n setTimeout(function() {\n\t alm.AjaxLoadMore.resetBtnText();\n alm.main.classList.remove('alm-loading');\n alm.button.classList.remove('loading'); // Loading button\n alm.AjaxLoadMore.triggerAddons(alm);\n if (!alm.addons.paging) {\n setTimeout(function() { \n alm.loading = false; // Delay to prevent loading to fast\n }, alm.speed * 3 ); \n }\n }, 100);\n hidePlaceholder(alm);\n };\n\n\n\n /** \n\t * setLocalizedVar\n * Set induvidual localized variable\n *\n * @param {string} name \n * @param {string} value \n * @since 4.1 \n */\n alm.AjaxLoadMore.setLocalizedVar = function(name = '', value = '') {\n if (alm.localize && name !== '' && value !== '') {\n alm.localize[name] = value.toString(); // Set ALM localize var\n window[alm.master_id + '_vars'][name] = value.toString(); // Update global window obj vars\n }\n };\n \n \n \n\t\t/**\n\t\t* getQueryVariable\n\t\t* Get querysting value\n\t\t*\n\t\t* @param {String} variable\n\t\t* @since 5.0\n\t\t*/\n\t\talm.AjaxLoadMore.getQueryVariable = function(variable) {\n\t\t\tvar query = window.location.search.substring(1);\n\t\t\tvar vars = query.split('&');\n\t\t\tfor (var i = 0; i < vars.length; i++) {\n\t\t\t\tvar pair = vars[i].split('=');\n\t\t\t\tif (decodeURIComponent(pair[0]) == variable) {\n\t\t\t\t\treturn decodeURIComponent(pair[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n \n \n \n\t\t/**\n\t\t* buildFilterURL\n\t\t* Build new paging URL for filters\n\t\t*\n\t\t* @param {String} querystring\n\t\t* @param {Number} page\n\t\t* @since 5.0\n\t\t*/\n\t\talm.AjaxLoadMore.buildFilterURL = function(querystring = '', page = 0) {\n\t\t\tlet qs = querystring;\t\n\t\t\t\n\t\t\tif(alm.addons.filters_paging){\t\n \t\t\t\t\t\t\t\n \t\t\tif(page > 1){ \n \t\t\t\t// Paged\n if(qs){\n // If already has `pg` in querystring\n if (alm.AjaxLoadMore.getQueryVariable('pg')) {\n qs = querystring.replace(/(pg=)[^\\&]+/, '$1' + page);\t\t\t\t \n } else {\n qs = querystring + '&pg=' + page;\n } \n \n } else {\t\t\t \n qs = '?pg=' + page;\n }\n } else { \n \t // Not Paged\t \n \t qs = querystring.replace(/(pg=)[^\\&]+/, '');\t \n \t qs = (qs === '?') ? '' : qs; // Remove `?` if only symbol in querystring\n \t qs = (qs[qs.length -1] === '&') ? qs.slice(0, -1) : qs; // Remove trailing `&` symbols\n \t \n } \n } \n \n return qs; \n\t\t};\n\n\n\n /** \n * Init Ajax load More\n * Load posts as user scrolls the page\n * \n * @since 2.0 \n */\n alm.AjaxLoadMore.init = function() {\n\n // Preloaded and destroy_after is 1 \n if (alm.addons.preloaded === 'true' && alm.destroy_after == 1) {\n alm.AjaxLoadMore.destroyed();\n }\n\n if (!alm.addons.paging && !alm.addons.single_post) {\n if (alm.disable_ajax) {\n alm.finished = true;\n alm.button.classList.add('done');\n } else {\n if (alm.pause === 'true') {\n alm.button.innerHTML = alm.button_label;\n alm.loading = false;\n } else {\n alm.AjaxLoadMore.loadPosts();\n }\n }\n }\n\n // Previous Post Add-on\n if (alm.addons.single_post) {\n alm.AjaxLoadMore.getSinglePost(); // Set next post on load\n alm.loading = false;\n }\n\n\n // Preloaded + SEO && !Paging\n if (alm.addons.preloaded === 'true' && alm.addons.seo && !alm.addons.paging) {\n // Delay for scripts to load\n setTimeout(function() {\n if (typeof almSEO === \"function\" && alm.start_page < 1) {\n window.almSEO(alm, true);\n }\n }, alm.speed);\n }\n\n\n // Preloaded && !Paging\n if (alm.addons.preloaded === 'true' && !alm.addons.paging) {\n // Delay for scripts to load\n setTimeout(function() {\n // triggerDone\n if (alm.addons.preloaded_total_posts <= parseInt(alm.addons.preloaded_amount)) {\n alm.AjaxLoadMore.triggerDone();\n }\n // almEmpty\n if (alm.addons.preloaded_total_posts == 0) {\n if (typeof almEmpty === 'function') {\n window.almEmpty(alm);\n }\n if(alm.no_results){\n\t\t almNoResults(alm.content, alm.no_results);\n\t }\n }\n }, alm.speed);\n\n }\n \n\t\t\t\n\t\t\t// Preloaded Add-on ONLY\n if (alm.addons.preloaded === 'true') {\n if (alm.resultsText) {\n\t resultsText.almInitResultsText(alm, 'preloaded');\n }\n }\n\n\n // Next Page Add-on\n if (alm.addons.nextpage) {\n\t \t \n\t \t// Check that posts remain on load\n if (alm.listing.querySelector('.alm-nextpage') && !alm.addons.paging) {\n var alm_nextpage_pages = alm.listing.querySelectorAll('.alm-nextpage'),\n alm_nextpage_total = alm.listing.querySelector('.alm-nextpage:first-child');\n \n if(alm_nextpage_total && alm_nextpage_pages){\n\t alm_nextpage_total = alm_nextpage_total.dataset.totalPosts;\n\t alm_nextpage_pages = alm_nextpage_pages.length; \n\t\t\t\t\t\t\n\t\t\t\t\t\t// Disable if on last page\n\t if (alm_nextpage_pages == alm_nextpage_total) {\n\t alm.AjaxLoadMore.triggerDone();\n\t }\n }\n } \n \n if (alm.resultsText) {\n resultsText.almInitResultsText(alm, 'nextpage');\n }\n \n }\n\n\n // Window Load (Masonry + Preloaded)\n alm.window.addEventListener('load', function() {\n if (alm.is_masonry_preloaded) {\n almMasonry(alm, true, false);\n alm.masonry_init = false;\n }\n\t\t\t\tif (typeof almOnLoad === 'function') {\n\t\t\t\t\twindow.almOnLoad(alm);\n\t\t\t\t}\n });\n\n };\n\n\n // Init Ajax Load More\n alm.AjaxLoadMore.init();\n\n\n // Flag to prevent unnecessary loading of posts on initial page load.\n setTimeout(function() {\n alm.proceed = true;\n }, alm.speed);\n\n\n\n /** \n\t * almUpdateCurrentPage\n * Update current page - triggered from paging add-on\n *\n * @since 2.7.0\n */\n window.almUpdateCurrentPage = function(current, obj, alm) {\n\n alm.page = current; \n alm.page = (alm.addons.nextpage && !alm.addons.paging) ? alm.page - 1 : alm.page; // Next Page add-on\n\n let data = '';\n let target = ''; \n \n if (alm.addons.paging_init && alm.addons.preloaded === 'true') {\n // Paging + Preloaded Firstrun\n target = alm.listing.querySelector('.alm-reveal') || alm.listing.querySelector('.alm-nextpage');\n if(target){\n data = target.innerHTML; // Get content \n target.parentNode.removeChild(target); // Remove target \n alm.addons.preloaded_amount = 0; // Reset preloaded\n alm.AjaxLoadMore.pagingPreloadedInit(data);\n }\n alm.addons.paging_init = false;\n alm.init = false;\n\n } else if (alm.addons.paging_init && alm.addons.nextpage) {\n // Paging + Next Page on firstrun\n target = alm.listing.querySelector('.alm-reveal') || alm.listing.querySelector('.alm-nextpage');\n if(target){\n data = target.innerHTML; // Get content \n target.parentNode.removeChild(target); // Remove target\n alm.AjaxLoadMore.pagingNextpageInit(data);\n }\n alm.addons.paging_init = false;\n alm.init = false;\n\n } else {\n // Standard Paging\n alm.AjaxLoadMore.loadPosts();\n\n }\n \n };\n\n\n\n /** \n\t * almGetParentContainer\n * return the parent ALM container\n *\n * @since 2.7.0\n * @return element\n */\n window.almGetParentContainer = function() {\n return alm.listing;\n };\n\n\n\n /**\n\t * almGetObj\n * Returns the current ALM obj\n *\n * @param {string} specific obj\n * @since 2.7.0\n * @return object\n */\n window.almGetObj = function(obj = '') {\n\t if(obj !== ''){\n\t\t return alm[obj]; // Return specific param\n\t } else {\n\t\t return alm; // Return the entire alm object\n\t }\n \n };\n\n\n\n /**\n\t * almTriggerClick\n * Trigger ajaxloadmore from any element on page\n *\n * @since 2.12.0\n */\n window.almTriggerClick = function() {\n alm.button.click();\n };\n\n\n };\n\n // End ajaxloadmore \n \n\n\n /** \n * almInit\n * Initiate instance of Ajax load More\n *\n * @since 5.0\n */\n window.almInit = function(el, id = 0) {\n new ajaxloadmore(el, id);\n }; \n\n\n\n /**\n * Initiate Ajax load More if div is present on screen\n * @since 2.1.2\n */\n\n let alm_instances = document.querySelectorAll('.ajax-load-more-wrap');\n if (alm_instances.length) {\n [...alm_instances].forEach((alm, e) => {\n new ajaxloadmore(alm, e);\n });\n }\n\n})();\n\n\n\n/** \n * filter\n * Filter an Ajax Load More instance\n * \n * @since 5.0\n * @param {*} transition\n * @param {*} speed\n * @param {*} data\n */\nlet filter = function(transition = 'fade', speed = '200', data = '') {\n if (!transition || !speed || !data) {\n return false;\n }\n alm_is_filtering = true;\n almFilter(transition, speed, data, 'filter');\n};\nexport { filter };\n\n\n\n/** \n * tab\n * Tabbed content for Ajax Load More instance\n * \n * @since 5.2\n * @param {*} data\n * @param {*} url\n */\nlet tab = function(data = '', url = false) {\n\t\n\tlet transition = 'fade';\n\tlet speed = (alm_localize.speed) ? parseInt(alm_localize.speed) : 200;\n\t\n if (!data) {\n return false;\n }\n \n alm_is_filtering = true;\n almFilter(transition, speed, data, 'tab');\n \n};\nexport { tab };\n\n\n\n/** \n * tracking\n * Track Page Views in Google Analytics\n *\n * @since 5.0\n * @param {*} path\n */\n\nlet tracking = function(path) {\n if (typeof gtag === 'function') { // Gtag GA Tracking\n gtag('event', 'page_view', {\n 'page_path': path\n });\n if(alm_localize.ga_debug){\n console.log('Pageview sent to Google Analytics (gtag)');\n }\n }\n if (typeof ga === 'function') { // Deprecated GA Tracking\n ga('send', 'pageview', path);\n if(alm_localize.ga_debug){\n console.log('Pageview sent to Google Analytics (ga)');\n }\n }\n if (typeof __gaTracker === 'function') { // Monster Insights\n __gaTracker('send', 'pageview', path);\n if(alm_localize.ga_debug){\n console.log('Pageview sent to Google Analytics (__gaTracker)');\n }\n } \n \n // Dispatch global Analytics callback\n if (typeof almAnalytics === 'function') {\n window.almAnalytics(path);\n }\n}; \nexport { tracking };\n\n\n\n/** \n * start\n * Trigger Ajax Load More from other events\n * \n * @since 5.0\n * @param {*} el\n */\nlet start = function(el) {\n if (!el) {\n return false;\n }\n window.almInit(el);\n};\nexport { start };\n\n\n\n/** \n * almScroll\n * Scroll window to position (global function)\n *\n * @since 5.0\n * @param {*} position\n */\nlet almScroll = function(position) {\n if (!position) {\n return false;\n }\n window.scrollTo({\n top: position,\n behavior: 'smooth'\n });\n};\nexport { almScroll };\n\n\n\n/** \n * getOffset\n * Get the current top/left coordinates of an element relative to the document.\n *\n * @since 5.0\n * @param {*} el\n */\nlet getOffset = function(el = null){\n\tif(!el){\n\t\treturn false;\n\t}\n\tlet rect = el.getBoundingClientRect(),\n scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,\n scrollTop = window.pageYOffset || document.documentElement.scrollTop;\n return { top: rect.top + scrollTop, left: rect.left + scrollLeft }\n};\nexport { getOffset };\n\n\n\n/** \n * almScroll\n * Scroll window to position (global function)\n *\n * @since 5.0\n * @param {*} position\n */\nlet render = function(el, options = null) {\n if (!el) {\n return false;\n }\n // console.log(el, options);\n};\nexport { render };\n","/**\n * Append a child element to a container\n *\n * @param {*} target | Target element to append items\n * @param {*} element | The element to append\n * @param {*} transition | The transiton\n * @since 5.0\n */\n \nlet nodeNameArray = ['#text', '#comment'];\n\nlet almAppendChild = function( target = null, element = null, transition = 'fade' ) {\n\tif(!target || !element){\n\t\treturn false; \n\t}\t\n\t\n\t// Do not append elements that are not actual element nodes (i.e. #text node)\n\t// Add item if not in exclude array\n\tif(nodeNameArray.indexOf(element.nodeName.toLowerCase()) === -1){\t\t\n\t\tif(transition === 'masonry'){ // If Masonry, opacity = zero\n\t\t\telement.style.opacity = 0;\n\t\t}\n\t\ttarget.appendChild(element);\n\t}\n};\nexport default almAppendChild;","import almAppendChild from './almAppendChild';\n/**\n * Loop array of elements and append to target\n *\n * @param {*} target | Target element to append items\n * @param {*} array | An array of elements\n * @param {*} transition | The transiton\n * @since 5.0\n */\n \nlet almAppendChildren = function( target = null, array = null, transition = 'fade' ) {\n\tif(!target || !array){\n\t\treturn false;\n\t}\t\n\tfor (var i = 0; i < array.length; i++) {\t\n\t\tlet element = array[i];\t\t\n\t\talmAppendChild(target, element, transition);\t\t\n\t}\n};\nexport default almAppendChildren;","/**\n * Convert a plain text string into an array of HTML nodes\n *\n * @param {*} html | The HTML string\n * @param {*} type\n * @return array\n * @since 5.0\n */\nlet almDomParser = function( html = '', type = 'text/html' ) {\n\tif(!html){\n \treturn false;\n\t}\n let parser = new DOMParser(); \n let data = parser.parseFromString(html, type);\t\t\t\t\t\t\t\n return (data) ? Array.prototype.slice.call(data.body.childNodes) : data;\t\n};\nexport default almDomParser;\n","/**\n * Generate the cache page URL for GET request\n *\n * @param {*} el | Target element to append items\n * @param {*} array | An array of elements\n * @since 5.0\n */\nlet almGetCacheUrl = function( alm ) {\n \n if(!alm){\n return false;\n }\n \n\tlet cache_url = '';\n\tlet ext = '.html';\n\t\n if (alm.init && alm.addons.seo && alm.isPaged) {\n // SEO Add-on\n // If the request is a paged URL (/page/3/)\n let firstpage = '1';\n cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + firstpage + '-' + alm.start_page + ext;\n \n } else if (alm.addons.nextpage) {\n // Nextpage add-on\n let nextpage_cache_url;\n if (alm.addons.paging) {\n nextpage_cache_url = parseInt(alm.page) + 1;\n } else {\n nextpage_cache_url = parseInt(alm.page) + 2;\n if (alm.isPaged) {\n // If the request a paged URL (/page/3/)\n nextpage_cache_url = parseInt(alm.page) + parseInt(alm.addons.nextpage_startpage) + 1;\n }\n }\n cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + nextpage_cache_url + ext;\n \n } else if (alm.addons.single_post) {\n // Previous Post\n cache_url = alm.addons.cache_path + alm.addons.cache_id + '/' + alm.addons.single_post_id + ext;\n \n } else {\n // Standard URL request\n cache_url = alm.addons.cache_path + alm.addons.cache_id + '/page-' + (alm.page + 1) + ext;\n \n }\n \n return cache_url;\n};\n\nexport default almGetCacheUrl;","/**\n * Wrap `table` containers in tbody elements\n * innerHTML and DOMParser do not work with <tr/> <td/> elements etc.\n *\n * @param {*} html | Plain text\n * @since 5.0\n */\nlet almTableWrap = function( html = null ) {\n if(!html){\n return false;\n }\n\tlet table_reveal = document.createElement('tbody');\n table_reveal.innerHTML = html;\n let table_reveal_array = [table_reveal];\n return table_reveal_array; // Return new array\n};\nexport default almTableWrap;","/**\n * commentReplyFix\n * Hotfix for Reply links not working in WordPress 5.1+\n * \n * @param listing object\n * @since 5.1\n */\nlet commentReplyFix = function( listing = null ) {\n \n // Get all `Reply` links.\n let replyLinks = listing.querySelectorAll('.comment-reply-link'); \n if(!replyLinks){\n return false;\n }\n \n // Loop links\n replyLinks.forEach(function(link){\n \n // Add custom click handler\n link.onclick = function(e) { \n \n e.preventDefault();\n \n let commId = link.dataset.belowelement,\n parentId = link.dataset.commentid,\n respondId = link.dataset.respondelement,\n postId = link.dataset.postid,\n follow;\n \n if ( ! commId || ! parentId || ! respondId || ! postId ) {\n /*\n * Theme or plugin defines own link via custom `wp_list_comments()` callback \n * and calls `moveForm()` either directly or via a custom event hook. \n */ \n return;\n \n }\n \n // Move reply form\n follow = window.addComment.moveForm(commId, parentId, respondId, postId);\n if (false === follow) {\n event.preventDefault(); \n }\n \n };\n \n }); \n \n};\nexport default commentReplyFix;","let getParameterByName = function( name, url ) {\n if (!url) url = window.location.href;\n name = name.replace(/[\\[\\]]/g, \"\\\\$&\");\n var regex = new RegExp(\"[?&]\" + name + \"(=([^&#]*)|&|#|$)\"),\n results = regex.exec(url);\n if (!results) return null;\n if (!results[2]) return '';\n return decodeURIComponent(results[2].replace(/\\+/g, \" \"));\n};\nexport default getParameterByName;","// Prevent native browser scrolling on popstate\n// https://developer.mozilla.org/en-US/docs/Web/API/History#Browser_compatibility\nif ('scrollRestoration' in history) {\n\t//history.scrollRestoration = 'manual';\n}\n\n\n// Object.entries\nif (!Object.entries){\n Object.entries = function( obj ){\n var ownProps = Object.keys( obj ),\n i = ownProps.length,\n resArray = new Array(i); // preallocate the Array\n while (i--)\n resArray[i] = [ownProps[i], obj[ownProps[i]]];\n\n return resArray;\n };\n} \n\n\n// isArray\nif (typeof Array.isArray === 'undefined') {\n Array.isArray = function(obj) {\n return Object.prototype.toString.call(obj) === '[object Array]';\n }\n};\n\n\n// Array.from\nif (!Array.from) {\n Array.from = (function () {\n var toStr = Object.prototype.toString;\n var isCallable = function (fn) {\n return typeof fn === 'function' || toStr.call(fn) === '[object Function]';\n };\n var toInteger = function (value) {\n var number = Number(value);\n if (isNaN(number)) { return 0; }\n if (number === 0 || !isFinite(number)) { return number; }\n return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));\n };\n var maxSafeInteger = Math.pow(2, 53) - 1;\n var toLength = function (value) {\n var len = toInteger(value);\n return Math.min(Math.max(len, 0), maxSafeInteger);\n };\n\n // The length property of the from method is 1.\n return function from(arrayLike/*, mapFn, thisArg */) {\n // 1. Let C be the this value.\n var C = this;\n\n // 2. Let items be ToObject(arrayLike).\n var items = Object(arrayLike);\n\n // 3. ReturnIfAbrupt(items).\n if (arrayLike == null) {\n throw new TypeError('Array.from requires an array-like object - not null or undefined');\n }\n\n // 4. If mapfn is undefined, then let mapping be false.\n var mapFn = arguments.length > 1 ? arguments[1] : void undefined;\n var T;\n if (typeof mapFn !== 'undefined') {\n // 5. else\n // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n if (!isCallable(mapFn)) {\n throw new TypeError('Array.from: when provided, the second argument must be a function');\n }\n\n // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.\n if (arguments.length > 2) {\n T = arguments[2];\n }\n }\n\n // 10. Let lenValue be Get(items, \"length\").\n // 11. Let len be ToLength(lenValue).\n var len = toLength(items.length);\n\n // 13. If IsConstructor(C) is true, then\n // 13. a. Let A be the result of calling the [[Construct]] internal method\n // of C with an argument list containing the single item len.\n // 14. a. Else, Let A be ArrayCreate(len).\n var A = isCallable(C) ? Object(new C(len)) : new Array(len);\n\n // 16. Let k be 0.\n var k = 0;\n // 17. Repeat, while k < len… (also steps a - h)\n var kValue;\n while (k < len) {\n kValue = items[k];\n if (mapFn) {\n A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);\n } else {\n A[k] = kValue;\n }\n k += 1;\n }\n // 18. Let putStatus be Put(A, \"length\", len, true).\n A.length = len;\n // 20. Return A.\n return A;\n };\n }());\n}\n\n\n// Nodelist\nif (window.NodeList && !NodeList.prototype.forEach) {\n\tNodeList.prototype.forEach = function (callback, thisArg) {\n\t\t thisArg = thisArg || window;\n\t\t for (var i = 0; i < this.length; i++) {\n\t\t\t callback.call(thisArg, this[i], i, this);\n\t\t }\n\t};\n}\n\n\n// removeChild\n// https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md\n(function (arr) {\n\tarr.forEach(function (item) {\n\t if (item.hasOwnProperty('remove')) {\n\t\t return;\n\t }\n\t Object.defineProperty(item, 'remove', {\n\t\t configurable: true,\n\t\t enumerable: true,\n\t\t writable: true,\n\t\t value: function remove() {\n\t\t\tif (this.parentNode !== null)\n\t\t\t this.parentNode.removeChild(this);\n\t\t }\n\t });\n\t});\n})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);\n","/**\n * Add dataset support to elements\n * No globals, no overriding prototype with non-standard methods, \n * handles CamelCase properly, attempts to use standard \n * Object.defineProperty() (and Function bind()) methods, \n * falls back to native implementation when existing\n * Inspired by http://code.eligrey.com/html5/dataset/ \n * (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )\n * Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)\n * All code below is Licensed under the X11/MIT License\n*/\nif (!Function.prototype.bind) {\n Function.prototype.bind = function (oThis) {\n 'use strict';\n if (typeof this !== \"function\") {\n // closest thing possible to the ECMAScript 5 internal IsCallable function\n throw new TypeError(\"Function.prototype.bind - what is trying to be bound is not callable\");\n }\n\n var aArgs = Array.prototype.slice.call(arguments, 1),\n fToBind = this,\n FNOP = function () {},\n fBound = function () {\n return fToBind.apply(\n this instanceof FNOP && oThis ? this : oThis,\n aArgs.concat(Array.prototype.slice.call(arguments))\n );\n };\n\n FNOP.prototype = this.prototype;\n fBound.prototype = new FNOP();\n\n return fBound;\n };\n}\n\n/*\n * Xccessors Standard: Cross-browser ECMAScript 5 accessors\n * http://purl.eligrey.com/github/Xccessors\n * \n * 2010-06-21\n * \n * By Eli Grey, http://eligrey.com\n * \n * A shim that partially implements Object.defineProperty,\n * Object.getOwnPropertyDescriptor, and Object.defineProperties in browsers that have\n * legacy __(define|lookup)[GS]etter__ support.\n * \n * Licensed under the X11/MIT License\n * See LICENSE.md\n*/\n\n(function () {\n 'use strict';\n var ObjectProto = Object.prototype,\n defineGetter = ObjectProto.__defineGetter__,\n defineSetter = ObjectProto.__defineSetter__,\n lookupGetter = ObjectProto.__lookupGetter__,\n lookupSetter = ObjectProto.__lookupSetter__,\n hasOwnProp = ObjectProto.hasOwnProperty;\n \n if (defineGetter && defineSetter && lookupGetter && lookupSetter) {\n\n if (!Object.defineProperty) {\n Object.defineProperty = function (obj, prop, descriptor) {\n if (arguments.length < 3) { // all arguments required\n throw new TypeError(\"Arguments not optional\");\n }\n \n prop += \"\"; // convert prop to string\n\n if (hasOwnProp.call(descriptor, \"value\")) {\n if (!lookupGetter.call(obj, prop) && !lookupSetter.call(obj, prop)) {\n // data property defined and no pre-existing accessors\n obj[prop] = descriptor.value;\n }\n\n if ((hasOwnProp.call(descriptor, \"get\") ||\n hasOwnProp.call(descriptor, \"set\"))) \n {\n // descriptor has a value prop but accessor already exists\n throw new TypeError(\"Cannot specify an accessor and a value\");\n }\n }\n\n // can't switch off these features in ECMAScript 3\n // so throw a TypeError if any are false\n if (!(descriptor.writable && descriptor.enumerable && \n descriptor.configurable))\n {\n throw new TypeError(\n \"This implementation of Object.defineProperty does not support\" +\n \" false for configurable, enumerable, or writable.\"\n );\n }\n \n if (descriptor.get) {\n defineGetter.call(obj, prop, descriptor.get);\n }\n if (descriptor.set) {\n defineSetter.call(obj, prop, descriptor.set);\n }\n \n return obj;\n };\n }\n\n if (!Object.getOwnPropertyDescriptor) {\n Object.getOwnPropertyDescriptor = function (obj, prop) {\n if (arguments.length < 2) { // all arguments required\n throw new TypeError(\"Arguments not optional.\");\n }\n \n prop += \"\"; // convert prop to string\n\n var descriptor = {\n configurable: true,\n enumerable : true,\n writable : true\n },\n getter = lookupGetter.call(obj, prop),\n setter = lookupSetter.call(obj, prop);\n\n if (!hasOwnProp.call(obj, prop)) {\n // property doesn't exist or is inherited\n return descriptor;\n }\n if (!getter && !setter) { // not an accessor so return prop\n descriptor.value = obj[prop];\n return descriptor;\n }\n\n // there is an accessor, remove descriptor.writable;\n // populate descriptor.get and descriptor.set (IE's behavior)\n delete descriptor.writable;\n descriptor.get = descriptor.set = undefined;\n \n if (getter) {\n descriptor.get = getter;\n }\n if (setter) {\n descriptor.set = setter;\n }\n \n return descriptor;\n };\n }\n\n if (!Object.defineProperties) {\n Object.defineProperties = function (obj, props) {\n var prop;\n for (prop in props) {\n if (hasOwnProp.call(props, prop)) {\n Object.defineProperty(obj, prop, props[prop]);\n }\n }\n };\n }\n }\n}());\n\n// Begin dataset code\n\nif (!document.documentElement.dataset && \n // FF is empty while IE gives empty object\n (!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset') ||\n !Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get)\n ) {\n var propDescriptor = {\n enumerable: true,\n get: function () {\n 'use strict';\n var i, \n that = this,\n HTML5_DOMStringMap, \n attrVal, attrName, propName,\n attribute,\n attributes = this.attributes,\n attsLength = attributes.length,\n toUpperCase = function (n0) {\n return n0.charAt(1).toUpperCase();\n },\n getter = function () {\n return this;\n },\n setter = function (attrName, value) {\n return (typeof value !== 'undefined') ? \n this.setAttribute(attrName, value) : \n this.removeAttribute(attrName);\n };\n try { // Simulate DOMStringMap w/accessor support\n // Test setting accessor on normal object\n ({}).__defineGetter__('test', function () {});\n HTML5_DOMStringMap = {};\n }\n catch (e1) { // Use a DOM object for IE8\n HTML5_DOMStringMap = document.createElement('div');\n }\n for (i = 0; i < attsLength; i++) {\n attribute = attributes[i];\n // Fix: This test really should allow any XML Name without \n // colons (and non-uppercase for XHTML)\n if (attribute && attribute.name && \n (/^data-\\w[\\w\\-]*$/).test(attribute.name)) {\n attrVal = attribute.value;\n attrName = attribute.name;\n // Change to CamelCase\n propName = attrName.substr(5).replace(/-./g, toUpperCase);\n try {\n Object.defineProperty(HTML5_DOMStringMap, propName, {\n enumerable: this.enumerable,\n get: getter.bind(attrVal || ''),\n set: setter.bind(that, attrName)\n });\n }\n catch (e2) { // if accessors are not working\n HTML5_DOMStringMap[propName] = attrVal;\n }\n }\n }\n return HTML5_DOMStringMap;\n }\n };\n try {\n // FF enumerates over element's dataset, but not \n // Element.prototype.dataset; IE9 iterates over both\n Object.defineProperty(Element.prototype, 'dataset', propDescriptor);\n } catch (e) {\n propDescriptor.enumerable = false; // IE8 does not allow setting to true\n Object.defineProperty(Element.prototype, 'dataset', propDescriptor);\n }\n}","/**\n * almGetAjaxParams\n * Build the data object to send with the Ajax request\n * \n * @param alm object\n * @param action string\n * @param queryType string \n * @since 3.6\n */\n\nexport function almGetAjaxParams(alm, action, queryType){\n\t\n\t// Defaults\n\tlet data = {\n id\t\t\t\t\t\t\t: alm.id,\n post_id\t\t\t\t\t: alm.post_id,\n slug : alm.slug,\n canonical_url : encodeURIComponent(alm.canonical_url),\n posts_per_page : alm.posts_per_page,\n page \t\t: alm.page,\n offset : alm.offset,\n post_type\t\t\t\t: alm.post_type,\n repeater\t\t\t\t\t: alm.repeater,\n seo_start_page \t: alm.start_page\n }; \n \n \n // Addons & Extensions\n if(alm.theme_repeater){\n data.theme_repeater = alm.theme_repeater;\n } \n if(alm.addons.paging){\n data.paging = alm.addons.paging;\n } \n if(alm.addons.preloaded){\n data.preloaded = alm.addons.preloaded;\n data.preloaded_amount = alm.addons.preloaded_amount;\n }\n if(alm.addons.cache === 'true'){\n data.cache_id = alm.addons.cache_id;\n data.cache_logged_in = alm.addons.cache_logged_in;\n }\t \n if(alm.acf_array){\n data.acf = alm.acf_array;\n } \n if(alm.cta_array){\n data.cta = alm.cta_array;\n } \n if(alm.comments_array){\n data.comments = alm.comments_array;\n } \n if(alm.nextpage_array){\n data.nextpage = alm.nextpage_array;\n } \n if(alm.single_post_array){\n data.single_post = alm.single_post_array;\n }\n if(alm.users_array){\n data.users = alm.users_array;\n }\n \n \n // Query data \n if(alm.listing.dataset.lang){\n data.lang = alm.listing.dataset.lang;\n }\n if(alm.listing.dataset.stickyPosts){\n data.sticky_posts = alm.listing.dataset.stickyPosts;\n }\n if(alm.listing.dataset.postFormat){\n data.post_format = alm.listing.dataset.postFormat;\n }\n if(alm.listing.dataset.category){\n data.category = alm.listing.dataset.category;\n }\n if(alm.listing.dataset.categoryAnd){\n data.category__and = alm.listing.dataset.categoryAnd;\n }\n if(alm.listing.dataset.categoryNotIn){\n data.category__not_in = alm.listing.dataset.categoryNotIn;\n }\n if(alm.listing.dataset.tag){\n data.tag = alm.listing.dataset.tag;\n }\n if(alm.listing.dataset.tagAnd){\n data.tag__and = alm.listing.dataset.tagAnd;\n }\n if(alm.listing.dataset.tagNotIn){\n data.tag__not_in = alm.listing.dataset.tagNotIn;\n }\n if(alm.listing.dataset.taxonomy){\n data.taxonomy = alm.listing.dataset.taxonomy;\n }\n if(alm.listing.dataset.taxonomyTerms){\n data.taxonomy_terms = alm.listing.dataset.taxonomyTerms;\n }\n if(alm.listing.dataset.taxonomyOperator){\n data.taxonomy_operator = alm.listing.dataset.taxonomyOperator;\n }\n if(alm.listing.dataset.taxonomyRelation){\n data.taxonomy_relation = alm.listing.dataset.taxonomyRelation;\n }\n if(alm.listing.dataset.metaKey){\n data.meta_key = alm.listing.dataset.metaKey;\n }\n if(alm.listing.dataset.metaValue){\n data.meta_value = alm.listing.dataset.metaValue;\n }\n if(alm.listing.dataset.metaCompare){\n data.meta_compare = alm.listing.dataset.metaCompare;\n }\n if(alm.listing.dataset.metaRelation){\n data.meta_relation = alm.listing.dataset.metaRelation;\n }\n if(alm.listing.dataset.metaType){\n data.meta_type = alm.listing.dataset.metaType;\n }\n if(alm.listing.dataset.author){\n data.author = alm.listing.dataset.author;\n }\n if(alm.listing.dataset.year){\n data.year = alm.listing.dataset.year;\n }\n if(alm.listing.dataset.month){\n data.month = alm.listing.dataset.month;\n }\n if(alm.listing.dataset.day){\n data.day = alm.listing.dataset.day;\n }\n if(alm.listing.dataset.order){\n data.order = alm.listing.dataset.order;\n }\n if(alm.listing.dataset.orderby){\n data.orderby = alm.listing.dataset.orderby;\n }\n if(alm.listing.dataset.postStatus){\n data.post_status = alm.listing.dataset.postStatus;\n }\n if(alm.listing.dataset.postIn){\n data.post__in = alm.listing.dataset.postIn;\n }\n if(alm.listing.dataset.postNotIn){\n data.post__not_in = alm.listing.dataset.postNotIn;\n }\n if(alm.listing.dataset.exclude){\n data.exclude = alm.listing.dataset.exclude;\n }\n if(alm.listing.dataset.search){\n data.search = alm.listing.dataset.search;\n }\n if(alm.listing.dataset.s){\n data.search = alm.listing.dataset.s;\n }\n if(alm.listing.dataset.customArgs){\n data.custom_args = alm.listing.dataset.customArgs;\n }\n \n data.action = action;\n data.query_type = queryType;\n \n return data;\n \n}\n\n\n\n/**\n * almGetRestParams\n * Build the REST API data object to send with REST API request\n * \n * @param alm object\n * @since 3.6\n */\nexport function almGetRestParams(alm){\n\tlet data = {\n\t\tid\t\t\t\t\t\t: alm.id,\n\t post_id\t\t\t\t: alm.post_id,\n\t posts_per_page : alm.posts_per_page,\n\t page : alm.page,\n\t offset : alm.offset,\n\t slug : alm.slug,\n\t canonical_url : encodeURIComponent(alm.canonical_url),\n\t post_type : alm.post_type,\n\t post_format : alm.listing.dataset.postFormat,\n\t category : alm.listing.dataset.category,\n\t category__not_in : alm.listing.dataset.categoryNotIn,\n\t tag : alm.listing.dataset.tag,\n\t tag__not_in : alm.listing.dataset.tagNotIn,\n\t taxonomy : alm.listing.dataset.taxonomy,\n\t taxonomy_terms : alm.listing.dataset.taxonomyTerms,\n\t taxonomy_operator : alm.listing.dataset.taxonomyOperator,\n\t taxonomy_relation : alm.listing.dataset.taxonomyRelation,\n\t meta_key : alm.listing.dataset.metaKey,\n\t meta_value : alm.listing.dataset.metaValue,\n\t meta_compare : alm.listing.dataset.metaCompare,\n\t meta_relation : alm.listing.dataset.metaRelation,\n\t meta_type : alm.listing.dataset.metaType,\n\t author : alm.listing.dataset.author,\n\t year : alm.listing.dataset.year,\n\t month : alm.listing.dataset.month,\n\t day : alm.listing.dataset.day,\n\t post_status : alm.listing.dataset.postStatus,\n\t order : alm.listing.dataset.order,\n\t orderby : alm.listing.dataset.orderby,\n\t post__in : alm.listing.dataset.postIn,\n\t post__not_in : alm.listing.dataset.postNotIn,\n\t search : alm.listing.dataset.search,\n\t s \t\t: alm.listing.dataset.s,\n\t custom_args : alm.listing.dataset.customArgs,\n\t lang : alm.lang,\n\t preloaded : alm.addons.preloaded,\n\t preloaded_amount : alm.addons.preloaded_amount,\n\t seo_start_page : alm.start_page\n };\n \n return data;\n}","/**\n * srcsetPolyfill\n * A Safari srcset polyfill to get Masonry and ImagesLoaded working\n *\n * @param {*} container Element\n * @param {*} ua String\n * @since 5.0.2\n */\nlet srcsetPolyfill = (container = null, ua = '') => {\n\t\n\t// Exit if no container\n\tif( !container ){ \n\t\treturn false;\n\t}\n\t\n\t// Exit if useragent is Chrome, Safari or Windows\n\tif( (ua.indexOf('Safari') > -1 && ua.indexOf('Chrome') != -1) || (ua.indexOf('Firefox') > -1) || (ua.indexOf('Windows') > -1) ){\n\t\treturn false;\n\t}\n\t\n\t// Get the images\n\tlet imgs = container.querySelectorAll('img[srcset]:not(.alm-loaded)');\n\t\n\t// Loop images\n\tfor ( var i=0; i < imgs.length; i++ ) {\n\t\tlet img = imgs[i];\n\t\timg.classList.add('alm-loaded');\n\t\timg.outerHTML = img.outerHTML;\n\t}\n}\nexport default srcsetPolyfill;","/**\n * Remove empty HTML nodes from array of nodes\n * Remove all empty text nodes from SEO and Filters return\n *\n * @param {*} nodes | Array of HTML nodes\n * @return array\n * @since 5.1.3\n */\nlet stripEmptyNodes = function( nodes = '' ) {\n\tif(!nodes){\n \treturn false;\n\t}\t\n\t\n\t// Exclude these nodeNames from being rendered\n\tlet nodeNameArray = ['#text', '#comment'];\n\t\n\t// Filter data by nodeName \n\tlet results = nodes.filter(node => (nodeNameArray.indexOf(node.nodeName.toLowerCase()) === -1) );\n \n // Send the results\n return results; \n \n};\nexport default stripEmptyNodes;\n","/** \n * Display alm_debug results\n * https://connekthq.com/plugins/ajax-load-more/docs/filter-hooks/#alm_debug\n *\n * @param {object} alm Global alm object\n * @since 5.1.6 \n */\n \nlet almDebug = function(alm){ \n\tif(alm && alm.debug){\n\t\tconsole.log('alm_debug info:', alm.debug); \n\t} \n}\n\nexport default almDebug;","/**\n * Fade element in\n * @param {*} element\n * @param {*} speed\n */ \nlet almFadeIn = (element, speed) => {\n\tif(speed == 0){\n\t\telement.style.opacity = 1;\n\t\telement.style.height = 'auto';\n\t\t\n\t} else {\n\t\tspeed = speed/10;\n\t\tlet op = 0; // initial opacity\n\t\tlet timer = setInterval(function () { \n\t\t\tif (op > 0.9){\n\t\t\t\telement.style.opacity = 1;\n\t\t\t\tclearInterval(timer);\n\t\t\t}\n\t\t\telement.style.opacity = op;\n\t\t\top += 0.1;\n\t\t}, speed);\n\t\telement.style.height = 'auto';\n\t}\n}\nexport default almFadeIn; ","/**\n * Fade element out\n * @param {*} element\n * @param {*} speed\n */ \nlet almFadeOut = (element, speed) => {\n\tspeed = speed/10;\n\telement.style.opacity = 0.5;\n\tlet fadeEffect = setInterval(function () {\n\t\tif (element.style.opacity < 0.1) {\n\t\t\tclearInterval(fadeEffect);\n\t\t} else {\n\t\t\telement.style.opacity -= 0.1;\n\t\t}\n\t}, speed);\n}\nexport default almFadeOut; ","import almFadeIn from './fadeIn';\nimport almFadeOut from './fadeOut';\n\n/**\n * almFilter(type, speed, data)\n * Filter Ajax Load More\n *\n * @param {*} transition string;\n * @param {*} speed number;\n * @param {*} data obj;\n * @param {*} type string;\n * @since 2.6.1\n */\n \nlet almFilter = function(transition, speed, data, type = \"filter\") {\n if(data.target){ // if a target has been specified\n\t let target = document.querySelectorAll('.ajax-load-more-wrap[data-id=\"'+ data.target + '\"]');\n\t\ttarget.forEach(function(element){\n\t\t\talmFilterTransition(transition, speed, data, element, type);\t \n\t\t});\n } else { // Target not specified\n\t let alm = document.querySelectorAll('.ajax-load-more-wrap');\n alm.forEach(function(element){\n\t\t\talmFilterTransition(transition, speed, data, element, type);\t \n\t\t});\n }\n}; \nexport default almFilter;\n\n\n\n/**\n * almFilterTransition(transition, speed, data, el)\n * Transition Ajax Load More\n *\n * @param {*} transition string;\n * @param {*} speed number;\n * @param {*} data obj;\n * @param {*} el element;\n * @param {*} type string;\n * @since 2.13.1\n */\nlet almFilterTransition = function(transition, speed, data, el, type){ \n \n if(transition === 'fade' || transition === 'masonry'){ \n\t // Fade, Masonry transition\n\t \n\t switch (type){\n\t\t case 'filter' :\n\t\t \tel.classList.add('alm-is-filtering');\n\t\t \talmFadeOut(el, speed);\n\t\t \t\n\t\t break;\n\t\t \n\t\t case 'tab' : \n\t\t \tel.classList.add('alm-loading');\n\t\t \tlet new_el = el.querySelector('.alm-listing');\n\t\t \tel.style.height = new_el.offsetHeight + 'px';\n\t\t \talmFadeOut(new_el, speed);\n\t\t \t\n\t\t break;\n\t }\n\t \n\t // Move to next function\n setTimeout(function(){\n\t almCompleteFilterTransition(speed, data, el, type);\n\t }, speed);\n\t \n }else{ \n\t // No transition\n\t el.classList.add('alm-is-filtering');\n almCompleteFilterTransition(speed, data, el, type);\n }\n \n}; \n\n\n\n/** \n * almCompleteFilterTransition\n * Complete the filter transition\n * \n * @param {*} speed number;\n * @param {*} data obj;\n * @param {*} el element;\n * @param {*} type string;\n * @since 3.3\n */\nlet almCompleteFilterTransition = (speed, data, el, type) => {\t\n\t\n\t// Get `.alm-btn-wrap` element\n\tlet btnWrap = el.querySelector('.alm-btn-wrap');\n\t\n\t// Get `.alm-listing` element\n\tlet listing = el.querySelectorAll('.alm-listing');\n\t\n\t// Loop over all .alm-listing divs\n\t[...listing].forEach(function(e){\n\t\te.innerHTML = ''; // Clear listings\n\t});\n\t \n\t// Get Load More button\n\tlet button = btnWrap.querySelector('.alm-load-more-btn');\n\tif(button){\n\t\tbutton.classList.remove('done');// Reset Button \n\t}\n\t\n\t// Clear paging navigation\n let paging = btnWrap.querySelector('.alm-paging');\n if(paging){\n paging.style.opacity = 0;\n }\n\t\n\t// Dispatch Filters\n\talmSetFilters(speed, data, el, type);\n\t\n}\n\n \n\n/**\n * almSetFilters\n * Set filter parameters on .alm-listing element\n *\n * @param {*} speed number;\n * @param {*} el element;\n * @param {*} data string;\n * @param {*} type string;\n * @updated 3.3\n * @since 2.6.1\n */\nlet almSetFilters = function(speed = 250, data, el, type){\n\t \n // Get `alm-listing` container\n let listing = el.querySelector('.alm-listing') || el.querySelector('.alm-comments'); \n if(!listing){\n\t return false;\n }\n \n switch (type){\t \n\t case 'filter' : \n\t\t // Update data attributes\n\t\t\tfor (let [key, value] of Object.entries(data)) {\n\t\t\t\t// Convert camelCase data atts back to dashes (-).\n\t\t key = key.replace(/\\W+/g, '-').replace(/([a-z\\d])([A-Z])/g, '$1-$2').toLowerCase(); \n\t\t\t\tlisting.setAttribute('data-'+ key, value);\n\t\t\t}\n\t\t\t// Fade ALM back (Filters only)\n\t\t\talmFadeIn(el, speed);\n\t\tbreak;\n\t\t\n\t\tcase 'tab' :\n\t\t\t// Update `data-tab-template` attribute\n\t\t\tlisting.setAttribute('data-preloaded', 'false');\n\t\t\tlisting.setAttribute('data-pause', 'false');\n\t\t\tlisting.setAttribute('data-tab-template', data.tabTemplate);\n\t\t\n\t\tbreak; \n\t}\n \n\t\n\t// Re-initiate Ajax Load More\n\tlet target = ''; \n if(data.target){\n // Target has been specified\n target = document.querySelector('.ajax-load-more-wrap[data-id=\"'+ data.target + '\"]');\n if(target){\n\t window.almInit(target);\n } \n } else {\n // Target not specified\n target = document.querySelector('.ajax-load-more-wrap');\n if(target){\n\t window.almInit(target);\n } \n }\n \n switch (type){\t \n\t \n\t case 'filter' : \n\t\t // Filters Complete \n\t\t if (typeof almFilterComplete === 'function') { // Standard Filtering\n\t\t almFilterComplete();\n\t\t }\n\t\t // Filter Add-on Complete\n\t\t if (typeof almFiltersAddonComplete === \"function\") { // Filters Add-on\n\t\t almFiltersAddonComplete(el);\n\t\t }\n\t\tbreak;\n\t\t\n\t\tcase 'tab' :\n\t\t\t// Tabs Complete \n\t\t if (typeof almTabsComplete === 'function') { // Standard Filtering\n\t\t almTabsComplete();\n\t\t }\t\t\n\t\tbreak; \n\t\t\n\t}\n \n};\n","import almDomParser from '../helpers/almDomParser';\n\n/**\n * insertScript\n * Search nodes for <script/> tags and run scripts.\n * Scripts cannot run with appendChild or innerHTML so this is necessary to function.\n * \n * @since 5.0\n */ \nlet insertScript = {\n\t\n\tinit: function(node){\n\t\tif ( this.isScript(node) === true ) {\n\t\t\tnode.parentNode.replaceChild( this.clone(node) , node );\n\t\t}\n\t\telse {\n\t\t\tlet i = 0;\n\t\t\tlet children = node.childNodes;\n\t\t\t\n\t\t\tif(children === undefined){\n let parser = new DOMParser(); \n let data = parser.parseFromString(node, 'text/html');\n if(data){\n children = data.body.childNodes;\n }\n }\n\t\t\twhile ( i < children.length ) {\n\t\t\t\tthis.replace( children[i++] );\n\t\t\t}\n\t\t}\t\t\t\n\t\treturn node;\n\t},\n\t\n\treplace: function(node) {\n\t\tif ( this.isScript(node) === true ) {\n\t\t\tnode.parentNode.replaceChild( this.clone(node) , node );\n\t\t}\n\t\telse {\n\t\t\tlet i = 0;\n\t\t\tlet children = node.childNodes;\n\t\t\twhile (i < children.length) {\n\t\t\t\tthis.replace( children[i++] );\n\t\t\t}\n\t\t}\t\n\t return node;\n\t},\n\t\n\tisScript: function(node){\n\t\treturn node.tagName === 'SCRIPT';\n\t},\n\t\n\tclone: function(node){\n\t\tlet script = document.createElement(\"script\");\n\t\tscript.text = node.innerHTML;\n\t\tfor( let i = node.attributes.length-1; i >= 0; i-- ) {\n\t\t\tscript.setAttribute( node.attributes[i].name, node.attributes[i].value );\n\t\t}\n\t\treturn script;\n\t}\n\t\n}\nexport default insertScript; \n","import almFadeIn from './fadeIn';\nimport almAppendChildren from '../helpers/almAppendChildren';\nimport almDomParser from '../helpers/almDomParser';\nimport srcsetPolyfill from '../helpers/srcsetPolyfill';\nlet imagesLoaded = require('imagesloaded');\n\n/**\n * almMasonry\n * Function to trigger built-in Ajax Load More Masonry\n * \n * @param {object} alm\n * @param {boolean} init\n * @param {boolean} filtering \n * @since 3.1\n * @updated 5.0.2\n*/\n\nlet msnry = '';\nlet almMasonry = (alm, init, filtering) => {\t\n\t\n\tlet container = alm.listing;\n\tlet html = alm.html;\n\t\n\tlet selector = alm.masonry_selector;\n\tlet columnWidth = alm.masonry_columnwidth;\n\tlet animation = alm.masonry_animation;\n\tlet horizontalOrder = alm.masonry_horizontalorder;\n\tlet speed = alm.speed;\t\n\tlet masonry_init = alm.masonry_init;\n \n let duration = (speed+100)/1000 +'s'; // Add 100 for some delay\n let hidden = 'scale(0.5)';\n let visible = 'scale(1)';\n \n if(animation === 'zoom-out'){\n hidden = 'translateY(-20px) scale(1.25)'; \n visible = 'translateY(0) scale(1)';\n }\n \n if(animation === 'slide-up'){\n hidden = 'translateY(50px)';\n visible = 'translateY(0)';\n } \n \n if(animation === 'slide-down'){\n hidden = 'translateY(-50px)';\n visible = 'translateY(0)';\n } \n \n if(animation === 'none'){\n hidden = 'translateY(0)'; \n visible = 'translateY(0)';\n }\n \n // columnWidth\n if(columnWidth){\n\t if(!isNaN(columnWidth)){// Check if number\n\t\t columnWidth = parseInt(columnWidth);\n\t\t}\n } else { // No columnWidth, use the selector\n\t columnWidth = selector;\n }\n \n // horizontalOrder\n horizontalOrder = (horizontalOrder === 'true') ? true : false;\n \n\tif(!filtering){\n \t\n\t\t// First Run\n\t\tif(masonry_init && init){\t\t\t\n\t\t\t\n\t\t\tsrcsetPolyfill(container, alm.ua); // Run srcSet polyfill\t\t\t\n\t\t\t\n\t\t\timagesLoaded( container, function() {\n\t\t\t\t\n\t\t\t\tlet defaults = {\n\t\t\t\t\titemSelector: selector,\n\t\t\t\t\ttransitionDuration: duration,\n\t\t\t\t\tcolumnWidth: columnWidth,\n\t\t\t\t\thorizontalOrder: horizontalOrder,\n hiddenStyle: {\n transform: hidden,\n opacity: 0\n },\n visibleStyle: {\n transform: visible,\n opacity: 1\n } \n }\n \n // Get custom Masonry options (https://masonry.desandro.com/options.html)\n let alm_masonry_vars = window.alm_masonry_vars;\n if(alm_masonry_vars){ \n\t\t Object.keys(alm_masonry_vars).forEach(function(key) {\t// Loop object\tto create key:prop\t\t\t\n\t\t\t\t\t\tdefaults[key] = alm_masonry_vars[key];\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t}\t\t\t\t\n \n // Init Masonry, delay to allow time for items to be added to the page\n setTimeout(function(){\n \tmsnry = new Masonry( container, defaults );\n \t// Fade In\n\t\t\t\t\talmFadeIn(container.parentNode, speed); \n }, 100 );\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t});\n\t\t}\n\t\t\n\t\t// Standard / Append content\n\t\telse{\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t// Loop all items and create array of node elements\n\t\t\tlet data = almDomParser(html, 'text/html');\n\t\t\t\n\t\t\tif(data){ \t\n\t\t\t\t\n \t\t\t// Append elements listing\n \t\t\talmAppendChildren(alm.listing, data, 'masonry');\n \t\t\t\n \t\t\t// Run srcSet polyfill\n \t\t\tsrcsetPolyfill(container, alm.ua);\n \t\t\t\n \t\t\t// Confirm imagesLoaded & append\n \t\t\timagesLoaded( container, function() {\n\t\t\t\t\tmsnry.appended( data );\t\t\t\t\n\t\t\t\t});\n\t\t\t\t\n\t\t\t}\n\t\t}\n\n\t} else{\n \t\n\t\t// Reset\n\t\tmsnry.destroy(); // destroy masonry\n\t\tcontainer.parentNode.style.opacity = 0;\n\t\talmMasonry(alm, true, false);\n\t\t\n\t}\n\n};\n\nexport default almMasonry;\n\n\n\n","/** \n * Set the results text if required.\n * \n * @param {*} target The target HTML element\n * @param {*} html The HTML\n * @since 5.1\n */\nlet almNoResults = (target, html = '') => {\n\tif(html === ''){ \n\t\treturn false; // exit if empty\t\n\t}\n\t\n\t// Remove empty <p/> tags\n\thtml = html.replace(/(<p><\\/p>)+/g, '');\n\t\n\t// Append to DOM\n\ttarget.innerHTML = html; \n}\n\nexport default almNoResults;","import almFadeIn from './fadeIn';\nimport almFadeOut from './fadeOut';\n\nexport function showPlaceholder(alm){\n\tif(!alm || !alm.main || alm.addons.paging){\n return false; \n }\n if(alm.placeholder){ \n alm.placeholder.style.display = 'block';\n almFadeIn(alm.placeholder, 75);\n }\n}\n\n\nexport function hidePlaceholder(alm){ \n if(!alm || !alm.main || alm.addons.paging){\n return false; \n }\n if(alm.placeholder){\n almFadeOut(alm.placeholder, 75); \n setTimeout(function(){\n \talm.placeholder.style.display = 'none'; \n\t }, 75); \n }\n}","/** \n * Set the results text if required.\n * \n * @param {object} alm Global alm object\n * @param {string} type Type of results\n * @since 5.1\n */\nexport function almResultsText(alm, type = 'standard'){\n\tif(!alm.resultsText) return false;\t\n\tlet resultsType = (type === 'nextpage') ? 'nextpage' : 'standard';\n\t\n almGetResultsText(alm, resultsType); \n}\n\n\n\n/** \n * Get values for showing results text.\n * \n * @param {Object} alm\n * @param {String} type\n * @since 4.1\n */\nexport function almGetResultsText( alm, type = 'standard' ){\n \n\t\n\tif(!alm.resultsText) return false;\n\t\n\tlet current = 0;\n\tlet total = 0;\n\tlet preloaded = (alm.addons.preloaded === 'true') ? true : false;\n\tlet paging = (alm.addons.paging) ? true : false;\n\tlet posts_per_page = alm.orginal_posts_per_page;\n\t\n\tswitch (type) {\n \t\n \t// Nextpage\n \tcase 'nextpage' :\n\t\n current = parseInt(alm.localize.page);\n total = parseInt(alm.localize.total_posts);\n almRenderResultsText(alm.resultsText, current, total);\n \t\n \tbreak;\n \n \tdefault :\n \t\t\n \t\tcurrent = parseInt(alm.page) + 1; \t\t\n \t\ttotal = Math.ceil(alm.localize.total_posts / posts_per_page);\n \t\t\n \t\t// Add 1 page if Preloaded\n \t\tif(preloaded){\n\t \t\tcurrent = (paging) ? alm.page + 1 : current + 1;\n \t\t}\n \t\t\n almRenderResultsText(alm.resultsText, current, total);\n \t\n }\n}\n\n\n\n/** \n * Display `Showing {x} of {y} pages` text.\n *\n * @param {Object} alm\n * @param {String} type\n * @since 4.1\n */\nexport function almInitResultsText( alm, type = 'standard'){\n \n\tif(!alm.resultsText) return false;\n\t\n\tlet current = 0;\n\tlet total = Math.ceil(alm.localize.total_posts / alm.orginal_posts_per_page);\n\t\n\tswitch (type) {\n \t\n \t// Nextpage\n \tcase 'nextpage' : \t\n \t\n almRenderResultsText(alm.resultsText, alm.addons.nextpage_startpage, alm.localize.total_posts);\n \t\n break;\n \t\n \t// Preloaded\n \tcase 'preloaded' : \n \t \n current = (alm.addons.paging && alm.addons.seo) ? parseInt(alm.start_page) + 1 : parseInt(alm.page) + 1; \n almRenderResultsText(alm.resultsText, current, total);\n \t\n \tbreak;\n \t\n \tdefault :\n \t\n \t console.log('Nothing to set.');\n \t \n\t}\n\t\n}\n\n\n/** \n * Render `Showing {x} of {y} results` text.\n * \n * @param {Element} el\n * @param {String} current\n * @param {String} total\n * @since 4.1\n */\nlet almRenderResultsText = function(el, current, total){\n \n total = parseInt(total);\n let text = (total > 0) ? alm_localize.results_text : alm_localize.no_results_text;\n \n if(total > 0){\n text = text.replace('{num}', `<span class=\"alm-results-current\">${current}</span>`);\n text = text.replace('{total}', `<span class=\"alm-results-total\">${total}</span>`);\n el.innerHTML = text; \n } else {\n el.innerHTML = text; \n }\n}\n","/**\n * setFocus\n * Set user focus to improve accessibility after load events\n * \n * @param {Boolean} init\n * @param {String} preloaded\n * @param {HTMLElement} element\n * @param {Boolean} alm_is_filtering\n * @since 5.1\n */ \nlet setFocus = (init = true, preloaded = 'false', element, alm_is_filtering = false) => {\n\t\n\tif(!alm_is_filtering){\n\t\tif( (init || !element) && preloaded !== 'true' ){\n\t return false; // Exit if first run\n\t }\n }\n\n // Check if element is an array.\n // If `transition_container=\"false\"`, `element` will be an array.\n /*\n let is_array = Array.isArray(element);\n element = (is_array) ? element[0] : element;\n */ \n \n // Set tabIndex on `.alm-reveal`\n\telement.setAttribute('tabIndex', '-1');\n element.style.outline = 'none';\n \n // Get Parent container\n // If `.alm-listing` set parent to element\n let parent = (!element.classList.contains('alm-listing')) ? element.parentNode : element;\t\n \n // Scroll Container\n\tlet scrollContainer = parent.dataset.scrollContainer;\n\t\n\t// If scroll container, move it, not the window.\t\n\tif(scrollContainer){\t\t\t\t\n\t\tlet container = document.querySelector(scrollContainer);\n\t\tif(container){\n\t\t\tlet left = container.scrollLeft;\n\t\t\tlet top = container.scrollTop;\n\t\t\telement.focus();\n\t\t\tcontainer.scrollLeft = left;\n\t\t\tcontainer.scrollTop = top;\t\t\t\n\t\t}\t\t\n\t} \n\t\n\t// Move window\n\telse { \n\t\tlet x = window.scrollX;\n\t\tlet y = window.scrollY;\n\t\telement.focus();\n\t\twindow.scrollTo(x, y);\n\t}\n\t\n}\nexport default setFocus; \n","import * as resultsText from './resultsText';\n\n/** \n * Set localized variables\n *\n * @param {object} alm Global alm object\n * @since 4.1 \n */\n \nlet setLocalizedVars = function(alm){ \n \n let type = 'standard'; \n\n\t// Current Page `page`\n\tif(alm.addons.nextpage){\n \ttype = 'nextpage';\n \tif(alm.addons.paging){\n alm.AjaxLoadMore.setLocalizedVar('page', parseIn