Post Grid - Version 2.0.46

Version Description

  • 2020-04-21 update - Layout builder re-designed.
    • 2020-04-21 update - Remove unnecessary CSS and JS files.
    • 2020-04-21 update - Optimize CSS and JS file loading.
Download this release

Release Info

Developer pickplugins
Plugin Icon 128x128 Post Grid
Version 2.0.46
Comparing to
See all releases

Code changes from version 2.0.44 to 2.0.46

Files changed (87) hide show
  1. assets/admin/css/codemirror.css +0 -334
  2. assets/admin/css/post-grid-meta-box.css +0 -26
  3. assets/admin/css/post-skin.css +0 -35
  4. assets/admin/css/settings-tabs.css +0 -357
  5. assets/admin/css/simplescrollbars.css +0 -66
  6. assets/admin/css/style-new.css +0 -188
  7. assets/admin/images/layout_grid.png +0 -0
  8. assets/admin/images/menu-grid-icon.png +0 -0
  9. assets/admin/js/codemirror.js +0 -8871
  10. assets/admin/js/color-picker.js +0 -5
  11. assets/admin/js/css.js +0 -825
  12. assets/admin/js/javascript.js +0 -723
  13. assets/admin/js/layout-editor.js +31 -65
  14. assets/admin/js/post-grid-meta-box.js +0 -40
  15. assets/admin/js/scripts-new.js +0 -80
  16. assets/admin/js/scripts.js +49 -0
  17. assets/admin/js/settings-tabs.js +0 -164
  18. assets/admin/js/simplescrollbars.js +0 -147
  19. assets/frontend/css/ajax-loader.gif +0 -0
  20. assets/frontend/css/images/arrow-next.png +0 -0
  21. assets/frontend/css/images/arrow-prev.png +0 -0
  22. assets/frontend/css/images/link.png +0 -0
  23. assets/frontend/css/images/quote.png +0 -0
  24. assets/frontend/css/owl.carousel.min.css +0 -6
  25. assets/frontend/css/style - Copy.css b/assets/frontend/css/style - → Copy.css +0 -0
  26. assets/frontend/js/scripts.js +42 -60
  27. assets/global/css/animate.css +0 -3340
  28. assets/settings-tabs/settings-tabs.css +621 -0
  29. assets/settings-tabs/settings-tabs.js +296 -0
  30. grid-items/custom-css.php +0 -544
  31. grid-items/hover_items.php +0 -64
  32. grid-items/index.php +0 -2
  33. grid-items/layer-content.php +0 -393
  34. grid-items/layer-hover.php +0 -9
  35. grid-items/layer-media.php +0 -39
  36. grid-items/lazy.php +0 -39
  37. grid-items/nav-bottom-new.php +0 -422
  38. grid-items/nav-search.php +0 -63
  39. grid-items/nav-top-new.php +0 -268
  40. grid-items/query.php +0 -323
  41. grid-items/scripts.php +0 -40
  42. grid-items/variables.php +0 -711
  43. includes/class-functions.php +5 -526
  44. includes/class-metabox-post-grid-layout-hook.php +480 -0
  45. includes/class-metabox-post-grid-layout.php +186 -0
  46. includes/class-post-grid-meta-box.php +2 -2
  47. includes/class-settings-tabs.php +803 -150
  48. includes/class-settings.php +23 -21
  49. includes/class-shortcodes.php +41 -4
  50. includes/classes/class-post-grid-support.php +4 -0
  51. includes/classes/class-post-types.php +121 -0
  52. includes/functions-data-upgrade.php +1237 -0
  53. includes/functions-layout-hook.php +3951 -0
  54. includes/functions.php +122 -93
  55. includes/functions/functions-post-grid-meta-box.php +634 -360
  56. includes/functions/functions-post-grid-settings.php +0 -78
  57. includes/functions/functions-post-grid.php +19 -0
  58. includes/functions/functions-post-meta-box.php +0 -296
  59. includes/functions/functions-settings-hook.php +295 -0
  60. includes/functions/media-source-options.php +189 -0
  61. includes/functions/post-grid-layout-elements.php +1943 -0
  62. includes/menu/layout-editor.php +0 -3
  63. includes/menu/{settings-new.php → settings-old.php} +0 -12
  64. includes/menu/settings.php +125 -0
  65. includes/post-grid-meta-box.php +113 -127
  66. includes/post-grid-skin-meta-box.php +0 -286
  67. includes/post-meta-settings.php +0 -176
  68. languages/en.mo +0 -0
  69. languages/en.po +0 -827
  70. languages/post-grid-bn_BD.mo +0 -0
  71. languages/post-grid-bn_BD.po +1844 -755
  72. languages/post-grid-de_DE.mo +0 -0
  73. languages/post-grid-de_DE.po +2087 -419
  74. languages/post-grid-fr_FR.mo +0 -0
  75. languages/post-grid-fr_FR.po +1754 -810
  76. languages/post-grid-it_IT.mo +0 -0
  77. languages/post-grid-it_IT.po +1823 -753
  78. languages/post-grid.mo +0 -0
  79. languages/post-grid.po +1809 -751
  80. post-grid.php +69 -79
  81. readme.txt +11 -1
  82. skins/index.php +0 -28
  83. templates/custom-css.php +19 -266
  84. templates/nav-bottom.php +1 -1
  85. templates/post-grid-hook.php +1810 -0
  86. templates/variables.php +28 -165
  87. upgrade/class-post-grid-data-update.php +0 -61
assets/admin/css/codemirror.css DELETED
@@ -1,334 +0,0 @@
1
- /* BASICS */
2
-
3
- .CodeMirror {
4
- /* Set height, width, borders, and global font properties here */
5
- font-family: monospace;
6
- height: 300px;
7
- color: black;
8
- }
9
-
10
- /* PADDING */
11
-
12
- .CodeMirror-lines {
13
- padding: 4px 0; /* Vertical padding around content */
14
- }
15
- .CodeMirror pre {
16
- padding: 0 4px; /* Horizontal padding of content */
17
- }
18
-
19
- .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
20
- background-color: white; /* The little square between H and V scrollbars */
21
- }
22
-
23
- /* GUTTER */
24
-
25
- .CodeMirror-gutters {
26
- border-right: 1px solid #ddd;
27
- background-color: #f7f7f7;
28
- white-space: nowrap;
29
- }
30
- .CodeMirror-linenumbers {}
31
- .CodeMirror-linenumber {
32
- padding: 0 3px 0 5px;
33
- min-width: 20px;
34
- text-align: right;
35
- color: #999;
36
- white-space: nowrap;
37
- }
38
-
39
- .CodeMirror-guttermarker { color: black; }
40
- .CodeMirror-guttermarker-subtle { color: #999; }
41
-
42
- /* CURSOR */
43
-
44
- .CodeMirror-cursor {
45
- border-left: 1px solid black;
46
- border-right: none;
47
- width: 0;
48
- }
49
- /* Shown when moving in bi-directional text */
50
- .CodeMirror div.CodeMirror-secondarycursor {
51
- border-left: 1px solid silver;
52
- }
53
- .cm-fat-cursor .CodeMirror-cursor {
54
- width: auto;
55
- border: 0;
56
- background: #7e7;
57
- }
58
- .cm-fat-cursor div.CodeMirror-cursors {
59
- z-index: 1;
60
- }
61
-
62
- .cm-animate-fat-cursor {
63
- width: auto;
64
- border: 0;
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
- background-color: #7e7;
69
- }
70
- @-moz-keyframes blink {
71
- 0% {}
72
- 50% { background-color: transparent; }
73
- 100% {}
74
- }
75
- @-webkit-keyframes blink {
76
- 0% {}
77
- 50% { background-color: transparent; }
78
- 100% {}
79
- }
80
- @keyframes blink {
81
- 0% {}
82
- 50% { background-color: transparent; }
83
- 100% {}
84
- }
85
-
86
- /* Can style cursor different in overwrite (non-insert) mode */
87
- .CodeMirror-overwrite .CodeMirror-cursor {}
88
-
89
- .cm-tab { display: inline-block; text-decoration: inherit; }
90
-
91
- .CodeMirror-ruler {
92
- border-left: 1px solid #ccc;
93
- position: absolute;
94
- }
95
-
96
- /* DEFAULT THEME */
97
-
98
- .cm-s-default .cm-header {color: blue;}
99
- .cm-s-default .cm-quote {color: #090;}
100
- .cm-negative {color: #d44;}
101
- .cm-positive {color: #292;}
102
- .cm-header, .cm-strong {font-weight: bold;}
103
- .cm-em {font-style: italic;}
104
- .cm-link {text-decoration: underline;}
105
- .cm-strikethrough {text-decoration: line-through;}
106
-
107
- .cm-s-default .cm-keyword {color: #708;}
108
- .cm-s-default .cm-atom {color: #219;}
109
- .cm-s-default .cm-number {color: #164;}
110
- .cm-s-default .cm-def {color: #00f;}
111
- .cm-s-default .cm-variable,
112
- .cm-s-default .cm-punctuation,
113
- .cm-s-default .cm-property,
114
- .cm-s-default .cm-operator {}
115
- .cm-s-default .cm-variable-2 {color: #05a;}
116
- .cm-s-default .cm-variable-3 {color: #085;}
117
- .cm-s-default .cm-comment {color: #a50;}
118
- .cm-s-default .cm-string {color: #a11;}
119
- .cm-s-default .cm-string-2 {color: #f50;}
120
- .cm-s-default .cm-meta {color: #555;}
121
- .cm-s-default .cm-qualifier {color: #555;}
122
- .cm-s-default .cm-builtin {color: #30a;}
123
- .cm-s-default .cm-bracket {color: #997;}
124
- .cm-s-default .cm-tag {color: #170;}
125
- .cm-s-default .cm-attribute {color: #00c;}
126
- .cm-s-default .cm-hr {color: #999;}
127
- .cm-s-default .cm-link {color: #00c;}
128
-
129
- .cm-s-default .cm-error {color: #f00;}
130
- .cm-invalidchar {color: #f00;}
131
-
132
- .CodeMirror-composing { border-bottom: 2px solid; }
133
-
134
- /* Default styles for common addons */
135
-
136
- div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
137
- div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
138
- .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
139
- .CodeMirror-activeline-background {background: #e8f2ff;}
140
-
141
- /* STOP */
142
-
143
- /* The rest of this file contains styles related to the mechanics of
144
- the editor. You probably shouldn't touch them. */
145
-
146
- .CodeMirror {
147
- position: relative;
148
- overflow: hidden;
149
- background: white;
150
- }
151
-
152
- .CodeMirror-scroll {
153
- overflow: scroll !important; /* Things will break if this is overridden */
154
- /* 30px is the magic margin used to hide the element's real scrollbars */
155
- /* See overflow: hidden in .CodeMirror */
156
- margin-bottom: -30px; margin-right: -30px;
157
- padding-bottom: 30px;
158
- height: 100%;
159
- outline: none; /* Prevent dragging from highlighting the element */
160
- position: relative;
161
- }
162
- .CodeMirror-sizer {
163
- position: relative;
164
- border-right: 30px solid transparent;
165
- }
166
-
167
- /* The fake, visible scrollbars. Used to force redraw during scrolling
168
- before actuall scrolling happens, thus preventing shaking and
169
- flickering artifacts. */
170
- .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
171
- position: absolute;
172
- z-index: 6;
173
- display: none;
174
- }
175
- .CodeMirror-vscrollbar {
176
- right: 0; top: 0;
177
- overflow-x: hidden;
178
- overflow-y: scroll;
179
- }
180
- .CodeMirror-hscrollbar {
181
- bottom: 0; left: 0;
182
- overflow-y: hidden;
183
- overflow-x: scroll;
184
- }
185
- .CodeMirror-scrollbar-filler {
186
- right: 0; bottom: 0;
187
- }
188
- .CodeMirror-gutter-filler {
189
- left: 0; bottom: 0;
190
- }
191
-
192
- .CodeMirror-gutters {
193
- position: absolute; left: 0; top: 0;
194
- z-index: 3;
195
- }
196
- .CodeMirror-gutter {
197
- white-space: normal;
198
- height: 100%;
199
- display: inline-block;
200
- margin-bottom: -30px;
201
- /* Hack to make IE7 behave */
202
- *zoom:1;
203
- *display:inline;
204
- }
205
- .CodeMirror-gutter-wrapper {
206
- position: absolute;
207
- z-index: 4;
208
- background: none !important;
209
- border: none !important;
210
- }
211
- .CodeMirror-gutter-background {
212
- position: absolute;
213
- top: 0; bottom: 0;
214
- z-index: 4;
215
- }
216
- .CodeMirror-gutter-elt {
217
- position: absolute;
218
- cursor: default;
219
- z-index: 4;
220
- }
221
- .CodeMirror-gutter-wrapper {
222
- -webkit-user-select: none;
223
- -moz-user-select: none;
224
- user-select: none;
225
- }
226
-
227
- .CodeMirror-lines {
228
- cursor: text;
229
- min-height: 1px; /* prevents collapsing before first draw */
230
- }
231
- .CodeMirror pre {
232
- /* Reset some styles that the rest of the page might have set */
233
- -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
234
- border-width: 0;
235
- background: transparent;
236
- font-family: inherit;
237
- font-size: inherit;
238
- margin: 0;
239
- white-space: pre;
240
- word-wrap: normal;
241
- line-height: inherit;
242
- color: inherit;
243
- z-index: 2;
244
- position: relative;
245
- overflow: visible;
246
- -webkit-tap-highlight-color: transparent;
247
- }
248
- .CodeMirror-wrap pre {
249
- word-wrap: break-word;
250
- white-space: pre-wrap;
251
- word-break: normal;
252
- }
253
-
254
- .CodeMirror-linebackground {
255
- position: absolute;
256
- left: 0; right: 0; top: 0; bottom: 0;
257
- z-index: 0;
258
- }
259
-
260
- .CodeMirror-linewidget {
261
- position: relative;
262
- z-index: 2;
263
- overflow: auto;
264
- }
265
-
266
- .CodeMirror-widget {}
267
-
268
- .CodeMirror-code {
269
- outline: none;
270
- }
271
-
272
- /* Force content-box sizing for the elements where we expect it */
273
- .CodeMirror-scroll,
274
- .CodeMirror-sizer,
275
- .CodeMirror-gutter,
276
- .CodeMirror-gutters,
277
- .CodeMirror-linenumber {
278
- -moz-box-sizing: content-box;
279
- box-sizing: content-box;
280
- }
281
-
282
- .CodeMirror-measure {
283
- position: absolute;
284
- width: 100%;
285
- height: 0;
286
- overflow: hidden;
287
- visibility: hidden;
288
- }
289
-
290
- .CodeMirror-cursor { position: absolute; }
291
- .CodeMirror-measure pre { position: static; }
292
-
293
- div.CodeMirror-cursors {
294
- visibility: hidden;
295
- position: relative;
296
- z-index: 3;
297
- }
298
- div.CodeMirror-dragcursors {
299
- visibility: visible;
300
- }
301
-
302
- .CodeMirror-focused div.CodeMirror-cursors {
303
- visibility: visible;
304
- }
305
-
306
- .CodeMirror-selected { background: #d9d9d9; }
307
- .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
308
- .CodeMirror-crosshair { cursor: crosshair; }
309
- .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
310
- .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
311
-
312
- .cm-searching {
313
- background: #ffa;
314
- background: rgba(255, 255, 0, .4);
315
- }
316
-
317
- /* IE7 hack to prevent it from returning funny offsetTops on the spans */
318
- .CodeMirror span { *vertical-align: text-bottom; }
319
-
320
- /* Used to force a border model for a node */
321
- .cm-force-border { padding-right: .1px; }
322
-
323
- @media print {
324
- /* Hide the cursor when printing */
325
- .CodeMirror div.CodeMirror-cursors {
326
- visibility: hidden;
327
- }
328
- }
329
-
330
- /* See issue #2901 */
331
- .cm-tab-wrap-hack:after { content: ''; }
332
-
333
- /* Help users use markselection to safely style text background */
334
- span.CodeMirror-selectedtext { background: none; }
assets/admin/css/post-grid-meta-box.css DELETED
@@ -1,26 +0,0 @@
1
- /*
2
- Admin css
3
- */
4
- .post-grid-meta-box{
5
- background: #fff;
6
- }
7
-
8
-
9
- .post-grid-meta-box .grid-type-wrap{
10
- padding: 20px 15px;
11
- border-bottom: 1px solid #ddd;
12
- position: sticky;
13
- top: 31px;
14
- background: #fff;
15
- z-index: 99;
16
- }
17
-
18
-
19
-
20
-
21
- .post-grid-meta-box .tab-navs {
22
- position: sticky;
23
- top: 92px;
24
- }
25
-
26
-
assets/admin/css/post-skin.css DELETED
@@ -1,35 +0,0 @@
1
- @charset "utf-8";
2
- /* CSS Document */
3
-
4
-
5
- .post-skin-metabox{}
6
-
7
- .post-skin-metabox .skin-elements{}
8
- .post-skin-metabox .skin-elements .groupItems{}
9
- .post-skin-metabox .skin-elements .groupItems .item{
10
- display: inline-block;
11
- padding: 6px 8px;
12
- background: #c3c2c270;
13
- margin: 3px 1px;
14
- border-radius: 3px;
15
- cursor: pointer;
16
- }
17
- .post-skin-metabox .skin-elements .groupItems .item:hover{
18
-
19
- background: #c3c2c2d6;
20
-
21
- }
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
assets/admin/css/settings-tabs.css DELETED
@@ -1,357 +0,0 @@
1
- @charset "utf-8";
2
- /* CSS Document */
3
-
4
-
5
- /*General CSS*/
6
-
7
- .settings-tabs .float-right{
8
- float: right;
9
- }
10
-
11
- .settings-tabs .float-left{
12
- float: right;
13
- }
14
-
15
- .settings-tabs .float-none{
16
- float: right;
17
- }
18
-
19
-
20
-
21
- /* Collapsible */
22
-
23
- .settings-tabs .collapsible{
24
- margin-bottom: 2px;
25
- }
26
- .settings-tabs .collapsible .header{
27
- background: #eee;
28
- padding: 8px 10px;
29
- }
30
-
31
- .settings-tabs .collapsible .header span{
32
- display: inline-block;
33
- vertical-align: middle;
34
- }
35
-
36
- .settings-tabs .collapsible .content{
37
- display: none;
38
- padding: 10px;
39
- background: #f1f1f1;
40
- }
41
-
42
-
43
- .settings-tabs .collapsible.active .content{
44
- display: block;
45
- }
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
- .settings-tabs{
54
- background: #fff;
55
- }
56
-
57
- .settings-tabs.vertical{
58
- position: relative;
59
- }
60
- .settings-tabs .tab-navs{
61
- float: left;
62
- margin: 0;
63
- padding: 0;
64
- position: sticky;
65
- top: 32px;
66
- }
67
- .settings-tabs .tab-nav{
68
- width: 200px;
69
- padding: 12px 10px;
70
- background: #f1f1f1;
71
- margin: 0;
72
- border-bottom: 1px solid #eee;
73
- cursor: pointer;
74
- font-size: 13px;
75
- }
76
-
77
- .settings-tabs .tab-nav.active{
78
- background:#f1f1f159;
79
- }
80
-
81
- .settings-tabs .tab-content{
82
- margin-left: 220px;
83
- padding: 20px 0;
84
- background: #f1f1f159;
85
- display: none;
86
- }
87
-
88
- .settings-tabs .tab-content.active{
89
- display: block;
90
- }
91
-
92
-
93
-
94
- /*horizontal*/
95
-
96
- .settings-tabs.horizontal{
97
-
98
- }
99
-
100
- .settings-tabs.horizontal .tab-navs{
101
- float: none;
102
- position: relative;
103
- top: 0;
104
- }
105
-
106
- .settings-tabs.horizontal .tab-navs .tab-nav{
107
- display: inline-block;
108
- float: left;
109
- width: auto;
110
- border-right: 1px solid #ddd;
111
- }
112
-
113
- .settings-tabs.horizontal .tab-navs .tab-nav:last-child{
114
- border-right: 1px solid rgba(0,0,0,0);
115
- }
116
-
117
-
118
- .settings-tabs.horizontal .tab-content{
119
- margin-left: 0;
120
- clear: both;
121
- }
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
- .settings-tabs .section{
139
- margin: 0;
140
- padding: 15px 0;
141
- }
142
- .settings-tabs .section-title{
143
- padding: 0 15px;
144
- font-size: 16px;
145
- font-weight: 600;
146
- }
147
-
148
- .settings-tabs .section-description{
149
- padding: 0 15px;
150
- margin-bottom: 25px;
151
- }
152
-
153
-
154
-
155
- .settings-tabs .setting-field{
156
- margin-bottom: 15px;
157
- border-bottom: 1px solid #eee;
158
- padding: 0 15px 15px 15px;
159
- }
160
- .settings-tabs .setting-field:last-child{
161
- border-bottom: 1px solid #eee0;
162
- }
163
-
164
-
165
-
166
- .settings-tabs .setting-field .field-lable{
167
- width: 270px;
168
- float: left;
169
- font-size: 14px;
170
- word-break: break-word;
171
- }
172
- .settings-tabs .setting-field .field-input{
173
- margin-left: 270px;
174
- }
175
- .settings-tabs .setting-field .description{
176
- word-break: break-word;
177
- }
178
-
179
-
180
-
181
-
182
- /*field-repeatable-wrapper*/
183
-
184
-
185
- .ppof-settings .repeatable .item-wrap{
186
- margin-bottom: 5px;
187
- padding-bottom: 0px;
188
- }
189
-
190
-
191
- .field-repeatable-wrapper .field-list{
192
- margin-top: 18px;
193
- }
194
- .field-repeatable-wrapper .button{
195
-
196
- }
197
-
198
-
199
-
200
-
201
-
202
- /*input*/
203
-
204
- .settings-tabs input[type="text"], .settings-tabs textarea, .settings-tabs select, .settings-tabs input[type="range"]{
205
- width: 360px;
206
- background: #f1f1f1;
207
- }
208
-
209
-
210
- @media (max-width: 1170px){
211
- .settings-tabs input[type="text"], .settings-tabs textarea, .settings-tabs select, .settings-tabs input[type="range"], .settings-tabs .select2{
212
- width: 100% !important;
213
-
214
- }
215
- }
216
-
217
-
218
- @media (max-width: 1440px){
219
-
220
- .settings-tabs .setting-field .field-lable{
221
- width: auto;
222
- float: none;
223
- font-size: 14px;
224
- }
225
- .settings-tabs .setting-field .field-input{
226
- margin-left: 0px;
227
- }
228
- .settings-tabs .setting-field .description{}
229
-
230
- }
231
-
232
- @media (max-width: 1700px){
233
-
234
- .settings-tabs .setting-field .setting-field .field-lable{
235
- width: auto;
236
- float: none;
237
- font-size: 14px;
238
- }
239
- .settings-tabs .setting-field .setting-field .field-input{
240
- margin-left: 0px;
241
- }
242
-
243
-
244
- }
245
-
246
-
247
-
248
-
249
- /*expandable*/
250
-
251
-
252
- .settings-tabs .expandable{}
253
- .settings-tabs .expandable .item {
254
-
255
- margin: 1px 0;
256
-
257
- }
258
-
259
-
260
- .settings-tabs .expandable .header label{
261
-
262
- }
263
-
264
-
265
-
266
- .settings-tabs .expandable .header {
267
- background: #eee none repeat scroll 0 0;
268
-
269
- }
270
-
271
-
272
- .settings-tabs .expandable {
273
-
274
- }
275
-
276
- .settings-tabs .expandable .options {
277
- background: #bde6fc;
278
- display: none;
279
- padding: 10px;
280
- }
281
-
282
-
283
-
284
- .settings-tabs .expandable .options {
285
- background:#f1f1f1;
286
- display: none;
287
- padding: 10px;
288
- }
289
-
290
-
291
- .settings-tabs .expandable .item.ui-sortable-helper {
292
- border: 1px dashed rgb(153, 153, 153);
293
- }
294
-
295
-
296
-
297
- .settings-tabs .expandable .header {
298
- padding: 5px;
299
-
300
- }
301
-
302
- .settings-tabs .expandable .active .options {
303
-
304
- display: block;
305
-
306
- }
307
-
308
- .settings-tabs .item .expand .fa-expand {
309
- display: inline-block;
310
- }
311
-
312
- .settings-tabs .item .expand .fa-compress {
313
- display: none;
314
- }
315
- .settings-tabs .item.active .expand .fa-compress {
316
- display: inline-block;
317
- }
318
- .settings-tabs .item.active .expand .fa-expand {
319
- display: none;
320
- }
321
-
322
-
323
-
324
- .settings-tabs .expandable .item .move {
325
- display: inline-block;
326
- padding: 5px;
327
- cursor: move;
328
- }
329
-
330
- .settings-tabs .expandable .item .expand {
331
- display: inline-block;
332
- padding: 5px;
333
- cursor: pointer;
334
- }
335
-
336
- .settings-tabs .expandable .remove {
337
- background: rgb(228, 65, 8) none repeat scroll 0 0;
338
- color: rgb(255, 255, 255);
339
- cursor: pointer;
340
- margin-right: 10px;
341
- padding: 2px 7px;
342
- border-radius: 3px;
343
- }
344
-
345
-
346
- .settings-tabs .pro-feature{
347
- background: #ffd87f;
348
- padding: 0 5px;
349
- }
350
-
351
-
352
-
353
- /*3rd Party*/
354
-
355
- .settings-tabs .field-input .CodeMirror{
356
- background: #f1f1f1;
357
- }
assets/admin/css/simplescrollbars.css DELETED
@@ -1,66 +0,0 @@
1
- .CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
2
- position: absolute;
3
- background: #ccc;
4
- -moz-box-sizing: border-box;
5
- box-sizing: border-box;
6
- border: 1px solid #bbb;
7
- border-radius: 2px;
8
- }
9
-
10
- .CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
11
- position: absolute;
12
- z-index: 6;
13
- background: #eee;
14
- }
15
-
16
- .CodeMirror-simplescroll-horizontal {
17
- bottom: 0; left: 0;
18
- height: 8px;
19
- }
20
- .CodeMirror-simplescroll-horizontal div {
21
- bottom: 0;
22
- height: 100%;
23
- }
24
-
25
- .CodeMirror-simplescroll-vertical {
26
- right: 0; top: 0;
27
- width: 8px;
28
- }
29
- .CodeMirror-simplescroll-vertical div {
30
- right: 0;
31
- width: 100%;
32
- }
33
-
34
-
35
- .CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
36
- display: none;
37
- }
38
-
39
- .CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
40
- position: absolute;
41
- background: #bcd;
42
- border-radius: 3px;
43
- }
44
-
45
- .CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
46
- position: absolute;
47
- z-index: 6;
48
- }
49
-
50
- .CodeMirror-overlayscroll-horizontal {
51
- bottom: 0; left: 0;
52
- height: 6px;
53
- }
54
- .CodeMirror-overlayscroll-horizontal div {
55
- bottom: 0;
56
- height: 100%;
57
- }
58
-
59
- .CodeMirror-overlayscroll-vertical {
60
- right: 0; top: 0;
61
- width: 6px;
62
- }
63
- .CodeMirror-overlayscroll-vertical div {
64
- right: 0;
65
- width: 100%;
66
- }
assets/admin/css/style-new.css DELETED
@@ -1,188 +0,0 @@
1
- /*
2
- Admin css
3
- */
4
-
5
- #post_grid_metabox, #post_grid_post_settings {
6
- background: #f1f1f1 none repeat scroll 0 0;
7
- border: medium none;
8
- box-shadow: none;
9
- }
10
-
11
- #post_grid_metabox .hndle, #post_grid_post_settings .hndle {
12
- background: #3f51b5;
13
- color: rgb(255, 255, 255) !important;
14
- }
15
-
16
- #post_grid_metabox .handlediv, #post_grid_post_settings .handlediv{
17
- color: rgb(255, 255, 255);
18
- }
19
-
20
-
21
-
22
-
23
- #post_grid_metabox .skin-list{
24
- text-align: center;
25
- }
26
-
27
- #post_grid_metabox .skin-list .skin-container {
28
- display: inline-block;
29
- margin: 10px;
30
- width: 310px;
31
- overflow: hidden;
32
- vertical-align: top;
33
- background: rgba(0, 0, 0, 0) url("../images/tile.png") repeat scroll 0 0;
34
- padding: 15px;
35
- }
36
-
37
- #post_grid_metabox .skin-list .skin-container .header {
38
- background: rgb(252, 110, 60) none repeat scroll 0 0;
39
- padding: 3px 10px;
40
- text-align: left;
41
- }
42
-
43
- #post_grid_metabox .skin-list .skin-container .header.selected {
44
- background: rgb(58, 212, 127) none repeat scroll 0 0;
45
- }
46
-
47
- #post_grid_metabox .skin-list .edit-link {
48
- float: right;
49
- }
50
-
51
- #post_grid_metabox .skin-list .edit-link a{
52
- color: #fff;
53
- text-decoration: none;
54
- }
55
-
56
-
57
-
58
-
59
-
60
- #post_grid_metabox .skin-list .skin-container label {
61
- color: rgb(255, 255, 255);
62
-
63
- }
64
-
65
-
66
-
67
-
68
- #post_grid_metabox .skin-list .skin {
69
- display: inline-block;
70
- overflow: hidden;
71
- vertical-align: top;
72
-
73
- }
74
-
75
-
76
-
77
-
78
-
79
-
80
- #post_grid_metabox .skin-list .skin .thumb img {
81
- height: auto;
82
- width: 100%;
83
- }
84
-
85
- #post_grid_metabox .skin-list .skin .title {
86
- font-size: 16px;
87
- line-height: normal;
88
- padding: 5px 0;
89
- }
90
-
91
- #post_grid_metabox .skin-list .skin .content {
92
- font-size: 13px;
93
- line-height: normal;
94
- padding: 5px 0;
95
- }
96
-
97
-
98
- #post_grid_metabox .skin-list .layer-content > div {
99
- padding: 5px 15px !important;
100
- }
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- #post_grid_metabox .layout-list{
111
-
112
- }
113
-
114
- #post_grid_metabox .layout-list .idle, #post_grid_metabox .layout-list .hover {
115
- background: rgba(0, 0, 0, 0) url("../images/tile.png") repeat scroll 0 0;
116
- display: inline-block;
117
- height: auto;
118
- margin: 0 10px;
119
- vertical-align: top;
120
- width: 400px;
121
- }
122
-
123
- #post_grid_metabox .layout-list .idle{}
124
- #post_grid_metabox .layout-list .hover {
125
- display: none;
126
- }
127
-
128
- #post_grid_metabox .layout-list .idle .name, #post_grid_metabox .layout-list .hover .name {
129
- background: rgb(240, 240, 240) none repeat scroll 0 0;
130
- border-bottom: 1px solid rgb(153, 153, 153);
131
- font-size: 20px;
132
- line-height: normal;
133
- padding: 5px 0;
134
- text-align: center;
135
- }
136
-
137
- #post_grid_metabox .layout-list .idle .name .edit-layout {
138
- background: #ddd none repeat scroll 0 0;
139
- padding: 2px 10px;
140
- text-decoration: none;
141
- }
142
-
143
-
144
- #post_grid_metabox .bg_image_src {
145
- border: 1px solid rgb(221, 221, 221);
146
- cursor: pointer;
147
- height: 50px;
148
- margin: 5px;
149
- vertical-align: top;
150
- width: 50px;
151
- }
152
-
153
- #post_grid_metabox .lazy_load_image {
154
- border: 1px solid rgb(221, 221, 221);
155
- cursor: pointer;
156
- margin: 5px;
157
- padding: 10px;
158
- vertical-align: top;
159
- }
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
- #post_grid_metabox .media-source-list{}
169
-
170
- #post_grid_metabox .media-source-list .items{}
171
-
172
- #post_grid_metabox .media-source-list .items .move {
173
- background: #ddd;
174
- padding: 1px 5px;
175
- margin-right: 10px;
176
- cursor: move;
177
- }
178
-
179
-
180
-
181
-
182
- .post-grid-settings .layout-list{}
183
- .post-grid-settings .layout-list li {
184
- background: #eeeeee none repeat scroll 0 0;
185
- padding: 6px 10px;
186
- }
187
-
188
-
assets/admin/images/layout_grid.png CHANGED
Binary file
assets/admin/images/menu-grid-icon.png DELETED
Binary file
assets/admin/js/codemirror.js DELETED
@@ -1,8871 +0,0 @@
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
- var userAgent = navigator.userAgent;
25
- var platform = navigator.platform;
26
-
27
- var gecko = /gecko\/\d/i.test(userAgent);
28
- var ie_upto10 = /MSIE \d/.test(userAgent);
29
- var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
30
- var ie = ie_upto10 || ie_11up;
31
- var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
32
- var webkit = /WebKit\//.test(userAgent);
33
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
34
- var chrome = /Chrome\//.test(userAgent);
35
- var presto = /Opera\//.test(userAgent);
36
- var safari = /Apple Computer/.test(navigator.vendor);
37
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
38
- var phantom = /PhantomJS/.test(userAgent);
39
-
40
- var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(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(userAgent);
43
- var mac = ios || /Mac/.test(platform);
44
- var windows = /win/i.test(platform);
45
-
46
- var presto_version = presto && 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 ? copyObj(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, null, options.lineSeparator);
71
- this.doc = doc;
72
-
73
- var input = new CodeMirror.inputStyles[options.inputStyle](this);
74
- var display = this.display = new Display(place, doc, input);
75
- display.wrapper.CodeMirror = this;
76
- updateGutters(this);
77
- themeChanged(this);
78
- if (options.lineWrapping)
79
- this.display.wrapper.className += " CodeMirror-wrap";
80
- if (options.autofocus && !mobile) display.input.focus();
81
- initScrollbars(this);
82
-
83
- this.state = {
84
- keyMaps: [], // stores maps added by addKeyMap
85
- overlays: [], // highlighting overlays, as added by addOverlay
86
- modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
87
- overwrite: false,
88
- delayingBlurEvent: false,
89
- focused: false,
90
- suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
91
- pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
92
- selectingText: false,
93
- draggingText: false,
94
- highlight: new Delayed(), // stores highlight worker timeout
95
- keySeq: null, // Unfinished key sequence
96
- specialChars: null
97
- };
98
-
99
- var cm = this;
100
-
101
- // Override magic textarea content restore that IE sometimes does
102
- // on our hidden textarea on reload
103
- if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
104
-
105
- registerEventHandlers(this);
106
- ensureGlobalHandlers();
107
-
108
- startOperation(this);
109
- this.curOp.forceUpdate = true;
110
- attachDoc(this, doc);
111
-
112
- if ((options.autofocus && !mobile) || cm.hasFocus())
113
- setTimeout(bind(onFocus, this), 20);
114
- else
115
- onBlur(this);
116
-
117
- for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
118
- optionHandlers[opt](this, options[opt], Init);
119
- maybeUpdateLineNumberWidth(this);
120
- if (options.finishInit) options.finishInit(this);
121
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
122
- endOperation(this);
123
- // Suppress optimizelegibility in Webkit, since it breaks text
124
- // measuring on line wrapping boundaries.
125
- if (webkit && options.lineWrapping &&
126
- getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
127
- display.lineDiv.style.textRendering = "auto";
128
- }
129
-
130
- // DISPLAY CONSTRUCTOR
131
-
132
- // The display handles the DOM integration, both for input reading
133
- // and content drawing. It holds references to DOM nodes and
134
- // display-related state.
135
-
136
- function Display(place, doc, input) {
137
- var d = this;
138
- this.input = input;
139
-
140
- // Covers bottom-right square when both scrollbars are present.
141
- d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
142
- d.scrollbarFiller.setAttribute("cm-not-content", "true");
143
- // Covers bottom of gutter when coverGutterNextToScrollbar is on
144
- // and h scrollbar is present.
145
- d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
146
- d.gutterFiller.setAttribute("cm-not-content", "true");
147
- // Will contain the actual code, positioned to cover the viewport.
148
- d.lineDiv = elt("div", null, "CodeMirror-code");
149
- // Elements are added to these to represent selection and cursors.
150
- d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
151
- d.cursorDiv = elt("div", null, "CodeMirror-cursors");
152
- // A visibility: hidden element used to find the size of things.
153
- d.measure = elt("div", null, "CodeMirror-measure");
154
- // When lines outside of the viewport are measured, they are drawn in this.
155
- d.lineMeasure = elt("div", null, "CodeMirror-measure");
156
- // Wraps everything that needs to exist inside the vertically-padded coordinate system
157
- d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
158
- null, "position: relative; outline: none");
159
- // Moved around its parent to cover visible view.
160
- d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
161
- // Set to the height of the document, allowing scrolling.
162
- d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
163
- d.sizerWidth = null;
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: " + scrollerGap + "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.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
176
-
177
- // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
178
- if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
179
- if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
180
-
181
- if (place) {
182
- if (place.appendChild) place.appendChild(d.wrapper);
183
- else place(d.wrapper);
184
- }
185
-
186
- // Current rendered range (may be bigger than the view window).
187
- d.viewFrom = d.viewTo = doc.first;
188
- d.reportedViewFrom = d.reportedViewTo = doc.first;
189
- // Information about the rendered lines.
190
- d.view = [];
191
- d.renderedView = null;
192
- // Holds info about a single rendered line when it was rendered
193
- // for measurement, while not in view.
194
- d.externalMeasured = null;
195
- // Empty space (in pixels) above the view
196
- d.viewOffset = 0;
197
- d.lastWrapHeight = d.lastWrapWidth = 0;
198
- d.updateLineNumbers = null;
199
-
200
- d.nativeBarWidth = d.barHeight = d.barWidth = 0;
201
- d.scrollbarsClipped = false;
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
- // Set to true when a non-horizontal-scrolling line widget is
207
- // added. As an optimization, line widget aligning is skipped when
208
- // this is false.
209
- d.alignWidgets = false;
210
-
211
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
212
-
213
- // Tracks the maximum line length so that the horizontal scrollbar
214
- // can be kept static when scrolling.
215
- d.maxLine = null;
216
- d.maxLineLength = 0;
217
- d.maxLineChanged = false;
218
-
219
- // Used for measuring wheel scrolling granularity
220
- d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
221
-
222
- // True when shift is held down.
223
- d.shift = false;
224
-
225
- // Used to track whether anything happened since the context menu
226
- // was opened.
227
- d.selForContextMenu = null;
228
-
229
- d.activeTouch = null;
230
-
231
- input.init(d);
232
- }
233
-
234
- // STATE UPDATES
235
-
236
- // Used to get the editor into a consistent state again when options change.
237
-
238
- function loadMode(cm) {
239
- cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
240
- resetModeState(cm);
241
- }
242
-
243
- function resetModeState(cm) {
244
- cm.doc.iter(function(line) {
245
- if (line.stateAfter) line.stateAfter = null;
246
- if (line.styles) line.styles = null;
247
- });
248
- cm.doc.frontier = cm.doc.first;
249
- startWorker(cm, 100);
250
- cm.state.modeGen++;
251
- if (cm.curOp) regChange(cm);
252
- }
253
-
254
- function wrappingChanged(cm) {
255
- if (cm.options.lineWrapping) {
256
- addClass(cm.display.wrapper, "CodeMirror-wrap");
257
- cm.display.sizer.style.minWidth = "";
258
- cm.display.sizerWidth = null;
259
- } else {
260
- rmClass(cm.display.wrapper, "CodeMirror-wrap");
261
- findMaxLine(cm);
262
- }
263
- estimateLineHeights(cm);
264
- regChange(cm);
265
- clearCaches(cm);
266
- setTimeout(function(){updateScrollbars(cm);}, 100);
267
- }
268
-
269
- // Returns a function that estimates the height of a line, to use as
270
- // first approximation until the line becomes visible (and is thus
271
- // properly measurable).
272
- function estimateHeight(cm) {
273
- var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
274
- var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
275
- return function(line) {
276
- if (lineIsHidden(cm.doc, line)) return 0;
277
-
278
- var widgetsHeight = 0;
279
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
280
- if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
281
- }
282
-
283
- if (wrapping)
284
- return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
285
- else
286
- return widgetsHeight + th;
287
- };
288
- }
289
-
290
- function estimateLineHeights(cm) {
291
- var doc = cm.doc, est = estimateHeight(cm);
292
- doc.iter(function(line) {
293
- var estHeight = est(line);
294
- if (estHeight != line.height) updateLineHeight(line, estHeight);
295
- });
296
- }
297
-
298
- function themeChanged(cm) {
299
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
300
- cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
301
- clearCaches(cm);
302
- }
303
-
304
- function guttersChanged(cm) {
305
- updateGutters(cm);
306
- regChange(cm);
307
- setTimeout(function(){alignHorizontally(cm);}, 20);
308
- }
309
-
310
- // Rebuild the gutter elements, ensure the margin to the left of the
311
- // code matches their width.
312
- function updateGutters(cm) {
313
- var gutters = cm.display.gutters, specs = cm.options.gutters;
314
- removeChildren(gutters);
315
- for (var i = 0; i < specs.length; ++i) {
316
- var gutterClass = specs[i];
317
- var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
318
- if (gutterClass == "CodeMirror-linenumbers") {
319
- cm.display.lineGutter = gElt;
320
- gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
321
- }
322
- }
323
- gutters.style.display = i ? "" : "none";
324
- updateGutterSpace(cm);
325
- }
326
-
327
- function updateGutterSpace(cm) {
328
- var width = cm.display.gutters.offsetWidth;
329
- cm.display.sizer.style.marginLeft = width + "px";
330
- }
331
-
332
- // Compute the character length of a line, taking into account
333
- // collapsed ranges (see markText) that might hide parts, and join
334
- // other lines onto it.
335
- function lineLength(line) {
336
- if (line.height == 0) return 0;
337
- var len = line.text.length, merged, cur = line;
338
- while (merged = collapsedSpanAtStart(cur)) {
339
- var found = merged.find(0, true);
340
- cur = found.from.line;
341
- len += found.from.ch - found.to.ch;
342
- }
343
- cur = line;
344
- while (merged = collapsedSpanAtEnd(cur)) {
345
- var found = merged.find(0, true);
346
- len -= cur.text.length - found.from.ch;
347
- cur = found.to.line;
348
- len += cur.text.length - found.to.ch;
349
- }
350
- return len;
351
- }
352
-
353
- // Find the longest line in the document.
354
- function findMaxLine(cm) {
355
- var d = cm.display, doc = cm.doc;
356
- d.maxLine = getLine(doc, doc.first);
357
- d.maxLineLength = lineLength(d.maxLine);
358
- d.maxLineChanged = true;
359
- doc.iter(function(line) {
360
- var len = lineLength(line);
361
- if (len > d.maxLineLength) {
362
- d.maxLineLength = len;
363
- d.maxLine = line;
364
- }
365
- });
366
- }
367
-
368
- // Make sure the gutters options contains the element
369
- // "CodeMirror-linenumbers" when the lineNumbers option is true.
370
- function setGuttersForLineNumbers(options) {
371
- var found = indexOf(options.gutters, "CodeMirror-linenumbers");
372
- if (found == -1 && options.lineNumbers) {
373
- options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
374
- } else if (found > -1 && !options.lineNumbers) {
375
- options.gutters = options.gutters.slice(0);
376
- options.gutters.splice(found, 1);
377
- }
378
- }
379
-
380
- // SCROLLBARS
381
-
382
- // Prepare DOM reads needed to update the scrollbars. Done in one
383
- // shot to minimize update/measure roundtrips.
384
- function measureForScrollbars(cm) {
385
- var d = cm.display, gutterW = d.gutters.offsetWidth;
386
- var docH = Math.round(cm.doc.height + paddingVert(cm.display));
387
- return {
388
- clientHeight: d.scroller.clientHeight,
389
- viewHeight: d.wrapper.clientHeight,
390
- scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
391
- viewWidth: d.wrapper.clientWidth,
392
- barLeft: cm.options.fixedGutter ? gutterW : 0,
393
- docHeight: docH,
394
- scrollHeight: docH + scrollGap(cm) + d.barHeight,
395
- nativeBarWidth: d.nativeBarWidth,
396
- gutterWidth: gutterW
397
- };
398
- }
399
-
400
- function NativeScrollbars(place, scroll, cm) {
401
- this.cm = cm;
402
- var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
403
- var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
404
- place(vert); place(horiz);
405
-
406
- on(vert, "scroll", function() {
407
- if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
408
- });
409
- on(horiz, "scroll", function() {
410
- if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
411
- });
412
-
413
- this.checkedZeroWidth = false;
414
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
415
- if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
416
- }
417
-
418
- NativeScrollbars.prototype = copyObj({
419
- update: function(measure) {
420
- var needsH = measure.scrollWidth > measure.clientWidth + 1;
421
- var needsV = measure.scrollHeight > measure.clientHeight + 1;
422
- var sWidth = measure.nativeBarWidth;
423
-
424
- if (needsV) {
425
- this.vert.style.display = "block";
426
- this.vert.style.bottom = needsH ? sWidth + "px" : "0";
427
- var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
428
- // A bug in IE8 can cause this value to be negative, so guard it.
429
- this.vert.firstChild.style.height =
430
- Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
431
- } else {
432
- this.vert.style.display = "";
433
- this.vert.firstChild.style.height = "0";
434
- }
435
-
436
- if (needsH) {
437
- this.horiz.style.display = "block";
438
- this.horiz.style.right = needsV ? sWidth + "px" : "0";
439
- this.horiz.style.left = measure.barLeft + "px";
440
- var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
441
- this.horiz.firstChild.style.width =
442
- (measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
443
- } else {
444
- this.horiz.style.display = "";
445
- this.horiz.firstChild.style.width = "0";
446
- }
447
-
448
- if (!this.checkedZeroWidth && measure.clientHeight > 0) {
449
- if (sWidth == 0) this.zeroWidthHack();
450
- this.checkedZeroWidth = true;
451
- }
452
-
453
- return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
454
- },
455
- setScrollLeft: function(pos) {
456
- if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
457
- if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
458
- },
459
- setScrollTop: function(pos) {
460
- if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
461
- if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
462
- },
463
- zeroWidthHack: function() {
464
- var w = mac && !mac_geMountainLion ? "12px" : "18px";
465
- this.horiz.style.height = this.vert.style.width = w;
466
- this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
467
- this.disableHoriz = new Delayed;
468
- this.disableVert = new Delayed;
469
- },
470
- enableZeroWidthBar: function(bar, delay) {
471
- bar.style.pointerEvents = "auto";
472
- function maybeDisable() {
473
- // To find out whether the scrollbar is still visible, we
474
- // check whether the element under the pixel in the bottom
475
- // left corner of the scrollbar box is the scrollbar box
476
- // itself (when the bar is still visible) or its filler child
477
- // (when the bar is hidden). If it is still visible, we keep
478
- // it enabled, if it's hidden, we disable pointer events.
479
- var box = bar.getBoundingClientRect();
480
- var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
481
- if (elt != bar) bar.style.pointerEvents = "none";
482
- else delay.set(1000, maybeDisable);
483
- }
484
- delay.set(1000, maybeDisable);
485
- },
486
- clear: function() {
487
- var parent = this.horiz.parentNode;
488
- parent.removeChild(this.horiz);
489
- parent.removeChild(this.vert);
490
- }
491
- }, NativeScrollbars.prototype);
492
-
493
- function NullScrollbars() {}
494
-
495
- NullScrollbars.prototype = copyObj({
496
- update: function() { return {bottom: 0, right: 0}; },
497
- setScrollLeft: function() {},
498
- setScrollTop: function() {},
499
- clear: function() {}
500
- }, NullScrollbars.prototype);
501
-
502
- CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
503
-
504
- function initScrollbars(cm) {
505
- if (cm.display.scrollbars) {
506
- cm.display.scrollbars.clear();
507
- if (cm.display.scrollbars.addClass)
508
- rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
509
- }
510
-
511
- cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
512
- cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
513
- // Prevent clicks in the scrollbars from killing focus
514
- on(node, "mousedown", function() {
515
- if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
516
- });
517
- node.setAttribute("cm-not-content", "true");
518
- }, function(pos, axis) {
519
- if (axis == "horizontal") setScrollLeft(cm, pos);
520
- else setScrollTop(cm, pos);
521
- }, cm);
522
- if (cm.display.scrollbars.addClass)
523
- addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
524
- }
525
-
526
- function updateScrollbars(cm, measure) {
527
- if (!measure) measure = measureForScrollbars(cm);
528
- var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
529
- updateScrollbarsInner(cm, measure);
530
- for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
531
- if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
532
- updateHeightsInViewport(cm);
533
- updateScrollbarsInner(cm, measureForScrollbars(cm));
534
- startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
535
- }
536
- }
537
-
538
- // Re-synchronize the fake scrollbars with the actual size of the
539
- // content.
540
- function updateScrollbarsInner(cm, measure) {
541
- var d = cm.display;
542
- var sizes = d.scrollbars.update(measure);
543
-
544
- d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
545
- d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
546
-
547
- if (sizes.right && sizes.bottom) {
548
- d.scrollbarFiller.style.display = "block";
549
- d.scrollbarFiller.style.height = sizes.bottom + "px";
550
- d.scrollbarFiller.style.width = sizes.right + "px";
551
- } else d.scrollbarFiller.style.display = "";
552
- if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
553
- d.gutterFiller.style.display = "block";
554
- d.gutterFiller.style.height = sizes.bottom + "px";
555
- d.gutterFiller.style.width = measure.gutterWidth + "px";
556
- } else d.gutterFiller.style.display = "";
557
- }
558
-
559
- // Compute the lines that are visible in a given viewport (defaults
560
- // the the current scroll position). viewport may contain top,
561
- // height, and ensure (see op.scrollToPos) properties.
562
- function visibleLines(display, doc, viewport) {
563
- var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
564
- top = Math.floor(top - paddingTop(display));
565
- var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
566
-
567
- var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
568
- // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
569
- // forces those lines into the viewport (if possible).
570
- if (viewport && viewport.ensure) {
571
- var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
572
- if (ensureFrom < from) {
573
- from = ensureFrom;
574
- to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
575
- } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
576
- from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
577
- to = ensureTo;
578
- }
579
- }
580
- return {from: from, to: Math.max(to, from + 1)};
581
- }
582
-
583
- // LINE NUMBERS
584
-
585
- // Re-align line numbers and gutter marks to compensate for
586
- // horizontal scrolling.
587
- function alignHorizontally(cm) {
588
- var display = cm.display, view = display.view;
589
- if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
590
- var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
591
- var gutterW = display.gutters.offsetWidth, left = comp + "px";
592
- for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
593
- if (cm.options.fixedGutter && view[i].gutter)
594
- view[i].gutter.style.left = left;
595
- var align = view[i].alignable;
596
- if (align) for (var j = 0; j < align.length; j++)
597
- align[j].style.left = left;
598
- }
599
- if (cm.options.fixedGutter)
600
- display.gutters.style.left = (comp + gutterW) + "px";
601
- }
602
-
603
- // Used to ensure that the line number gutter is still the right
604
- // size for the current document size. Returns true when an update
605
- // is needed.
606
- function maybeUpdateLineNumberWidth(cm) {
607
- if (!cm.options.lineNumbers) return false;
608
- var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
609
- if (last.length != display.lineNumChars) {
610
- var test = display.measure.appendChild(elt("div", [elt("div", last)],
611
- "CodeMirror-linenumber CodeMirror-gutter-elt"));
612
- var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
613
- display.lineGutter.style.width = "";
614
- display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
615
- display.lineNumWidth = display.lineNumInnerWidth + padding;
616
- display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
617
- display.lineGutter.style.width = display.lineNumWidth + "px";
618
- updateGutterSpace(cm);
619
- return true;
620
- }
621
- return false;
622
- }
623
-
624
- function lineNumberFor(options, i) {
625
- return String(options.lineNumberFormatter(i + options.firstLineNumber));
626
- }
627
-
628
- // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
629
- // but using getBoundingClientRect to get a sub-pixel-accurate
630
- // result.
631
- function compensateForHScroll(display) {
632
- return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
633
- }
634
-
635
- // DISPLAY DRAWING
636
-
637
- function DisplayUpdate(cm, viewport, force) {
638
- var display = cm.display;
639
-
640
- this.viewport = viewport;
641
- // Store some values that we'll need later (but don't want to force a relayout for)
642
- this.visible = visibleLines(display, cm.doc, viewport);
643
- this.editorIsHidden = !display.wrapper.offsetWidth;
644
- this.wrapperHeight = display.wrapper.clientHeight;
645
- this.wrapperWidth = display.wrapper.clientWidth;
646
- this.oldDisplayWidth = displayWidth(cm);
647
- this.force = force;
648
- this.dims = getDimensions(cm);
649
- this.events = [];
650
- }
651
-
652
- DisplayUpdate.prototype.signal = function(emitter, type) {
653
- if (hasHandler(emitter, type))
654
- this.events.push(arguments);
655
- };
656
- DisplayUpdate.prototype.finish = function() {
657
- for (var i = 0; i < this.events.length; i++)
658
- signal.apply(null, this.events[i]);
659
- };
660
-
661
- function maybeClipScrollbars(cm) {
662
- var display = cm.display;
663
- if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
664
- display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
665
- display.heightForcer.style.height = scrollGap(cm) + "px";
666
- display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
667
- display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
668
- display.scrollbarsClipped = true;
669
- }
670
- }
671
-
672
- // Does the actual updating of the line display. Bails out
673
- // (returning false) when there is nothing to be done and forced is
674
- // false.
675
- function updateDisplayIfNeeded(cm, update) {
676
- var display = cm.display, doc = cm.doc;
677
-
678
- if (update.editorIsHidden) {
679
- resetView(cm);
680
- return false;
681
- }
682
-
683
- // Bail out if the visible area is already rendered and nothing changed.
684
- if (!update.force &&
685
- update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
686
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
687
- display.renderedView == display.view && countDirtyView(cm) == 0)
688
- return false;
689
-
690
- if (maybeUpdateLineNumberWidth(cm)) {
691
- resetView(cm);
692
- update.dims = getDimensions(cm);
693
- }
694
-
695
- // Compute a suitable new viewport (from & to)
696
- var end = doc.first + doc.size;
697
- var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
698
- var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
699
- if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
700
- if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
701
- if (sawCollapsedSpans) {
702
- from = visualLineNo(cm.doc, from);
703
- to = visualLineEndNo(cm.doc, to);
704
- }
705
-
706
- var different = from != display.viewFrom || to != display.viewTo ||
707
- display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
708
- adjustView(cm, from, to);
709
-
710
- display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
711
- // Position the mover div to align with the current scroll position
712
- cm.display.mover.style.top = display.viewOffset + "px";
713
-
714
- var toUpdate = countDirtyView(cm);
715
- if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
716
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
717
- return false;
718
-
719
- // For big changes, we hide the enclosing element during the
720
- // update, since that speeds up the operations on most browsers.
721
- var focused = activeElt();
722
- if (toUpdate > 4) display.lineDiv.style.display = "none";
723
- patchDisplay(cm, display.updateLineNumbers, update.dims);
724
- if (toUpdate > 4) display.lineDiv.style.display = "";
725
- display.renderedView = display.view;
726
- // There might have been a widget with a focused element that got
727
- // hidden or updated, if so re-focus it.
728
- if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
729
-
730
- // Prevent selection and cursors from interfering with the scroll
731
- // width and height.
732
- removeChildren(display.cursorDiv);
733
- removeChildren(display.selectionDiv);
734
- display.gutters.style.height = display.sizer.style.minHeight = 0;
735
-
736
- if (different) {
737
- display.lastWrapHeight = update.wrapperHeight;
738
- display.lastWrapWidth = update.wrapperWidth;
739
- startWorker(cm, 400);
740
- }
741
-
742
- display.updateLineNumbers = null;
743
-
744
- return true;
745
- }
746
-
747
- function postUpdateDisplay(cm, update) {
748
- var viewport = update.viewport;
749
- for (var first = true;; first = false) {
750
- if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
751
- // Clip forced viewport to actual scrollable area.
752
- if (viewport && viewport.top != null)
753
- viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
754
- // Updated line heights might result in the drawn area not
755
- // actually covering the viewport. Keep looping until it does.
756
- update.visible = visibleLines(cm.display, cm.doc, viewport);
757
- if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
758
- break;
759
- }
760
- if (!updateDisplayIfNeeded(cm, update)) break;
761
- updateHeightsInViewport(cm);
762
- var barMeasure = measureForScrollbars(cm);
763
- updateSelection(cm);
764
- setDocumentHeight(cm, barMeasure);
765
- updateScrollbars(cm, barMeasure);
766
- }
767
-
768
- update.signal(cm, "update", cm);
769
- if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
770
- update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
771
- cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
772
- }
773
- }
774
-
775
- function updateDisplaySimple(cm, viewport) {
776
- var update = new DisplayUpdate(cm, viewport);
777
- if (updateDisplayIfNeeded(cm, update)) {
778
- updateHeightsInViewport(cm);
779
- postUpdateDisplay(cm, update);
780
- var barMeasure = measureForScrollbars(cm);
781
- updateSelection(cm);
782
- setDocumentHeight(cm, barMeasure);
783
- updateScrollbars(cm, barMeasure);
784
- update.finish();
785
- }
786
- }
787
-
788
- function setDocumentHeight(cm, measure) {
789
- cm.display.sizer.style.minHeight = measure.docHeight + "px";
790
- var total = measure.docHeight + cm.display.barHeight;
791
- cm.display.heightForcer.style.top = total + "px";
792
- cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
793
- }
794
-
795
- // Read the actual heights of the rendered lines, and update their
796
- // stored heights to match.
797
- function updateHeightsInViewport(cm) {
798
- var display = cm.display;
799
- var prevBottom = display.lineDiv.offsetTop;
800
- for (var i = 0; i < display.view.length; i++) {
801
- var cur = display.view[i], height;
802
- if (cur.hidden) continue;
803
- if (ie && ie_version < 8) {
804
- var bot = cur.node.offsetTop + cur.node.offsetHeight;
805
- height = bot - prevBottom;
806
- prevBottom = bot;
807
- } else {
808
- var box = cur.node.getBoundingClientRect();
809
- height = box.bottom - box.top;
810
- }
811
- var diff = cur.line.height - height;
812
- if (height < 2) height = textHeight(display);
813
- if (diff > .001 || diff < -.001) {
814
- updateLineHeight(cur.line, height);
815
- updateWidgetHeight(cur.line);
816
- if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
817
- updateWidgetHeight(cur.rest[j]);
818
- }
819
- }
820
- }
821
-
822
- // Read and store the height of line widgets associated with the
823
- // given line.
824
- function updateWidgetHeight(line) {
825
- if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
826
- line.widgets[i].height = line.widgets[i].node.offsetHeight;
827
- }
828
-
829
- // Do a bulk-read of the DOM positions and sizes needed to draw the
830
- // view, so that we don't interleave reading and writing to the DOM.
831
- function getDimensions(cm) {
832
- var d = cm.display, left = {}, width = {};
833
- var gutterLeft = d.gutters.clientLeft;
834
- for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
835
- left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
836
- width[cm.options.gutters[i]] = n.clientWidth;
837
- }
838
- return {fixedPos: compensateForHScroll(d),
839
- gutterTotalWidth: d.gutters.offsetWidth,
840
- gutterLeft: left,
841
- gutterWidth: width,
842
- wrapperWidth: d.wrapper.clientWidth};
843
- }
844
-
845
- // Sync the actual display DOM structure with display.view, removing
846
- // nodes for lines that are no longer in view, and creating the ones
847
- // that are not there yet, and updating the ones that are out of
848
- // date.
849
- function patchDisplay(cm, updateNumbersFrom, dims) {
850
- var display = cm.display, lineNumbers = cm.options.lineNumbers;
851
- var container = display.lineDiv, cur = container.firstChild;
852
-
853
- function rm(node) {
854
- var next = node.nextSibling;
855
- // Works around a throw-scroll bug in OS X Webkit
856
- if (webkit && mac && cm.display.currentWheelTarget == node)
857
- node.style.display = "none";
858
- else
859
- node.parentNode.removeChild(node);
860
- return next;
861
- }
862
-
863
- var view = display.view, lineN = display.viewFrom;
864
- // Loop over the elements in the view, syncing cur (the DOM nodes
865
- // in display.lineDiv) with the view as we go.
866
- for (var i = 0; i < view.length; i++) {
867
- var lineView = view[i];
868
- if (lineView.hidden) {
869
- } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
870
- var node = buildLineElement(cm, lineView, lineN, dims);
871
- container.insertBefore(node, cur);
872
- } else { // Already drawn
873
- while (cur != lineView.node) cur = rm(cur);
874
- var updateNumber = lineNumbers && updateNumbersFrom != null &&
875
- updateNumbersFrom <= lineN && lineView.lineNumber;
876
- if (lineView.changes) {
877
- if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
878
- updateLineForChanges(cm, lineView, lineN, dims);
879
- }
880
- if (updateNumber) {
881
- removeChildren(lineView.lineNumber);
882
- lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
883
- }
884
- cur = lineView.node.nextSibling;
885
- }
886
- lineN += lineView.size;
887
- }
888
- while (cur) cur = rm(cur);
889
- }
890
-
891
- // When an aspect of a line changes, a string is added to
892
- // lineView.changes. This updates the relevant part of the line's
893
- // DOM structure.
894
- function updateLineForChanges(cm, lineView, lineN, dims) {
895
- for (var j = 0; j < lineView.changes.length; j++) {
896
- var type = lineView.changes[j];
897
- if (type == "text") updateLineText(cm, lineView);
898
- else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
899
- else if (type == "class") updateLineClasses(lineView);
900
- else if (type == "widget") updateLineWidgets(cm, lineView, dims);
901
- }
902
- lineView.changes = null;
903
- }
904
-
905
- // Lines with gutter elements, widgets or a background class need to
906
- // be wrapped, and have the extra elements added to the wrapper div
907
- function ensureLineWrapped(lineView) {
908
- if (lineView.node == lineView.text) {
909
- lineView.node = elt("div", null, null, "position: relative");
910
- if (lineView.text.parentNode)
911
- lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
912
- lineView.node.appendChild(lineView.text);
913
- if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
914
- }
915
- return lineView.node;
916
- }
917
-
918
- function updateLineBackground(lineView) {
919
- var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
920
- if (cls) cls += " CodeMirror-linebackground";
921
- if (lineView.background) {
922
- if (cls) lineView.background.className = cls;
923
- else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
924
- } else if (cls) {
925
- var wrap = ensureLineWrapped(lineView);
926
- lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
927
- }
928
- }
929
-
930
- // Wrapper around buildLineContent which will reuse the structure
931
- // in display.externalMeasured when possible.
932
- function getLineContent(cm, lineView) {
933
- var ext = cm.display.externalMeasured;
934
- if (ext && ext.line == lineView.line) {
935
- cm.display.externalMeasured = null;
936
- lineView.measure = ext.measure;
937
- return ext.built;
938
- }
939
- return buildLineContent(cm, lineView);
940
- }
941
-
942
- // Redraw the line's text. Interacts with the background and text
943
- // classes because the mode may output tokens that influence these
944
- // classes.
945
- function updateLineText(cm, lineView) {
946
- var cls = lineView.text.className;
947
- var built = getLineContent(cm, lineView);
948
- if (lineView.text == lineView.node) lineView.node = built.pre;
949
- lineView.text.parentNode.replaceChild(built.pre, lineView.text);
950
- lineView.text = built.pre;
951
- if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
952
- lineView.bgClass = built.bgClass;
953
- lineView.textClass = built.textClass;
954
- updateLineClasses(lineView);
955
- } else if (cls) {
956
- lineView.text.className = cls;
957
- }
958
- }
959
-
960
- function updateLineClasses(lineView) {
961
- updateLineBackground(lineView);
962
- if (lineView.line.wrapClass)
963
- ensureLineWrapped(lineView).className = lineView.line.wrapClass;
964
- else if (lineView.node != lineView.text)
965
- lineView.node.className = "";
966
- var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
967
- lineView.text.className = textClass || "";
968
- }
969
-
970
- function updateLineGutter(cm, lineView, lineN, dims) {
971
- if (lineView.gutter) {
972
- lineView.node.removeChild(lineView.gutter);
973
- lineView.gutter = null;
974
- }
975
- if (lineView.gutterBackground) {
976
- lineView.node.removeChild(lineView.gutterBackground);
977
- lineView.gutterBackground = null;
978
- }
979
- if (lineView.line.gutterClass) {
980
- var wrap = ensureLineWrapped(lineView);
981
- lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
982
- "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
983
- "px; width: " + dims.gutterTotalWidth + "px");
984
- wrap.insertBefore(lineView.gutterBackground, lineView.text);
985
- }
986
- var markers = lineView.line.gutterMarkers;
987
- if (cm.options.lineNumbers || markers) {
988
- var wrap = ensureLineWrapped(lineView);
989
- var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
990
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
991
- cm.display.input.setUneditable(gutterWrap);
992
- wrap.insertBefore(gutterWrap, lineView.text);
993
- if (lineView.line.gutterClass)
994
- gutterWrap.className += " " + lineView.line.gutterClass;
995
- if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
996
- lineView.lineNumber = gutterWrap.appendChild(
997
- elt("div", lineNumberFor(cm.options, lineN),
998
- "CodeMirror-linenumber CodeMirror-gutter-elt",
999
- "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
1000
- + cm.display.lineNumInnerWidth + "px"));
1001
- if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
1002
- var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
1003
- if (found)
1004
- gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
1005
- dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
1006
- }
1007
- }
1008
- }
1009
-
1010
- function updateLineWidgets(cm, lineView, dims) {
1011
- if (lineView.alignable) lineView.alignable = null;
1012
- for (var node = lineView.node.firstChild, next; node; node = next) {
1013
- var next = node.nextSibling;
1014
- if (node.className == "CodeMirror-linewidget")
1015
- lineView.node.removeChild(node);
1016
- }
1017
- insertLineWidgets(cm, lineView, dims);
1018
- }
1019
-
1020
- // Build a line's DOM representation from scratch
1021
- function buildLineElement(cm, lineView, lineN, dims) {
1022
- var built = getLineContent(cm, lineView);
1023
- lineView.text = lineView.node = built.pre;
1024
- if (built.bgClass) lineView.bgClass = built.bgClass;
1025
- if (built.textClass) lineView.textClass = built.textClass;
1026
-
1027
- updateLineClasses(lineView);
1028
- updateLineGutter(cm, lineView, lineN, dims);
1029
- insertLineWidgets(cm, lineView, dims);
1030
- return lineView.node;
1031
- }
1032
-
1033
- // A lineView may contain multiple logical lines (when merged by
1034
- // collapsed spans). The widgets for all of them need to be drawn.
1035
- function insertLineWidgets(cm, lineView, dims) {
1036
- insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
1037
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
1038
- insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
1039
- }
1040
-
1041
- function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
1042
- if (!line.widgets) return;
1043
- var wrap = ensureLineWrapped(lineView);
1044
- for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
1045
- var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
1046
- if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
1047
- positionLineWidget(widget, node, lineView, dims);
1048
- cm.display.input.setUneditable(node);
1049
- if (allowAbove && widget.above)
1050
- wrap.insertBefore(node, lineView.gutter || lineView.text);
1051
- else
1052
- wrap.appendChild(node);
1053
- signalLater(widget, "redraw");
1054
- }
1055
- }
1056
-
1057
- function positionLineWidget(widget, node, lineView, dims) {
1058
- if (widget.noHScroll) {
1059
- (lineView.alignable || (lineView.alignable = [])).push(node);
1060
- var width = dims.wrapperWidth;
1061
- node.style.left = dims.fixedPos + "px";
1062
- if (!widget.coverGutter) {
1063
- width -= dims.gutterTotalWidth;
1064
- node.style.paddingLeft = dims.gutterTotalWidth + "px";
1065
- }
1066
- node.style.width = width + "px";
1067
- }
1068
- if (widget.coverGutter) {
1069
- node.style.zIndex = 5;
1070
- node.style.position = "relative";
1071
- if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
1072
- }
1073
- }
1074
-
1075
- // POSITION OBJECT
1076
-
1077
- // A Pos instance represents a position within the text.
1078
- var Pos = CodeMirror.Pos = function(line, ch) {
1079
- if (!(this instanceof Pos)) return new Pos(line, ch);
1080
- this.line = line; this.ch = ch;
1081
- };
1082
-
1083
- // Compare two positions, return 0 if they are the same, a negative
1084
- // number when a is less, and a positive number otherwise.
1085
- var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
1086
-
1087
- function copyPos(x) {return Pos(x.line, x.ch);}
1088
- function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
1089
- function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
1090
-
1091
- // INPUT HANDLING
1092
-
1093
- function ensureFocus(cm) {
1094
- if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
1095
- }
1096
-
1097
- function isReadOnly(cm) {
1098
- return cm.options.readOnly || cm.doc.cantEdit;
1099
- }
1100
-
1101
- // This will be set to an array of strings when copying, so that,
1102
- // when pasting, we know what kind of selections the copied text
1103
- // was made out of.
1104
- var lastCopied = null;
1105
-
1106
- function applyTextInput(cm, inserted, deleted, sel, origin) {
1107
- var doc = cm.doc;
1108
- cm.display.shift = false;
1109
- if (!sel) sel = doc.sel;
1110
-
1111
- var paste = cm.state.pasteIncoming || origin == "paste";
1112
- var textLines = doc.splitLines(inserted), multiPaste = null;
1113
- // When pasing N lines into N selections, insert one line per selection
1114
- if (paste && sel.ranges.length > 1) {
1115
- if (lastCopied && lastCopied.join("\n") == inserted) {
1116
- if (sel.ranges.length % lastCopied.length == 0) {
1117
- multiPaste = [];
1118
- for (var i = 0; i < lastCopied.length; i++)
1119
- multiPaste.push(doc.splitLines(lastCopied[i]));
1120
- }
1121
- } else if (textLines.length == sel.ranges.length) {
1122
- multiPaste = map(textLines, function(l) { return [l]; });
1123
- }
1124
- }
1125
-
1126
- // Normal behavior is to insert the new text into every selection
1127
- for (var i = sel.ranges.length - 1; i >= 0; i--) {
1128
- var range = sel.ranges[i];
1129
- var from = range.from(), to = range.to();
1130
- if (range.empty()) {
1131
- if (deleted && deleted > 0) // Handle deletion
1132
- from = Pos(from.line, from.ch - deleted);
1133
- else if (cm.state.overwrite && !paste) // Handle overwrite
1134
- to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
1135
- }
1136
- var updateInput = cm.curOp.updateInput;
1137
- var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
1138
- origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
1139
- makeChange(cm.doc, changeEvent);
1140
- signalLater(cm, "inputRead", cm, changeEvent);
1141
- }
1142
- if (inserted && !paste)
1143
- triggerElectric(cm, inserted);
1144
-
1145
- ensureCursorVisible(cm);
1146
- cm.curOp.updateInput = updateInput;
1147
- cm.curOp.typing = true;
1148
- cm.state.pasteIncoming = cm.state.cutIncoming = false;
1149
- }
1150
-
1151
- function handlePaste(e, cm) {
1152
- var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
1153
- if (pasted) {
1154
- e.preventDefault();
1155
- if (!isReadOnly(cm) && !cm.options.disableInput)
1156
- runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
1157
- return true;
1158
- }
1159
- }
1160
-
1161
- function triggerElectric(cm, inserted) {
1162
- // When an 'electric' character is inserted, immediately trigger a reindent
1163
- if (!cm.options.electricChars || !cm.options.smartIndent) return;
1164
- var sel = cm.doc.sel;
1165
-
1166
- for (var i = sel.ranges.length - 1; i >= 0; i--) {
1167
- var range = sel.ranges[i];
1168
- if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
1169
- var mode = cm.getModeAt(range.head);
1170
- var indented = false;
1171
- if (mode.electricChars) {
1172
- for (var j = 0; j < mode.electricChars.length; j++)
1173
- if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
1174
- indented = indentLine(cm, range.head.line, "smart");
1175
- break;
1176
- }
1177
- } else if (mode.electricInput) {
1178
- if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
1179
- indented = indentLine(cm, range.head.line, "smart");
1180
- }
1181
- if (indented) signalLater(cm, "electricInput", cm, range.head.line);
1182
- }
1183
- }
1184
-
1185
- function copyableRanges(cm) {
1186
- var text = [], ranges = [];
1187
- for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
1188
- var line = cm.doc.sel.ranges[i].head.line;
1189
- var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
1190
- ranges.push(lineRange);
1191
- text.push(cm.getRange(lineRange.anchor, lineRange.head));
1192
- }
1193
- return {text: text, ranges: ranges};
1194
- }
1195
-
1196
- function disableBrowserMagic(field) {
1197
- field.setAttribute("autocorrect", "off");
1198
- field.setAttribute("autocapitalize", "off");
1199
- field.setAttribute("spellcheck", "false");
1200
- }
1201
-
1202
- // TEXTAREA INPUT STYLE
1203
-
1204
- function TextareaInput(cm) {
1205
- this.cm = cm;
1206
- // See input.poll and input.reset
1207
- this.prevInput = "";
1208
-
1209
- // Flag that indicates whether we expect input to appear real soon
1210
- // now (after some event like 'keypress' or 'input') and are
1211
- // polling intensively.
1212
- this.pollingFast = false;
1213
- // Self-resetting timeout for the poller
1214
- this.polling = new Delayed();
1215
- // Tracks when input.reset has punted to just putting a short
1216
- // string into the textarea instead of the full selection.
1217
- this.inaccurateSelection = false;
1218
- // Used to work around IE issue with selection being forgotten when focus moves away from textarea
1219
- this.hasSelection = false;
1220
- this.composing = null;
1221
- };
1222
-
1223
- function hiddenTextarea() {
1224
- var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
1225
- var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
1226
- // The textarea is kept positioned near the cursor to prevent the
1227
- // fact that it'll be scrolled into view on input from scrolling
1228
- // our fake cursor out of view. On webkit, when wrap=off, paste is
1229
- // very slow. So make the area wide instead.
1230
- if (webkit) te.style.width = "1000px";
1231
- else te.setAttribute("wrap", "off");
1232
- // If border: 0; -- iOS fails to open keyboard (issue #1287)
1233
- if (ios) te.style.border = "1px solid black";
1234
- disableBrowserMagic(te);
1235
- return div;
1236
- }
1237
-
1238
- TextareaInput.prototype = copyObj({
1239
- init: function(display) {
1240
- var input = this, cm = this.cm;
1241
-
1242
- // Wraps and hides input textarea
1243
- var div = this.wrapper = hiddenTextarea();
1244
- // The semihidden textarea that is focused when the editor is
1245
- // focused, and receives input.
1246
- var te = this.textarea = div.firstChild;
1247
- display.wrapper.insertBefore(div, display.wrapper.firstChild);
1248
-
1249
- // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
1250
- if (ios) te.style.width = "0px";
1251
-
1252
- on(te, "input", function() {
1253
- if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
1254
- input.poll();
1255
- });
1256
-
1257
- on(te, "paste", function(e) {
1258
- if (handlePaste(e, cm)) return true;
1259
-
1260
- cm.state.pasteIncoming = true;
1261
- input.fastPoll();
1262
- });
1263
-
1264
- function prepareCopyCut(e) {
1265
- if (cm.somethingSelected()) {
1266
- lastCopied = cm.getSelections();
1267
- if (input.inaccurateSelection) {
1268
- input.prevInput = "";
1269
- input.inaccurateSelection = false;
1270
- te.value = lastCopied.join("\n");
1271
- selectInput(te);
1272
- }
1273
- } else if (!cm.options.lineWiseCopyCut) {
1274
- return;
1275
- } else {
1276
- var ranges = copyableRanges(cm);
1277
- lastCopied = ranges.text;
1278
- if (e.type == "cut") {
1279
- cm.setSelections(ranges.ranges, null, sel_dontScroll);
1280
- } else {
1281
- input.prevInput = "";
1282
- te.value = ranges.text.join("\n");
1283
- selectInput(te);
1284
- }
1285
- }
1286
- if (e.type == "cut") cm.state.cutIncoming = true;
1287
- }
1288
- on(te, "cut", prepareCopyCut);
1289
- on(te, "copy", prepareCopyCut);
1290
-
1291
- on(display.scroller, "paste", function(e) {
1292
- if (eventInWidget(display, e)) return;
1293
- cm.state.pasteIncoming = true;
1294
- input.focus();
1295
- });
1296
-
1297
- // Prevent normal selection in the editor (we handle our own)
1298
- on(display.lineSpace, "selectstart", function(e) {
1299
- if (!eventInWidget(display, e)) e_preventDefault(e);
1300
- });
1301
-
1302
- on(te, "compositionstart", function() {
1303
- var start = cm.getCursor("from");
1304
- if (input.composing) input.composing.range.clear()
1305
- input.composing = {
1306
- start: start,
1307
- range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
1308
- };
1309
- });
1310
- on(te, "compositionend", function() {
1311
- if (input.composing) {
1312
- input.poll();
1313
- input.composing.range.clear();
1314
- input.composing = null;
1315
- }
1316
- });
1317
- },
1318
-
1319
- prepareSelection: function() {
1320
- // Redraw the selection and/or cursor
1321
- var cm = this.cm, display = cm.display, doc = cm.doc;
1322
- var result = prepareSelection(cm);
1323
-
1324
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
1325
- if (cm.options.moveInputWithCursor) {
1326
- var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
1327
- var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
1328
- result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
1329
- headPos.top + lineOff.top - wrapOff.top));
1330
- result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
1331
- headPos.left + lineOff.left - wrapOff.left));
1332
- }
1333
-
1334
- return result;
1335
- },
1336
-
1337
- showSelection: function(drawn) {
1338
- var cm = this.cm, display = cm.display;
1339
- removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
1340
- removeChildrenAndAdd(display.selectionDiv, drawn.selection);
1341
- if (drawn.teTop != null) {
1342
- this.wrapper.style.top = drawn.teTop + "px";
1343
- this.wrapper.style.left = drawn.teLeft + "px";
1344
- }
1345
- },
1346
-
1347
- // Reset the input to correspond to the selection (or to be empty,
1348
- // when not typing and nothing is selected)
1349
- reset: function(typing) {
1350
- if (this.contextMenuPending) return;
1351
- var minimal, selected, cm = this.cm, doc = cm.doc;
1352
- if (cm.somethingSelected()) {
1353
- this.prevInput = "";
1354
- var range = doc.sel.primary();
1355
- minimal = hasCopyEvent &&
1356
- (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
1357
- var content = minimal ? "-" : selected || cm.getSelection();
1358
- this.textarea.value = content;
1359
- if (cm.state.focused) selectInput(this.textarea);
1360
- if (ie && ie_version >= 9) this.hasSelection = content;
1361
- } else if (!typing) {
1362
- this.prevInput = this.textarea.value = "";
1363
- if (ie && ie_version >= 9) this.hasSelection = null;
1364
- }
1365
- this.inaccurateSelection = minimal;
1366
- },
1367
-
1368
- getField: function() { return this.textarea; },
1369
-
1370
- supportsTouch: function() { return false; },
1371
-
1372
- focus: function() {
1373
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
1374
- try { this.textarea.focus(); }
1375
- catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
1376
- }
1377
- },
1378
-
1379
- blur: function() { this.textarea.blur(); },
1380
-
1381
- resetPosition: function() {
1382
- this.wrapper.style.top = this.wrapper.style.left = 0;
1383
- },
1384
-
1385
- receivedFocus: function() { this.slowPoll(); },
1386
-
1387
- // Poll for input changes, using the normal rate of polling. This
1388
- // runs as long as the editor is focused.
1389
- slowPoll: function() {
1390
- var input = this;
1391
- if (input.pollingFast) return;
1392
- input.polling.set(this.cm.options.pollInterval, function() {
1393
- input.poll();
1394
- if (input.cm.state.focused) input.slowPoll();
1395
- });
1396
- },
1397
-
1398
- // When an event has just come in that is likely to add or change
1399
- // something in the input textarea, we poll faster, to ensure that
1400
- // the change appears on the screen quickly.
1401
- fastPoll: function() {
1402
- var missed = false, input = this;
1403
- input.pollingFast = true;
1404
- function p() {
1405
- var changed = input.poll();
1406
- if (!changed && !missed) {missed = true; input.polling.set(60, p);}
1407
- else {input.pollingFast = false; input.slowPoll();}
1408
- }
1409
- input.polling.set(20, p);
1410
- },
1411
-
1412
- // Read input from the textarea, and update the document to match.
1413
- // When something is selected, it is present in the textarea, and
1414
- // selected (unless it is huge, in which case a placeholder is
1415
- // used). When nothing is selected, the cursor sits after previously
1416
- // seen text (can be empty), which is stored in prevInput (we must
1417
- // not reset the textarea when typing, because that breaks IME).
1418
- poll: function() {
1419
- var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
1420
- // Since this is called a *lot*, try to bail out as cheaply as
1421
- // possible when it is clear that nothing happened. hasSelection
1422
- // will be the case when there is a lot of text in the textarea,
1423
- // in which case reading its value would be expensive.
1424
- if (this.contextMenuPending || !cm.state.focused ||
1425
- (hasSelection(input) && !prevInput && !this.composing) ||
1426
- isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
1427
- return false;
1428
-
1429
- var text = input.value;
1430
- // If nothing changed, bail.
1431
- if (text == prevInput && !cm.somethingSelected()) ret