Version Description
Download this release
Release Info
Developer | mlehelsz |
Plugin | Contact Form 7 Style |
Version | 3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.8 to 3.0
- admin/css/admin.css +517 -97
- admin/images/donate1.jpg +0 -0
- admin/images/left.png +0 -0
- admin/images/right.png +0 -0
- admin/js/admin.js +406 -30
- admin/js/ajax.preview.tool.js +0 -18
- admin/js/codemirror.js +5 -8645
- admin/js/color.picker.js +0 -5
- admin/js/mode/css/css.js +1 -766
- admin/js/quick.edit.js +1 -1
- cf7-style-match-old.php +292 -0
- cf7-style-meta-box.php +101 -422
- cf7-style.php +335 -289
- css/admin-bar.css +21 -0
- css/frontend.css +338 -75
- css/responsive.css +173 -28
- inc/editor_page.php +65 -0
- inc/slider_meta_box.php +107 -0
- js/frontend.js +2 -3
- misc/index.php +1 -0
- misc/tracking.php +123 -0
- misc/welcome.php +75 -0
- options.json +341 -0
- options.php +297 -0
- predefined-templates.json +42 -0
- readme.txt +156 -137
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- screenshot-4.jpg +0 -0
- screenshot-5.jpg +0 -0
- screenshot-6.jpg +0 -0
- screenshot-7.jpg +0 -0
- screenshot-8.jpg +0 -0
admin/css/admin.css
CHANGED
@@ -1,157 +1,577 @@
|
|
1 |
/* After update admin css */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
.menu-icon-cf7_style .dashicons-twitter {
|
3 |
-
|
4 |
}
|
|
|
5 |
.post-type-cf7_style .wp-list-table td {
|
6 |
-
|
7 |
-
|
8 |
}
|
|
|
9 |
.post-type-cf7_style #preview-style {
|
10 |
-
|
11 |
}
|
|
|
12 |
#cf7_style_meta_box_image img {
|
13 |
-
|
14 |
}
|
|
|
15 |
.post-type-cf7_style .preview-style {
|
16 |
-
|
17 |
}
|
|
|
18 |
.post-type-cf7_style .thumb-preview {
|
19 |
-
|
20 |
-
|
21 |
}
|
|
|
22 |
.post-type-cf7_style .thumb-preview:hover .previewed-img {
|
23 |
-
|
24 |
-
|
25 |
}
|
|
|
26 |
.post-type-cf7_style .thumb-preview img {
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
}
|
|
|
31 |
.type-cf7_style .taxonomy-style_category {
|
32 |
-
|
33 |
}
|
|
|
34 |
.post-type-cf7_style .previewed-img {
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
}
|
|
|
52 |
.post-type-cf7_style .previewed-img img {
|
53 |
-
|
54 |
-
|
55 |
}
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
61 |
}
|
|
|
62 |
.cf7-style.preview-zone {
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
}
|
|
|
68 |
.cf7-style.preview-zone h4 {
|
69 |
-
|
70 |
}
|
|
|
71 |
.cf7-style.preview-zone p {
|
72 |
-
|
73 |
}
|
|
|
74 |
.menu-icon-cf7_style .dashicons-twitter:after {
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
}
|
|
|
82 |
.wp-admin .widefat .different-style input {
|
83 |
-
|
84 |
-
|
85 |
}
|
|
|
86 |
.general-settings {
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
}
|
|
|
92 |
.general-settings.full-width {
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
}
|
101 |
|
102 |
.general-settings:nth-of-type(2n+3) {
|
103 |
-
|
104 |
}
|
|
|
105 |
.general-settings h3 {
|
106 |
-
|
107 |
}
|
|
|
108 |
.general-settings:after {
|
109 |
-
|
110 |
}
|
|
|
111 |
.general-settings label {
|
112 |
-
|
113 |
}
|
|
|
114 |
.general-settings label strong {
|
115 |
-
|
116 |
-
|
117 |
}
|
|
|
118 |
.general-settings label input {
|
119 |
-
|
120 |
}
|
|
|
121 |
.general-settings small {
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
}
|
|
|
127 |
.general-settings .element {
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
}
|
|
|
134 |
.general-settings .element table {
|
135 |
-
|
136 |
}
|
|
|
137 |
.general-settings .element td {
|
138 |
-
|
139 |
}
|
|
|
140 |
.CodeMirror {
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/* After update admin css */
|
2 |
+
|
3 |
+
.clearfix:after {
|
4 |
+
visibility: hidden;
|
5 |
+
display: block;
|
6 |
+
font-size: 0;
|
7 |
+
content: " ";
|
8 |
+
clear: both;
|
9 |
+
height: 0;
|
10 |
+
}
|
11 |
+
|
12 |
+
.hidden,
|
13 |
+
.panel .hidden {
|
14 |
+
display: none;
|
15 |
+
}
|
16 |
+
|
17 |
.menu-icon-cf7_style .dashicons-twitter {
|
18 |
+
position: relative;
|
19 |
}
|
20 |
+
|
21 |
.post-type-cf7_style .wp-list-table td {
|
22 |
+
position: relative;
|
23 |
+
overflow: visible;
|
24 |
}
|
25 |
+
|
26 |
.post-type-cf7_style #preview-style {
|
27 |
+
width: 200px;
|
28 |
}
|
29 |
+
|
30 |
#cf7_style_meta_box_image img {
|
31 |
+
max-width: 100%;
|
32 |
}
|
33 |
+
|
34 |
.post-type-cf7_style .preview-style {
|
35 |
+
text-align: center;
|
36 |
}
|
37 |
+
|
38 |
.post-type-cf7_style .thumb-preview {
|
39 |
+
width: 50px;
|
40 |
+
display: inline-block;
|
41 |
}
|
42 |
+
|
43 |
.post-type-cf7_style .thumb-preview:hover .previewed-img {
|
44 |
+
opacity: 1;
|
45 |
+
visibility: visible;
|
46 |
}
|
47 |
+
|
48 |
.post-type-cf7_style .thumb-preview img {
|
49 |
+
width: 100%;
|
50 |
+
border: 1px solid #e1e1e1;
|
51 |
+
padding: 5px;
|
52 |
}
|
53 |
+
|
54 |
.type-cf7_style .taxonomy-style_category {
|
55 |
+
text-transform: capitalize;
|
56 |
}
|
57 |
+
|
58 |
.post-type-cf7_style .previewed-img {
|
59 |
+
opacity: 0;
|
60 |
+
visibility: hidden;
|
61 |
+
position: absolute;
|
62 |
+
z-index: 100;
|
63 |
+
top: -70px;
|
64 |
+
left: 0;
|
65 |
+
width: 202px;
|
66 |
+
height: auto;
|
67 |
+
border: 1px solid #e1e1e1;
|
68 |
+
padding: 5px;
|
69 |
+
background-color: #fff;
|
70 |
+
-webkit-transition: all 300ms ease-in-out;
|
71 |
+
-moz-transition: all 300ms ease-in-out;
|
72 |
+
-ms-transition: all 300ms ease-in-out;
|
73 |
+
-o-transition: all 300ms ease-in-out;
|
74 |
+
transition: all 300ms ease-in-out;
|
75 |
}
|
76 |
+
|
77 |
.post-type-cf7_style .previewed-img img {
|
78 |
+
padding: 0;
|
79 |
+
border: none;
|
80 |
}
|
81 |
+
|
82 |
+
.post-type-cf7_style select[ name='cf7_style_font_selector'] {
|
83 |
+
float: left;
|
84 |
+
margin-right: 10px;
|
85 |
+
width: 25%;
|
86 |
+
margin-bottom: 15px;
|
87 |
}
|
88 |
+
|
89 |
.cf7-style.preview-zone {
|
90 |
+
border: 1px solid #e5e5e5;
|
91 |
+
padding: 8px 4px;
|
92 |
+
width: 70%;
|
93 |
+
float: left;
|
94 |
}
|
95 |
+
|
96 |
.cf7-style.preview-zone h4 {
|
97 |
+
margin: 5px 0 10px;
|
98 |
}
|
99 |
+
|
100 |
.cf7-style.preview-zone p {
|
101 |
+
font-size: 14px;
|
102 |
}
|
103 |
+
|
104 |
.menu-icon-cf7_style .dashicons-twitter:after {
|
105 |
+
color: #000;
|
106 |
+
content: ".";
|
107 |
+
font-size: 10px;
|
108 |
+
left: 20px;
|
109 |
+
position: absolute;
|
110 |
+
top: 0;
|
111 |
}
|
112 |
+
|
113 |
.wp-admin .widefat .different-style input {
|
114 |
+
margin: 0 10px 0 0;
|
115 |
+
height: 21px;
|
116 |
}
|
117 |
+
|
118 |
.general-settings {
|
119 |
+
float: left;
|
120 |
+
width: 32%;
|
121 |
+
margin-right: 2%;
|
122 |
+
margin-bottom: 10px;
|
123 |
}
|
124 |
+
|
125 |
.general-settings.full-width {
|
126 |
+
margin-right: 0;
|
127 |
+
width: 99%;
|
128 |
+
border: 1px solid #ddd;
|
129 |
+
padding: 5px;
|
130 |
+
-moz-border-size: border-box;
|
131 |
+
-webkit-border-size: border-box;
|
132 |
+
border-size: border-box;
|
133 |
}
|
134 |
|
135 |
.general-settings:nth-of-type(2n+3) {
|
136 |
+
margin-right: 0;
|
137 |
}
|
138 |
+
|
139 |
.general-settings h3 {
|
140 |
+
text-transform: uppercase;
|
141 |
}
|
142 |
+
|
143 |
.general-settings:after {
|
144 |
+
clear: both;
|
145 |
}
|
146 |
+
|
147 |
.general-settings label {
|
148 |
+
line-height: 26px;
|
149 |
}
|
150 |
+
|
151 |
.general-settings label strong {
|
152 |
+
display: block;
|
153 |
+
margin-right: 10px;
|
154 |
}
|
155 |
+
|
156 |
.general-settings label input {
|
157 |
+
margin-right: 5px;
|
158 |
}
|
159 |
+
|
160 |
.general-settings small {
|
161 |
+
display: block;
|
162 |
+
color: #999;
|
163 |
+
margin-top: 5px;
|
164 |
+
line-height: 12px;
|
165 |
}
|
166 |
+
|
167 |
.general-settings .element {
|
168 |
+
width: 100%;
|
169 |
+
border: 1px solid #ddd;
|
170 |
+
padding: 10px 10px;
|
171 |
+
box-sizing: border-box;
|
172 |
+
margin-bottom: 10px;
|
173 |
}
|
174 |
+
|
175 |
.general-settings .element table {
|
176 |
+
width: 100%;
|
177 |
}
|
178 |
+
|
179 |
.general-settings .element td {
|
180 |
+
width: 50%;
|
181 |
}
|
182 |
+
|
183 |
.CodeMirror {
|
184 |
+
background: #f8f8ff;
|
185 |
+
}
|
186 |
+
|
187 |
+
@media screen and ( max-width: 1332px) {
|
188 |
+
.general-settings {
|
189 |
+
width: 47%;
|
190 |
+
}
|
191 |
+
.general-settings.full-width {
|
192 |
+
width: 99%;
|
193 |
+
margin-right: 0;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
@media screen and ( max-width: 1100px) {
|
198 |
+
.general-settings {
|
199 |
+
width: 99%;
|
200 |
+
margin-right: 0;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
/*home panel*/
|
206 |
+
|
207 |
+
.close-cf7-panel {
|
208 |
+
float: right;
|
209 |
+
}
|
210 |
+
|
211 |
+
.cf7style-welcome-panel img {
|
212 |
+
max-width : 160px;
|
213 |
+
height: auto;
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
/*cf7 stlider*/
|
218 |
+
|
219 |
+
.cf7-style-slider {
|
220 |
+
position: relative;
|
221 |
+
display: block;
|
222 |
+
width: 202px;
|
223 |
+
height: 300px;
|
224 |
+
margin: 0 auto;
|
225 |
+
}
|
226 |
+
|
227 |
+
.cf7-style-slider-wrap {
|
228 |
+
width: 202px;
|
229 |
+
overflow: hidden;
|
230 |
+
}
|
231 |
+
|
232 |
+
.cf7-style-slider-wrap img {
|
233 |
+
width: 198px;
|
234 |
+
position: relative;
|
235 |
+
display: block;
|
236 |
+
margin: 0 auto;
|
237 |
+
z-index: 1;
|
238 |
+
}
|
239 |
+
|
240 |
+
.cf7-style-slider-wrap .overlay {
|
241 |
+
width: 100%;
|
242 |
+
height: 100%;
|
243 |
+
position: absolute;
|
244 |
+
display: block;
|
245 |
+
background: rgba(192, 192, 192, 0.4);
|
246 |
+
z-index: 2;
|
247 |
+
text-align: center;
|
248 |
+
-webkit-transition: 100ms ease-in 0.1s;
|
249 |
+
-moz-transition: 100ms ease-in 0.1s;
|
250 |
+
-o-transition: 100ms ease-in 0.1s;
|
251 |
+
transition: 100ms ease-in 0.1s;
|
252 |
+
}
|
253 |
+
|
254 |
+
.cf7-style-slider-wrap .overlay em {
|
255 |
+
color: #fff;
|
256 |
+
line-height: 200px;
|
257 |
+
font-size: 20px;
|
258 |
+
-webkit-transform: rotate(-45deg);
|
259 |
+
-moz-transform: rotate(-45deg);
|
260 |
+
-ms-transform: rotate(-45deg);
|
261 |
+
-o-transform: rotate(-45deg);
|
262 |
+
filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=2);
|
263 |
+
position: relative;
|
264 |
+
display: block;
|
265 |
+
font-weight: bold;
|
266 |
+
}
|
267 |
+
|
268 |
+
.cf7slider li {
|
269 |
+
display: block;
|
270 |
+
float: left;
|
271 |
+
width: 202px;
|
272 |
+
cursor: pointer;
|
273 |
+
-webkit-transition: 100ms ease-in 0.1s;
|
274 |
+
-moz-transition: 100ms ease-in 0.1s;
|
275 |
+
-o-transition: 100ms ease-in 0.1s;
|
276 |
+
transition: 100ms ease-in 0.1s;
|
277 |
+
}
|
278 |
+
|
279 |
+
.cf7slider li:hover > span em {
|
280 |
+
display: none;
|
281 |
+
}
|
282 |
+
|
283 |
+
.cf7slider li:hover > span .overlay {
|
284 |
+
background: transparent;
|
285 |
+
}
|
286 |
+
|
287 |
+
.cf7slider li:hover > span .overlay em {
|
288 |
+
color: #000;
|
289 |
+
}
|
290 |
+
|
291 |
+
input.cf7style_template {
|
292 |
+
display: none;
|
293 |
+
}
|
294 |
+
|
295 |
+
.cf7-style-slider .current-saved span .overlay {
|
296 |
+
background: rgba(255, 0, 0, 0.1);
|
297 |
+
}
|
298 |
+
|
299 |
+
.cf7-style-slider .current-saved span {
|
300 |
+
width: 100%;
|
301 |
+
height: 100%;
|
302 |
+
position: relative;
|
303 |
+
display: block;
|
304 |
+
background: rgba(255, 0, 0, 0.5);
|
305 |
+
padding-top: 2px;
|
306 |
+
padding-bottom: 2px;
|
307 |
+
}
|
308 |
+
|
309 |
+
.cf7-style-slider span {
|
310 |
+
background: #c0c0c0;
|
311 |
+
width: 100%;
|
312 |
+
height: 100%;
|
313 |
+
position: relative;
|
314 |
+
display: block;
|
315 |
+
padding-top: 2px;
|
316 |
+
padding-bottom: 2px;
|
317 |
+
}
|
318 |
+
|
319 |
+
.cf7arrows a {
|
320 |
+
position: absolute;
|
321 |
+
display: block;
|
322 |
+
width: 90px;
|
323 |
+
height: 90px;
|
324 |
+
background-repeat: no-repeat;
|
325 |
+
top: 50px;
|
326 |
+
color: transparent;
|
327 |
+
opacity: 0.7;
|
328 |
+
-webkit-transition: 100ms ease-in 0.1s;
|
329 |
+
-moz-transition: 100ms ease-in 0.1s;
|
330 |
+
-o-transition: 100ms ease-in 0.1s;
|
331 |
+
transition: 100ms ease-in 0.1s;
|
332 |
+
outline: none;
|
333 |
+
background-size: 100% auto;
|
334 |
+
}
|
335 |
+
|
336 |
+
.cf7arrows a:hover {
|
337 |
+
opacity: 1;
|
338 |
+
}
|
339 |
+
|
340 |
+
.cf7arrows a.left {
|
341 |
+
left: -145px;
|
342 |
+
background-image: url('../images/left.png');
|
343 |
+
}
|
344 |
+
|
345 |
+
.cf7arrows a.right {
|
346 |
+
right: -145px;
|
347 |
+
background-image: url('../images/right.png');
|
348 |
+
}
|
349 |
+
|
350 |
+
|
351 |
+
/*admin panel customizations*/
|
352 |
+
|
353 |
+
.generate-preview {
|
354 |
+
display: block;
|
355 |
+
position: relative;
|
356 |
+
}
|
357 |
+
|
358 |
+
.panel-options {
|
359 |
+
display: block;
|
360 |
+
width: 60%;
|
361 |
+
float: right;
|
362 |
+
}
|
363 |
+
|
364 |
+
.panel-header {
|
365 |
+
padding-right: 12px;
|
366 |
+
position: relative;
|
367 |
+
width: 40%;
|
368 |
+
float: left;
|
369 |
+
-webkit-box-sizing: border-box;
|
370 |
+
box-sizing: border-box;
|
371 |
+
z-index: 5;
|
372 |
+
}
|
373 |
+
|
374 |
+
.generate-preview:after,
|
375 |
+
.panel-header:after {
|
376 |
+
display: block;
|
377 |
+
content: "";
|
378 |
+
clear: both;
|
379 |
+
}
|
380 |
+
|
381 |
+
.panel li,
|
382 |
+
.panel-header select,
|
383 |
+
.preview-form-tag {
|
384 |
+
display: inline-block;
|
385 |
+
vertical-align: top;
|
386 |
+
}
|
387 |
+
|
388 |
+
.preview-form-tag {
|
389 |
+
width: 100%;
|
390 |
+
box-sizing: border-box;
|
391 |
+
height: 630px;
|
392 |
+
}
|
393 |
+
|
394 |
+
#form-tag,
|
395 |
+
.preview-form-tag {
|
396 |
+
background: #f2f2f2;
|
397 |
+
overflow-x: auto;
|
398 |
+
padding: 10px;
|
399 |
+
}
|
400 |
+
|
401 |
+
.element-selector {
|
402 |
+
background: #f2f2f2;
|
403 |
+
margin-bottom: 7px;
|
404 |
+
margin-top: 3px;
|
405 |
+
padding-left: 11px;
|
406 |
+
padding-top: 7px;
|
407 |
+
}
|
408 |
+
|
409 |
+
#form-tag h4,
|
410 |
+
.element-selector h4 {
|
411 |
+
margin-top: 0;
|
412 |
+
margin-bottom: 12px;
|
413 |
+
}
|
414 |
+
|
415 |
+
.element-selector label {
|
416 |
+
display: block;
|
417 |
+
margin-bottom: 10px;
|
418 |
+
width: 50%;
|
419 |
+
float: left;
|
420 |
+
}
|
421 |
+
|
422 |
+
#form-tag a {
|
423 |
+
margin-right: 2px;
|
424 |
+
margin-bottom: 5px;
|
425 |
+
}
|
426 |
+
|
427 |
+
#cf7_style_meta_box_font_selector,
|
428 |
+
#cf7_style_meta_box_form_selector {
|
429 |
+
display: inline-block;
|
430 |
+
width: 49.5%;
|
431 |
+
}
|
432 |
+
|
433 |
+
.post-type-cf7_style #normal-sortables {
|
434 |
+
display: none;
|
435 |
+
}
|
436 |
+
|
437 |
+
.preview-form-container > h4 {
|
438 |
+
text-align: center;
|
439 |
+
margin-top: 0;
|
440 |
+
}
|
441 |
+
|
442 |
+
.element-styling {
|
443 |
+
float: left;
|
444 |
+
padding: 0 10px;
|
445 |
+
width: 100%;
|
446 |
+
border-bottom: 1px solid #CCC;
|
447 |
+
box-sizing: border-box;
|
448 |
+
}
|
449 |
+
|
450 |
+
.element-styling.half-size {
|
451 |
+
width: 50%;
|
452 |
+
}
|
453 |
+
|
454 |
+
.element-styling label {
|
455 |
+
display: inline-block;
|
456 |
+
position: relative;
|
457 |
+
margin-right: 5px;
|
458 |
+
}
|
459 |
+
|
460 |
+
.element-styling label select {
|
461 |
+
width: 123px;
|
462 |
+
}
|
463 |
+
|
464 |
+
.element-styling label select[name*=unit] {
|
465 |
+
width: 46px;
|
466 |
+
margin-left: 3px;
|
467 |
+
}
|
468 |
+
|
469 |
+
.element-styling input[type=number] {
|
470 |
+
height: 28px;
|
471 |
+
position: relative;
|
472 |
+
top: 2px;
|
473 |
+
width: 60px;
|
474 |
+
}
|
475 |
+
|
476 |
+
.wp-picker-container {
|
477 |
+
position: relative;
|
478 |
+
top: 10px;
|
479 |
+
}
|
480 |
+
|
481 |
+
.element-styling.background li,
|
482 |
+
.element-styling.font li {
|
483 |
+
width: 50%;
|
484 |
+
}
|
485 |
+
|
486 |
+
.element-styling label strong {
|
487 |
+
margin-right: 3px;
|
488 |
+
font-weight: normal;
|
489 |
+
display: inline-block;
|
490 |
+
min-width: 153px;
|
491 |
+
}
|
492 |
+
|
493 |
+
.choose-preview {
|
494 |
+
background-color: #f2f2f2;
|
495 |
+
padding: 10px;
|
496 |
+
margin-bottom: 3px;
|
497 |
+
}
|
498 |
+
|
499 |
+
.choose-preview h4 {
|
500 |
+
margin: 0 0 10px;
|
501 |
+
}
|
502 |
+
|
503 |
+
.element-styling.background label,
|
504 |
+
.element-styling.font label {
|
505 |
+
margin-right: 0;
|
506 |
+
}
|
507 |
+
|
508 |
+
.element-styling h3 {
|
509 |
+
font-size: 13px;
|
510 |
+
margin-bottom: 10px;
|
511 |
+
}
|
512 |
+
|
513 |
+
.element-styling h3 span {
|
514 |
+
color: #008EC2;
|
515 |
+
opacity: 0.8;
|
516 |
+
}
|
517 |
+
|
518 |
+
.panel li {
|
519 |
+
width: 100%;
|
520 |
+
margin-bottom: 10px;
|
521 |
+
}
|
522 |
+
|
523 |
+
.fixed-save-style {
|
524 |
+
position: fixed;
|
525 |
+
width: 100%;
|
526 |
+
left: 0;
|
527 |
+
bottom: 0;
|
528 |
+
z-index: 9999;
|
529 |
+
text-align: center;
|
530 |
+
display: none;
|
531 |
+
}
|
532 |
+
|
533 |
+
.wp-core-ui .fixed-save-style input.button {
|
534 |
+
width: 100%;
|
535 |
+
height: 40px;
|
536 |
+
line-height: 40px;
|
537 |
+
font-size: 18px;
|
538 |
+
}
|
539 |
+
|
540 |
+
.remove_template_notice {
|
541 |
+
float: right;
|
542 |
+
}
|
543 |
+
|
544 |
+
@media all and (max-width:1600px) {
|
545 |
+
.panel-header,
|
546 |
+
.panel-options,
|
547 |
+
.element-styling.half-size {
|
548 |
+
width: 100%;
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
|
553 |
+
/*Add arrows*/
|
554 |
+
|
555 |
+
.element-styling .icon {
|
556 |
+
display: inline-block;
|
557 |
+
height: 26px;
|
558 |
+
border: 1px solid #CCC;
|
559 |
+
padding: 0 7px;
|
560 |
+
background-color: #f2f2f2;
|
561 |
+
position: relative;
|
562 |
+
top: 2px;
|
563 |
+
font-size: 13px;
|
564 |
+
line-height: 26px;
|
565 |
+
margin-right: -2px;
|
566 |
+
}
|
567 |
+
|
568 |
+
.element-styling .icon.smaller {
|
569 |
+
height: 23px;
|
570 |
+
line-height: 23px;
|
571 |
+
top: 1px;
|
572 |
+
font-size: 13px;
|
573 |
+
}
|
574 |
+
|
575 |
+
.description-title {
|
576 |
+
padding-left: 10px;
|
577 |
+
}
|
admin/images/donate1.jpg
ADDED
Binary file
|
admin/images/left.png
ADDED
Binary file
|
admin/images/right.png
ADDED
Binary file
|
admin/js/admin.js
CHANGED
@@ -1,34 +1,410 @@
|
|
1 |
/*
|
2 |
jQuery functions for the Admin area
|
3 |
*/
|
4 |
-
|
5 |
-
$(".google-fontos").remove();
|
6 |
-
if( "none" != value && "undefined" != typeof value ) {
|
7 |
-
$("head").append('<link class="google-fontos" rel="stylesheet" href="http://fonts.googleapis.com/css?family=' + value + ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese" />');
|
8 |
-
$(".cf7-style.preview-zone p").css("font-family", "'" + value + "', sans-serif" );
|
9 |
-
}
|
10 |
-
}
|
11 |
-
jQuery ( document ).ready( function( $ ) {
|
12 |
-
var selectVar = $('select[name=cf7_style_font_selector]');
|
13 |
-
if( $("#manual-style").length > 0 ){
|
14 |
-
var editor = CodeMirror.fromTextArea( document.getElementById( "manual-style" ), {
|
15 |
-
lineNumbers: true,
|
16 |
-
theme: "default",
|
17 |
-
mode: "text/css",
|
18 |
-
indentUnit: 4,
|
19 |
-
styleActiveLine: true
|
20 |
-
});
|
21 |
-
}
|
22 |
-
$('.cf7-style-color-field').wpColorPicker();
|
23 |
-
|
24 |
-
$("#select_all").on("click", function(){
|
25 |
-
$(".cf7style_body_select_all input").prop('checked', ( $(this).is(":checked") ) ? true : false );
|
26 |
-
});
|
27 |
-
|
28 |
-
changeFont( selectVar.val(), $ );
|
29 |
-
selectVar.on( "change", function(){
|
30 |
-
changeFont( $( this ).val(), $ );
|
31 |
-
});
|
32 |
-
|
33 |
-
});
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/*
|
2 |
jQuery functions for the Admin area
|
3 |
*/
|
4 |
+
var $ = jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
String.prototype.filename = function(extension) {
|
7 |
+
var s = this.replace(/\\/g, '/');
|
8 |
+
s = s.substring(s.lastIndexOf('/') + 1);
|
9 |
+
return extension ? s.replace(/[?#].+$/, '') : s.split('.')[0];
|
10 |
+
}
|
11 |
+
|
12 |
+
function changeFont(value) {
|
13 |
+
$(".google-fontos").remove();
|
14 |
+
if ("none" != value && "undefined" != typeof value) {
|
15 |
+
$("head").append('<link class="google-fontos" rel="stylesheet" href="http://fonts.googleapis.com/css?family=' + value + ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese" />');
|
16 |
+
$(".cf7-style.preview-zone p").css("font-family", "'" + value + "', sans-serif");
|
17 |
+
$('.preview-form-container .wpcf7').css("font-family", "'" + value + "', sans-serif");
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
function scrolling(element) {
|
22 |
+
$(window).scroll(function() {
|
23 |
+
if ($(window).width() > 1600) {
|
24 |
+
var offset = element.find('.panel-header').offset(),
|
25 |
+
cf7styleOffset = $('#cf7_style_meta_box_style_customizer').offset(),
|
26 |
+
diff = $(window).scrollTop() - cf7styleOffset.top;
|
27 |
+
if (diff > 0) {
|
28 |
+
element.find('.panel-header').css('top', diff);
|
29 |
+
}
|
30 |
+
if (diff <= 0) {
|
31 |
+
element.find('.panel-header').css('top', 0);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
if ($(window).scrollTop() > 700) {
|
35 |
+
$('.fixed-save-style').show();
|
36 |
+
} else {
|
37 |
+
$('.fixed-save-style').hide();
|
38 |
+
}
|
39 |
+
|
40 |
+
}).trigger('scroll');
|
41 |
+
}
|
42 |
+
|
43 |
+
function autoCompleteOtherValues() {
|
44 |
+
$("input[type='number']").on("change", function() {
|
45 |
+
var value = $(this).val(),
|
46 |
+
indexor = $(this).index(),
|
47 |
+
allInput = $(this).parent().find("input[type=number]");
|
48 |
+
switch (indexor) {
|
49 |
+
case 2:
|
50 |
+
allInput.val(value);
|
51 |
+
break;
|
52 |
+
case 5:
|
53 |
+
allInput.eq(3).val(value);
|
54 |
+
break;
|
55 |
+
}
|
56 |
+
});
|
57 |
+
}
|
58 |
+
|
59 |
+
function getPreviewElements(previewType) {
|
60 |
+
var notElem = (previewType == "hover") ? "" : ",[name*='hover']";
|
61 |
+
$('[name^=cf7stylecustom]').not("[name*='unit']" + notElem).each(function() {
|
62 |
+
var _t = $(this);
|
63 |
+
if (_t.attr('value').length > 0) {
|
64 |
+
var elem_name = _t.attr('name'),
|
65 |
+
splitArray = elem_name.substr(15).replace("]", "").split("_"),
|
66 |
+
newElem = splitArray[0],
|
67 |
+
unit = _t.parent().find('select[name*="unit"]').val();
|
68 |
+
if (splitArray[0] == "submit") {
|
69 |
+
newElem = "input[type='submit']";
|
70 |
+
}
|
71 |
+
if (splitArray[0] == "form") {
|
72 |
+
newElem = ".wpcf7";
|
73 |
+
}
|
74 |
+
|
75 |
+
unit = (typeof unit == 'undefined' || _t.val() == "") ? "" : unit;
|
76 |
+
var newValue = _t.val() + unit;
|
77 |
+
if (_t.hasClass('cf7-style-upload-field')) {
|
78 |
+
newValue = 'url(' + _t.val() + ')';
|
79 |
+
if (_t.val() == "") {
|
80 |
+
newValue = _t.val();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$('.preview-form-container ' + newElem).css(splitArray[1], newValue);
|
84 |
+
}
|
85 |
+
});
|
86 |
+
}
|
87 |
+
|
88 |
+
function selectAllForms(element) {
|
89 |
+
element.on("click", function() {
|
90 |
+
$(".cf7style_body_select_all input").prop('checked', ($(this).is(":checked")) ? true : false);
|
91 |
+
});
|
92 |
+
}
|
93 |
+
|
94 |
+
function cf7_slider(elem, slideWidth, animationSpeed, showArrows) {
|
95 |
+
|
96 |
+
var active = elem.find('.active'),
|
97 |
+
index = active.index() + 1,
|
98 |
+
slide = elem.find('li'),
|
99 |
+
sliderViewport = elem.find('ul'),
|
100 |
+
arrow = elem.find('.narrow'),
|
101 |
+
arrowLeft = elem.find('.narrow.left'),
|
102 |
+
arrowRight = elem.find('.narrow.right'),
|
103 |
+
totalSlides = elem.find('li').length;
|
104 |
+
|
105 |
+
arrowRight.addClass('visible');
|
106 |
+
sliderViewport.css('width', totalSlides * slideWidth);
|
107 |
+
|
108 |
+
if (showArrows == false) {
|
109 |
+
elem.mouseenter(function() {
|
110 |
+
elem.find('.visible').stop().show();
|
111 |
+
}).mouseleave(function() {
|
112 |
+
elem.find('.visible').stop().hide();
|
113 |
+
});
|
114 |
+
}
|
115 |
+
|
116 |
+
arrow.on('click', function(e) {
|
117 |
+
e.stopPropagation();
|
118 |
+
e.preventDefault();
|
119 |
+
var direction = $(this).attr('data-direction');
|
120 |
+
|
121 |
+
if (direction == "left" && index !== 1) {
|
122 |
+
sliderViewport.stop(true, true).animate({
|
123 |
+
marginLeft: "+=" + (slideWidth) + "px"
|
124 |
+
}, animationSpeed);
|
125 |
+
|
126 |
+
index--;
|
127 |
+
}
|
128 |
+
|
129 |
+
if (direction == "right" && index !== totalSlides) {
|
130 |
+
sliderViewport.stop(true, true).animate({
|
131 |
+
marginLeft: -(slideWidth * index) + "px"
|
132 |
+
}, animationSpeed);
|
133 |
+
|
134 |
+
index++;
|
135 |
+
}
|
136 |
+
|
137 |
+
if (index == 1) {
|
138 |
+
arrowLeft.hide().removeClass('visible');
|
139 |
+
arrowRight.show().addClass('visible');
|
140 |
+
}
|
141 |
+
|
142 |
+
if (index == totalSlides) {
|
143 |
+
arrowRight.hide().removeClass('visible');
|
144 |
+
}
|
145 |
+
|
146 |
+
if (index < totalSlides) {
|
147 |
+
arrowRight.show().addClass('visible');
|
148 |
+
}
|
149 |
+
|
150 |
+
if (index > 1) {
|
151 |
+
arrowLeft.show().addClass('visible');
|
152 |
+
}
|
153 |
+
|
154 |
+
slide.removeClass('active').eq(index - 1).addClass('active');
|
155 |
+
});
|
156 |
+
sliderViewport.css({
|
157 |
+
'margin-left': '-' + (index - 1) * slideWidth + 'px'
|
158 |
+
});
|
159 |
+
}
|
160 |
+
|
161 |
+
function sliderInit(element) {
|
162 |
+
cf7_slider(element, 202, 500, true);
|
163 |
+
element.find('li').on('click', function() {
|
164 |
+
if (!$(this).hasClass('current-saved')) {
|
165 |
+
element.find('li').removeClass('current-saved');
|
166 |
+
$(this).addClass('current-saved');
|
167 |
+
element.find('.overlay em').html('Not Active');
|
168 |
+
$(this).find('.overlay em').html('Active');
|
169 |
+
$('.cf7style_template').removeAttr('checked');
|
170 |
+
$(this).find('.cf7style_template').attr("checked", "checked");
|
171 |
+
}
|
172 |
+
});
|
173 |
+
}
|
174 |
+
|
175 |
+
function showTheOption() {
|
176 |
+
$('#form-tag a.button').on('click', function(e) {
|
177 |
+
e.preventDefault();
|
178 |
+
var _t = $(this);
|
179 |
+
var currentElement = $('.' + _t.attr('data-property') + '-panel');
|
180 |
+
if (!_t.hasClass('button-primary')) {
|
181 |
+
$('.panel').stop(true, true).animate({
|
182 |
+
'opacity': 0
|
183 |
+
}, 300, function() {
|
184 |
+
$('.panel').addClass('hidden');
|
185 |
+
currentElement.css('opacity', '0');
|
186 |
+
currentElement.removeClass('hidden');
|
187 |
+
currentElement.stop(true, true).animate({
|
188 |
+
'opacity': 1
|
189 |
+
}, 300);
|
190 |
+
});
|
191 |
+
|
192 |
+
$(".element-selector input:eq(0)").prop("checked", true);
|
193 |
+
}
|
194 |
+
$('#form-tag a.button').removeClass('button-primary');
|
195 |
+
_t.addClass('button-primary');
|
196 |
+
$('input[name="cf7styleactivepane"]').val(_t.attr('data-property'));
|
197 |
+
});
|
198 |
+
$('.element-selector input').on('change', function() {
|
199 |
+
$('.element-selector input').prop('checked', false);
|
200 |
+
$(this).prop('checked', true);
|
201 |
+
if ($(this).val() == "hover") {
|
202 |
+
$('.panel:visible li').addClass('hidden');
|
203 |
+
$('.panel:visible li.hover-element').removeClass('hidden');
|
204 |
+
getPreviewElements("hover");
|
205 |
+
} else {
|
206 |
+
$('.panel:visible li.hover-element').addClass('hidden');
|
207 |
+
$('.panel:visible li').not('.hover-element').removeClass('hidden');
|
208 |
+
getPreviewElements();
|
209 |
+
}
|
210 |
+
});
|
211 |
+
$('#form-preview').on('change', function() {
|
212 |
+
$('.preview-form-container').addClass('hidden');
|
213 |
+
$('.preview-form-container').eq($(this).val()).removeClass('hidden');
|
214 |
+
});
|
215 |
+
$('[name^="cf7stylecustom"]').on("change", function() {
|
216 |
+
if ($('input[name="element-type"]:checked').val() == "hover") {
|
217 |
+
getPreviewElements('hover');
|
218 |
+
} else {
|
219 |
+
getPreviewElements();
|
220 |
+
}
|
221 |
+
});
|
222 |
+
}
|
223 |
+
|
224 |
+
function removePreviewfields(element) {
|
225 |
+
element.remove();
|
226 |
+
}
|
227 |
+
|
228 |
+
function disableSubmit(element) {
|
229 |
+
element.on('click', function(e) {
|
230 |
+
e.preventDefault();
|
231 |
+
});
|
232 |
+
}
|
233 |
+
|
234 |
+
function addBgImage() {
|
235 |
+
var bgFormInput = $('.cf7-style-upload-field');
|
236 |
+
bgFormInput.addClass('hidden');
|
237 |
+
bgFormInput.each(function() {
|
238 |
+
var _t = $(this);
|
239 |
+
$('<span class="image-info-box"></span>').insertAfter(_t);
|
240 |
+
if (_t.val() != "") {
|
241 |
+
_t.parent().find('.image-info-box').text(_t.val().filename('yes'));
|
242 |
+
}
|
243 |
+
});
|
244 |
+
if ($('.upload-btn').length <= 0) {
|
245 |
+
$("<a href='javascript: void(0);' class='remove-btn button'>Remove</a>").insertAfter(bgFormInput);
|
246 |
+
$("<a href='javascript: void(0);' class='upload-btn button'>Upload</a>").insertAfter(bgFormInput);
|
247 |
+
}
|
248 |
+
$('.upload-btn').on('click', function() {
|
249 |
+
var _t = $(this),
|
250 |
+
currentimage = _t.parent().find('.cf7-style-upload-field');
|
251 |
+
tb_show('New Banner', 'media-upload.php?type=image&TB_iframe=1');
|
252 |
+
window.send_to_editor = function(html) {
|
253 |
+
currentimage.val($(html).attr('src'));
|
254 |
+
currentimage.trigger('change');
|
255 |
+
_t.parent().find('.image-info-box').text($(html).attr('src').filename('yes'));
|
256 |
+
tb_remove();
|
257 |
+
}
|
258 |
+
});
|
259 |
+
$('.remove-btn').on('click', function() {
|
260 |
+
var _t = $(this),
|
261 |
+
currentimage = _t.parent().find('.cf7-style-upload-field');
|
262 |
+
currentimage.val(' ');
|
263 |
+
currentimage.attr('value', ' ');
|
264 |
+
currentimage.trigger('change');
|
265 |
+
_t.parent().find('.image-info-box').text('');
|
266 |
+
});
|
267 |
+
}
|
268 |
+
|
269 |
+
function codeMirrorInit() {
|
270 |
+
if ($("#cf7_style_manual_style").length > 0) {
|
271 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("cf7_style_manual_style"), {
|
272 |
+
lineNumbers: true,
|
273 |
+
theme: "default",
|
274 |
+
mode: "text/css"
|
275 |
+
});
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
function dismissRemoveMessage() {
|
280 |
+
$.ajax({
|
281 |
+
'url': ajaxurl,
|
282 |
+
'method': 'POST',
|
283 |
+
'data': {
|
284 |
+
'action': 'cf7_style_remove_box'
|
285 |
+
},
|
286 |
+
'success': function(data) {}
|
287 |
+
});
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
jQuery(document).ready(function($) {
|
292 |
+
|
293 |
+
var previewEl = $(".generate-preview"),
|
294 |
+
cf7StylePostType = $(".post-type-cf7_style "),
|
295 |
+
selectAll = $('#select_all'),
|
296 |
+
fontSelectVar = $('select[name="cf7_style_font_selector"]'),
|
297 |
+
sliderWrapper = $('.cf7-style-slider-wrap'),
|
298 |
+
previewForm = $('.preview-form-container'),
|
299 |
+
options = {
|
300 |
+
change: function(event, ui) {
|
301 |
+
if ($('input[name="element-type"]:checked').val() == "hover") {
|
302 |
+
getPreviewElements('hover');
|
303 |
+
} else {
|
304 |
+
getPreviewElements();
|
305 |
+
}
|
306 |
+
}
|
307 |
+
};
|
308 |
+
|
309 |
+
$('.cf7-style-color-field').wpColorPicker(options);
|
310 |
+
/*Scrolling on settings*/
|
311 |
+
if (previewEl.length > 0) {
|
312 |
+
scrolling(previewEl);
|
313 |
+
}
|
314 |
+
|
315 |
+
if (cf7StylePostType.length > 0) {
|
316 |
+
/*codemirror*/
|
317 |
+
codeMirrorInit();
|
318 |
+
/*backgroundimage*/
|
319 |
+
addBgImage();
|
320 |
+
/*Autocomplete number fields*/
|
321 |
+
autoCompleteOtherValues();
|
322 |
+
/*Checkbox for select all the forms*/
|
323 |
+
selectAllForms(selectAll);
|
324 |
+
/*Change Font*/
|
325 |
+
changeFont(fontSelectVar.val());
|
326 |
+
fontSelectVar.on("change", function() {
|
327 |
+
changeFont($(this).val());
|
328 |
+
});
|
329 |
+
/*show the right options*/
|
330 |
+
showTheOption();
|
331 |
+
/*preview changes on the fly*/
|
332 |
+
getPreviewElements();
|
333 |
+
/*remove nonce*/
|
334 |
+
removePreviewfields(previewForm.find('input[type="hidden"]'));
|
335 |
+
/*disable submit*/
|
336 |
+
disableSubmit(previewForm.find('input[type="submit"]'));
|
337 |
+
$(document).on('click', '.editinline', function() {
|
338 |
+
setTimeout(function() { $('.special-colspan').attr('colspan', 4); }, 60);
|
339 |
+
});
|
340 |
+
}
|
341 |
+
if (sliderWrapper.length > 0) {
|
342 |
+
sliderInit(sliderWrapper);
|
343 |
+
}
|
344 |
+
$('input[name="custom_template_check"]').on('change', function() {
|
345 |
+
if ($(this).is(':checked')) {
|
346 |
+
$('.double-check').hide();
|
347 |
+
} else {
|
348 |
+
$('.double-check').show();
|
349 |
+
}
|
350 |
+
});
|
351 |
+
$('.confirm-remove-template').on('click', function(e) {
|
352 |
+
e.preventDefault();
|
353 |
+
var curParent = $(this).parent();
|
354 |
+
if ($('input[name="double_check_template"]:checked').val() == "no") {
|
355 |
+
curParent.hide();
|
356 |
+
$('input[name="custom_template_check"]').attr('checked', 'checked');
|
357 |
+
} else {
|
358 |
+
dismissRemoveMessage();
|
359 |
+
$.ajax({
|
360 |
+
'url': ajaxurl,
|
361 |
+
'method': 'POST',
|
362 |
+
'data': {
|
363 |
+
'action': 'cf7_style_remove_templates'
|
364 |
+
},
|
365 |
+
'success': function(data) {
|
366 |
+
if (data) {
|
367 |
+
$('<p class="succeded">Predefined templates successfully removed.</p>').appendTo(curParent);
|
368 |
+
setTimeout(function() {
|
369 |
+
curParent.fadeOut('slow');
|
370 |
+
curParent.parent().fadeOut('slow', function() {
|
371 |
+
setTimeout(function() {
|
372 |
+
window.location.reload(false);
|
373 |
+
}, 300);
|
374 |
+
});
|
375 |
+
}, 3000);
|
376 |
+
}
|
377 |
+
}
|
378 |
+
});
|
379 |
+
}
|
380 |
+
});
|
381 |
+
$('.remove_template_notice').on('click', function(e) {
|
382 |
+
e.preventDefault();
|
383 |
+
$('.template-message-box').fadeOut('slow');
|
384 |
+
dismissRemoveMessage();
|
385 |
+
});
|
386 |
+
$('.close-cf7-panel').on('click', function(e) {
|
387 |
+
e.preventDefault();
|
388 |
+
$.ajax({
|
389 |
+
'url': ajaxurl,
|
390 |
+
'method': 'POST',
|
391 |
+
'data': {
|
392 |
+
'action': 'cf7_style_remove_welcome_box'
|
393 |
+
},
|
394 |
+
'success': function(data) {
|
395 |
+
$('.welcome-container').fadeOut('slow');
|
396 |
+
}
|
397 |
+
});
|
398 |
+
});
|
399 |
+
$(document).on('change', '#cf7_style_allow_tracking', function() {
|
400 |
+
$.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=1", function(res) {});
|
401 |
+
$('.cf7style-pointer').hide();
|
402 |
+
return false;
|
403 |
+
});
|
404 |
+
$(document).on('click', '.cf7style-pointer a.close', function() {
|
405 |
+
$.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=0", function(res) {});
|
406 |
+
$('.cf7style-pointer').hide();
|
407 |
+
return false;
|
408 |
+
});
|
409 |
+
|
410 |
+
}); /*doc.ready end*/
|
admin/js/ajax.preview.tool.js
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function( $ ) {
|
2 |
-
|
3 |
-
// Google Font preview for admin area
|
4 |
-
function cf7_style_font_preview( select, area ) {
|
5 |
-
$.ajaxSetup( { cache: false } );
|
6 |
-
|
7 |
-
$("."+select).on( "click", function() {
|
8 |
-
var opt = $(this).attr( "value" ).split( ":" );
|
9 |
-
$("."+area).css( "font-family", opt[0] );
|
10 |
-
return false;
|
11 |
-
});
|
12 |
-
}
|
13 |
-
|
14 |
-
cf7_style_font_preview( "font-load", "font-viewer3" );
|
15 |
-
cf7_style_font_preview( "font-load", "font-viewer" );
|
16 |
-
cf7_style_font_preview( "font-load2", "font-viewer2" );
|
17 |
-
|
18 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/js/codemirror.js
CHANGED
@@ -1,8645 +1,5 @@
|
|
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 |
-
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
|
27 |
-
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
28 |
-
var ie = ie_upto10 || ie_11up;
|
29 |
-
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
|
30 |
-
var webkit = /WebKit\//.test(navigator.userAgent);
|
31 |
-
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
|
32 |
-
var chrome = /Chrome\//.test(navigator.userAgent);
|
33 |
-
var presto = /Opera\//.test(navigator.userAgent);
|
34 |
-
var safari = /Apple Computer/.test(navigator.vendor);
|
35 |
-
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
|
36 |
-
var phantom = /PhantomJS/.test(navigator.userAgent);
|
37 |
-
|
38 |
-
var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
39 |
-
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
40 |
-
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
|
41 |
-
var mac = ios || /Mac/.test(navigator.platform);
|
42 |
-
var windows = /win/i.test(navigator.platform);
|
43 |
-
|
44 |
-
var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
|
45 |
-
if (presto_version) presto_version = Number(presto_version[1]);
|
46 |
-
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
|
47 |
-
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
48 |
-
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
|
49 |
-
var captureRightClick = gecko || (ie && ie_version >= 9);
|
50 |
-
|
51 |
-
// Optimize some code when these features are not used.
|
52 |
-
var sawReadOnlySpans = false, sawCollapsedSpans = false;
|
53 |
-
|
54 |
-
// EDITOR CONSTRUCTOR
|
55 |
-
|
56 |
-
// A CodeMirror instance represents an editor. This is the object
|
57 |
-
// that user code is usually dealing with.
|
58 |
-
|
59 |
-
function CodeMirror(place, options) {
|
60 |
-
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
|
61 |
-
|
62 |
-
this.options = options = options ? copyObj(options) : {};
|
63 |
-
// Determine effective options based on given values and defaults.
|
64 |
-
copyObj(defaults, options, false);
|
65 |
-
setGuttersForLineNumbers(options);
|
66 |
-
|
67 |
-
var doc = options.value;
|
68 |
-
if (typeof doc == "string") doc = new Doc(doc, options.mode);
|
69 |
-
this.doc = doc;
|
70 |
-
|
71 |
-
var input = new CodeMirror.inputStyles[options.inputStyle](this);
|
72 |
-
var display = this.display = new Display(place, doc, input);
|
73 |
-
display.wrapper.CodeMirror = this;
|
74 |
-
updateGutters(this);
|
75 |
-
themeChanged(this);
|
76 |
-
if (options.lineWrapping)
|
77 |
-
this.display.wrapper.className += " CodeMirror-wrap";
|
78 |
-
if (options.autofocus && !mobile) display.input.focus();
|
79 |
-
initScrollbars(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 input.poll
|
88 |
-
draggingText: false,
|
89 |
-
highlight: new Delayed(), // stores highlight worker timeout
|
90 |
-
keySeq: null // Unfinished key sequence
|
91 |
-
};
|
92 |
-
|
93 |
-
var cm = this;
|
94 |
-
|
95 |
-
// Override magic textarea content restore that IE sometimes does
|
96 |
-
// on our hidden textarea on reload
|
97 |
-
if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
|
98 |
-
|
99 |
-
registerEventHandlers(this);
|
100 |
-
ensureGlobalHandlers();
|
101 |
-
|
102 |
-
startOperation(this);
|
103 |
-
this.curOp.forceUpdate = true;
|
104 |
-
attachDoc(this, doc);
|
105 |
-
|
106 |
-
if ((options.autofocus && !mobile) || cm.hasFocus())
|
107 |
-
setTimeout(bind(onFocus, this), 20);
|
108 |
-
else
|
109 |
-
onBlur(this);
|
110 |
-
|
111 |
-
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
|
112 |
-
optionHandlers[opt](this, options[opt], Init);
|
113 |
-
maybeUpdateLineNumberWidth(this);
|
114 |
-
if (options.finishInit) options.finishInit(this);
|
115 |
-
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
|
116 |
-
endOperation(this);
|
117 |
-
// Suppress optimizelegibility in Webkit, since it breaks text
|
118 |
-
// measuring on line wrapping boundaries.
|
119 |
-
if (webkit && options.lineWrapping &&
|
120 |
-
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
|
121 |
-
display.lineDiv.style.textRendering = "auto";
|
122 |
-
}
|
123 |
-
|
124 |
-
// DISPLAY CONSTRUCTOR
|
125 |
-
|
126 |
-
// The display handles the DOM integration, both for input reading
|
127 |
-
// and content drawing. It holds references to DOM nodes and
|
128 |
-
// display-related state.
|
129 |
-
|
130 |
-
function Display(place, doc, input) {
|
131 |
-
var d = this;
|
132 |
-
this.input = input;
|
133 |
-
|
134 |
-
// Covers bottom-right square when both scrollbars are present.
|
135 |
-
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
|
136 |
-
d.scrollbarFiller.setAttribute("cm-not-content", "true");
|
137 |
-
// Covers bottom of gutter when coverGutterNextToScrollbar is on
|
138 |
-
// and h scrollbar is present.
|
139 |
-
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
|
140 |
-
d.gutterFiller.setAttribute("cm-not-content", "true");
|
141 |
-
// Will contain the actual code, positioned to cover the viewport.
|
142 |
-
d.lineDiv = elt("div", null, "CodeMirror-code");
|
143 |
-
// Elements are added to these to represent selection and cursors.
|
144 |
-
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
|
145 |
-
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
|
146 |
-
// A visibility: hidden element used to find the size of things.
|
147 |
-
d.measure = elt("div", null, "CodeMirror-measure");
|
148 |
-
// When lines outside of the viewport are measured, they are drawn in this.
|
149 |
-
d.lineMeasure = elt("div", null, "CodeMirror-measure");
|
150 |
-
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
151 |
-
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
|
152 |
-
null, "position: relative; outline: none");
|
153 |
-
// Moved around its parent to cover visible view.
|
154 |
-
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
|
155 |
-
// Set to the height of the document, allowing scrolling.
|
156 |
-
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
|
157 |
-
d.sizerWidth = null;
|
158 |
-
// Behavior of elts with overflow: auto and padding is
|
159 |
-
// inconsistent across browsers. This is used to ensure the
|
160 |
-
// scrollable area is big enough.
|
161 |
-
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
|
162 |
-
// Will contain the gutters, if any.
|
163 |
-
d.gutters = elt("div", null, "CodeMirror-gutters");
|
164 |
-
d.lineGutter = null;
|
165 |
-
// Actual scrollable element.
|
166 |
-
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
|
167 |
-
d.scroller.setAttribute("tabIndex", "-1");
|
168 |
-
// The element in which the editor lives.
|
169 |
-
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
|
170 |
-
|
171 |
-
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
|
172 |
-
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
|
173 |
-
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
|
174 |
-
|
175 |
-
if (place) {
|
176 |
-
if (place.appendChild) place.appendChild(d.wrapper);
|
177 |
-
else place(d.wrapper);
|
178 |
-
}
|
179 |
-
|
180 |
-
// Current rendered range (may be bigger than the view window).
|
181 |
-
d.viewFrom = d.viewTo = doc.first;
|
182 |
-
d.reportedViewFrom = d.reportedViewTo = doc.first;
|
183 |
-
// Information about the rendered lines.
|
184 |
-
d.view = [];
|
185 |
-
d.renderedView = null;
|
186 |
-
// Holds info about a single rendered line when it was rendered
|
187 |
-
// for measurement, while not in view.
|
188 |
-
d.externalMeasured = null;
|
189 |
-
// Empty space (in pixels) above the view
|
190 |
-
d.viewOffset = 0;
|
191 |
-
d.lastWrapHeight = d.lastWrapWidth = 0;
|
192 |
-
d.updateLineNumbers = null;
|
193 |
-
|
194 |
-
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
|
195 |
-
d.scrollbarsClipped = false;
|
196 |
-
|
197 |
-
// Used to only resize the line number gutter when necessary (when
|
198 |
-
// the amount of lines crosses a boundary that makes its width change)
|
199 |
-
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
|
200 |
-
// Set to true when a non-horizontal-scrolling line widget is
|
201 |
-
// added. As an optimization, line widget aligning is skipped when
|
202 |
-
// this is false.
|
203 |
-
d.alignWidgets = false;
|
204 |
-
|
205 |
-
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
206 |
-
|
207 |
-
// Tracks the maximum line length so that the horizontal scrollbar
|
208 |
-
// can be kept static when scrolling.
|
209 |
-
d.maxLine = null;
|
210 |
-
d.maxLineLength = 0;
|
211 |
-
d.maxLineChanged = false;
|
212 |
-
|
213 |
-
// Used for measuring wheel scrolling granularity
|
214 |
-
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
|
215 |
-
|
216 |
-
// True when shift is held down.
|
217 |
-
d.shift = false;
|
218 |
-
|
219 |
-
// Used to track whether anything happened since the context menu
|
220 |
-
// was opened.
|
221 |
-
d.selForContextMenu = null;
|
222 |
-
|
223 |
-
d.activeTouch = null;
|
224 |
-
|
225 |
-
input.init(d);
|
226 |
-
}
|
227 |
-
|
228 |
-
// STATE UPDATES
|
229 |
-
|
230 |
-
// Used to get the editor into a consistent state again when options change.
|
231 |
-
|
232 |
-
function loadMode(cm) {
|
233 |
-
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
|
234 |
-
resetModeState(cm);
|
235 |
-
}
|
236 |
-
|
237 |
-
function resetModeState(cm) {
|
238 |
-
cm.doc.iter(function(line) {
|
239 |
-
if (line.stateAfter) line.stateAfter = null;
|
240 |
-
if (line.styles) line.styles = null;
|
241 |
-
});
|
242 |
-
cm.doc.frontier = cm.doc.first;
|
243 |
-
startWorker(cm, 100);
|
244 |
-
cm.state.modeGen++;
|
245 |
-
if (cm.curOp) regChange(cm);
|
246 |
-
}
|
247 |
-
|
248 |
-
function wrappingChanged(cm) {
|
249 |
-
if (cm.options.lineWrapping) {
|
250 |
-
addClass(cm.display.wrapper, "CodeMirror-wrap");
|
251 |
-
cm.display.sizer.style.minWidth = "";
|
252 |
-
cm.display.sizerWidth = null;
|
253 |
-
} else {
|
254 |
-
rmClass(cm.display.wrapper, "CodeMirror-wrap");
|
255 |
-
findMaxLine(cm);
|
256 |
-
}
|
257 |
-
estimateLineHeights(cm);
|
258 |
-
regChange(cm);
|
259 |
-
clearCaches(cm);
|
260 |
-
setTimeout(function(){updateScrollbars(cm);}, 100);
|
261 |
-
}
|
262 |
-
|
263 |
-
// Returns a function that estimates the height of a line, to use as
|
264 |
-
// first approximation until the line becomes visible (and is thus
|
265 |
-
// properly measurable).
|
266 |
-
function estimateHeight(cm) {
|
267 |
-
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
|
268 |
-
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
|
269 |
-
return function(line) {
|
270 |
-
if (lineIsHidden(cm.doc, line)) return 0;
|
271 |
-
|
272 |
-
var widgetsHeight = 0;
|
273 |
-
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
|
274 |
-
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
|
275 |
-
}
|
276 |
-
|
277 |
-
if (wrapping)
|
278 |
-
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
|
279 |
-
else
|
280 |
-
return widgetsHeight + th;
|
281 |
-
};
|
282 |
-
}
|
283 |
-
|
284 |
-
function estimateLineHeights(cm) {
|
285 |
-
var doc = cm.doc, est = estimateHeight(cm);
|
286 |
-
doc.iter(function(line) {
|
287 |
-
var estHeight = est(line);
|
288 |
-
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
289 |
-
});
|
290 |
-
}
|
291 |
-
|
292 |
-
function themeChanged(cm) {
|
293 |
-
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
|
294 |
-
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
|
295 |
-
clearCaches(cm);
|
296 |
-
}
|
297 |
-
|
298 |
-
function guttersChanged(cm) {
|
299 |
-
updateGutters(cm);
|
300 |
-
regChange(cm);
|
301 |
-
setTimeout(function(){alignHorizontally(cm);}, 20);
|
302 |
-
}
|
303 |
-
|
304 |
-
// Rebuild the gutter elements, ensure the margin to the left of the
|
305 |
-
// code matches their width.
|
306 |
-
function updateGutters(cm) {
|
307 |
-
var gutters = cm.display.gutters, specs = cm.options.gutters;
|
308 |
-
removeChildren(gutters);
|
309 |
-
for (var i = 0; i < specs.length; ++i) {
|
310 |
-
var gutterClass = specs[i];
|
311 |
-
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
|
312 |
-
if (gutterClass == "CodeMirror-linenumbers") {
|
313 |
-
cm.display.lineGutter = gElt;
|
314 |
-
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
|
315 |
-
}
|
316 |
-
}
|
317 |
-
gutters.style.display = i ? "" : "none";
|
318 |
-
updateGutterSpace(cm);
|
319 |
-
}
|
320 |
-
|
321 |
-
function updateGutterSpace(cm) {
|
322 |
-
var width = cm.display.gutters.offsetWidth;
|
323 |
-
cm.display.sizer.style.marginLeft = width + "px";
|
324 |
-
}
|
325 |
-
|
326 |
-
// Compute the character length of a line, taking into account
|
327 |
-
// collapsed ranges (see markText) that might hide parts, and join
|
328 |
-
// other lines onto it.
|
329 |
-
function lineLength(line) {
|
330 |
-
if (line.height == 0) return 0;
|
331 |
-
var len = line.text.length, merged, cur = line;
|
332 |
-
while (merged = collapsedSpanAtStart(cur)) {
|
333 |
-
var found = merged.find(0, true);
|
334 |
-
cur = found.from.line;
|
335 |
-
len += found.from.ch - found.to.ch;
|
336 |
-
}
|
337 |
-
cur = line;
|
338 |
-
while (merged = collapsedSpanAtEnd(cur)) {
|
339 |
-
var found = merged.find(0, true);
|
340 |
-
len -= cur.text.length - found.from.ch;
|
341 |
-
cur = found.to.line;
|
342 |
-
len += cur.text.length - found.to.ch;
|
343 |
-
}
|
344 |
-
return len;
|
345 |
-
}
|
346 |
-
|
347 |
-
// Find the longest line in the document.
|
348 |
-
function findMaxLine(cm) {
|
349 |
-
var d = cm.display, doc = cm.doc;
|
350 |
-
d.maxLine = getLine(doc, doc.first);
|
351 |
-
d.maxLineLength = lineLength(d.maxLine);
|
352 |
-
d.maxLineChanged = true;
|
353 |
-
doc.iter(function(line) {
|
354 |
-
var len = lineLength(line);
|
355 |
-
if (len > d.maxLineLength) {
|
356 |
-
d.maxLineLength = len;
|
357 |
-
d.maxLine = line;
|
358 |
-
}
|
359 |
-
});
|
360 |
-
}
|
361 |
-
|
362 |
-
// Make sure the gutters options contains the element
|
363 |
-
// "CodeMirror-linenumbers" when the lineNumbers option is true.
|
364 |
-
function setGuttersForLineNumbers(options) {
|
365 |
-
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
|
366 |
-
if (found == -1 && options.lineNumbers) {
|
367 |
-
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
|
368 |
-
} else if (found > -1 && !options.lineNumbers) {
|
369 |
-
options.gutters = options.gutters.slice(0);
|
370 |
-
options.gutters.splice(found, 1);
|
371 |
-
}
|
372 |
-
}
|
373 |
-
|
374 |
-
// SCROLLBARS
|
375 |
-
|
376 |
-
// Prepare DOM reads needed to update the scrollbars. Done in one
|
377 |
-
// shot to minimize update/measure roundtrips.
|
378 |
-
function measureForScrollbars(cm) {
|
379 |
-
var d = cm.display, gutterW = d.gutters.offsetWidth;
|
380 |
-
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
|
381 |
-
return {
|
382 |
-
clientHeight: d.scroller.clientHeight,
|
383 |
-
viewHeight: d.wrapper.clientHeight,
|
384 |
-
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
|
385 |
-
viewWidth: d.wrapper.clientWidth,
|
386 |
-
barLeft: cm.options.fixedGutter ? gutterW : 0,
|
387 |
-
docHeight: docH,
|
388 |
-
scrollHeight: docH + scrollGap(cm) + d.barHeight,
|
389 |
-
nativeBarWidth: d.nativeBarWidth,
|
390 |
-
gutterWidth: gutterW
|
391 |
-
};
|
392 |
-
}
|
393 |
-
|
394 |
-
function NativeScrollbars(place, scroll, cm) {
|
395 |
-
this.cm = cm;
|
396 |
-
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
|
397 |
-
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
|
398 |
-
place(vert); place(horiz);
|
399 |
-
|
400 |
-
on(vert, "scroll", function() {
|
401 |
-
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
|
402 |
-
});
|
403 |
-
on(horiz, "scroll", function() {
|
404 |
-
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
|
405 |
-
});
|
406 |
-
|
407 |
-
this.checkedOverlay = false;
|
408 |
-
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
409 |
-
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
|
410 |
-
}
|
411 |
-
|
412 |
-
NativeScrollbars.prototype = copyObj({
|
413 |
-
update: function(measure) {
|
414 |
-
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
415 |
-
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
416 |
-
var sWidth = measure.nativeBarWidth;
|
417 |
-
|
418 |
-
if (needsV) {
|
419 |
-
this.vert.style.display = "block";
|
420 |
-
this.vert.style.bottom = needsH ? sWidth + "px" : "0";
|
421 |
-
var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
|
422 |
-
// A bug in IE8 can cause this value to be negative, so guard it.
|
423 |
-
this.vert.firstChild.style.height =
|
424 |
-
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
|
425 |
-
} else {
|
426 |
-
this.vert.style.display = "";
|
427 |
-
this.vert.firstChild.style.height = "0";
|
428 |
-
}
|
429 |
-
|
430 |
-
if (needsH) {
|
431 |
-
this.horiz.style.display = "block";
|
432 |
-
this.horiz.style.right = needsV ? sWidth + "px" : "0";
|
433 |
-
this.horiz.style.left = measure.barLeft + "px";
|
434 |
-
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
|
435 |
-
this.horiz.firstChild.style.width =
|
436 |
-
(measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
|
437 |
-
} else {
|
438 |
-
this.horiz.style.display = "";
|
439 |
-
this.horiz.firstChild.style.width = "0";
|
440 |
-
}
|
441 |
-
|
442 |
-
if (!this.checkedOverlay && measure.clientHeight > 0) {
|
443 |
-
if (sWidth == 0) this.overlayHack();
|
444 |
-
this.checkedOverlay = true;
|
445 |
-
}
|
446 |
-
|
447 |
-
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
|
448 |
-
},
|
449 |
-
setScrollLeft: function(pos) {
|
450 |
-
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
|
451 |
-
},
|
452 |
-
setScrollTop: function(pos) {
|
453 |
-
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
|
454 |
-
},
|
455 |
-
overlayHack: function() {
|
456 |
-
var w = mac && !mac_geMountainLion ? "12px" : "18px";
|
457 |
-
this.horiz.style.minHeight = this.vert.style.minWidth = w;
|
458 |
-
var self = this;
|
459 |
-
var barMouseDown = function(e) {
|
460 |
-
if (e_target(e) != self.vert && e_target(e) != self.horiz)
|
461 |
-
operation(self.cm, onMouseDown)(e);
|
462 |
-
};
|
463 |
-
on(this.vert, "mousedown", barMouseDown);
|
464 |
-
on(this.horiz, "mousedown", barMouseDown);
|
465 |
-
},
|
466 |
-
clear: function() {
|
467 |
-
var parent = this.horiz.parentNode;
|
468 |
-
parent.removeChild(this.horiz);
|
469 |
-
parent.removeChild(this.vert);
|
470 |
-
}
|
471 |
-
}, NativeScrollbars.prototype);
|
472 |
-
|
473 |
-
function NullScrollbars() {}
|
474 |
-
|
475 |
-
NullScrollbars.prototype = copyObj({
|
476 |
-
update: function() { return {bottom: 0, right: 0}; },
|
477 |
-
setScrollLeft: function() {},
|
478 |
-
setScrollTop: function() {},
|
479 |
-
clear: function() {}
|
480 |
-
}, NullScrollbars.prototype);
|
481 |
-
|
482 |
-
CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
|
483 |
-
|
484 |
-
function initScrollbars(cm) {
|
485 |
-
if (cm.display.scrollbars) {
|
486 |
-
cm.display.scrollbars.clear();
|
487 |
-
if (cm.display.scrollbars.addClass)
|
488 |
-
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
489 |
-
}
|
490 |
-
|
491 |
-
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
|
492 |
-
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
|
493 |
-
// Prevent clicks in the scrollbars from killing focus
|
494 |
-
on(node, "mousedown", function() {
|
495 |
-
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
|
496 |
-
});
|
497 |
-
node.setAttribute("cm-not-content", "true");
|
498 |
-
}, function(pos, axis) {
|
499 |
-
if (axis == "horizontal") setScrollLeft(cm, pos);
|
500 |
-
else setScrollTop(cm, pos);
|
501 |
-
}, cm);
|
502 |
-
if (cm.display.scrollbars.addClass)
|
503 |
-
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
504 |
-
}
|
505 |
-
|
506 |
-
function updateScrollbars(cm, measure) {
|
507 |
-
if (!measure) measure = measureForScrollbars(cm);
|
508 |
-
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
|
509 |
-
updateScrollbarsInner(cm, measure);
|
510 |
-
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
|
511 |
-
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
|
512 |
-
updateHeightsInViewport(cm);
|
513 |
-
updateScrollbarsInner(cm, measureForScrollbars(cm));
|
514 |
-
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
// Re-synchronize the fake scrollbars with the actual size of the
|
519 |
-
// content.
|
520 |
-
function updateScrollbarsInner(cm, measure) {
|
521 |
-
var d = cm.display;
|
522 |
-
var sizes = d.scrollbars.update(measure);
|
523 |
-
|
524 |
-
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
|
525 |
-
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
|
526 |
-
|
527 |
-
if (sizes.right && sizes.bottom) {
|
528 |
-
d.scrollbarFiller.style.display = "block";
|
529 |
-
d.scrollbarFiller.style.height = sizes.bottom + "px";
|
530 |
-
d.scrollbarFiller.style.width = sizes.right + "px";
|
531 |
-
} else d.scrollbarFiller.style.display = "";
|
532 |
-
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
|
533 |
-
d.gutterFiller.style.display = "block";
|
534 |
-
d.gutterFiller.style.height = sizes.bottom + "px";
|
535 |
-
d.gutterFiller.style.width = measure.gutterWidth + "px";
|
536 |
-
} else d.gutterFiller.style.display = "";
|
537 |
-
}
|
538 |
-
|
539 |
-
// Compute the lines that are visible in a given viewport (defaults
|
540 |
-
// the the current scroll position). viewport may contain top,
|
541 |
-
// height, and ensure (see op.scrollToPos) properties.
|
542 |
-
function visibleLines(display, doc, viewport) {
|
543 |
-
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
|
544 |
-
top = Math.floor(top - paddingTop(display));
|
545 |
-
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
|
546 |
-
|
547 |
-
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
|
548 |
-
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
|
549 |
-
// forces those lines into the viewport (if possible).
|
550 |
-
if (viewport && viewport.ensure) {
|
551 |
-
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
|
552 |
-
if (ensureFrom < from) {
|
553 |
-
from = ensureFrom;
|
554 |
-
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
|
555 |
-
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
|
556 |
-
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
|
557 |
-
to = ensureTo;
|
558 |
-
}
|
559 |
-
}
|
560 |
-
return {from: from, to: Math.max(to, from + 1)};
|
561 |
-
}
|
562 |
-
|
563 |
-
// LINE NUMBERS
|
564 |
-
|
565 |
-
// Re-align line numbers and gutter marks to compensate for
|
566 |
-
// horizontal scrolling.
|
567 |
-
function alignHorizontally(cm) {
|
568 |
-
var display = cm.display, view = display.view;
|
569 |
-
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
|
570 |
-
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
571 |
-
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
572 |
-
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
573 |
-
if (cm.options.fixedGutter && view[i].gutter)
|
574 |
-
view[i].gutter.style.left = left;
|
575 |
-
var align = view[i].alignable;
|
576 |
-
if (align) for (var j = 0; j < align.length; j++)
|
577 |
-
align[j].style.left = left;
|
578 |
-
}
|
579 |
-
if (cm.options.fixedGutter)
|
580 |
-
display.gutters.style.left = (comp + gutterW) + "px";
|
581 |
-
}
|
582 |
-
|
583 |
-
// Used to ensure that the line number gutter is still the right
|
584 |
-
// size for the current document size. Returns true when an update
|
585 |
-
// is needed.
|
586 |
-
function maybeUpdateLineNumberWidth(cm) {
|
587 |
-
if (!cm.options.lineNumbers) return false;
|
588 |
-
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
|
589 |
-
if (last.length != display.lineNumChars) {
|
590 |
-
var test = display.measure.appendChild(elt("div", [elt("div", last)],
|
591 |
-
"CodeMirror-linenumber CodeMirror-gutter-elt"));
|
592 |
-
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
|
593 |
-
display.lineGutter.style.width = "";
|
594 |
-
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
|
595 |
-
display.lineNumWidth = display.lineNumInnerWidth + padding;
|
596 |
-
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
|
597 |
-
display.lineGutter.style.width = display.lineNumWidth + "px";
|
598 |
-
updateGutterSpace(cm);
|
599 |
-
return true;
|
600 |
-
}
|
601 |
-
return false;
|
602 |
-
}
|
603 |
-
|
604 |
-
function lineNumberFor(options, i) {
|
605 |
-
return String(options.lineNumberFormatter(i + options.firstLineNumber));
|
606 |
-
}
|
607 |
-
|
608 |
-
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
|
609 |
-
// but using getBoundingClientRect to get a sub-pixel-accurate
|
610 |
-
// result.
|
611 |
-
function compensateForHScroll(display) {
|
612 |
-
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
|
613 |
-
}
|
614 |
-
|
615 |
-
// DISPLAY DRAWING
|
616 |
-
|
617 |
-
function DisplayUpdate(cm, viewport, force) {
|
618 |
-
var display = cm.display;
|
619 |
-
|
620 |
-
this.viewport = viewport;
|
621 |
-
// Store some values that we'll need later (but don't want to force a relayout for)
|
622 |
-
this.visible = visibleLines(display, cm.doc, viewport);
|
623 |
-
this.editorIsHidden = !display.wrapper.offsetWidth;
|
624 |
-
this.wrapperHeight = display.wrapper.clientHeight;
|
625 |
-
this.wrapperWidth = display.wrapper.clientWidth;
|
626 |
-
this.oldDisplayWidth = displayWidth(cm);
|
627 |
-
this.force = force;
|
628 |
-
this.dims = getDimensions(cm);
|
629 |
-
this.events = [];
|
630 |
-
}
|
631 |
-
|
632 |
-
DisplayUpdate.prototype.signal = function(emitter, type) {
|
633 |
-
if (hasHandler(emitter, type))
|
634 |
-
this.events.push(arguments);
|
635 |
-
};
|
636 |
-
DisplayUpdate.prototype.finish = function() {
|
637 |
-
for (var i = 0; i < this.events.length; i++)
|
638 |
-
signal.apply(null, this.events[i]);
|
639 |
-
};
|
640 |
-
|
641 |
-
function maybeClipScrollbars(cm) {
|
642 |
-
var display = cm.display;
|
643 |
-
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
644 |
-
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
|
645 |
-
display.heightForcer.style.height = scrollGap(cm) + "px";
|
646 |
-
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
|
647 |
-
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
|
648 |
-
display.scrollbarsClipped = true;
|
649 |
-
}
|
650 |
-
}
|
651 |
-
|
652 |
-
// Does the actual updating of the line display. Bails out
|
653 |
-
// (returning false) when there is nothing to be done and forced is
|
654 |
-
// false.
|
655 |
-
function updateDisplayIfNeeded(cm, update) {
|
656 |
-
var display = cm.display, doc = cm.doc;
|
657 |
-
|
658 |
-
if (update.editorIsHidden) {
|
659 |
-
resetView(cm);
|
660 |
-
return false;
|
661 |
-
}
|
662 |
-
|
663 |
-
// Bail out if the visible area is already rendered and nothing changed.
|
664 |
-
if (!update.force &&
|
665 |
-
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
|
666 |
-
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
|
667 |
-
display.renderedView == display.view && countDirtyView(cm) == 0)
|
668 |
-
return false;
|
669 |
-
|
670 |
-
if (maybeUpdateLineNumberWidth(cm)) {
|
671 |
-
resetView(cm);
|
672 |
-
update.dims = getDimensions(cm);
|
673 |
-
}
|
674 |
-
|
675 |
-
// Compute a suitable new viewport (from & to)
|
676 |
-
var end = doc.first + doc.size;
|
677 |
-
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
|
678 |
-
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
|
679 |
-
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
|
680 |
-
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
|
681 |
-
if (sawCollapsedSpans) {
|
682 |
-
from = visualLineNo(cm.doc, from);
|
683 |
-
to = visualLineEndNo(cm.doc, to);
|
684 |
-
}
|
685 |
-
|
686 |
-
var different = from != display.viewFrom || to != display.viewTo ||
|
687 |
-
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
|
688 |
-
adjustView(cm, from, to);
|
689 |
-
|
690 |
-
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
|
691 |
-
// Position the mover div to align with the current scroll position
|
692 |
-
cm.display.mover.style.top = display.viewOffset + "px";
|
693 |
-
|
694 |
-
var toUpdate = countDirtyView(cm);
|
695 |
-
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
|
696 |
-
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
|
697 |
-
return false;
|
698 |
-
|
699 |
-
// For big changes, we hide the enclosing element during the
|
700 |
-
// update, since that speeds up the operations on most browsers.
|
701 |
-
var focused = activeElt();
|
702 |
-
if (toUpdate > 4) display.lineDiv.style.display = "none";
|
703 |
-
patchDisplay(cm, display.updateLineNumbers, update.dims);
|
704 |
-
if (toUpdate > 4) display.lineDiv.style.display = "";
|
705 |
-
display.renderedView = display.view;
|
706 |
-
// There might have been a widget with a focused element that got
|
707 |
-
// hidden or updated, if so re-focus it.
|
708 |
-
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
|
709 |
-
|
710 |
-
// Prevent selection and cursors from interfering with the scroll
|
711 |
-
// width and height.
|
712 |
-
removeChildren(display.cursorDiv);
|
713 |
-
removeChildren(display.selectionDiv);
|
714 |
-
display.gutters.style.height = 0;
|
715 |
-
|
716 |
-
if (different) {
|
717 |
-
display.lastWrapHeight = update.wrapperHeight;
|
718 |
-
display.lastWrapWidth = update.wrapperWidth;
|
719 |
-
startWorker(cm, 400);
|
720 |
-
}
|
721 |
-
|
722 |
-
display.updateLineNumbers = null;
|
723 |
-
|
724 |
-
return true;
|
725 |
-
}
|
726 |
-
|
727 |
-
function postUpdateDisplay(cm, update) {
|
728 |
-
var force = update.force, viewport = update.viewport;
|
729 |
-
for (var first = true;; first = false) {
|
730 |
-
if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) {
|
731 |
-
force = true;
|
732 |
-
} else {
|
733 |
-
force = false;
|
734 |
-
// Clip forced viewport to actual scrollable area.
|
735 |
-
if (viewport && viewport.top != null)
|
736 |
-
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
|
737 |
-
// Updated line heights might result in the drawn area not
|
738 |
-
// actually covering the viewport. Keep looping until it does.
|
739 |
-
update.visible = visibleLines(cm.display, cm.doc, viewport);
|
740 |
-
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
|
741 |
-
break;
|
742 |
-
}
|
743 |
-
if (!updateDisplayIfNeeded(cm, update)) break;
|
744 |
-
updateHeightsInViewport(cm);
|
745 |
-
var barMeasure = measureForScrollbars(cm);
|
746 |
-
updateSelection(cm);
|
747 |
-
setDocumentHeight(cm, barMeasure);
|
748 |
-
updateScrollbars(cm, barMeasure);
|
749 |
-
}
|
750 |
-
|
751 |
-
update.signal(cm, "update", cm);
|
752 |
-
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
753 |
-
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
|
754 |
-
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
|
755 |
-
}
|
756 |
-
}
|
757 |
-
|
758 |
-
function updateDisplaySimple(cm, viewport) {
|
759 |
-
var update = new DisplayUpdate(cm, viewport);
|
760 |
-
if (updateDisplayIfNeeded(cm, update)) {
|
761 |
-
updateHeightsInViewport(cm);
|
762 |
-
postUpdateDisplay(cm, update);
|
763 |
-
var barMeasure = measureForScrollbars(cm);
|
764 |
-
updateSelection(cm);
|
765 |
-
setDocumentHeight(cm, barMeasure);
|
766 |
-
updateScrollbars(cm, barMeasure);
|
767 |
-
update.finish();
|
768 |
-
}
|
769 |
-
}
|
770 |
-
|
771 |
-
function setDocumentHeight(cm, measure) {
|
772 |
-
cm.display.sizer.style.minHeight = measure.docHeight + "px";
|
773 |
-
var total = measure.docHeight + cm.display.barHeight;
|
774 |
-
cm.display.heightForcer.style.top = total + "px";
|
775 |
-
cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
|
776 |
-
}
|
777 |
-
|
778 |
-
// Read the actual heights of the rendered lines, and update their
|
779 |
-
// stored heights to match.
|
780 |
-
function updateHeightsInViewport(cm) {
|
781 |
-
var display = cm.display;
|
782 |
-
var prevBottom = display.lineDiv.offsetTop;
|
783 |
-
for (var i = 0; i < display.view.length; i++) {
|
784 |
-
var cur = display.view[i], height;
|
785 |
-
if (cur.hidden) continue;
|
786 |
-
if (ie && ie_version < 8) {
|
787 |
-
var bot = cur.node.offsetTop + cur.node.offsetHeight;
|
788 |
-
height = bot - prevBottom;
|
789 |
-
prevBottom = bot;
|
790 |
-
} else {
|
791 |
-
var box = cur.node.getBoundingClientRect();
|
792 |
-
height = box.bottom - box.top;
|
793 |
-
}
|
794 |
-
var diff = cur.line.height - height;
|
795 |
-
if (height < 2) height = textHeight(display);
|
796 |
-
if (diff > .001 || diff < -.001) {
|
797 |
-
updateLineHeight(cur.line, height);
|
798 |
-
updateWidgetHeight(cur.line);
|
799 |
-
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
|
800 |
-
updateWidgetHeight(cur.rest[j]);
|
801 |
-
}
|
802 |
-
}
|
803 |
-
}
|
804 |
-
|
805 |
-
// Read and store the height of line widgets associated with the
|
806 |
-
// given line.
|
807 |
-
function updateWidgetHeight(line) {
|
808 |
-
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
|
809 |
-
line.widgets[i].height = line.widgets[i].node.offsetHeight;
|
810 |
-
}
|
811 |
-
|
812 |
-
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
813 |
-
// view, so that we don't interleave reading and writing to the DOM.
|
814 |
-
function getDimensions(cm) {
|
815 |
-
var d = cm.display, left = {}, width = {};
|
816 |
-
var gutterLeft = d.gutters.clientLeft;
|
817 |
-
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
|
818 |
-
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
|
819 |
-
width[cm.options.gutters[i]] = n.clientWidth;
|
820 |
-
}
|
821 |
-
return {fixedPos: compensateForHScroll(d),
|
822 |
-
gutterTotalWidth: d.gutters.offsetWidth,
|
823 |
-
gutterLeft: left,
|
824 |
-
gutterWidth: width,
|
825 |
-
wrapperWidth: d.wrapper.clientWidth};
|
826 |
-
}
|
827 |
-
|
828 |
-
// Sync the actual display DOM structure with display.view, removing
|
829 |
-
// nodes for lines that are no longer in view, and creating the ones
|
830 |
-
// that are not there yet, and updating the ones that are out of
|
831 |
-
// date.
|
832 |
-
function patchDisplay(cm, updateNumbersFrom, dims) {
|
833 |
-
var display = cm.display, lineNumbers = cm.options.lineNumbers;
|
834 |
-
var container = display.lineDiv, cur = container.firstChild;
|
835 |
-
|
836 |
-
function rm(node) {
|
837 |
-
var next = node.nextSibling;
|
838 |
-
// Works around a throw-scroll bug in OS X Webkit
|
839 |
-
if (webkit && mac && cm.display.currentWheelTarget == node)
|
840 |
-
node.style.display = "none";
|
841 |
-
else
|
842 |
-
node.parentNode.removeChild(node);
|
843 |
-
return next;
|
844 |
-
}
|
845 |
-
|
846 |
-
var view = display.view, lineN = display.viewFrom;
|
847 |
-
// Loop over the elements in the view, syncing cur (the DOM nodes
|
848 |
-
// in display.lineDiv) with the view as we go.
|
849 |
-
for (var i = 0; i < view.length; i++) {
|
850 |
-
var lineView = view[i];
|
851 |
-
if (lineView.hidden) {
|
852 |
-
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
|
853 |
-
var node = buildLineElement(cm, lineView, lineN, dims);
|
854 |
-
container.insertBefore(node, cur);
|
855 |
-
} else { // Already drawn
|
856 |
-
while (cur != lineView.node) cur = rm(cur);
|
857 |
-
var updateNumber = lineNumbers && updateNumbersFrom != null &&
|
858 |
-
updateNumbersFrom <= lineN && lineView.lineNumber;
|
859 |
-
if (lineView.changes) {
|
860 |
-
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
|
861 |
-
updateLineForChanges(cm, lineView, lineN, dims);
|
862 |
-
}
|
863 |
-
if (updateNumber) {
|
864 |
-
removeChildren(lineView.lineNumber);
|
865 |
-
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
|
866 |
-
}
|
867 |
-
cur = lineView.node.nextSibling;
|
868 |
-
}
|
869 |
-
lineN += lineView.size;
|
870 |
-
}
|
871 |
-
while (cur) cur = rm(cur);
|
872 |
-
}
|
873 |
-
|
874 |
-
// When an aspect of a line changes, a string is added to
|
875 |
-
// lineView.changes. This updates the relevant part of the line's
|
876 |
-
// DOM structure.
|
877 |
-
function updateLineForChanges(cm, lineView, lineN, dims) {
|
878 |
-
for (var j = 0; j < lineView.changes.length; j++) {
|
879 |
-
var type = lineView.changes[j];
|
880 |
-
if (type == "text") updateLineText(cm, lineView);
|
881 |
-
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
|
882 |
-
else if (type == "class") updateLineClasses(lineView);
|
883 |
-
else if (type == "widget") updateLineWidgets(cm, lineView, dims);
|
884 |
-
}
|
885 |
-
lineView.changes = null;
|
886 |
-
}
|
887 |
-
|
888 |
-
// Lines with gutter elements, widgets or a background class need to
|
889 |
-
// be wrapped, and have the extra elements added to the wrapper div
|
890 |
-
function ensureLineWrapped(lineView) {
|
891 |
-
if (lineView.node == lineView.text) {
|
892 |
-
lineView.node = elt("div", null, null, "position: relative");
|
893 |
-
if (lineView.text.parentNode)
|
894 |
-
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
|
895 |
-
lineView.node.appendChild(lineView.text);
|
896 |
-
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
|
897 |
-
}
|
898 |
-
return lineView.node;
|
899 |
-
}
|
900 |
-
|
901 |
-
function updateLineBackground(lineView) {
|
902 |
-
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
|
903 |
-
if (cls) cls += " CodeMirror-linebackground";
|
904 |
-
if (lineView.background) {
|
905 |
-
if (cls) lineView.background.className = cls;
|
906 |
-
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
|
907 |
-
} else if (cls) {
|
908 |
-
var wrap = ensureLineWrapped(lineView);
|
909 |
-
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
|
910 |
-
}
|
911 |
-
}
|
912 |
-
|
913 |
-
// Wrapper around buildLineContent which will reuse the structure
|
914 |
-
// in display.externalMeasured when possible.
|
915 |
-
function getLineContent(cm, lineView) {
|
916 |
-
var ext = cm.display.externalMeasured;
|
917 |
-
if (ext && ext.line == lineView.line) {
|
918 |
-
cm.display.externalMeasured = null;
|
919 |
-
lineView.measure = ext.measure;
|
920 |
-
return ext.built;
|
921 |
-
}
|
922 |
-
return buildLineContent(cm, lineView);
|
923 |
-
}
|
924 |
-
|
925 |
-
// Redraw the line's text. Interacts with the background and text
|
926 |
-
// classes because the mode may output tokens that influence these
|
927 |
-
// classes.
|
928 |
-
function updateLineText(cm, lineView) {
|
929 |
-
var cls = lineView.text.className;
|
930 |
-
var built = getLineContent(cm, lineView);
|
931 |
-
if (lineView.text == lineView.node) lineView.node = built.pre;
|
932 |
-
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
|
933 |
-
lineView.text = built.pre;
|
934 |
-
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
935 |
-
lineView.bgClass = built.bgClass;
|
936 |
-
lineView.textClass = built.textClass;
|
937 |
-
updateLineClasses(lineView);
|
938 |
-
} else if (cls) {
|
939 |
-
lineView.text.className = cls;
|
940 |
-
}
|
941 |
-
}
|
942 |
-
|
943 |
-
function updateLineClasses(lineView) {
|
944 |
-
updateLineBackground(lineView);
|
945 |
-
if (lineView.line.wrapClass)
|
946 |
-
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
|
947 |
-
else if (lineView.node != lineView.text)
|
948 |
-
lineView.node.className = "";
|
949 |
-
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
|
950 |
-
lineView.text.className = textClass || "";
|
951 |
-
}
|
952 |
-
|
953 |
-
function updateLineGutter(cm, lineView, lineN, dims) {
|
954 |
-
if (lineView.gutter) {
|
955 |
-
lineView.node.removeChild(lineView.gutter);
|
956 |
-
lineView.gutter = null;
|
957 |
-
}
|
958 |
-
var markers = lineView.line.gutterMarkers;
|
959 |
-
if (cm.options.lineNumbers || markers) {
|
960 |
-
var wrap = ensureLineWrapped(lineView);
|
961 |
-
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
|
962 |
-
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
|
963 |
-
"px; width: " + dims.gutterTotalWidth + "px");
|
964 |
-
cm.display.input.setUneditable(gutterWrap);
|
965 |
-
wrap.insertBefore(gutterWrap, lineView.text);
|
966 |
-
if (lineView.line.gutterClass)
|
967 |
-
gutterWrap.className += " " + lineView.line.gutterClass;
|
968 |
-
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
969 |
-
lineView.lineNumber = gutterWrap.appendChild(
|
970 |
-
elt("div", lineNumberFor(cm.options, lineN),
|
971 |
-
"CodeMirror-linenumber CodeMirror-gutter-elt",
|
972 |
-
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
|
973 |
-
+ cm.display.lineNumInnerWidth + "px"));
|
974 |
-
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
|
975 |
-
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
|
976 |
-
if (found)
|
977 |
-
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
|
978 |
-
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
|
979 |
-
}
|
980 |
-
}
|
981 |
-
}
|
982 |
-
|
983 |
-
function updateLineWidgets(cm, lineView, dims) {
|
984 |
-
if (lineView.alignable) lineView.alignable = null;
|
985 |
-
for (var node = lineView.node.firstChild, next; node; node = next) {
|
986 |
-
var next = node.nextSibling;
|
987 |
-
if (node.className == "CodeMirror-linewidget")
|
988 |
-
lineView.node.removeChild(node);
|
989 |
-
}
|
990 |
-
insertLineWidgets(cm, lineView, dims);
|
991 |
-
}
|
992 |
-
|
993 |
-
// Build a line's DOM representation from scratch
|
994 |
-
function buildLineElement(cm, lineView, lineN, dims) {
|
995 |
-
var built = getLineContent(cm, lineView);
|
996 |
-
lineView.text = lineView.node = built.pre;
|
997 |
-
if (built.bgClass) lineView.bgClass = built.bgClass;
|
998 |
-
if (built.textClass) lineView.textClass = built.textClass;
|
999 |
-
|
1000 |
-
updateLineClasses(lineView);
|
1001 |
-
updateLineGutter(cm, lineView, lineN, dims);
|
1002 |
-
insertLineWidgets(cm, lineView, dims);
|
1003 |
-
return lineView.node;
|
1004 |
-
}
|
1005 |
-
|
1006 |
-
// A lineView may contain multiple logical lines (when merged by
|
1007 |
-
// collapsed spans). The widgets for all of them need to be drawn.
|
1008 |
-
function insertLineWidgets(cm, lineView, dims) {
|
1009 |
-
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
|
1010 |
-
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
1011 |
-
insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
|
1012 |
-
}
|
1013 |
-
|
1014 |
-
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
|
1015 |
-
if (!line.widgets) return;
|
1016 |
-
var wrap = ensureLineWrapped(lineView);
|
1017 |
-
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
|
1018 |
-
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
|
1019 |
-
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
|
1020 |
-
positionLineWidget(widget, node, lineView, dims);
|
1021 |
-
cm.display.input.setUneditable(node);
|
1022 |
-
if (allowAbove && widget.above)
|
1023 |
-
wrap.insertBefore(node, lineView.gutter || lineView.text);
|
1024 |
-
else
|
1025 |
-
wrap.appendChild(node);
|
1026 |
-
signalLater(widget, "redraw");
|
1027 |
-
}
|
1028 |
-
}
|
1029 |
-
|
1030 |
-
function positionLineWidget(widget, node, lineView, dims) {
|
1031 |
-
if (widget.noHScroll) {
|
1032 |
-
(lineView.alignable || (lineView.alignable = [])).push(node);
|
1033 |
-
var width = dims.wrapperWidth;
|
1034 |
-
node.style.left = dims.fixedPos + "px";
|
1035 |
-
if (!widget.coverGutter) {
|
1036 |
-
width -= dims.gutterTotalWidth;
|
1037 |
-
node.style.paddingLeft = dims.gutterTotalWidth + "px";
|
1038 |
-
}
|
1039 |
-
node.style.width = width + "px";
|
1040 |
-
}
|
1041 |
-
if (widget.coverGutter) {
|
1042 |
-
node.style.zIndex = 5;
|
1043 |
-
node.style.position = "relative";
|
1044 |
-
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
|
1045 |
-
}
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
// POSITION OBJECT
|
1049 |
-
|
1050 |
-
// A Pos instance represents a position within the text.
|
1051 |
-
var Pos = CodeMirror.Pos = function(line, ch) {
|
1052 |
-
if (!(this instanceof Pos)) return new Pos(line, ch);
|
1053 |
-
this.line = line; this.ch = ch;
|
1054 |
-
};
|
1055 |
-
|
1056 |
-
// Compare two positions, return 0 if they are the same, a negative
|
1057 |
-
// number when a is less, and a positive number otherwise.
|
1058 |
-
var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
|
1059 |
-
|
1060 |
-
function copyPos(x) {return Pos(x.line, x.ch);}
|
1061 |
-
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
|
1062 |
-
function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
|
1063 |
-
|
1064 |
-
// INPUT HANDLING
|
1065 |
-
|
1066 |
-
function ensureFocus(cm) {
|
1067 |
-
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
function isReadOnly(cm) {
|
1071 |
-
return cm.options.readOnly || cm.doc.cantEdit;
|
1072 |
-
}
|
1073 |
-
|
1074 |
-
// This will be set to an array of strings when copying, so that,
|
1075 |
-
// when pasting, we know what kind of selections the copied text
|
1076 |
-
// was made out of.
|
1077 |
-
var lastCopied = null;
|
1078 |
-
|
1079 |
-
function applyTextInput(cm, inserted, deleted, sel) {
|
1080 |
-
var doc = cm.doc;
|
1081 |
-
cm.display.shift = false;
|
1082 |
-
if (!sel) sel = doc.sel;
|
1083 |
-
|
1084 |
-
var textLines = splitLines(inserted), multiPaste = null;
|
1085 |
-
// When pasing N lines into N selections, insert one line per selection
|
1086 |
-
if (cm.state.pasteIncoming && sel.ranges.length > 1) {
|
1087 |
-
if (lastCopied && lastCopied.join("\n") == inserted)
|
1088 |
-
multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
|
1089 |
-
else if (textLines.length == sel.ranges.length)
|
1090 |
-
multiPaste = map(textLines, function(l) { return [l]; });
|
1091 |
-
}
|
1092 |
-
|
1093 |
-
// Normal behavior is to insert the new text into every selection
|
1094 |
-
for (var i = sel.ranges.length - 1; i >= 0; i--) {
|
1095 |
-
var range = sel.ranges[i];
|
1096 |
-
var from = range.from(), to = range.to();
|
1097 |
-
if (range.empty()) {
|
1098 |
-
if (deleted && deleted > 0) // Handle deletion
|
1099 |
-
from = Pos(from.line, from.ch - deleted);
|
1100 |
-
else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite
|
1101 |
-
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
|
1102 |
-
}
|
1103 |
-
var updateInput = cm.curOp.updateInput;
|
1104 |
-
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
|
1105 |
-
origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
|
1106 |
-
makeChange(cm.doc, changeEvent);
|
1107 |
-
signalLater(cm, "inputRead", cm, changeEvent);
|
1108 |
-
// When an 'electric' character is inserted, immediately trigger a reindent
|
1109 |
-
if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
|
1110 |
-
cm.options.smartIndent && range.head.ch < 100 &&
|
1111 |
-
(!i || sel.ranges[i - 1].head.line != range.head.line)) {
|
1112 |
-
var mode = cm.getModeAt(range.head);
|
1113 |
-
var end = changeEnd(changeEvent);
|
1114 |
-
if (mode.electricChars) {
|
1115 |
-
for (var j = 0; j < mode.electricChars.length; j++)
|
1116 |
-
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
1117 |
-
indentLine(cm, end.line, "smart");
|
1118 |
-
break;
|
1119 |
-
}
|
1120 |
-
} else if (mode.electricInput) {
|
1121 |
-
if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
|
1122 |
-
indentLine(cm, end.line, "smart");
|
1123 |
-
}
|
1124 |
-
}
|
1125 |
-
}
|
1126 |
-
ensureCursorVisible(cm);
|
1127 |
-
cm.curOp.updateInput = updateInput;
|
1128 |
-
cm.curOp.typing = true;
|
1129 |
-
cm.state.pasteIncoming = cm.state.cutIncoming = false;
|
1130 |
-
}
|
1131 |
-
|
1132 |
-
function copyableRanges(cm) {
|
1133 |
-
var text = [], ranges = [];
|
1134 |
-
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
1135 |
-
var line = cm.doc.sel.ranges[i].head.line;
|
1136 |
-
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
|
1137 |
-
ranges.push(lineRange);
|
1138 |
-
text.push(cm.getRange(lineRange.anchor, lineRange.head));
|
1139 |
-
}
|
1140 |
-
return {text: text, ranges: ranges};
|
1141 |
-
}
|
1142 |
-
|
1143 |
-
function disableBrowserMagic(field) {
|
1144 |
-
field.setAttribute("autocorrect", "off");
|
1145 |
-
field.setAttribute("autocapitalize", "off");
|
1146 |
-
field.setAttribute("spellcheck", "false");
|
1147 |
-
}
|
1148 |
-
|
1149 |
-
// TEXTAREA INPUT STYLE
|
1150 |
-
|
1151 |
-
function TextareaInput(cm) {
|
1152 |
-
this.cm = cm;
|
1153 |
-
// See input.poll and input.reset
|
1154 |
-
this.prevInput = "";
|
1155 |
-
|
1156 |
-
// Flag that indicates whether we expect input to appear real soon
|
1157 |
-
// now (after some event like 'keypress' or 'input') and are
|
1158 |
-
// polling intensively.
|
1159 |
-
this.pollingFast = false;
|
1160 |
-
// Self-resetting timeout for the poller
|
1161 |
-
this.polling = new Delayed();
|
1162 |
-
// Tracks when input.reset has punted to just putting a short
|
1163 |
-
// string into the textarea instead of the full selection.
|
1164 |
-
this.inaccurateSelection = false;
|
1165 |
-
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
|
1166 |
-
this.hasSelection = false;
|
1167 |
-
};
|
1168 |
-
|
1169 |
-
function hiddenTextarea() {
|
1170 |
-
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
|
1171 |
-
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
|
1172 |
-
// The textarea is kept positioned near the cursor to prevent the
|
1173 |
-
// fact that it'll be scrolled into view on input from scrolling
|
1174 |
-
// our fake cursor out of view. On webkit, when wrap=off, paste is
|
1175 |
-
// very slow. So make the area wide instead.
|
1176 |
-
if (webkit) te.style.width = "1000px";
|
1177 |
-
else te.setAttribute("wrap", "off");
|
1178 |
-
// If border: 0; -- iOS fails to open keyboard (issue #1287)
|
1179 |
-
if (ios) te.style.border = "1px solid black";
|
1180 |
-
disableBrowserMagic(te);
|
1181 |
-
return div;
|
1182 |
-
}
|
1183 |
-
|
1184 |
-
TextareaInput.prototype = copyObj({
|
1185 |
-
init: function(display) {
|
1186 |
-
var input = this, cm = this.cm;
|
1187 |
-
|
1188 |
-
// Wraps and hides input textarea
|
1189 |
-
var div = this.wrapper = hiddenTextarea();
|
1190 |
-
// The semihidden textarea that is focused when the editor is
|
1191 |
-
// focused, and receives input.
|
1192 |
-
var te = this.textarea = div.firstChild;
|
1193 |
-
display.wrapper.insertBefore(div, display.wrapper.firstChild);
|
1194 |
-
|
1195 |
-
// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
|
1196 |
-
if (ios) te.style.width = "0px";
|
1197 |
-
|
1198 |
-
on(te, "input", function() {
|
1199 |
-
if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
|
1200 |
-
input.poll();
|
1201 |
-
});
|
1202 |
-
|
1203 |
-
on(te, "paste", function() {
|
1204 |
-
// Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
|
1205 |
-
// Add a char to the end of textarea before paste occur so that
|
1206 |
-
// selection doesn't span to the end of textarea.
|
1207 |
-
if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
|
1208 |
-
var start = te.selectionStart, end = te.selectionEnd;
|
1209 |
-
te.value += "$";
|
1210 |
-
// The selection end needs to be set before the start, otherwise there
|
1211 |
-
// can be an intermediate non-empty selection between the two, which
|
1212 |
-
// can override the middle-click paste buffer on linux and cause the
|
1213 |
-
// wrong thing to get pasted.
|
1214 |
-
te.selectionEnd = end;
|
1215 |
-
te.selectionStart = start;
|
1216 |
-
cm.state.fakedLastChar = true;
|
1217 |
-
}
|
1218 |
-
cm.state.pasteIncoming = true;
|
1219 |
-
input.fastPoll();
|
1220 |
-
});
|
1221 |
-
|
1222 |
-
function prepareCopyCut(e) {
|
1223 |
-
if (cm.somethingSelected()) {
|
1224 |
-
lastCopied = cm.getSelections();
|
1225 |
-
if (input.inaccurateSelection) {
|
1226 |
-
input.prevInput = "";
|
1227 |
-
input.inaccurateSelection = false;
|
1228 |
-
te.value = lastCopied.join("\n");
|
1229 |
-
selectInput(te);
|
1230 |
-
}
|
1231 |
-
} else {
|
1232 |
-
var ranges = copyableRanges(cm);
|
1233 |
-
lastCopied = ranges.text;
|
1234 |
-
if (e.type == "cut") {
|
1235 |
-
cm.setSelections(ranges.ranges, null, sel_dontScroll);
|
1236 |
-
} else {
|
1237 |
-
input.prevInput = "";
|
1238 |
-
te.value = ranges.text.join("\n");
|
1239 |
-
selectInput(te);
|
1240 |
-
}
|
1241 |
-
}
|
1242 |
-
if (e.type == "cut") cm.state.cutIncoming = true;
|
1243 |
-
}
|
1244 |
-
on(te, "cut", prepareCopyCut);
|
1245 |
-
on(te, "copy", prepareCopyCut);
|
1246 |
-
|
1247 |
-
on(display.scroller, "paste", function(e) {
|
1248 |
-
if (eventInWidget(display, e)) return;
|
1249 |
-
cm.state.pasteIncoming = true;
|
1250 |
-
input.focus();
|
1251 |
-
});
|
1252 |
-
|
1253 |
-
// Prevent normal selection in the editor (we handle our own)
|
1254 |
-
on(display.lineSpace, "selectstart", function(e) {
|
1255 |
-
if (!eventInWidget(display, e)) e_preventDefault(e);
|
1256 |
-
});
|
1257 |
-
},
|
1258 |
-
|
1259 |
-
prepareSelection: function() {
|
1260 |
-
// Redraw the selection and/or cursor
|
1261 |
-
var cm = this.cm, display = cm.display, doc = cm.doc;
|
1262 |
-
var result = prepareSelection(cm);
|
1263 |
-
|
1264 |
-
// Move the hidden textarea near the cursor to prevent scrolling artifacts
|
1265 |
-
if (cm.options.moveInputWithCursor) {
|
1266 |
-
var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
|
1267 |
-
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
|
1268 |
-
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
|
1269 |
-
headPos.top + lineOff.top - wrapOff.top));
|
1270 |
-
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
|
1271 |
-
headPos.left + lineOff.left - wrapOff.left));
|
1272 |
-
}
|
1273 |
-
|
1274 |
-
return result;
|
1275 |
-
},
|
1276 |
-
|
1277 |
-
showSelection: function(drawn) {
|
1278 |
-
var cm = this.cm, display = cm.display;
|
1279 |
-
removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
|
1280 |
-
removeChildrenAndAdd(display.selectionDiv, drawn.selection);
|
1281 |
-
if (drawn.teTop != null) {
|
1282 |
-
this.wrapper.style.top = drawn.teTop + "px";
|
1283 |
-
this.wrapper.style.left = drawn.teLeft + "px";
|
1284 |
-
}
|
1285 |
-
},
|
1286 |
-
|
1287 |
-
// Reset the input to correspond to the selection (or to be empty,
|
1288 |
-
// when not typing and nothing is selected)
|
1289 |
-
reset: function(typing) {
|
1290 |
-
if (this.contextMenuPending) return;
|
1291 |
-
var minimal, selected, cm = this.cm, doc = cm.doc;
|
1292 |
-
if (cm.somethingSelected()) {
|
1293 |
-
this.prevInput = "";
|
1294 |
-
var range = doc.sel.primary();
|
1295 |
-
minimal = hasCopyEvent &&
|
1296 |
-
(range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
|
1297 |
-
var content = minimal ? "-" : selected || cm.getSelection();
|
1298 |
-
this.textarea.value = content;
|
1299 |
-
if (cm.state.focused) selectInput(this.textarea);
|
1300 |
-
if (ie && ie_version >= 9) this.hasSelection = content;
|
1301 |
-
} else if (!typing) {
|
1302 |
-
this.prevInput = this.textarea.value = "";
|
1303 |
-
if (ie && ie_version >= 9) this.hasSelection = null;
|
1304 |
-
}
|
1305 |
-
this.inaccurateSelection = minimal;
|
1306 |
-
},
|
1307 |
-
|
1308 |
-
getField: function() { return this.textarea; },
|
1309 |
-
|
1310 |
-
supportsTouch: function() { return false; },
|
1311 |
-
|
1312 |
-
focus: function() {
|
1313 |
-
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
|
1314 |
-
try { this.textarea.focus(); }
|
1315 |
-
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
1316 |
-
}
|
1317 |
-
},
|
1318 |
-
|
1319 |
-
blur: function() { this.textarea.blur(); },
|
1320 |
-
|
1321 |
-
resetPosition: function() {
|
1322 |
-
this.wrapper.style.top = this.wrapper.style.left = 0;
|
1323 |
-
},
|
1324 |
-
|
1325 |
-
receivedFocus: function() { this.slowPoll(); },
|
1326 |
-
|
1327 |
-
// Poll for input changes, using the normal rate of polling. This
|
1328 |
-
// runs as long as the editor is focused.
|
1329 |
-
slowPoll: function() {
|
1330 |
-
var input = this;
|
1331 |
-
if (input.pollingFast) return;
|
1332 |
-
input.polling.set(this.cm.options.pollInterval, function() {
|
1333 |
-
input.poll();
|
1334 |
-
if (input.cm.state.focused) input.slowPoll();
|
1335 |
-
});
|
1336 |
-
},
|
1337 |
-
|
1338 |
-
// When an event has just come in that is likely to add or change
|
1339 |
-
// something in the input textarea, we poll faster, to ensure that
|
1340 |
-
// the change appears on the screen quickly.
|
1341 |
-
fastPoll: function() {
|
1342 |
-
var missed = false, input = this;
|
1343 |
-
input.pollingFast = true;
|
1344 |
-
function p() {
|
1345 |
-
var changed = input.poll();
|
1346 |
-
if (!changed && !missed) {missed = true; input.polling.set(60, p);}
|
1347 |
-
else {input.pollingFast = false; input.slowPoll();}
|
1348 |
-
}
|
1349 |
-
input.polling.set(20, p);
|
1350 |
-
},
|
1351 |
-
|
1352 |
-
// Read input from the textarea, and update the document to match.
|
1353 |
-
// When something is selected, it is present in the textarea, and
|
1354 |
-
// selected (unless it is huge, in which case a placeholder is
|
1355 |
-
// used). When nothing is selected, the cursor sits after previously
|
1356 |
-
// seen text (can be empty), which is stored in prevInput (we must
|
1357 |
-
// not reset the textarea when typing, because that breaks IME).
|
1358 |
-
poll: function() {
|
1359 |
-
var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
|
1360 |
-
// Since this is called a *lot*, try to bail out as cheaply as
|
1361 |
-
// possible when it is clear that nothing happened. hasSelection
|
1362 |
-
// will be the case when there is a lot of text in the textarea,
|
1363 |
-
// in which case reading its value would be expensive.
|
1364 |
-
if (!cm.state.focused || (hasSelection(input) && !prevInput) ||
|
1365 |
-
isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
1366 |
-
return false;
|
1367 |
-
// See paste handler for more on the fakedLastChar kludge
|
1368 |
-
if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
|
1369 |
-
input.value = input.value.substring(0, input.value.length - 1);
|
1370 |
-
cm.state.fakedLastChar = false;
|
1371 |
-
}
|
1372 |
-
var text = input.value;
|
1373 |
-
// If nothing changed, bail.
|
1374 |
-
if (text == prevInput && !cm.somethingSelected()) return false;
|
1375 |
-
// Work around nonsensical selection resetting in IE9/10, and
|
1376 |
-
// inexplicable appearance of private area unicode characters on
|
1377 |
-
// some key combos in Mac (#2689).
|
1378 |
-
if (ie && ie_version >= 9 && this.hasSelection === text ||
|
1379 |
-
mac && /[\uf700-\uf7ff]/.test(text)) {
|
1380 |
-
cm.display.input.reset();
|
1381 |
-
return false;
|
1382 |
-
}
|
1383 |
-
|
1384 |
-
if (text.charCodeAt(0) == 0x200b && cm.doc.sel == cm.display.selForContextMenu && !prevInput)
|
1385 |
-
prevInput = "\u200b";
|
1386 |
-
// Find the part of the input that is actually new
|
1387 |
-
var same = 0, l = Math.min(prevInput.length, text.length);
|
1388 |
-
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
|
1389 |
-
|
1390 |
-
var self = this;
|
1391 |
-
runInOp(cm, function() {
|
1392 |
-
applyTextInput(cm, text.slice(same), prevInput.length - same);
|
1393 |
-
|
1394 |
-
// Don't leave long text in the textarea, since it makes further polling slow
|
1395 |
-
if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
|
1396 |
-
else self.prevInput = text;
|
1397 |
-
});
|
1398 |
-
return true;
|
1399 |
-
},
|
1400 |
-
|
1401 |
-
ensurePolled: function() {
|
1402 |
-
if (this.pollingFast && this.poll()) this.pollingFast = false;
|
1403 |
-
},
|
1404 |
-
|
1405 |
-
onKeyPress: function() {
|
1406 |
-
if (ie && ie_version >= 9) this.hasSelection = null;
|
1407 |
-
this.fastPoll();
|
1408 |
-
},
|
1409 |
-
|
1410 |
-
onContextMenu: function(e) {
|
1411 |
-
var input = this, cm = input.cm, display = cm.display, te = input.textarea;
|
1412 |
-
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
|
1413 |
-
if (!pos || presto) return; // Opera is difficult.
|
1414 |
-
|
1415 |
-
// Reset the current text selection only if the click is done outside of the selection
|
1416 |
-
// and 'resetSelectionOnContextMenu' option is true.
|
1417 |
-
var reset = cm.options.resetSelectionOnContextMenu;
|
1418 |
-
if (reset && cm.doc.sel.contains(pos) == -1)
|
1419 |
-
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
|
1420 |
-
|
1421 |
-
var oldCSS = te.style.cssText;
|
1422 |
-
input.wrapper.style.position = "absolute";
|
1423 |
-
te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
|
1424 |
-
"px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
|
1425 |
-
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
|
1426 |
-
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
|
1427 |
-
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
|
1428 |
-
display.input.focus();
|
1429 |
-
if (webkit) window.scrollTo(null, oldScrollY);
|
1430 |
-
display.input.reset();
|
1431 |
-
// Adds "Select all" to context menu in FF
|
1432 |
-
if (!cm.somethingSelected()) te.value = input.prevInput = " ";
|
1433 |
-
input.contextMenuPending = true;
|
1434 |
-
display.selForContextMenu = cm.doc.sel;
|
1435 |
-
clearTimeout(display.detectingSelectAll);
|
1436 |
-
|
1437 |
-
// Select-all will be greyed out if there's nothing to select, so
|
1438 |
-
// this adds a zero-width space so that we can later check whether
|
1439 |
-
// it got selected.
|
1440 |
-
function prepareSelectAllHack() {
|
1441 |
-
if (te.selectionStart != null) {
|
1442 |
-
var selected = cm.somethingSelected();
|
1443 |
-
var extval = te.value = "\u200b" + (selected ? te.value : "");
|
1444 |
-
input.prevInput = selected ? "" : "\u200b";
|
1445 |
-
te.selectionStart = 1; te.selectionEnd = extval.length;
|
1446 |
-
// Re-set this, in case some other handler touched the
|
1447 |
-
// selection in the meantime.
|
1448 |
-
display.selForContextMenu = cm.doc.sel;
|
1449 |
-
}
|
1450 |
-
}
|
1451 |
-
function rehide() {
|
1452 |
-
input.contextMenuPending = false;
|
1453 |
-
input.wrapper.style.position = "relative";
|
1454 |
-
te.style.cssText = oldCSS;
|
1455 |
-
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
|
1456 |
-
|
1457 |
-
// Try to detect the user choosing select-all
|
1458 |
-
if (te.selectionStart != null) {
|
1459 |
-
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
|
1460 |
-
var i = 0, poll = function() {
|
1461 |
-
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0)
|
1462 |
-
operation(cm, commands.selectAll)(cm);
|
1463 |
-
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
|
1464 |
-
else display.input.reset();
|
1465 |
-
};
|
1466 |
-
display.detectingSelectAll = setTimeout(poll, 200);
|
1467 |
-
}
|
1468 |
-
}
|
1469 |
-
|
1470 |
-
if (ie && ie_version >= 9) prepareSelectAllHack();
|
1471 |
-
if (captureRightClick) {
|
1472 |
-
e_stop(e);
|
1473 |
-
var mouseup = function() {
|
1474 |
-
off(window, "mouseup", mouseup);
|
1475 |
-
setTimeout(rehide, 20);
|
1476 |
-
};
|
1477 |
-
on(window, "mouseup", mouseup);
|
1478 |
-
} else {
|
1479 |
-
setTimeout(rehide, 50);
|
1480 |
-
}
|
1481 |
-
},
|
1482 |
-
|
1483 |
-
setUneditable: nothing,
|
1484 |
-
|
1485 |
-
needsContentAttribute: false
|
1486 |
-
}, TextareaInput.prototype);
|
1487 |
-
|
1488 |
-
// CONTENTEDITABLE INPUT STYLE
|
1489 |
-
|
1490 |
-
function ContentEditableInput(cm) {
|
1491 |
-
this.cm = cm;
|
1492 |
-
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
|
1493 |
-
this.polling = new Delayed();
|
1494 |
-
}
|
1495 |
-
|
1496 |
-
ContentEditableInput.prototype = copyObj({
|
1497 |
-
init: function(display) {
|
1498 |
-
var input = this, cm = input.cm;
|
1499 |
-
var div = input.div = display.lineDiv;
|
1500 |
-
div.contentEditable = "true";
|
1501 |
-
disableBrowserMagic(div);
|
1502 |
-
|
1503 |
-
on(div, "paste", function(e) {
|
1504 |
-
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
1505 |
-
if (pasted) {
|
1506 |
-
e.preventDefault();
|
1507 |
-
cm.replaceSelection(pasted, null, "paste");
|
1508 |
-
}
|
1509 |
-
});
|
1510 |
-
|
1511 |
-
on(div, "compositionstart", function(e) {
|
1512 |
-
var data = e.data;
|
1513 |
-
input.composing = {sel: cm.doc.sel, data: data, startData: data};
|
1514 |
-
if (!data) return;
|
1515 |
-
var prim = cm.doc.sel.primary();
|
1516 |
-
var line = cm.getLine(prim.head.line);
|
1517 |
-
var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
|
1518 |
-
if (found > -1 && found <= prim.head.ch)
|
1519 |
-
input.composing.sel = simpleSelection(Pos(prim.head.line, found),
|
1520 |
-
Pos(prim.head.line, found + data.length));
|
1521 |
-
});
|
1522 |
-
on(div, "compositionupdate", function(e) {
|
1523 |
-
input.composing.data = e.data;
|
1524 |
-
});
|
1525 |
-
on(div, "compositionend", function(e) {
|
1526 |
-
var ours = input.composing;
|
1527 |
-
if (!ours) return;
|
1528 |
-
if (e.data != ours.startData && !/\u200b/.test(e.data))
|
1529 |
-
ours.data = e.data;
|
1530 |
-
// Need a small delay to prevent other code (input event,
|
1531 |
-
// selection polling) from doing damage when fired right after
|
1532 |
-
// compositionend.
|
1533 |
-
setTimeout(function() {
|
1534 |
-
if (!ours.handled)
|
1535 |
-
input.applyComposition(ours);
|
1536 |
-
if (input.composing == ours)
|
1537 |
-
input.composing = null;
|
1538 |
-
}, 50);
|
1539 |
-
});
|
1540 |
-
|
1541 |
-
on(div, "touchstart", function() {
|
1542 |
-
input.forceCompositionEnd();
|
1543 |
-
});
|
1544 |
-
|
1545 |
-
on(div, "input", function() {
|
1546 |
-
if (input.composing) return;
|
1547 |
-
if (!input.pollContent())
|
1548 |
-
runInOp(input.cm, function() {regChange(cm);});
|
1549 |
-
});
|
1550 |
-
|
1551 |
-
function onCopyCut(e) {
|
1552 |
-
if (cm.somethingSelected()) {
|
1553 |
-
lastCopied = cm.getSelections();
|
1554 |
-
if (e.type == "cut") cm.replaceSelection("", null, "cut");
|
1555 |
-
} else {
|
1556 |
-
var ranges = copyableRanges(cm);
|
1557 |
-
lastCopied = ranges.text;
|
1558 |
-
if (e.type == "cut") {
|
1559 |
-
cm.operation(function() {
|
1560 |
-
cm.setSelections(ranges.ranges, 0, sel_dontScroll);
|
1561 |
-
cm.replaceSelection("", null, "cut");
|
1562 |
-
});
|
1563 |
-
}
|
1564 |
-
}
|
1565 |
-
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
1566 |
-
if (e.clipboardData && !ios) {
|
1567 |
-
e.preventDefault();
|
1568 |
-
e.clipboardData.clearData();
|
1569 |
-
e.clipboardData.setData("text/plain", lastCopied.join("\n"));
|
1570 |
-
} else {
|
1571 |
-
// Old-fashioned briefly-focus-a-textarea hack
|
1572 |
-
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
1573 |
-
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
1574 |
-
te.value = lastCopied.join("\n");
|
1575 |
-
var hadFocus = document.activeElement;
|
1576 |
-
selectInput(te);
|
1577 |
-
setTimeout(function() {
|
1578 |
-
cm.display.lineSpace.removeChild(kludge);
|
1579 |
-
hadFocus.focus();
|
1580 |
-
}, 50);
|
1581 |
-
}
|
1582 |
-
}
|
1583 |
-
on(div, "copy", onCopyCut);
|
1584 |
-
on(div, "cut", onCopyCut);
|
1585 |
-
},
|
1586 |
-
|
1587 |
-
prepareSelection: function() {
|
1588 |
-
var result = prepareSelection(this.cm, false);
|
1589 |
-
result.focus = this.cm.state.focused;
|
1590 |
-
return result;
|
1591 |
-
},
|
1592 |
-
|
1593 |
-
showSelection: function(info) {
|
1594 |
-
if (!info || !this.cm.display.view.length) return;
|
1595 |
-
if (info.focus) this.showPrimarySelection();
|
1596 |
-
this.showMultipleSelections(info);
|
1597 |
-
},
|
1598 |
-
|
1599 |
-
showPrimarySelection: function() {
|
1600 |
-
var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
|
1601 |
-
var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
|
1602 |
-
var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
|
1603 |
-
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
|
1604 |
-
cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
|
1605 |
-
cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
|
1606 |
-
return;
|
1607 |
-
|
1608 |
-
var start = posToDOM(this.cm, prim.from());
|
1609 |
-
var end = posToDOM(this.cm, prim.to());
|
1610 |
-
if (!start && !end) return;
|
1611 |
-
|
1612 |
-
var view = this.cm.display.view;
|
1613 |
-
var old = sel.rangeCount && sel.getRangeAt(0);
|
1614 |
-
if (!start) {
|
1615 |
-
start = {node: view[0].measure.map[2], offset: 0};
|
1616 |
-
} else if (!end) { // FIXME dangerously hacky
|
1617 |
-
var measure = view[view.length - 1].measure;
|
1618 |
-
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
|
1619 |
-
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
|
1620 |
-
}
|
1621 |
-
|
1622 |
-
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
1623 |
-
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
1624 |
-
if (rng) {
|
1625 |
-
sel.removeAllRanges();
|
1626 |
-
sel.addRange(rng);
|
1627 |
-
if (old && sel.anchorNode == null) sel.addRange(old);
|
1628 |
-
}
|
1629 |
-
this.rememberSelection();
|
1630 |
-
},
|
1631 |
-
|
1632 |
-
showMultipleSelections: function(info) {
|
1633 |
-
removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
|
1634 |
-
removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
|
1635 |
-
},
|
1636 |
-
|
1637 |
-
rememberSelection: function() {
|
1638 |
-
var sel = window.getSelection();
|
1639 |
-
this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
|
1640 |
-
this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
|
1641 |
-
},
|
1642 |
-
|
1643 |
-
selectionInEditor: function() {
|
1644 |
-
var sel = window.getSelection();
|
1645 |
-
if (!sel.rangeCount) return false;
|
1646 |
-
var node = sel.getRangeAt(0).commonAncestorContainer;
|
1647 |
-
return contains(this.div, node);
|
1648 |
-
},
|
1649 |
-
|
1650 |
-
focus: function() {
|
1651 |
-
if (this.cm.options.readOnly != "nocursor") this.div.focus();
|
1652 |
-
},
|
1653 |
-
blur: function() { this.div.blur(); },
|
1654 |
-
getField: function() { return this.div; },
|
1655 |
-
|
1656 |
-
supportsTouch: function() { return true; },
|
1657 |
-
|
1658 |
-
receivedFocus: function() {
|
1659 |
-
var input = this;
|
1660 |
-
if (this.selectionInEditor())
|
1661 |
-
this.pollSelection();
|
1662 |
-
else
|
1663 |
-
runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
|
1664 |
-
|
1665 |
-
function poll() {
|
1666 |
-
if (input.cm.state.focused) {
|
1667 |
-
input.pollSelection();
|
1668 |
-
input.polling.set(input.cm.options.pollInterval, poll);
|
1669 |
-
}
|
1670 |
-
}
|
1671 |
-
this.polling.set(this.cm.options.pollInterval, poll);
|
1672 |
-
},
|
1673 |
-
|
1674 |
-
pollSelection: function() {
|
1675 |
-
if (this.composing) return;
|
1676 |
-
|
1677 |
-
var sel = window.getSelection(), cm = this.cm;
|
1678 |
-
if (sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
|
1679 |
-
sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset) {
|
1680 |
-
this.rememberSelection();
|
1681 |
-
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
|
1682 |
-
var head = domToPos(cm, sel.focusNode, sel.focusOffset);
|
1683 |
-
if (anchor && head) runInOp(cm, function() {
|
1684 |
-
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
|
1685 |
-
if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
|
1686 |
-
});
|
1687 |
-
}
|
1688 |
-
},
|
1689 |
-
|
1690 |
-
pollContent: function() {
|
1691 |
-
var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
|
1692 |
-
var from = sel.from(), to = sel.to();
|
1693 |
-
if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
|
1694 |
-
|
1695 |
-
var fromIndex;
|
1696 |
-
if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
|
1697 |
-
var fromLine = lineNo(display.view[0].line);
|
1698 |
-
var fromNode = display.view[0].node;
|
1699 |
-
} else {
|
1700 |
-
var fromLine = lineNo(display.view[fromIndex].line);
|
1701 |
-
var fromNode = display.view[fromIndex - 1].node.nextSibling;
|
1702 |
-
}
|
1703 |
-
var toIndex = findViewIndex(cm, to.line);
|
1704 |
-
if (toIndex == display.view.length - 1) {
|
1705 |
-
var toLine = display.viewTo - 1;
|
1706 |
-
var toNode = display.view[toIndex].node;
|
1707 |
-
} else {
|
1708 |
-
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
|
1709 |
-
var toNode = display.view[toIndex + 1].node.previousSibling;
|
1710 |
-
}
|
1711 |
-
|
1712 |
-
var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
|
1713 |
-
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
|
1714 |
-
while (newText.length > 1 && oldText.length > 1) {
|
1715 |
-
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
|
1716 |
-
else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
|
1717 |
-
else break;
|
1718 |
-
}
|
1719 |
-
|
1720 |
-
var cutFront = 0, cutEnd = 0;
|
1721 |
-
var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
|
1722 |
-
while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
|
1723 |
-
++cutFront;
|
1724 |
-
var newBot = lst(newText), oldBot = lst(oldText);
|
1725 |
-
var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
|
1726 |
-
oldBot.length - (oldText.length == 1 ? cutFront : 0));
|
1727 |
-
while (cutEnd < maxCutEnd &&
|
1728 |
-
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
|
1729 |
-
++cutEnd;
|
1730 |
-
|
1731 |
-
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
|
1732 |
-
newText[0] = newText[0].slice(cutFront);
|
1733 |
-
|
1734 |
-
var chFrom = Pos(fromLine, cutFront);
|
1735 |
-
var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
|
1736 |
-
if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
|
1737 |
-
replaceRange(cm.doc, newText, chFrom, chTo, "+input");
|
1738 |
-
return true;
|
1739 |
-
}
|
1740 |
-
},
|
1741 |
-
|
1742 |
-
ensurePolled: function() {
|
1743 |
-
this.forceCompositionEnd();
|
1744 |
-
},
|
1745 |
-
reset: function() {
|
1746 |
-
this.forceCompositionEnd();
|
1747 |
-
},
|
1748 |
-
forceCompositionEnd: function() {
|
1749 |
-
if (!this.composing || this.composing.handled) return;
|
1750 |
-
this.applyComposition(this.composing);
|
1751 |
-
this.composing.handled = true;
|
1752 |
-
this.div.blur();
|
1753 |
-
this.div.focus();
|
1754 |
-
},
|
1755 |
-
applyComposition: function(composing) {
|
1756 |
-
if (composing.data && composing.data != composing.startData)
|
1757 |
-
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
1758 |
-
},
|
1759 |
-
|
1760 |
-
setUneditable: function(node) {
|
1761 |
-
node.setAttribute("contenteditable", "false");
|
1762 |
-
},
|
1763 |
-
|
1764 |
-
onKeyPress: function(e) {
|
1765 |
-
e.preventDefault();
|
1766 |
-
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
1767 |
-
},
|
1768 |
-
|
1769 |
-
onContextMenu: nothing,
|
1770 |
-
resetPosition: nothing,
|
1771 |
-
|
1772 |
-
needsContentAttribute: true
|
1773 |
-
}, ContentEditableInput.prototype);
|
1774 |
-
|
1775 |
-
function posToDOM(cm, pos) {
|
1776 |
-
var view = findViewForLine(cm, pos.line);
|
1777 |
-
if (!view || view.hidden) return null;
|
1778 |
-
var line = getLine(cm.doc, pos.line);
|
1779 |
-
var info = mapFromLineView(view, line, pos.line);
|
1780 |
-
|
1781 |
-
var order = getOrder(line), side = "left";
|
1782 |
-
if (order) {
|
1783 |
-
var partPos = getBidiPartAt(order, pos.ch);
|
1784 |
-
side = partPos % 2 ? "right" : "left";
|
1785 |
-
}
|
1786 |
-
var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left");
|
1787 |
-
result.offset = result.collapse == "right" ? result.end : result.start;
|
1788 |
-
return result;
|
1789 |
-
}
|
1790 |
-
|
1791 |
-
function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
|
1792 |
-
|
1793 |
-
function domToPos(cm, node, offset) {
|
1794 |
-
var lineNode;
|
1795 |
-
if (node == cm.display.lineDiv) {
|
1796 |
-
lineNode = cm.display.lineDiv.childNodes[offset];
|
1797 |
-
if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
|
1798 |
-
node = null; offset = 0;
|
1799 |
-
} else {
|
1800 |
-
for (lineNode = node;; lineNode = lineNode.parentNode) {
|
1801 |
-
if (!lineNode || lineNode == cm.display.lineDiv) return null;
|
1802 |
-
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
|
1803 |
-
}
|
1804 |
-
}
|
1805 |
-
for (var i = 0; i < cm.display.view.length; i++) {
|
1806 |
-
var lineView = cm.display.view[i];
|
1807 |
-
if (lineView.node == lineNode)
|
1808 |
-
return locateNodeInLineView(lineView, node, offset);
|
1809 |
-
}
|
1810 |
-
}
|
1811 |
-
|
1812 |
-
function locateNodeInLineView(lineView, node, offset) {
|
1813 |
-
var wrapper = lineView.text.firstChild, bad = false;
|
1814 |
-
if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
|
1815 |
-
if (node == wrapper) {
|
1816 |
-
bad = true;
|
1817 |
-
node = wrapper.childNodes[offset];
|
1818 |
-
offset = 0;
|
1819 |
-
if (!node) {
|
1820 |
-
var line = lineView.rest ? lst(lineView.rest) : lineView.line;
|
1821 |
-
return badPos(Pos(lineNo(line), line.text.length), bad);
|
1822 |
-
}
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
var textNode = node.nodeType == 3 ? node : null, topNode = node;
|
1826 |
-
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
|
1827 |
-
textNode = node.firstChild;
|
1828 |
-
if (offset) offset = textNode.nodeValue.length;
|
1829 |
-
}
|
1830 |
-
while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
|
1831 |
-
var measure = lineView.measure, maps = measure.maps;
|
1832 |
-
|
1833 |
-
function find(textNode, topNode, offset) {
|
1834 |
-
for (var i = -1; i < (maps ? maps.length : 0); i++) {
|
1835 |
-
var map = i < 0 ? measure.map : maps[i];
|
1836 |
-
for (var j = 0; j < map.length; j += 3) {
|
1837 |
-
var curNode = map[j + 2];
|
1838 |
-
if (curNode == textNode || curNode == topNode) {
|
1839 |
-
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
|
1840 |
-
var ch = map[j] + offset;
|
1841 |
-
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
|
1842 |
-
return Pos(line, ch);
|
1843 |
-
}
|
1844 |
-
}
|
1845 |
-
}
|
1846 |
-
}
|
1847 |
-
var found = find(textNode, topNode, offset);
|
1848 |
-
if (found) return badPos(found, bad);
|
1849 |
-
|
1850 |
-
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
|
1851 |
-
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
|
1852 |
-
found = find(after, after.firstChild, 0);
|
1853 |
-
if (found)
|
1854 |
-
return badPos(Pos(found.line, found.ch - dist), bad);
|
1855 |
-
else
|
1856 |
-
dist += after.textContent.length;
|
1857 |
-
}
|
1858 |
-
for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
|
1859 |
-
found = find(before, before.firstChild, -1);
|
1860 |
-
if (found)
|
1861 |
-
return badPos(Pos(found.line, found.ch + dist), bad);
|
1862 |
-
else
|
1863 |
-
dist += after.textContent.length;
|
1864 |
-
}
|
1865 |
-
}
|
1866 |
-
|
1867 |
-
function domTextBetween(cm, from, to, fromLine, toLine) {
|
1868 |
-
var text = "", closing = false;
|
1869 |
-
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
|
1870 |
-
function walk(node) {
|
1871 |
-
if (node.nodeType == 1) {
|
1872 |
-
var cmText = node.getAttribute("cm-text");
|
1873 |
-
if (cmText != null) {
|
1874 |
-
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
|
1875 |
-
text += cmText;
|
1876 |
-
return;
|
1877 |
-
}
|
1878 |
-
var markerID = node.getAttribute("cm-marker"), range;
|
1879 |
-
if (markerID) {
|
1880 |
-
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
|
1881 |
-
if (found.length && (range = found[0].find()))
|
1882 |
-
text += getBetween(cm.doc, range.from, range.to).join("\n");
|
1883 |
-
return;
|
1884 |
-
}
|
1885 |
-
if (node.getAttribute("contenteditable") == "false") return;
|
1886 |
-
for (var i = 0; i < node.childNodes.length; i++)
|
1887 |
-
walk(node.childNodes[i]);
|
1888 |
-
if (/^(pre|div|p)$/i.test(node.nodeName))
|
1889 |
-
closing = true;
|
1890 |
-
} else if (node.nodeType == 3) {
|
1891 |
-
var val = node.nodeValue;
|
1892 |
-
if (!val) return;
|
1893 |
-
if (closing) {
|
1894 |
-
text += "\n";
|
1895 |
-
closing = false;
|
1896 |
-
}
|
1897 |
-
text += val;
|
1898 |
-
}
|
1899 |
-
}
|
1900 |
-
for (;;) {
|
1901 |
-
walk(from);
|
1902 |
-
if (from == to) break;
|
1903 |
-
from = from.nextSibling;
|
1904 |
-
}
|
1905 |
-
return text;
|
1906 |
-
}
|
1907 |
-
|
1908 |
-
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
|
1909 |
-
|
1910 |
-
// SELECTION / CURSOR
|
1911 |
-
|
1912 |
-
// Selection objects are immutable. A new one is created every time
|
1913 |
-
// the selection changes. A selection is one or more non-overlapping
|
1914 |
-
// (and non-touching) ranges, sorted, and an integer that indicates
|
1915 |
-
// which one is the primary selection (the one that's scrolled into
|
1916 |
-
// view, that getCursor returns, etc).
|
1917 |
-
function Selection(ranges, primIndex) {
|
1918 |
-
this.ranges = ranges;
|
1919 |
-
this.primIndex = primIndex;
|
1920 |
-
}
|
1921 |
-
|
1922 |
-
Selection.prototype = {
|
1923 |
-
primary: function() { return this.ranges[this.primIndex]; },
|
1924 |
-
equals: function(other) {
|
1925 |
-
if (other == this) return true;
|
1926 |
-
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
|
1927 |
-
for (var i = 0; i < this.ranges.length; i++) {
|
1928 |
-
var here = this.ranges[i], there = other.ranges[i];
|
1929 |
-
if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
|
1930 |
-
}
|
1931 |
-
return true;
|
1932 |
-
},
|
1933 |
-
deepCopy: function() {
|
1934 |
-
for (var out = [], i = 0; i < this.ranges.length; i++)
|
1935 |
-
out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
|
1936 |
-
return new Selection(out, this.primIndex);
|
1937 |
-
},
|
1938 |
-
somethingSelected: function() {
|
1939 |
-
for (var i = 0; i < this.ranges.length; i++)
|
1940 |
-
if (!this.ranges[i].empty()) return true;
|
1941 |
-
return false;
|
1942 |
-
},
|
1943 |
-
contains: function(pos, end) {
|
1944 |
-
if (!end) end = pos;
|
1945 |
-
for (var i = 0; i < this.ranges.length; i++) {
|
1946 |
-
var range = this.ranges[i];
|
1947 |
-
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
|
1948 |
-
return i;
|
1949 |
-
}
|
1950 |
-
return -1;
|
1951 |
-
}
|
1952 |
-
};
|
1953 |
-
|
1954 |
-
function Range(anchor, head) {
|
1955 |
-
this.anchor = anchor; this.head = head;
|
1956 |
-
}
|
1957 |
-
|
1958 |
-
Range.prototype = {
|
1959 |
-
from: function() { return minPos(this.anchor, this.head); },
|
1960 |
-
to: function() { return maxPos(this.anchor, this.head); },
|
1961 |
-
empty: function() {
|
1962 |
-
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
|
1963 |
-
}
|
1964 |
-
};
|
1965 |
-
|
1966 |
-
// Take an unsorted, potentially overlapping set of ranges, and
|
1967 |
-
// build a selection out of it. 'Consumes' ranges array (modifying
|
1968 |
-
// it).
|
1969 |
-
function normalizeSelection(ranges, primIndex) {
|
1970 |
-
var prim = ranges[primIndex];
|
1971 |
-
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
|
1972 |
-
primIndex = indexOf(ranges, prim);
|
1973 |
-
for (var i = 1; i < ranges.length; i++) {
|
1974 |
-
var cur = ranges[i], prev = ranges[i - 1];
|
1975 |
-
if (cmp(prev.to(), cur.from()) >= 0) {
|
1976 |
-
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
|
1977 |
-
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
|
1978 |
-
if (i <= primIndex) --primIndex;
|
1979 |
-
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
|
1980 |
-
}
|
1981 |
-
}
|
1982 |
-
return new Selection(ranges, primIndex);
|
1983 |
-
}
|
1984 |
-
|
1985 |
-
function simpleSelection(anchor, head) {
|
1986 |
-
return new Selection([new Range(anchor, head || anchor)], 0);
|
1987 |
-
}
|
1988 |
-
|
1989 |
-
// Most of the external API clips given positions to make sure they
|
1990 |
-
// actually exist within the document.
|
1991 |
-
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
|
1992 |
-
function clipPos(doc, pos) {
|
1993 |
-
if (pos.line < doc.first) return Pos(doc.first, 0);
|
1994 |
-
var last = doc.first + doc.size - 1;
|
1995 |
-
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
|
1996 |
-
return clipToLen(pos, getLine(doc, pos.line).text.length);
|
1997 |
-
}
|
1998 |
-
function clipToLen(pos, linelen) {
|
1999 |
-
var ch = pos.ch;
|
2000 |
-
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
|
2001 |
-
else if (ch < 0) return Pos(pos.line, 0);
|
2002 |
-
else return pos;
|
2003 |
-
}
|
2004 |
-
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
|
2005 |
-
function clipPosArray(doc, array) {
|
2006 |
-
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
|
2007 |
-
return out;
|
2008 |
-
}
|
2009 |
-
|
2010 |
-
// SELECTION UPDATES
|
2011 |
-
|
2012 |
-
// The 'scroll' parameter given to many of these indicated whether
|
2013 |
-
// the new cursor position should be scrolled into view after
|
2014 |
-
// modifying the selection.
|
2015 |
-
|
2016 |
-
// If shift is held or the extend flag is set, extends a range to
|
2017 |
-
// include a given position (and optionally a second position).
|
2018 |
-
// Otherwise, simply returns the range between the given positions.
|
2019 |
-
// Used for cursor motion and such.
|
2020 |
-
function extendRange(doc, range, head, other) {
|
2021 |
-
if (doc.cm && doc.cm.display.shift || doc.extend) {
|
2022 |
-
var anchor = range.anchor;
|
2023 |
-
if (other) {
|
2024 |
-
var posBefore = cmp(head, anchor) < 0;
|
2025 |
-
if (posBefore != (cmp(other, anchor) < 0)) {
|
2026 |
-
anchor = head;
|
2027 |
-
head = other;
|
2028 |
-
} else if (posBefore != (cmp(head, other) < 0)) {
|
2029 |
-
head = other;
|
2030 |
-
}
|
2031 |
-
}
|
2032 |
-
return new Range(anchor, head);
|
2033 |
-
} else {
|
2034 |
-
return new Range(other || head, head);
|
2035 |
-
}
|
2036 |
-
}
|
2037 |
-
|
2038 |
-
// Extend the primary selection range, discard the rest.
|
2039 |
-
function extendSelection(doc, head, other, options) {
|
2040 |
-
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
|
2041 |
-
}
|
2042 |
-
|
2043 |
-
// Extend all selections (pos is an array of selections with length
|
2044 |
-
// equal the number of selections)
|
2045 |
-
function extendSelections(doc, heads, options) {
|
2046 |
-
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
|
2047 |
-
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
|
2048 |
-
var newSel = normalizeSelection(out, doc.sel.primIndex);
|
2049 |
-
setSelection(doc, newSel, options);
|
2050 |
-
}
|
2051 |
-
|
2052 |
-
// Updates a single range in the selection.
|
2053 |
-
function replaceOneSelection(doc, i, range, options) {
|
2054 |
-
var ranges = doc.sel.ranges.slice(0);
|
2055 |
-
ranges[i] = range;
|
2056 |
-
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
|
2057 |
-
}
|
2058 |
-
|
2059 |
-
// Reset the selection to a single range.
|
2060 |
-
function setSimpleSelection(doc, anchor, head, options) {
|
2061 |
-
setSelection(doc, simpleSelection(anchor, head), options);
|
2062 |
-
}
|
2063 |
-
|
2064 |
-
// Give beforeSelectionChange handlers a change to influence a
|
2065 |
-
// selection update.
|
2066 |
-
function filterSelectionChange(doc, sel) {
|
2067 |
-
var obj = {
|
2068 |
-
ranges: sel.ranges,
|
2069 |
-
update: function(ranges) {
|
2070 |
-
this.ranges = [];
|
2071 |
-
for (var i = 0; i < ranges.length; i++)
|
2072 |
-
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
2073 |
-
clipPos(doc, ranges[i].head));
|
2074 |
-
}
|
2075 |
-
};
|
2076 |
-
signal(doc, "beforeSelectionChange", doc, obj);
|
2077 |
-
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
2078 |
-
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
|
2079 |
-
else return sel;
|
2080 |
-
}
|
2081 |
-
|
2082 |
-
function setSelectionReplaceHistory(doc, sel, options) {
|
2083 |
-
var done = doc.history.done, last = lst(done);
|
2084 |
-
if (last && last.ranges) {
|
2085 |
-
done[done.length - 1] = sel;
|
2086 |
-
setSelectionNoUndo(doc, sel, options);
|
2087 |
-
} else {
|
2088 |
-
setSelection(doc, sel, options);
|
2089 |
-
}
|
2090 |
-
}
|
2091 |
-
|
2092 |
-
// Set a new selection.
|
2093 |
-
function setSelection(doc, sel, options) {
|
2094 |
-
setSelectionNoUndo(doc, sel, options);
|
2095 |
-
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
|
2096 |
-
}
|
2097 |
-
|
2098 |
-
function setSelectionNoUndo(doc, sel, options) {
|
2099 |
-
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
2100 |
-
sel = filterSelectionChange(doc, sel);
|
2101 |
-
|
2102 |
-
var bias = options && options.bias ||
|
2103 |
-
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
2104 |
-
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
|
2105 |
-
|
2106 |
-
if (!(options && options.scroll === false) && doc.cm)
|
2107 |
-
ensureCursorVisible(doc.cm);
|
2108 |
-
}
|
2109 |
-
|
2110 |
-
function setSelectionInner(doc, sel) {
|
2111 |
-
if (sel.equals(doc.sel)) return;
|
2112 |
-
|
2113 |
-
doc.sel = sel;
|
2114 |
-
|
2115 |
-
if (doc.cm) {
|
2116 |
-
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
|
2117 |
-
signalCursorActivity(doc.cm);
|
2118 |
-
}
|
2119 |
-
signalLater(doc, "cursorActivity", doc);
|
2120 |
-
}
|
2121 |
-
|
2122 |
-
// Verify that the selection does not partially select any atomic
|
2123 |
-
// marked ranges.
|
2124 |
-
function reCheckSelection(doc) {
|
2125 |
-
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
|
2126 |
-
}
|
2127 |
-
|
2128 |
-
// Return a selection that does not partially select any atomic
|
2129 |
-
// ranges.
|
2130 |
-
function skipAtomicInSelection(doc, sel, bias, mayClear) {
|
2131 |
-
var out;
|
2132 |
-
for (var i = 0; i < sel.ranges.length; i++) {
|
2133 |
-
var range = sel.ranges[i];
|
2134 |
-
var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
|
2135 |
-
var newHead = skipAtomic(doc, range.head, bias, mayClear);
|
2136 |
-
if (out || newAnchor != range.anchor || newHead != range.head) {
|
2137 |
-
if (!out) out = sel.ranges.slice(0, i);
|
2138 |
-
out[i] = new Range(newAnchor, newHead);
|
2139 |
-
}
|
2140 |
-
}
|
2141 |
-
return out ? normalizeSelection(out, sel.primIndex) : sel;
|
2142 |
-
}
|
2143 |
-
|
2144 |
-
// Ensure a given position is not inside an atomic range.
|
2145 |
-
function skipAtomic(doc, pos, bias, mayClear) {
|
2146 |
-
var flipped = false, curPos = pos;
|
2147 |
-
var dir = bias || 1;
|
2148 |
-
doc.cantEdit = false;
|
2149 |
-
search: for (;;) {
|
2150 |
-
var line = getLine(doc, curPos.line);
|
2151 |
-
if (line.markedSpans) {
|
2152 |
-
for (var i = 0; i < line.markedSpans.length; ++i) {
|
2153 |
-
var sp = line.markedSpans[i], m = sp.marker;
|
2154 |
-
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
|
2155 |
-
(sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
|
2156 |
-
if (mayClear) {
|
2157 |
-
signal(m, "beforeCursorEnter");
|
2158 |
-
if (m.explicitlyCleared) {
|
2159 |
-
if (!line.markedSpans) break;
|
2160 |
-
else {--i; continue;}
|
2161 |
-
}
|
2162 |
-
}
|
2163 |
-
if (!m.atomic) continue;
|
2164 |
-
var newPos = m.find(dir < 0 ? -1 : 1);
|
2165 |
-
if (cmp(newPos, curPos) == 0) {
|
2166 |
-
newPos.ch += dir;
|
2167 |
-
if (newPos.ch < 0) {
|
2168 |
-
if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
|
2169 |
-
else newPos = null;
|
2170 |
-
} else if (newPos.ch > line.text.length) {
|
2171 |
-
if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
|
2172 |
-
else newPos = null;
|
2173 |
-
}
|
2174 |
-
if (!newPos) {
|
2175 |
-
if (flipped) {
|
2176 |
-
// Driven in a corner -- no valid cursor position found at all
|
2177 |
-
// -- try again *with* clearing, if we didn't already
|
2178 |
-
if (!mayClear) return skipAtomic(doc, pos, bias, true);
|
2179 |
-
// Otherwise, turn off editing until further notice, and return the start of the doc
|
2180 |
-
doc.cantEdit = true;
|
2181 |
-
return Pos(doc.first, 0);
|
2182 |
-
}
|
2183 |
-
flipped = true; newPos = pos; dir = -dir;
|
2184 |
-
}
|
2185 |
-
}
|
2186 |
-
curPos = newPos;
|
2187 |
-
continue search;
|
2188 |
-
}
|
2189 |
-
}
|
2190 |
-
}
|
2191 |
-
return curPos;
|
2192 |
-
}
|
2193 |
-
}
|
2194 |
-
|
2195 |
-
// SELECTION DRAWING
|
2196 |
-
|
2197 |
-
function updateSelection(cm) {
|
2198 |
-
cm.display.input.showSelection(cm.display.input.prepareSelection());
|
2199 |
-
}
|
2200 |
-
|
2201 |
-
function prepareSelection(cm, primary) {
|
2202 |
-
var doc = cm.doc, result = {};
|
2203 |
-
var curFragment = result.cursors = document.createDocumentFragment();
|
2204 |
-
var selFragment = result.selection = document.createDocumentFragment();
|
2205 |
-
|
2206 |
-
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
2207 |
-
if (primary === false && i == doc.sel.primIndex) continue;
|
2208 |
-
var range = doc.sel.ranges[i];
|
2209 |
-
var collapsed = range.empty();
|
2210 |
-
if (collapsed || cm.options.showCursorWhenSelecting)
|
2211 |
-
drawSelectionCursor(cm, range, curFragment);
|
2212 |
-
if (!collapsed)
|
2213 |
-
drawSelectionRange(cm, range, selFragment);
|
2214 |
-
}
|
2215 |
-
return result;
|
2216 |
-
}
|
2217 |
-
|
2218 |
-
// Draws a cursor for the given range
|
2219 |
-
function drawSelectionCursor(cm, range, output) {
|
2220 |
-
var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
|
2221 |
-
|
2222 |
-
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
|
2223 |
-
cursor.style.left = pos.left + "px";
|
2224 |
-
cursor.style.top = pos.top + "px";
|
2225 |
-
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
|
2226 |
-
|
2227 |
-
if (pos.other) {
|
2228 |
-
// Secondary cursor, shown when on a 'jump' in bi-directional text
|
2229 |
-
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
|
2230 |
-
otherCursor.style.display = "";
|
2231 |
-
otherCursor.style.left = pos.other.left + "px";
|
2232 |
-
otherCursor.style.top = pos.other.top + "px";
|
2233 |
-
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
|
2234 |
-
}
|
2235 |
-
}
|
2236 |
-
|
2237 |
-
// Draws the given range as a highlighted selection
|
2238 |
-
function drawSelectionRange(cm, range, output) {
|
2239 |
-
var display = cm.display, doc = cm.doc;
|
2240 |
-
var fragment = document.createDocumentFragment();
|
2241 |
-
var padding = paddingH(cm.display), leftSide = padding.left;
|
2242 |
-
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
|
2243 |
-
|
2244 |
-
function add(left, top, width, bottom) {
|
2245 |
-
if (top < 0) top = 0;
|
2246 |
-
top = Math.round(top);
|
2247 |
-
bottom = Math.round(bottom);
|
2248 |
-
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
|
2249 |
-
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
|
2250 |
-
"px; height: " + (bottom - top) + "px"));
|
2251 |
-
}
|
2252 |
-
|
2253 |
-
function drawForLine(line, fromArg, toArg) {
|
2254 |
-
var lineObj = getLine(doc, line);
|
2255 |
-
var lineLen = lineObj.text.length;
|
2256 |
-
var start, end;
|
2257 |
-
function coords(ch, bias) {
|
2258 |
-
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
|
2259 |
-
}
|
2260 |
-
|
2261 |
-
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
|
2262 |
-
var leftPos = coords(from, "left"), rightPos, left, right;
|
2263 |
-
if (from == to) {
|
2264 |
-
rightPos = leftPos;
|
2265 |
-
left = right = leftPos.left;
|
2266 |
-
} else {
|
2267 |
-
rightPos = coords(to - 1, "right");
|
2268 |
-
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
|
2269 |
-
left = leftPos.left;
|
2270 |
-
right = rightPos.right;
|
2271 |
-
}
|
2272 |
-
if (fromArg == null && from == 0) left = leftSide;
|
2273 |
-
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
|
2274 |
-
add(left, leftPos.top, null, leftPos.bottom);
|
2275 |
-
left = leftSide;
|
2276 |
-
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
|
2277 |
-
}
|
2278 |
-
if (toArg == null && to == lineLen) right = rightSide;
|
2279 |
-
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
|
2280 |
-
start = leftPos;
|
2281 |
-
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
|
2282 |
-
end = rightPos;
|
2283 |
-
if (left < leftSide + 1) left = leftSide;
|
2284 |
-
add(left, rightPos.top, right - left, rightPos.bottom);
|
2285 |
-
});
|
2286 |
-
return {start: start, end: end};
|
2287 |
-
}
|
2288 |
-
|
2289 |
-
var sFrom = range.from(), sTo = range.to();
|
2290 |
-
if (sFrom.line == sTo.line) {
|
2291 |
-
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
|
2292 |
-
} else {
|
2293 |
-
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
|
2294 |
-
var singleVLine = visualLine(fromLine) == visualLine(toLine);
|
2295 |
-
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
|
2296 |
-
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
|
2297 |
-
if (singleVLine) {
|
2298 |
-
if (leftEnd.top < rightStart.top - 2) {
|
2299 |
-
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
|
2300 |
-
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
|
2301 |
-
} else {
|
2302 |
-
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
|
2303 |
-
}
|
2304 |
-
}
|
2305 |
-
if (leftEnd.bottom < rightStart.top)
|
2306 |
-
add(leftSide, leftEnd.bottom, null, rightStart.top);
|
2307 |
-
}
|
2308 |
-
|
2309 |
-
output.appendChild(fragment);
|
2310 |
-
}
|
2311 |
-
|
2312 |
-
// Cursor-blinking
|
2313 |
-
function restartBlink(cm) {
|
2314 |
-
if (!cm.state.focused) return;
|
2315 |
-
var display = cm.display;
|
2316 |
-
clearInterval(display.blinker);
|
2317 |
-
var on = true;
|
2318 |
-
display.cursorDiv.style.visibility = "";
|
2319 |
-
if (cm.options.cursorBlinkRate > 0)
|
2320 |
-
display.blinker = setInterval(function() {
|
2321 |
-
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
|
2322 |
-
}, cm.options.cursorBlinkRate);
|
2323 |
-
else if (cm.options.cursorBlinkRate < 0)
|
2324 |
-
display.cursorDiv.style.visibility = "hidden";
|
2325 |
-
}
|
2326 |
-
|
2327 |
-
// HIGHLIGHT WORKER
|
2328 |
-
|
2329 |
-
function startWorker(cm, time) {
|
2330 |
-
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
|
2331 |
-
cm.state.highlight.set(time, bind(highlightWorker, cm));
|
2332 |
-
}
|
2333 |
-
|
2334 |
-
function highlightWorker(cm) {
|
2335 |
-
var doc = cm.doc;
|
2336 |
-
if (doc.frontier < doc.first) doc.frontier = doc.first;
|
2337 |
-
if (doc.frontier >= cm.display.viewTo) return;
|
2338 |
-
var end = +new Date + cm.options.workTime;
|
2339 |
-
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
|
2340 |
-
var changedLines = [];
|
2341 |
-
|
2342 |
-
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
|
2343 |
-
if (doc.frontier >= cm.display.viewFrom) { // Visible
|
2344 |
-
var oldStyles = line.styles;
|
2345 |
-
var highlighted = highlightLine(cm, line, state, true);
|
2346 |
-
line.styles = highlighted.styles;
|
2347 |
-
var oldCls = line.styleClasses, newCls = highlighted.classes;
|
2348 |
-
if (newCls) line.styleClasses = newCls;
|
2349 |
-
else if (oldCls) line.styleClasses = null;
|
2350 |
-
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
|
2351 |
-
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
|
2352 |
-
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
2353 |
-
if (ischange) changedLines.push(doc.frontier);
|
2354 |
-
line.stateAfter = copyState(doc.mode, state);
|
2355 |
-
} else {
|
2356 |
-
processLine(cm, line.text, state);
|
2357 |
-
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
2358 |
-
}
|
2359 |
-
++doc.frontier;
|
2360 |
-
if (+new Date > end) {
|
2361 |
-
startWorker(cm, cm.options.workDelay);
|
2362 |
-
return true;
|
2363 |
-
}
|
2364 |
-
});
|
2365 |
-
if (changedLines.length) runInOp(cm, function() {
|
2366 |
-
for (var i = 0; i < changedLines.length; i++)
|
2367 |
-
regLineChange(cm, changedLines[i], "text");
|
2368 |
-
});
|
2369 |
-
}
|
2370 |
-
|
2371 |
-
// Finds the line to start with when starting a parse. Tries to
|
2372 |
-
// find a line with a stateAfter, so that it can start with a
|
2373 |
-
// valid state. If that fails, it returns the line with the
|
2374 |
-
// smallest indentation, which tends to need the least context to
|
2375 |
-
// parse correctly.
|
2376 |
-
function findStartLine(cm, n, precise) {
|
2377 |
-
var minindent, minline, doc = cm.doc;
|
2378 |
-
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
|
2379 |
-
for (var search = n; search > lim; --search) {
|
2380 |
-
if (search <= doc.first) return doc.first;
|
2381 |
-
var line = getLine(doc, search - 1);
|
2382 |
-
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
|
2383 |
-
var indented = countColumn(line.text, null, cm.options.tabSize);
|
2384 |
-
if (minline == null || minindent > indented) {
|
2385 |
-
minline = search - 1;
|
2386 |
-
minindent = indented;
|
2387 |
-
}
|
2388 |
-
}
|
2389 |
-
return minline;
|
2390 |
-
}
|
2391 |
-
|
2392 |
-
function getStateBefore(cm, n, precise) {
|
2393 |
-
var doc = cm.doc, display = cm.display;
|
2394 |
-
if (!doc.mode.startState) return true;
|
2395 |
-
var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
|
2396 |
-
if (!state) state = startState(doc.mode);
|
2397 |
-
else state = copyState(doc.mode, state);
|
2398 |
-
doc.iter(pos, n, function(line) {
|
2399 |
-
processLine(cm, line.text, state);
|
2400 |
-
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
|
2401 |
-
line.stateAfter = save ? copyState(doc.mode, state) : null;
|
2402 |
-
++pos;
|
2403 |
-
});
|
2404 |
-
if (precise) doc.frontier = pos;
|
2405 |
-
return state;
|
2406 |
-
}
|
2407 |
-
|
2408 |
-
// POSITION MEASUREMENT
|
2409 |
-
|
2410 |
-
function paddingTop(display) {return display.lineSpace.offsetTop;}
|
2411 |
-
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
|
2412 |
-
function paddingH(display) {
|
2413 |
-
if (display.cachedPaddingH) return display.cachedPaddingH;
|
2414 |
-
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
|
2415 |
-
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
|
2416 |
-
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
|
2417 |
-
if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
|
2418 |
-
return data;
|
2419 |
-
}
|
2420 |
-
|
2421 |
-
function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
|
2422 |
-
function displayWidth(cm) {
|
2423 |
-
return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
|
2424 |
-
}
|
2425 |
-
function displayHeight(cm) {
|
2426 |
-
return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
|
2427 |
-
}
|
2428 |
-
|
2429 |
-
// Ensure the lineView.wrapping.heights array is populated. This is
|
2430 |
-
// an array of bottom offsets for the lines that make up a drawn
|
2431 |
-
// line. When lineWrapping is on, there might be more than one
|
2432 |
-
// height.
|
2433 |
-
function ensureLineHeights(cm, lineView, rect) {
|
2434 |
-
var wrapping = cm.options.lineWrapping;
|
2435 |
-
var curWidth = wrapping && displayWidth(cm);
|
2436 |
-
if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
|
2437 |
-
var heights = lineView.measure.heights = [];
|
2438 |
-
if (wrapping) {
|
2439 |
-
lineView.measure.width = curWidth;
|
2440 |
-
var rects = lineView.text.firstChild.getClientRects();
|
2441 |
-
for (var i = 0; i < rects.length - 1; i++) {
|
2442 |
-
var cur = rects[i], next = rects[i + 1];
|
2443 |
-
if (Math.abs(cur.bottom - next.bottom) > 2)
|
2444 |
-
heights.push((cur.bottom + next.top) / 2 - rect.top);
|
2445 |
-
}
|
2446 |
-
}
|
2447 |
-
heights.push(rect.bottom - rect.top);
|
2448 |
-
}
|
2449 |
-
}
|
2450 |
-
|
2451 |
-
// Find a line map (mapping character offsets to text nodes) and a
|
2452 |
-
// measurement cache for the given line number. (A line view might
|
2453 |
-
// contain multiple lines when collapsed ranges are present.)
|
2454 |
-
function mapFromLineView(lineView, line, lineN) {
|
2455 |
-
if (lineView.line == line)
|
2456 |
-
return {map: lineView.measure.map, cache: lineView.measure.cache};
|
2457 |
-
for (var i = 0; i < lineView.rest.length; i++)
|
2458 |
-
if (lineView.rest[i] == line)
|
2459 |
-
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
|
2460 |
-
for (var i = 0; i < lineView.rest.length; i++)
|
2461 |
-
if (lineNo(lineView.rest[i]) > lineN)
|
2462 |
-
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
|
2463 |
-
}
|
2464 |
-
|
2465 |
-
// Render a line into the hidden node display.externalMeasured. Used
|
2466 |
-
// when measurement is needed for a line that's not in the viewport.
|
2467 |
-
function updateExternalMeasurement(cm, line) {
|
2468 |
-
line = visualLine(line);
|
2469 |
-
var lineN = lineNo(line);
|
2470 |
-
var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
|
2471 |
-
view.lineN = lineN;
|
2472 |
-
var built = view.built = buildLineContent(cm, view);
|
2473 |
-
view.text = built.pre;
|
2474 |
-
removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
|
2475 |
-
return view;
|
2476 |
-
}
|
2477 |
-
|
2478 |
-
// Get a {top, bottom, left, right} box (in line-local coordinates)
|
2479 |
-
// for a given character.
|
2480 |
-
function measureChar(cm, line, ch, bias) {
|
2481 |
-
return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
|
2482 |
-
}
|
2483 |
-
|
2484 |
-
// Find a line view that corresponds to the given line number.
|
2485 |
-
function findViewForLine(cm, lineN) {
|
2486 |
-
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
|
2487 |
-
return cm.display.view[findViewIndex(cm, lineN)];
|
2488 |
-
var ext = cm.display.externalMeasured;
|
2489 |
-
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
|
2490 |
-
return ext;
|
2491 |
-
}
|
2492 |
-
|
2493 |
-
// Measurement can be split in two steps, the set-up work that
|
2494 |
-
// applies to the whole line, and the measurement of the actual
|
2495 |
-
// character. Functions like coordsChar, that need to do a lot of
|
2496 |
-
// measurements in a row, can thus ensure that the set-up work is
|
2497 |
-
// only done once.
|
2498 |
-
function prepareMeasureForLine(cm, line) {
|
2499 |
-
var lineN = lineNo(line);
|
2500 |
-
var view = findViewForLine(cm, lineN);
|
2501 |
-
if (view && !view.text)
|
2502 |
-
view = null;
|
2503 |
-
else if (view && view.changes)
|
2504 |
-
updateLineForChanges(cm, view, lineN, getDimensions(cm));
|
2505 |
-
if (!view)
|
2506 |
-
view = updateExternalMeasurement(cm, line);
|
2507 |
-
|
2508 |
-
var info = mapFromLineView(view, line, lineN);
|
2509 |
-
return {
|
2510 |
-
line: line, view: view, rect: null,
|
2511 |
-
map: info.map, cache: info.cache, before: info.before,
|
2512 |
-
hasHeights: false
|
2513 |
-
};
|
2514 |
-
}
|
2515 |
-
|
2516 |
-
// Given a prepared measurement object, measures the position of an
|
2517 |
-
// actual character (or fetches it from the cache).
|
2518 |
-
function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
|
2519 |
-
if (prepared.before) ch = -1;
|
2520 |
-
var key = ch + (bias || ""), found;
|
2521 |
-
if (prepared.cache.hasOwnProperty(key)) {
|
2522 |
-
found = prepared.cache[key];
|
2523 |
-
} else {
|
2524 |
-
if (!prepared.rect)
|
2525 |
-
prepared.rect = prepared.view.text.getBoundingClientRect();
|
2526 |
-
if (!prepared.hasHeights) {
|
2527 |
-
ensureLineHeights(cm, prepared.view, prepared.rect);
|
2528 |
-
prepared.hasHeights = true;
|
2529 |
-
}
|
2530 |
-
found = measureCharInner(cm, prepared, ch, bias);
|
2531 |
-
if (!found.bogus) prepared.cache[key] = found;
|
2532 |
-
}
|
2533 |
-
return {left: found.left, right: found.right,
|
2534 |
-
top: varHeight ? found.rtop : found.top,
|
2535 |
-
bottom: varHeight ? found.rbottom : found.bottom};
|
2536 |
-
}
|
2537 |
-
|
2538 |
-
var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
|
2539 |
-
|
2540 |
-
function nodeAndOffsetInLineMap(map, ch, bias) {
|
2541 |
-
var node, start, end, collapse;
|
2542 |
-
// First, search the line map for the text node corresponding to,
|
2543 |
-
// or closest to, the target character.
|
2544 |
-
for (var i = 0; i < map.length; i += 3) {
|
2545 |
-
var mStart = map[i], mEnd = map[i + 1];
|
2546 |
-
if (ch < mStart) {
|
2547 |
-
start = 0; end = 1;
|
2548 |
-
collapse = "left";
|
2549 |
-
} else if (ch < mEnd) {
|
2550 |
-
start = ch - mStart;
|
2551 |
-
end = start + 1;
|
2552 |
-
} else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
|
2553 |
-
end = mEnd - mStart;
|
2554 |
-
start = end - 1;
|
2555 |
-
if (ch >= mEnd) collapse = "right";
|
2556 |
-
}
|
2557 |
-
if (start != null) {
|
2558 |
-
node = map[i + 2];
|
2559 |
-
if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
|
2560 |
-
collapse = bias;
|
2561 |
-
if (bias == "left" && start == 0)
|
2562 |
-
while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
|
2563 |
-
node = map[(i -= 3) + 2];
|
2564 |
-
collapse = "left";
|
2565 |
-
}
|
2566 |
-
if (bias == "right" && start == mEnd - mStart)
|
2567 |
-
while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
|
2568 |
-
node = map[(i += 3) + 2];
|
2569 |
-
collapse = "right";
|
2570 |
-
}
|
2571 |
-
break;
|
2572 |
-
}
|
2573 |
-
}
|
2574 |
-
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
|
2575 |
-
}
|
2576 |
-
|
2577 |
-
function measureCharInner(cm, prepared, ch, bias) {
|
2578 |
-
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
|
2579 |
-
var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
|
2580 |
-
|
2581 |
-
var rect;
|
2582 |
-
if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
|
2583 |
-
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
|
2584 |
-
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
|
2585 |
-
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
|
2586 |
-
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
|
2587 |
-
rect = node.parentNode.getBoundingClientRect();
|
2588 |
-
} else if (ie && cm.options.lineWrapping) {
|
2589 |
-
var rects = range(node, start, end).getClientRects();
|
2590 |
-
if (rects.length)
|
2591 |
-
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
2592 |
-
else
|
2593 |
-
rect = nullRect;
|
2594 |
-
} else {
|
2595 |
-
rect = range(node, start, end).getBoundingClientRect() || nullRect;
|
2596 |
-
}
|
2597 |
-
if (rect.left || rect.right || start == 0) break;
|
2598 |
-
end = start;
|
2599 |
-
start = start - 1;
|
2600 |
-
collapse = "right";
|
2601 |
-
}
|
2602 |
-
if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
|
2603 |
-
} else { // If it is a widget, simply get the box for the whole widget.
|
2604 |
-
if (start > 0) collapse = bias = "right";
|
2605 |
-
var rects;
|
2606 |
-
if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
|
2607 |
-
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
2608 |
-
else
|
2609 |
-
rect = node.getBoundingClientRect();
|
2610 |
-
}
|
2611 |
-
if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
|
2612 |
-
var rSpan = node.parentNode.getClientRects()[0];
|
2613 |
-
if (rSpan)
|
2614 |
-
rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
|
2615 |
-
else
|
2616 |
-
rect = nullRect;
|
2617 |
-
}
|
2618 |
-
|
2619 |
-
var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
|
2620 |
-
var mid = (rtop + rbot) / 2;
|
2621 |
-
var heights = prepared.view.measure.heights;
|
2622 |
-
for (var i = 0; i < heights.length - 1; i++)
|
2623 |
-
if (mid < heights[i]) break;
|
2624 |
-
var top = i ? heights[i - 1] : 0, bot = heights[i];
|
2625 |
-
var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
|
2626 |
-
right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
|
2627 |
-
top: top, bottom: bot};
|
2628 |
-
if (!rect.left && !rect.right) result.bogus = true;
|
2629 |
-
if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
|
2630 |
-
|
2631 |
-
return result;
|
2632 |
-
}
|
2633 |
-
|
2634 |
-
// Work around problem with bounding client rects on ranges being
|
2635 |
-
// returned incorrectly when zoomed on IE10 and below.
|
2636 |
-
function maybeUpdateRectForZooming(measure, rect) {
|
2637 |
-
if (!window.screen || screen.logicalXDPI == null ||
|
2638 |
-
screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
|
2639 |
-
return rect;
|
2640 |
-
var scaleX = screen.logicalXDPI / screen.deviceXDPI;
|
2641 |
-
var scaleY = screen.logicalYDPI / screen.deviceYDPI;
|
2642 |
-
return {left: rect.left * scaleX, right: rect.right * scaleX,
|
2643 |
-
top: rect.top * scaleY, bottom: rect.bottom * scaleY};
|
2644 |
-
}
|
2645 |
-
|
2646 |
-
function clearLineMeasurementCacheFor(lineView) {
|
2647 |
-
if (lineView.measure) {
|
2648 |
-
lineView.measure.cache = {};
|
2649 |
-
lineView.measure.heights = null;
|
2650 |
-
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
2651 |
-
lineView.measure.caches[i] = {};
|
2652 |
-
}
|
2653 |
-
}
|
2654 |
-
|
2655 |
-
function clearLineMeasurementCache(cm) {
|
2656 |
-
cm.display.externalMeasure = null;
|
2657 |
-
removeChildren(cm.display.lineMeasure);
|
2658 |
-
for (var i = 0; i < cm.display.view.length; i++)
|
2659 |
-
clearLineMeasurementCacheFor(cm.display.view[i]);
|
2660 |
-
}
|
2661 |
-
|
2662 |
-
function clearCaches(cm) {
|
2663 |
-
clearLineMeasurementCache(cm);
|
2664 |
-
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
|
2665 |
-
if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
|
2666 |
-
cm.display.lineNumChars = null;
|
2667 |
-
}
|
2668 |
-
|
2669 |
-
function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
|
2670 |
-
function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
|
2671 |
-
|
2672 |
-
// Converts a {top, bottom, left, right} box from line-local
|
2673 |
-
// coordinates into another coordinate system. Context may be one of
|
2674 |
-
// "line", "div" (display.lineDiv), "local"/null (editor), "window",
|
2675 |
-
// or "page".
|
2676 |
-
function intoCoordSystem(cm, lineObj, rect, context) {
|
2677 |
-
if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
|
2678 |
-
var size = widgetHeight(lineObj.widgets[i]);
|
2679 |
-
rect.top += size; rect.bottom += size;
|
2680 |
-
}
|
2681 |
-
if (context == "line") return rect;
|
2682 |
-
if (!context) context = "local";
|
2683 |
-
var yOff = heightAtLine(lineObj);
|
2684 |
-
if (context == "local") yOff += paddingTop(cm.display);
|
2685 |
-
else yOff -= cm.display.viewOffset;
|
2686 |
-
if (context == "page" || context == "window") {
|
2687 |
-
var lOff = cm.display.lineSpace.getBoundingClientRect();
|
2688 |
-
yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
|
2689 |
-
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
|
2690 |
-
rect.left += xOff; rect.right += xOff;
|
2691 |
-
}
|
2692 |
-
rect.top += yOff; rect.bottom += yOff;
|
2693 |
-
return rect;
|
2694 |
-
}
|
2695 |
-
|
2696 |
-
// Coverts a box from "div" coords to another coordinate system.
|
2697 |
-
// Context may be "window", "page", "div", or "local"/null.
|
2698 |
-
function fromCoordSystem(cm, coords, context) {
|
2699 |
-
if (context == "div") return coords;
|
2700 |
-
var left = coords.left, top = coords.top;
|
2701 |
-
// First move into "page" coordinate system
|
2702 |
-
if (context == "page") {
|
2703 |
-
left -= pageScrollX();
|
2704 |
-
top -= pageScrollY();
|
2705 |
-
} else if (context == "local" || !context) {
|
2706 |
-
var localBox = cm.display.sizer.getBoundingClientRect();
|
2707 |
-
left += localBox.left;
|
2708 |
-
top += localBox.top;
|
2709 |
-
}
|
2710 |
-
|
2711 |
-
var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
|
2712 |
-
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
|
2713 |
-
}
|
2714 |
-
|
2715 |
-
function charCoords(cm, pos, context, lineObj, bias) {
|
2716 |
-
if (!lineObj) lineObj = getLine(cm.doc, pos.line);
|
2717 |
-
return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
|
2718 |
-
}
|
2719 |
-
|
2720 |
-
// Returns a box for a given cursor position, which may have an
|
2721 |
-
// 'other' property containing the position of the secondary cursor
|
2722 |
-
// on a bidi boundary.
|
2723 |
-
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
2724 |
-
lineObj = lineObj || getLine(cm.doc, pos.line);
|
2725 |
-
if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
2726 |
-
function get(ch, right) {
|
2727 |
-
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
|
2728 |
-
if (right) m.left = m.right; else m.right = m.left;
|
2729 |
-
return intoCoordSystem(cm, lineObj, m, context);
|
2730 |
-
}
|
2731 |
-
function getBidi(ch, partPos) {
|
2732 |
-
var part = order[partPos], right = part.level % 2;
|
2733 |
-
if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
|
2734 |
-
part = order[--partPos];
|
2735 |
-
ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
|
2736 |
-
right = true;
|
2737 |
-
} else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
|
2738 |
-
part = order[++partPos];
|
2739 |
-
ch = bidiLeft(part) - part.level % 2;
|
2740 |
-
right = false;
|
2741 |
-
}
|
2742 |
-
if (right && ch == part.to && ch > part.from) return get(ch - 1);
|
2743 |
-
return get(ch, right);
|
2744 |
-
}
|
2745 |
-
var order = getOrder(lineObj), ch = pos.ch;
|
2746 |
-
if (!order) return get(ch);
|
2747 |
-
var partPos = getBidiPartAt(order, ch);
|
2748 |
-
var val = getBidi(ch, partPos);
|
2749 |
-
if (bidiOther != null) val.other = getBidi(ch, bidiOther);
|
2750 |
-
return val;
|
2751 |
-
}
|
2752 |
-
|
2753 |
-
// Used to cheaply estimate the coordinates for a position. Used for
|
2754 |
-
// intermediate scroll updates.
|
2755 |
-
function estimateCoords(cm, pos) {
|
2756 |
-
var left = 0, pos = clipPos(cm.doc, pos);
|
2757 |
-
if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
|
2758 |
-
var lineObj = getLine(cm.doc, pos.line);
|
2759 |
-
var top = heightAtLine(lineObj) + paddingTop(cm.display);
|
2760 |
-
return {left: left, right: left, top: top, bottom: top + lineObj.height};
|
2761 |
-
}
|
2762 |
-
|
2763 |
-
// Positions returned by coordsChar contain some extra information.
|
2764 |
-
// xRel is the relative x position of the input coordinates compared
|
2765 |
-
// to the found position (so xRel > 0 means the coordinates are to
|
2766 |
-
// the right of the character position, for example). When outside
|
2767 |
-
// is true, that means the coordinates lie outside the line's
|
2768 |
-
// vertical range.
|
2769 |
-
function PosWithInfo(line, ch, outside, xRel) {
|
2770 |
-
var pos = Pos(line, ch);
|
2771 |
-
pos.xRel = xRel;
|
2772 |
-
if (outside) pos.outside = true;
|
2773 |
-
return pos;
|
2774 |
-
}
|
2775 |
-
|
2776 |
-
// Compute the character position closest to the given coordinates.
|
2777 |
-
// Input must be lineSpace-local ("div" coordinate system).
|
2778 |
-
function coordsChar(cm, x, y) {
|
2779 |
-
var doc = cm.doc;
|
2780 |
-
y += cm.display.viewOffset;
|
2781 |
-
if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
|
2782 |
-
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
|
2783 |
-
if (lineN > last)
|
2784 |
-
return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
|
2785 |
-
if (x < 0) x = 0;
|
2786 |
-
|
2787 |
-
var lineObj = getLine(doc, lineN);
|
2788 |
-
for (;;) {
|
2789 |
-
var found = coordsCharInner(cm, lineObj, lineN, x, y);
|
2790 |
-
var merged = collapsedSpanAtEnd(lineObj);
|
2791 |
-
var mergedPos = merged && merged.find(0, true);
|
2792 |
-
if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
|
2793 |
-
lineN = lineNo(lineObj = mergedPos.to.line);
|
2794 |
-
else
|
2795 |
-
return found;
|
2796 |
-
}
|
2797 |
-
}
|
2798 |
-
|
2799 |
-
function coordsCharInner(cm, lineObj, lineNo, x, y) {
|
2800 |
-
var innerOff = y - heightAtLine(lineObj);
|
2801 |
-
var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
|
2802 |
-
var preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
2803 |
-
|
2804 |
-
function getX(ch) {
|
2805 |
-
var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
|
2806 |
-
wrongLine = true;
|
2807 |
-
if (innerOff > sp.bottom) return sp.left - adjust;
|
2808 |
-
else if (innerOff < sp.top) return sp.left + adjust;
|
2809 |
-
else wrongLine = false;
|
2810 |
-
return sp.left;
|
2811 |
-
}
|
2812 |
-
|
2813 |
-
var bidi = getOrder(lineObj), dist = lineObj.text.length;
|
2814 |
-
var from = lineLeft(lineObj), to = lineRight(lineObj);
|
2815 |
-
var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
|
2816 |
-
|
2817 |
-
if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
|
2818 |
-
// Do a binary search between these bounds.
|
2819 |
-
for (;;) {
|
2820 |
-
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
|
2821 |
-
var ch = x < fromX || x - fromX <= toX - x ? from : to;
|
2822 |
-
var xDiff = x - (ch == from ? fromX : toX);
|
2823 |
-
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
|
2824 |
-
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
|
2825 |
-
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
|
2826 |
-
return pos;
|
2827 |
-
}
|
2828 |
-
var step = Math.ceil(dist / 2), middle = from + step;
|
2829 |
-
if (bidi) {
|
2830 |
-
middle = from;
|
2831 |
-
for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
|
2832 |
-
}
|
2833 |
-
var middleX = getX(middle);
|
2834 |
-
if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
|
2835 |
-
else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
|
2836 |
-
}
|
2837 |
-
}
|
2838 |
-
|
2839 |
-
var measureText;
|
2840 |
-
// Compute the default text height.
|
2841 |
-
function textHeight(display) {
|
2842 |
-
if (display.cachedTextHeight != null) return display.cachedTextHeight;
|
2843 |
-
if (measureText == null) {
|
2844 |
-
measureText = elt("pre");
|
2845 |
-
// Measure a bunch of lines, for browsers that compute
|
2846 |
-
// fractional heights.
|
2847 |
-
for (var i = 0; i < 49; ++i) {
|
2848 |
-
measureText.appendChild(document.createTextNode("x"));
|
2849 |
-
measureText.appendChild(elt("br"));
|
2850 |
-
}
|
2851 |
-
measureText.appendChild(document.createTextNode("x"));
|
2852 |
-
}
|
2853 |
-
removeChildrenAndAdd(display.measure, measureText);
|
2854 |
-
var height = measureText.offsetHeight / 50;
|
2855 |
-
if (height > 3) display.cachedTextHeight = height;
|
2856 |
-
removeChildren(display.measure);
|
2857 |
-
return height || 1;
|
2858 |
-
}
|
2859 |
-
|
2860 |
-
// Compute the default character width.
|
2861 |
-
function charWidth(display) {
|
2862 |
-
if (display.cachedCharWidth != null) return display.cachedCharWidth;
|
2863 |
-
var anchor = elt("span", "xxxxxxxxxx");
|
2864 |
-
var pre = elt("pre", [anchor]);
|
2865 |
-
removeChildrenAndAdd(display.measure, pre);
|
2866 |
-
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
|
2867 |
-
if (width > 2) display.cachedCharWidth = width;
|
2868 |
-
return width || 10;
|
2869 |
-
}
|
2870 |
-
|
2871 |
-
// OPERATIONS
|
2872 |
-
|
2873 |
-
// Operations are used to wrap a series of changes to the editor
|
2874 |
-
// state in such a way that each change won't have to update the
|
2875 |
-
// cursor and display (which would be awkward, slow, and
|
2876 |
-
// error-prone). Instead, display updates are batched and then all
|
2877 |
-
// combined and executed at once.
|
2878 |
-
|
2879 |
-
var operationGroup = null;
|
2880 |
-
|
2881 |
-
var nextOpId = 0;
|
2882 |
-
// Start a new operation.
|
2883 |
-
function startOperation(cm) {
|
2884 |
-
cm.curOp = {
|
2885 |
-
cm: cm,
|
2886 |
-
viewChanged: false, // Flag that indicates that lines might need to be redrawn
|
2887 |
-
startHeight: cm.doc.height, // Used to detect need to update scrollbar
|
2888 |
-
forceUpdate: false, // Used to force a redraw
|
2889 |
-
updateInput: null, // Whether to reset the input textarea
|
2890 |
-
typing: false, // Whether this reset should be careful to leave existing text (for compositing)
|
2891 |
-
changeObjs: null, // Accumulated changes, for firing change events
|
2892 |
-
cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
|
2893 |
-
cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
|
2894 |
-
selectionChanged: false, // Whether the selection needs to be redrawn
|
2895 |
-
updateMaxLine: false, // Set when the widest line needs to be determined anew
|
2896 |
-
scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
|
2897 |
-
scrollToPos: null, // Used to scroll to a specific position
|
2898 |
-
id: ++nextOpId // Unique ID
|
2899 |
-
};
|
2900 |
-
if (operationGroup) {
|
2901 |
-
operationGroup.ops.push(cm.curOp);
|
2902 |
-
} else {
|
2903 |
-
cm.curOp.ownsGroup = operationGroup = {
|
2904 |
-
ops: [cm.curOp],
|
2905 |
-
delayedCallbacks: []
|
2906 |
-
};
|
2907 |
-
}
|
2908 |
-
}
|
2909 |
-
|
2910 |
-
function fireCallbacksForOps(group) {
|
2911 |
-
// Calls delayed callbacks and cursorActivity handlers until no
|
2912 |
-
// new ones appear
|
2913 |
-
var callbacks = group.delayedCallbacks, i = 0;
|
2914 |
-
do {
|
2915 |
-
for (; i < callbacks.length; i++)
|
2916 |
-
callbacks[i]();
|
2917 |
-
for (var j = 0; j < group.ops.length; j++) {
|
2918 |
-
var op = group.ops[j];
|
2919 |
-
if (op.cursorActivityHandlers)
|
2920 |
-
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
2921 |
-
op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
|
2922 |
-
}
|
2923 |
-
} while (i < callbacks.length);
|
2924 |
-
}
|
2925 |
-
|
2926 |
-
// Finish an operation, updating the display and signalling delayed events
|
2927 |
-
function endOperation(cm) {
|
2928 |
-
var op = cm.curOp, group = op.ownsGroup;
|
2929 |
-
if (!group) return;
|
2930 |
-
|
2931 |
-
try { fireCallbacksForOps(group); }
|
2932 |
-
finally {
|
2933 |
-
operationGroup = null;
|
2934 |
-
for (var i = 0; i < group.ops.length; i++)
|
2935 |
-
group.ops[i].cm.curOp = null;
|
2936 |
-
endOperations(group);
|
2937 |
-
}
|
2938 |
-
}
|
2939 |
-
|
2940 |
-
// The DOM updates done when an operation finishes are batched so
|
2941 |
-
// that the minimum number of relayouts are required.
|
2942 |
-
function endOperations(group) {
|
2943 |
-
var ops = group.ops;
|
2944 |
-
for (var i = 0; i < ops.length; i++) // Read DOM
|
2945 |
-
endOperation_R1(ops[i]);
|
2946 |
-
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
2947 |
-
endOperation_W1(ops[i]);
|
2948 |
-
for (var i = 0; i < ops.length; i++) // Read DOM
|
2949 |
-
endOperation_R2(ops[i]);
|
2950 |
-
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
2951 |
-
endOperation_W2(ops[i]);
|
2952 |
-
for (var i = 0; i < ops.length; i++) // Read DOM
|
2953 |
-
endOperation_finish(ops[i]);
|
2954 |
-
}
|
2955 |
-
|
2956 |
-
function endOperation_R1(op) {
|
2957 |
-
var cm = op.cm, display = cm.display;
|
2958 |
-
maybeClipScrollbars(cm);
|
2959 |
-
if (op.updateMaxLine) findMaxLine(cm);
|
2960 |
-
|
2961 |
-
op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
|
2962 |
-
op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
|
2963 |
-
op.scrollToPos.to.line >= display.viewTo) ||
|
2964 |
-
display.maxLineChanged && cm.options.lineWrapping;
|
2965 |
-
op.update = op.mustUpdate &&
|
2966 |
-
new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
|
2967 |
-
}
|
2968 |
-
|
2969 |
-
function endOperation_W1(op) {
|
2970 |
-
op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
|
2971 |
-
}
|
2972 |
-
|
2973 |
-
function endOperation_R2(op) {
|
2974 |
-
var cm = op.cm, display = cm.display;
|
2975 |
-
if (op.updatedDisplay) updateHeightsInViewport(cm);
|
2976 |
-
|
2977 |
-
op.barMeasure = measureForScrollbars(cm);
|
2978 |
-
|
2979 |
-
// If the max line changed since it was last measured, measure it,
|
2980 |
-
// and ensure the document's width matches it.
|
2981 |
-
// updateDisplay_W2 will use these properties to do the actual resizing
|
2982 |
-
if (display.maxLineChanged && !cm.options.lineWrapping) {
|
2983 |
-
op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
|
2984 |
-
cm.display.sizerWidth = op.adjustWidthTo;
|
2985 |
-
op.barMeasure.scrollWidth =
|
2986 |
-
Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
|
2987 |
-
op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
|
2988 |
-
}
|
2989 |
-
|
2990 |
-
if (op.updatedDisplay || op.selectionChanged)
|
2991 |
-
op.preparedSelection = display.input.prepareSelection();
|
2992 |
-
}
|
2993 |
-
|
2994 |
-
function endOperation_W2(op) {
|
2995 |
-
var cm = op.cm;
|
2996 |
-
|
2997 |
-
if (op.adjustWidthTo != null) {
|
2998 |
-
cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
|
2999 |
-
if (op.maxScrollLeft < cm.doc.scrollLeft)
|
3000 |
-
setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
|
3001 |
-
cm.display.maxLineChanged = false;
|
3002 |
-
}
|
3003 |
-
|
3004 |
-
if (op.preparedSelection)
|
3005 |
-
cm.display.input.showSelection(op.preparedSelection);
|
3006 |
-
if (op.updatedDisplay)
|
3007 |
-
setDocumentHeight(cm, op.barMeasure);
|
3008 |
-
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
3009 |
-
updateScrollbars(cm, op.barMeasure);
|
3010 |
-
|
3011 |
-
if (op.selectionChanged) restartBlink(cm);
|
3012 |
-
|
3013 |
-
if (cm.state.focused && op.updateInput)
|
3014 |
-
cm.display.input.reset(op.typing);
|
3015 |
-
}
|
3016 |
-
|
3017 |
-
function endOperation_finish(op) {
|
3018 |
-
var cm = op.cm, display = cm.display, doc = cm.doc;
|
3019 |
-
|
3020 |
-
if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
|
3021 |
-
|
3022 |
-
// Abort mouse wheel delta measurement, when scrolling explicitly
|
3023 |
-
if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
|
3024 |
-
display.wheelStartX = display.wheelStartY = null;
|
3025 |
-
|
3026 |
-
// Propagate the scroll position to the actual DOM scroller
|
3027 |
-
if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
|
3028 |
-
doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
|
3029 |
-
display.scrollbars.setScrollTop(doc.scrollTop);
|
3030 |
-
display.scroller.scrollTop = doc.scrollTop;
|
3031 |
-
}
|
3032 |
-
if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
|
3033 |
-
doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
|
3034 |
-
display.scrollbars.setScrollLeft(doc.scrollLeft);
|
3035 |
-
display.scroller.scrollLeft = doc.scrollLeft;
|
3036 |
-
alignHorizontally(cm);
|
3037 |
-
}
|
3038 |
-
// If we need to scroll a specific position into view, do so.
|
3039 |
-
if (op.scrollToPos) {
|
3040 |
-
var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
|
3041 |
-
clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
|
3042 |
-
if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
|
3043 |
-
}
|
3044 |
-
|
3045 |
-
// Fire events for markers that are hidden/unidden by editing or
|
3046 |
-
// undoing
|
3047 |
-
var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
|
3048 |
-
if (hidden) for (var i = 0; i < hidden.length; ++i)
|
3049 |
-
if (!hidden[i].lines.length) signal(hidden[i], "hide");
|
3050 |
-
if (unhidden) for (var i = 0; i < unhidden.length; ++i)
|
3051 |
-
if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
|
3052 |
-
|
3053 |
-
if (display.wrapper.offsetHeight)
|
3054 |
-
doc.scrollTop = cm.display.scroller.scrollTop;
|
3055 |
-
|
3056 |
-
// Fire change events, and delayed event handlers
|
3057 |
-
if (op.changeObjs)
|
3058 |
-
signal(cm, "changes", cm, op.changeObjs);
|
3059 |
-
if (op.update)
|
3060 |
-
op.update.finish();
|
3061 |
-
}
|
3062 |
-
|
3063 |
-
// Run the given function in an operation
|
3064 |
-
function runInOp(cm, f) {
|
3065 |
-
if (cm.curOp) return f();
|
3066 |
-
startOperation(cm);
|
3067 |
-
try { return f(); }
|
3068 |
-
finally { endOperation(cm); }
|
3069 |
-
}
|
3070 |
-
// Wraps a function in an operation. Returns the wrapped function.
|
3071 |
-
function operation(cm, f) {
|
3072 |
-
return function() {
|
3073 |
-
if (cm.curOp) return f.apply(cm, arguments);
|
3074 |
-
startOperation(cm);
|
3075 |
-
try { return f.apply(cm, arguments); }
|
3076 |
-
finally { endOperation(cm); }
|
3077 |
-
};
|
3078 |
-
}
|
3079 |
-
// Used to add methods to editor and doc instances, wrapping them in
|
3080 |
-
// operations.
|
3081 |
-
function methodOp(f) {
|
3082 |
-
return function() {
|
3083 |
-
if (this.curOp) return f.apply(this, arguments);
|
3084 |
-
startOperation(this);
|
3085 |
-
try { return f.apply(this, arguments); }
|
3086 |
-
finally { endOperation(this); }
|
3087 |
-
};
|
3088 |
-
}
|
3089 |
-
function docMethodOp(f) {
|
3090 |
-
return function() {
|
3091 |
-
var cm = this.cm;
|
3092 |
-
if (!cm || cm.curOp) return f.apply(this, arguments);
|
3093 |
-
startOperation(cm);
|
3094 |
-
try { return f.apply(this, arguments); }
|
3095 |
-
finally { endOperation(cm); }
|
3096 |
-
};
|
3097 |
-
}
|
3098 |
-
|
3099 |
-
// VIEW TRACKING
|
3100 |
-
|
3101 |
-
// These objects are used to represent the visible (currently drawn)
|
3102 |
-
// part of the document. A LineView may correspond to multiple
|
3103 |
-
// logical lines, if those are connected by collapsed ranges.
|
3104 |
-
function LineView(doc, line, lineN) {
|
3105 |
-
// The starting line
|
3106 |
-
this.line = line;
|
3107 |
-
// Continuing lines, if any
|
3108 |
-
this.rest = visualLineContinued(line);
|
3109 |
-
// Number of logical lines in this visual line
|
3110 |
-
this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
|
3111 |
-
this.node = this.text = null;
|
3112 |
-
this.hidden = lineIsHidden(doc, line);
|
3113 |
-
}
|
3114 |
-
|
3115 |
-
// Create a range of LineView objects for the given lines.
|
3116 |
-
function buildViewArray(cm, from, to) {
|
3117 |
-
var array = [], nextPos;
|
3118 |
-
for (var pos = from; pos < to; pos = nextPos) {
|
3119 |
-
var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
|
3120 |
-
nextPos = pos + view.size;
|
3121 |
-
array.push(view);
|
3122 |
-
}
|
3123 |
-
return array;
|
3124 |
-
}
|
3125 |
-
|
3126 |
-
// Updates the display.view data structure for a given change to the
|
3127 |
-
// document. From and to are in pre-change coordinates. Lendiff is
|
3128 |
-
// the amount of lines added or subtracted by the change. This is
|
3129 |
-
// used for changes that span multiple lines, or change the way
|
3130 |
-
// lines are divided into visual lines. regLineChange (below)
|
3131 |
-
// registers single-line changes.
|
3132 |
-
function regChange(cm, from, to, lendiff) {
|
3133 |
-
if (from == null) from = cm.doc.first;
|
3134 |
-
if (to == null) to = cm.doc.first + cm.doc.size;
|
3135 |
-
if (!lendiff) lendiff = 0;
|
3136 |
-
|
3137 |
-
var display = cm.display;
|
3138 |
-
if (lendiff && to < display.viewTo &&
|
3139 |
-
(display.updateLineNumbers == null || display.updateLineNumbers > from))
|
3140 |
-
display.updateLineNumbers = from;
|
3141 |
-
|
3142 |
-
cm.curOp.viewChanged = true;
|
3143 |
-
|
3144 |
-
if (from >= display.viewTo) { // Change after
|
3145 |
-
if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
|
3146 |
-
resetView(cm);
|
3147 |
-
} else if (to <= display.viewFrom) { // Change before
|
3148 |
-
if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
|
3149 |
-
resetView(cm);
|
3150 |
-
} else {
|
3151 |
-
display.viewFrom += lendiff;
|
3152 |
-
display.viewTo += lendiff;
|
3153 |
-
}
|
3154 |
-
} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
|
3155 |
-
resetView(cm);
|
3156 |
-
} else if (from <= display.viewFrom) { // Top overlap
|
3157 |
-
var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
|
3158 |
-
if (cut) {
|
3159 |
-
display.view = display.view.slice(cut.index);
|
3160 |
-
display.viewFrom = cut.lineN;
|
3161 |
-
display.viewTo += lendiff;
|
3162 |
-
} else {
|
3163 |
-
resetView(cm);
|
3164 |
-
}
|
3165 |
-
} else if (to >= display.viewTo) { // Bottom overlap
|
3166 |
-
var cut = viewCuttingPoint(cm, from, from, -1);
|
3167 |
-
if (cut) {
|
3168 |
-
display.view = display.view.slice(0, cut.index);
|
3169 |
-
display.viewTo = cut.lineN;
|
3170 |
-
} else {
|
3171 |
-
resetView(cm);
|
3172 |
-
}
|
3173 |
-
} else { // Gap in the middle
|
3174 |
-
var cutTop = viewCuttingPoint(cm, from, from, -1);
|
3175 |
-
var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
|
3176 |
-
if (cutTop && cutBot) {
|
3177 |
-
display.view = display.view.slice(0, cutTop.index)
|
3178 |
-
.concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
|
3179 |
-
.concat(display.view.slice(cutBot.index));
|
3180 |
-
display.viewTo += lendiff;
|
3181 |
-
} else {
|
3182 |
-
resetView(cm);
|
3183 |
-
}
|
3184 |
-
}
|
3185 |
-
|
3186 |
-
var ext = display.externalMeasured;
|
3187 |
-
if (ext) {
|
3188 |
-
if (to < ext.lineN)
|
3189 |
-
ext.lineN += lendiff;
|
3190 |
-
else if (from < ext.lineN + ext.size)
|
3191 |
-
display.externalMeasured = null;
|
3192 |
-
}
|
3193 |
-
}
|
3194 |
-
|
3195 |
-
// Register a change to a single line. Type must be one of "text",
|
3196 |
-
// "gutter", "class", "widget"
|
3197 |
-
function regLineChange(cm, line, type) {
|
3198 |
-
cm.curOp.viewChanged = true;
|
3199 |
-
var display = cm.display, ext = cm.display.externalMeasured;
|
3200 |
-
if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
|
3201 |
-
display.externalMeasured = null;
|
3202 |
-
|
3203 |
-
if (line < display.viewFrom || line >= display.viewTo) return;
|
3204 |
-
var lineView = display.view[findViewIndex(cm, line)];
|
3205 |
-
if (lineView.node == null) return;
|
3206 |
-
var arr = lineView.changes || (lineView.changes = []);
|
3207 |
-
if (indexOf(arr, type) == -1) arr.push(type);
|
3208 |
-
}
|
3209 |
-
|
3210 |
-
// Clear the view.
|
3211 |
-
function resetView(cm) {
|
3212 |
-
cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
|
3213 |
-
cm.display.view = [];
|
3214 |
-
cm.display.viewOffset = 0;
|
3215 |
-
}
|
3216 |
-
|
3217 |
-
// Find the view element corresponding to a given line. Return null
|
3218 |
-
// when the line isn't visible.
|
3219 |
-
function findViewIndex(cm, n) {
|
3220 |
-
if (n >= cm.display.viewTo) return null;
|
3221 |
-
n -= cm.display.viewFrom;
|
3222 |
-
if (n < 0) return null;
|
3223 |
-
var view = cm.display.view;
|
3224 |
-
for (var i = 0; i < view.length; i++) {
|
3225 |
-
n -= view[i].size;
|
3226 |
-
if (n < 0) return i;
|
3227 |
-
}
|
3228 |
-
}
|
3229 |
-
|
3230 |
-
function viewCuttingPoint(cm, oldN, newN, dir) {
|
3231 |
-
var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
|
3232 |
-
if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
|
3233 |
-
return {index: index, lineN: newN};
|
3234 |
-
for (var i = 0, n = cm.display.viewFrom; i < index; i++)
|
3235 |
-
n += view[i].size;
|
3236 |
-
if (n != oldN) {
|
3237 |
-
if (dir > 0) {
|
3238 |
-
if (index == view.length - 1) return null;
|
3239 |
-
diff = (n + view[index].size) - oldN;
|
3240 |
-
index++;
|
3241 |
-
} else {
|
3242 |
-
diff = n - oldN;
|
3243 |
-
}
|
3244 |
-
oldN += diff; newN += diff;
|
3245 |
-
}
|
3246 |
-
while (visualLineNo(cm.doc, newN) != newN) {
|
3247 |
-
if (index == (dir < 0 ? 0 : view.length - 1)) return null;
|
3248 |
-
newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
|
3249 |
-
index += dir;
|
3250 |
-
}
|
3251 |
-
return {index: index, lineN: newN};
|
3252 |
-
}
|
3253 |
-
|
3254 |
-
// Force the view to cover a given range, adding empty view element
|
3255 |
-
// or clipping off existing ones as needed.
|
3256 |
-
function adjustView(cm, from, to) {
|
3257 |
-
var display = cm.display, view = display.view;
|
3258 |
-
if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
|
3259 |
-
display.view = buildViewArray(cm, from, to);
|
3260 |
-
display.viewFrom = from;
|
3261 |
-
} else {
|
3262 |
-
if (display.viewFrom > from)
|
3263 |
-
display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
|
3264 |
-
else if (display.viewFrom < from)
|
3265 |
-
display.view = display.view.slice(findViewIndex(cm, from));
|
3266 |
-
display.viewFrom = from;
|
3267 |
-
if (display.viewTo < to)
|
3268 |
-
display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
|
3269 |
-
else if (display.viewTo > to)
|
3270 |
-
display.view = display.view.slice(0, findViewIndex(cm, to));
|
3271 |
-
}
|
3272 |
-
display.viewTo = to;
|
3273 |
-
}
|
3274 |
-
|
3275 |
-
// Count the number of lines in the view whose DOM representation is
|
3276 |
-
// out of date (or nonexistent).
|
3277 |
-
function countDirtyView(cm) {
|
3278 |
-
var view = cm.display.view, dirty = 0;
|
3279 |
-
for (var i = 0; i < view.length; i++) {
|
3280 |
-
var lineView = view[i];
|
3281 |
-
if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
|
3282 |
-
}
|
3283 |
-
return dirty;
|
3284 |
-
}
|
3285 |
-
|
3286 |
-
// EVENT HANDLERS
|
3287 |
-
|
3288 |
-
// Attach the necessary event handlers when initializing the editor
|
3289 |
-
function registerEventHandlers(cm) {
|
3290 |
-
var d = cm.display;
|
3291 |
-
on(d.scroller, "mousedown", operation(cm, onMouseDown));
|
3292 |
-
// Older IE's will not fire a second mousedown for a double click
|
3293 |
-
if (ie && ie_version < 11)
|
3294 |
-
on(d.scroller, "dblclick", operation(cm, function(e) {
|
3295 |
-
if (signalDOMEvent(cm, e)) return;
|
3296 |
-
var pos = posFromMouse(cm, e);
|
3297 |
-
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
|
3298 |
-
e_preventDefault(e);
|
3299 |
-
var word = cm.findWordAt(pos);
|
3300 |
-
extendSelection(cm.doc, word.anchor, word.head);
|
3301 |
-
}));
|
3302 |
-
else
|
3303 |
-
on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
|
3304 |
-
// Some browsers fire contextmenu *after* opening the menu, at
|
3305 |
-
// which point we can't mess with it anymore. Context menu is
|
3306 |
-
// handled in onMouseDown for these browsers.
|
3307 |
-
if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
|
3308 |
-
|
3309 |
-
// Used to suppress mouse event handling when a touch happens
|
3310 |
-
var touchFinished, prevTouch = {end: 0};
|
3311 |
-
function finishTouch() {
|
3312 |
-
if (d.activeTouch) {
|
3313 |
-
touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000);
|
3314 |
-
prevTouch = d.activeTouch;
|
3315 |
-
prevTouch.end = +new Date;
|
3316 |
-
}
|
3317 |
-
};
|
3318 |
-
function isMouseLikeTouchEvent(e) {
|
3319 |
-
if (e.touches.length != 1) return false;
|
3320 |
-
var touch = e.touches[0];
|
3321 |
-
return touch.radiusX <= 1 && touch.radiusY <= 1;
|
3322 |
-
}
|
3323 |
-
function farAway(touch, other) {
|
3324 |
-
if (other.left == null) return true;
|
3325 |
-
var dx = other.left - touch.left, dy = other.top - touch.top;
|
3326 |
-
return dx * dx + dy * dy > 20 * 20;
|
3327 |
-
}
|
3328 |
-
on(d.scroller, "touchstart", function(e) {
|
3329 |
-
if (!isMouseLikeTouchEvent(e)) {
|
3330 |
-
clearTimeout(touchFinished);
|
3331 |
-
var now = +new Date;
|
3332 |
-
d.activeTouch = {start: now, moved: false,
|
3333 |
-
prev: now - prevTouch.end <= 300 ? prevTouch : null};
|
3334 |
-
if (e.touches.length == 1) {
|
3335 |
-
d.activeTouch.left = e.touches[0].pageX;
|
3336 |
-
d.activeTouch.top = e.touches[0].pageY;
|
3337 |
-
}
|
3338 |
-
}
|
3339 |
-
});
|
3340 |
-
on(d.scroller, "touchmove", function() {
|
3341 |
-
if (d.activeTouch) d.activeTouch.moved = true;
|
3342 |
-
});
|
3343 |
-
on(d.scroller, "touchend", function(e) {
|
3344 |
-
var touch = d.activeTouch;
|
3345 |
-
if (touch && !eventInWidget(d, e) && touch.left != null &&
|
3346 |
-
!touch.moved && new Date - touch.start < 300) {
|
3347 |
-
var pos = cm.coordsChar(d.activeTouch, "page"), range;
|
3348 |
-
if (!touch.prev || farAway(touch, touch.prev)) // Single tap
|
3349 |
-
range = new Range(pos, pos);
|
3350 |
-
else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
|
3351 |
-
range = cm.findWordAt(pos);
|
3352 |
-
else // Triple tap
|
3353 |
-
range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
|
3354 |
-
cm.setSelection(range.anchor, range.head);
|
3355 |
-
cm.focus();
|
3356 |
-
e_preventDefault(e);
|
3357 |
-
}
|
3358 |
-
finishTouch();
|
3359 |
-
});
|
3360 |
-
on(d.scroller, "touchcancel", finishTouch);
|
3361 |
-
|
3362 |
-
// Sync scrolling between fake scrollbars and real scrollable
|
3363 |
-
// area, ensure viewport is updated when scrolling.
|
3364 |
-
on(d.scroller, "scroll", function() {
|
3365 |
-
if (d.scroller.clientHeight) {
|
3366 |
-
setScrollTop(cm, d.scroller.scrollTop);
|
3367 |
-
setScrollLeft(cm, d.scroller.scrollLeft, true);
|
3368 |
-
signal(cm, "scroll", cm);
|
3369 |
-
}
|
3370 |
-
});
|
3371 |
-
|
3372 |
-
// Listen to wheel events in order to try and update the viewport on time.
|
3373 |
-
on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
|
3374 |
-
on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
|
3375 |
-
|
3376 |
-
// Prevent wrapper from ever scrolling
|
3377 |
-
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
|
3378 |
-
|
3379 |
-
function drag_(e) {
|
3380 |
-
if (!signalDOMEvent(cm, e)) e_stop(e);
|
3381 |
-
}
|
3382 |
-
if (cm.options.dragDrop) {
|
3383 |
-
on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
|
3384 |
-
on(d.scroller, "dragenter", drag_);
|
3385 |
-
on(d.scroller, "dragover", drag_);
|
3386 |
-
on(d.scroller, "drop", operation(cm, onDrop));
|
3387 |
-
}
|
3388 |
-
|
3389 |
-
var inp = d.input.getField();
|
3390 |
-
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
|
3391 |
-
on(inp, "keydown", operation(cm, onKeyDown));
|
3392 |
-
on(inp, "keypress", operation(cm, onKeyPress));
|
3393 |
-
on(inp, "focus", bind(onFocus, cm));
|
3394 |
-
on(inp, "blur", bind(onBlur, cm));
|
3395 |
-
}
|
3396 |
-
|
3397 |
-
// Called when the window resizes
|
3398 |
-
function onResize(cm) {
|
3399 |
-
var d = cm.display;
|
3400 |
-
if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
|
3401 |
-
return;
|
3402 |
-
// Might be a text scaling operation, clear size caches.
|
3403 |
-
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
3404 |
-
d.scrollbarsClipped = false;
|
3405 |
-
cm.setSize();
|
3406 |
-
}
|
3407 |
-
|
3408 |
-
// MOUSE EVENTS
|
3409 |
-
|
3410 |
-
// Return true when the given mouse event happened in a widget
|
3411 |
-
function eventInWidget(display, e) {
|
3412 |
-
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
|
3413 |
-
if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
|
3414 |
-
(n.parentNode == display.sizer && n != display.mover))
|
3415 |
-
return true;
|
3416 |
-
}
|
3417 |
-
}
|
3418 |
-
|
3419 |
-
// Given a mouse event, find the corresponding position. If liberal
|
3420 |
-
// is false, it checks whether a gutter or scrollbar was clicked,
|
3421 |
-
// and returns null if it was. forRect is used by rectangular
|
3422 |
-
// selections, and tries to estimate a character position even for
|
3423 |
-
// coordinates beyond the right of the text.
|
3424 |
-
function posFromMouse(cm, e, liberal, forRect) {
|
3425 |
-
var display = cm.display;
|
3426 |
-
if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
|
3427 |
-
|
3428 |
-
var x, y, space = display.lineSpace.getBoundingClientRect();
|
3429 |
-
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
|
3430 |
-
try { x = e.clientX - space.left; y = e.clientY - space.top; }
|
3431 |
-
catch (e) { return null; }
|
3432 |
-
var coords = coordsChar(cm, x, y), line;
|
3433 |
-
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
|
3434 |
-
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
|
3435 |
-
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
|
3436 |
-
}
|
3437 |
-
return coords;
|
3438 |
-
}
|
3439 |
-
|
3440 |
-
// A mouse down can be a single click, double click, triple click,
|
3441 |
-
// start of selection drag, start of text drag, new cursor
|
3442 |
-
// (ctrl-click), rectangle drag (alt-drag), or xwin
|
3443 |
-
// middle-click-paste. Or it might be a click on something we should
|
3444 |
-
// not interfere with, such as a scrollbar or widget.
|
3445 |
-
function onMouseDown(e) {
|
3446 |
-
var cm = this, display = cm.display;
|
3447 |
-
if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
|
3448 |
-
display.shift = e.shiftKey;
|
3449 |
-
|
3450 |
-
if (eventInWidget(display, e)) {
|
3451 |
-
if (!webkit) {
|
3452 |
-
// Briefly turn off draggability, to allow widgets to do
|
3453 |
-
// normal dragging things.
|
3454 |
-
display.scroller.draggable = false;
|
3455 |
-
setTimeout(function(){display.scroller.draggable = true;}, 100);
|
3456 |
-
}
|
3457 |
-
return;
|
3458 |
-
}
|
3459 |
-
if (clickInGutter(cm, e)) return;
|
3460 |
-
var start = posFromMouse(cm, e);
|
3461 |
-
window.focus();
|
3462 |
-
|
3463 |
-
switch (e_button(e)) {
|
3464 |
-
case 1:
|
3465 |
-
if (start)
|
3466 |
-
leftButtonDown(cm, e, start);
|
3467 |
-
else if (e_target(e) == display.scroller)
|
3468 |
-
e_preventDefault(e);
|
3469 |
-
break;
|
3470 |
-
case 2:
|
3471 |
-
if (webkit) cm.state.lastMiddleDown = +new Date;
|
3472 |
-
if (start) extendSelection(cm.doc, start);
|
3473 |
-
setTimeout(function() {display.input.focus();}, 20);
|
3474 |
-
e_preventDefault(e);
|
3475 |
-
break;
|
3476 |
-
case 3:
|
3477 |
-
if (captureRightClick) onContextMenu(cm, e);
|
3478 |
-
break;
|
3479 |
-
}
|
3480 |
-
}
|
3481 |
-
|
3482 |
-
var lastClick, lastDoubleClick;
|
3483 |
-
function leftButtonDown(cm, e, start) {
|
3484 |
-
if (ie) setTimeout(bind(ensureFocus, cm), 0);
|
3485 |
-
else ensureFocus(cm);
|
3486 |
-
|
3487 |
-
var now = +new Date, type;
|
3488 |
-
if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
|
3489 |
-
type = "triple";
|
3490 |
-
} else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
|
3491 |
-
type = "double";
|
3492 |
-
lastDoubleClick = {time: now, pos: start};
|
3493 |
-
} else {
|
3494 |
-
type = "single";
|
3495 |
-
lastClick = {time: now, pos: start};
|
3496 |
-
}
|
3497 |
-
|
3498 |
-
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
3499 |
-
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
|
3500 |
-
type == "single" && (contained = sel.contains(start)) > -1 &&
|
3501 |
-
!sel.ranges[contained].empty())
|
3502 |
-
leftButtonStartDrag(cm, e, start, modifier);
|
3503 |
-
else
|
3504 |
-
leftButtonSelect(cm, e, start, type, modifier);
|
3505 |
-
}
|
3506 |
-
|
3507 |
-
// Start a text drag. When it ends, see if any dragging actually
|
3508 |
-
// happen, and treat as a click if it didn't.
|
3509 |
-
function leftButtonStartDrag(cm, e, start, modifier) {
|
3510 |
-
var display = cm.display;
|
3511 |
-
var dragEnd = operation(cm, function(e2) {
|
3512 |
-
if (webkit) display.scroller.draggable = false;
|
3513 |
-
cm.state.draggingText = false;
|
3514 |
-
off(document, "mouseup", dragEnd);
|
3515 |
-
off(display.scroller, "drop", dragEnd);
|
3516 |
-
if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
|
3517 |
-
e_preventDefault(e2);
|
3518 |
-
if (!modifier)
|
3519 |
-
extendSelection(cm.doc, start);
|
3520 |
-
display.input.focus();
|
3521 |
-
// Work around unexplainable focus problem in IE9 (#2127)
|
3522 |
-
if (ie && ie_version == 9)
|
3523 |
-
setTimeout(function() {document.body.focus(); display.input.focus();}, 20);
|
3524 |
-
}
|
3525 |
-
});
|
3526 |
-
// Let the drag handler handle this.
|
3527 |
-
if (webkit) display.scroller.draggable = true;
|
3528 |
-
cm.state.draggingText = dragEnd;
|
3529 |
-
// IE's approach to draggable
|
3530 |
-
if (display.scroller.dragDrop) display.scroller.dragDrop();
|
3531 |
-
on(document, "mouseup", dragEnd);
|
3532 |
-
on(display.scroller, "drop", dragEnd);
|
3533 |
-
}
|
3534 |
-
|
3535 |
-
// Normal selection, as opposed to text dragging.
|
3536 |
-
function leftButtonSelect(cm, e, start, type, addNew) {
|
3537 |
-
var display = cm.display, doc = cm.doc;
|
3538 |
-
e_preventDefault(e);
|
3539 |
-
|
3540 |
-
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
3541 |
-
if (addNew && !e.shiftKey) {
|
3542 |
-
ourIndex = doc.sel.contains(start);
|
3543 |
-
if (ourIndex > -1)
|
3544 |
-
ourRange = ranges[ourIndex];
|
3545 |
-
else
|
3546 |
-
ourRange = new Range(start, start);
|
3547 |
-
} else {
|
3548 |
-
ourRange = doc.sel.primary();
|
3549 |
-
}
|
3550 |
-
|
3551 |
-
if (e.altKey) {
|
3552 |
-
type = "rect";
|
3553 |
-
if (!addNew) ourRange = new Range(start, start);
|
3554 |
-
start = posFromMouse(cm, e, true, true);
|
3555 |
-
ourIndex = -1;
|
3556 |
-
} else if (type == "double") {
|
3557 |
-
var word = cm.findWordAt(start);
|
3558 |
-
if (cm.display.shift || doc.extend)
|
3559 |
-
ourRange = extendRange(doc, ourRange, word.anchor, word.head);
|
3560 |
-
else
|
3561 |
-
ourRange = word;
|
3562 |
-
} else if (type == "triple") {
|
3563 |
-
var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
|
3564 |
-
if (cm.display.shift || doc.extend)
|
3565 |
-
ourRange = extendRange(doc, ourRange, line.anchor, line.head);
|
3566 |
-
else
|
3567 |
-
ourRange = line;
|
3568 |
-
} else {
|
3569 |
-
ourRange = extendRange(doc, ourRange, start);
|
3570 |
-
}
|
3571 |
-
|
3572 |
-
if (!addNew) {
|
3573 |
-
ourIndex = 0;
|
3574 |
-
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
3575 |
-
startSel = doc.sel;
|
3576 |
-
} else if (ourIndex == -1) {
|
3577 |
-
ourIndex = ranges.length;
|
3578 |
-
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
3579 |
-
{scroll: false, origin: "*mouse"});
|
3580 |
-
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single") {
|
3581 |
-
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
|
3582 |
-
startSel = doc.sel;
|
3583 |
-
} else {
|
3584 |
-
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
3585 |
-
}
|
3586 |
-
|
3587 |
-
var lastPos = start;
|
3588 |
-
function extendTo(pos) {
|
3589 |
-
if (cmp(lastPos, pos) == 0) return;
|
3590 |
-
lastPos = pos;
|
3591 |
-
|
3592 |
-
if (type == "rect") {
|
3593 |
-
var ranges = [], tabSize = cm.options.tabSize;
|
3594 |
-
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
3595 |
-
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
3596 |
-
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
3597 |
-
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
3598 |
-
line <= end; line++) {
|
3599 |
-
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
3600 |
-
if (left == right)
|
3601 |
-
ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
|
3602 |
-
else if (text.length > leftPos)
|
3603 |
-
ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
|
3604 |
-
}
|
3605 |
-
if (!ranges.length) ranges.push(new Range(start, start));
|
3606 |
-
setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
3607 |
-
{origin: "*mouse", scroll: false});
|
3608 |
-
cm.scrollIntoView(pos);
|
3609 |
-
} else {
|
3610 |
-
var oldRange = ourRange;
|
3611 |
-
var anchor = oldRange.anchor, head = pos;
|
3612 |
-
if (type != "single") {
|
3613 |
-
if (type == "double")
|
3614 |
-
var range = cm.findWordAt(pos);
|
3615 |
-
else
|
3616 |
-
var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
|
3617 |
-
if (cmp(range.anchor, anchor) > 0) {
|
3618 |
-
head = range.head;
|
3619 |
-
anchor = minPos(oldRange.from(), range.anchor);
|
3620 |
-
} else {
|
3621 |
-
head = range.anchor;
|
3622 |
-
anchor = maxPos(oldRange.to(), range.head);
|
3623 |
-
}
|
3624 |
-
}
|
3625 |
-
var ranges = startSel.ranges.slice(0);
|
3626 |
-
ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
|
3627 |
-
setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
|
3628 |
-
}
|
3629 |
-
}
|
3630 |
-
|
3631 |
-
var editorSize = display.wrapper.getBoundingClientRect();
|
3632 |
-
// Used to ensure timeout re-tries don't fire when another extend
|
3633 |
-
// happened in the meantime (clearTimeout isn't reliable -- at
|
3634 |
-
// least on Chrome, the timeouts still happen even when cleared,
|
3635 |
-
// if the clear happens after their scheduled firing time).
|
3636 |
-
var counter = 0;
|
3637 |
-
|
3638 |
-
function extend(e) {
|
3639 |
-
var curCount = ++counter;
|
3640 |
-
var cur = posFromMouse(cm, e, true, type == "rect");
|
3641 |
-
if (!cur) return;
|
3642 |
-
if (cmp(cur, lastPos) != 0) {
|
3643 |
-
ensureFocus(cm);
|
3644 |
-
extendTo(cur);
|
3645 |
-
var visible = visibleLines(display, doc);
|
3646 |
-
if (cur.line >= visible.to || cur.line < visible.from)
|
3647 |
-
setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
|
3648 |
-
} else {
|
3649 |
-
var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
|
3650 |
-
if (outside) setTimeout(operation(cm, function() {
|
3651 |
-
if (counter != curCount) return;
|
3652 |
-
display.scroller.scrollTop += outside;
|
3653 |
-
extend(e);
|
3654 |
-
}), 50);
|
3655 |
-
}
|
3656 |
-
}
|
3657 |
-
|
3658 |
-
function done(e) {
|
3659 |
-
counter = Infinity;
|
3660 |
-
e_preventDefault(e);
|
3661 |
-
display.input.focus();
|
3662 |
-
off(document, "mousemove", move);
|
3663 |
-
off(document, "mouseup", up);
|
3664 |
-
doc.history.lastSelOrigin = null;
|
3665 |
-
}
|
3666 |
-
|
3667 |
-
var move = operation(cm, function(e) {
|
3668 |
-
if (!e_button(e)) done(e);
|
3669 |
-
else extend(e);
|
3670 |
-
});
|
3671 |
-
var up = operation(cm, done);
|
3672 |
-
on(document, "mousemove", move);
|
3673 |
-
on(document, "mouseup", up);
|
3674 |
-
}
|
3675 |
-
|
3676 |
-
// Determines whether an event happened in the gutter, and fires the
|
3677 |
-
// handlers for the corresponding event.
|
3678 |
-
function gutterEvent(cm, e, type, prevent, signalfn) {
|
3679 |
-
try { var mX = e.clientX, mY = e.clientY; }
|
3680 |
-
catch(e) { return false; }
|
3681 |
-
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
|
3682 |
-
if (prevent) e_preventDefault(e);
|
3683 |
-
|
3684 |
-
var display = cm.display;
|
3685 |
-
var lineBox = display.lineDiv.getBoundingClientRect();
|
3686 |
-
|
3687 |
-
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
|
3688 |
-
mY -= lineBox.top - display.viewOffset;
|
3689 |
-
|
3690 |
-
for (var i = 0; i < cm.options.gutters.length; ++i) {
|
3691 |
-
var g = display.gutters.childNodes[i];
|
3692 |
-
if (g && g.getBoundingClientRect().right >= mX) {
|
3693 |
-
var line = lineAtHeight(cm.doc, mY);
|
3694 |
-
var gutter = cm.options.gutters[i];
|
3695 |
-
signalfn(cm, type, cm, line, gutter, e);
|
3696 |
-
return e_defaultPrevented(e);
|
3697 |
-
}
|
3698 |
-
}
|
3699 |
-
}
|
3700 |
-
|
3701 |
-
function clickInGutter(cm, e) {
|
3702 |
-
return gutterEvent(cm, e, "gutterClick", true, signalLater);
|
3703 |
-
}
|
3704 |
-
|
3705 |
-
// Kludge to work around strange IE behavior where it'll sometimes
|
3706 |
-
// re-fire a series of drag-related events right after the drop (#1551)
|
3707 |
-
var lastDrop = 0;
|
3708 |
-
|
3709 |
-
function onDrop(e) {
|
3710 |
-
var cm = this;
|
3711 |
-
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
3712 |
-
return;
|
3713 |
-
e_preventDefault(e);
|
3714 |
-
if (ie) lastDrop = +new Date;
|
3715 |
-
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
3716 |
-
if (!pos || isReadOnly(cm)) return;
|
3717 |
-
// Might be a file drop, in which case we simply extract the text
|
3718 |
-
// and insert it.
|
3719 |
-
if (files && files.length && window.FileReader && window.File) {
|
3720 |
-
var n = files.length, text = Array(n), read = 0;
|
3721 |
-
var loadFile = function(file, i) {
|
3722 |
-
var reader = new FileReader;
|
3723 |
-
reader.onload = operation(cm, function() {
|
3724 |
-
text[i] = reader.result;
|
3725 |
-
if (++read == n) {
|
3726 |
-
pos = clipPos(cm.doc, pos);
|
3727 |
-
var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
|
3728 |
-
makeChange(cm.doc, change);
|
3729 |
-
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
|
3730 |
-
}
|
3731 |
-
});
|
3732 |
-
reader.readAsText(file);
|
3733 |
-
};
|
3734 |
-
for (var i = 0; i < n; ++i) loadFile(files[i], i);
|
3735 |
-
} else { // Normal drop
|
3736 |
-
// Don't do a replace if the drop happened inside of the selected text.
|
3737 |
-
if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
|
3738 |
-
cm.state.draggingText(e);
|
3739 |
-
// Ensure the editor is re-focused
|
3740 |
-
setTimeout(function() {cm.display.input.focus();}, 20);
|
3741 |
-
return;
|
3742 |
-
}
|
3743 |
-
try {
|
3744 |
-
var text = e.dataTransfer.getData("Text");
|
3745 |
-
if (text) {
|
3746 |
-
if (cm.state.draggingText && !(mac ? e.metaKey : e.ctrlKey))
|
3747 |
-
var selected = cm.listSelections();
|
3748 |
-
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
|
3749 |
-
if (selected) for (var i = 0; i < selected.length; ++i)
|
3750 |
-
replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
|
3751 |
-
cm.replaceSelection(text, "around", "paste");
|
3752 |
-
cm.display.input.focus();
|
3753 |
-
}
|
3754 |
-
}
|
3755 |
-
catch(e){}
|
3756 |
-
}
|
3757 |
-
}
|
3758 |
-
|
3759 |
-
function onDragStart(cm, e) {
|
3760 |
-
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
|
3761 |
-
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
|
3762 |
-
|
3763 |
-
e.dataTransfer.setData("Text", cm.getSelection());
|
3764 |
-
|
3765 |
-
// Use dummy image instead of default browsers image.
|
3766 |
-
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
|
3767 |
-
if (e.dataTransfer.setDragImage && !safari) {
|
3768 |
-
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
|
3769 |
-
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
3770 |
-
if (presto) {
|
3771 |
-
img.width = img.height = 1;
|
3772 |
-
cm.display.wrapper.appendChild(img);
|
3773 |
-
// Force a relayout, or Opera won't use our image for some obscure reason
|
3774 |
-
img._top = img.offsetTop;
|
3775 |
-
}
|
3776 |
-
e.dataTransfer.setDragImage(img, 0, 0);
|
3777 |
-
if (presto) img.parentNode.removeChild(img);
|
3778 |
-
}
|
3779 |
-
}
|
3780 |
-
|
3781 |
-
// SCROLL EVENTS
|
3782 |
-
|
3783 |
-
// Sync the scrollable area and scrollbars, ensure the viewport
|
3784 |
-
// covers the visible area.
|
3785 |
-
function setScrollTop(cm, val) {
|
3786 |
-
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
|
3787 |
-
cm.doc.scrollTop = val;
|
3788 |
-
if (!gecko) updateDisplaySimple(cm, {top: val});
|
3789 |
-
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
|
3790 |
-
cm.display.scrollbars.setScrollTop(val);
|
3791 |
-
if (gecko) updateDisplaySimple(cm);
|
3792 |
-
startWorker(cm, 100);
|
3793 |
-
}
|
3794 |
-
// Sync scroller and scrollbar, ensure the gutter elements are
|
3795 |
-
// aligned.
|
3796 |
-
function setScrollLeft(cm, val, isScroller) {
|
3797 |
-
if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
|
3798 |
-
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
|
3799 |
-
cm.doc.scrollLeft = val;
|
3800 |
-
alignHorizontally(cm);
|
3801 |
-
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
|
3802 |
-
cm.display.scrollbars.setScrollLeft(val);
|
3803 |
-
}
|
3804 |
-
|
3805 |
-
// Since the delta values reported on mouse wheel events are
|
3806 |
-
// unstandardized between browsers and even browser versions, and
|
3807 |
-
// generally horribly unpredictable, this code starts by measuring
|
3808 |
-
// the scroll effect that the first few mouse wheel events have,
|
3809 |
-
// and, from that, detects the way it can convert deltas to pixel
|
3810 |
-
// offsets afterwards.
|
3811 |
-
//
|
3812 |
-
// The reason we want to know the amount a wheel event will scroll
|
3813 |
-
// is that it gives us a chance to update the display before the
|
3814 |
-
// actual scrolling happens, reducing flickering.
|
3815 |
-
|
3816 |
-
var wheelSamples = 0, wheelPixelsPerUnit = null;
|
3817 |
-
// Fill in a browser-detected starting value on browsers where we
|
3818 |
-
// know one. These don't have to be accurate -- the result of them
|
3819 |
-
// being wrong would just be a slight flicker on the first wheel
|
3820 |
-
// scroll (if it is large enough).
|
3821 |
-
if (ie) wheelPixelsPerUnit = -.53;
|
3822 |
-
else if (gecko) wheelPixelsPerUnit = 15;
|
3823 |
-
else if (chrome) wheelPixelsPerUnit = -.7;
|
3824 |
-
else if (safari) wheelPixelsPerUnit = -1/3;
|
3825 |
-
|
3826 |
-
var wheelEventDelta = function(e) {
|
3827 |
-
var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
|
3828 |
-
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
|
3829 |
-
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
|
3830 |
-
else if (dy == null) dy = e.wheelDelta;
|
3831 |
-
return {x: dx, y: dy};
|
3832 |
-
};
|
3833 |
-
CodeMirror.wheelEventPixels = function(e) {
|
3834 |
-
var delta = wheelEventDelta(e);
|
3835 |
-
delta.x *= wheelPixelsPerUnit;
|
3836 |
-
delta.y *= wheelPixelsPerUnit;
|
3837 |
-
return delta;
|
3838 |
-
};
|
3839 |
-
|
3840 |
-
function onScrollWheel(cm, e) {
|
3841 |
-
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
|
3842 |
-
|
3843 |
-
var display = cm.display, scroll = display.scroller;
|
3844 |
-
// Quit if there's nothing to scroll here
|
3845 |
-
if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
|
3846 |
-
dy && scroll.scrollHeight > scroll.clientHeight)) return;
|
3847 |
-
|
3848 |
-
// Webkit browsers on OS X abort momentum scrolls when the target
|
3849 |
-
// of the scroll event is removed from the scrollable element.
|
3850 |
-
// This hack (see related code in patchDisplay) makes sure the
|
3851 |
-
// element is kept around.
|
3852 |
-
if (dy && mac && webkit) {
|
3853 |
-
outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
|
3854 |
-
for (var i = 0; i < view.length; i++) {
|
3855 |
-
if (view[i].node == cur) {
|
3856 |
-
cm.display.currentWheelTarget = cur;
|
3857 |
-
break outer;
|
3858 |
-
}
|
3859 |
-
}
|
3860 |
-
}
|
3861 |
-
}
|
3862 |
-
|
3863 |
-
// On some browsers, horizontal scrolling will cause redraws to
|
3864 |
-
// happen before the gutter has been realigned, causing it to
|
3865 |
-
// wriggle around in a most unseemly way. When we have an
|
3866 |
-
// estimated pixels/delta value, we just handle horizontal
|
3867 |
-
// scrolling entirely here. It'll be slightly off from native, but
|
3868 |
-
// better than glitching out.
|
3869 |
-
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
3870 |
-
if (dy)
|
3871 |
-
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
|
3872 |
-
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
|
3873 |
-
e_preventDefault(e);
|
3874 |
-
display.wheelStartX = null; // Abort measurement, if in progress
|
3875 |
-
return;
|
3876 |
-
}
|
3877 |
-
|
3878 |
-
// 'Project' the visible viewport to cover the area that is being
|
3879 |
-
// scrolled into view (if we know enough to estimate it).
|
3880 |
-
if (dy && wheelPixelsPerUnit != null) {
|
3881 |
-
var pixels = dy * wheelPixelsPerUnit;
|
3882 |
-
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
|
3883 |
-
if (pixels < 0) top = Math.max(0, top + pixels - 50);
|
3884 |
-
else bot = Math.min(cm.doc.height, bot + pixels + 50);
|
3885 |
-
updateDisplaySimple(cm, {top: top, bottom: bot});
|
3886 |
-
}
|
3887 |
-
|
3888 |
-
if (wheelSamples < 20) {
|
3889 |
-
if (display.wheelStartX == null) {
|
3890 |
-
display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
|
3891 |
-
display.wheelDX = dx; display.wheelDY = dy;
|
3892 |
-
setTimeout(function() {
|
3893 |
-
if (display.wheelStartX == null) return;
|
3894 |
-
var movedX = scroll.scrollLeft - display.wheelStartX;
|
3895 |
-
var movedY = scroll.scrollTop - display.wheelStartY;
|
3896 |
-
var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
|
3897 |
-
(movedX && display.wheelDX && movedX / display.wheelDX);
|
3898 |
-
display.wheelStartX = display.wheelStartY = null;
|
3899 |
-
if (!sample) return;
|
3900 |
-
wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
|
3901 |
-
++wheelSamples;
|
3902 |
-
}, 200);
|
3903 |
-
} else {
|
3904 |
-
display.wheelDX += dx; display.wheelDY += dy;
|
3905 |
-
}
|
3906 |
-
}
|
3907 |
-
}
|
3908 |
-
|
3909 |
-
// KEY EVENTS
|
3910 |
-
|
3911 |
-
// Run a handler that was bound to a key.
|
3912 |
-
function doHandleBinding(cm, bound, dropShift) {
|
3913 |
-
if (typeof bound == "string") {
|
3914 |
-
bound = commands[bound];
|
3915 |
-
if (!bound) return false;
|
3916 |
-
}
|
3917 |
-
// Ensure previous input has been read, so that the handler sees a
|
3918 |
-
// consistent view of the document
|
3919 |
-
cm.display.input.ensurePolled();
|
3920 |
-
var prevShift = cm.display.shift, done = false;
|
3921 |
-
try {
|
3922 |
-
if (isReadOnly(cm)) cm.state.suppressEdits = true;
|
3923 |
-
if (dropShift) cm.display.shift = false;
|
3924 |
-
done = bound(cm) != Pass;
|
3925 |
-
} finally {
|
3926 |
-
cm.display.shift = prevShift;
|
3927 |
-
cm.state.suppressEdits = false;
|
3928 |
-
}
|
3929 |
-
return done;
|
3930 |
-
}
|
3931 |
-
|
3932 |
-
function lookupKeyForEditor(cm, name, handle) {
|
3933 |
-
for (var i = 0; i < cm.state.keyMaps.length; i++) {
|
3934 |
-
var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
|
3935 |
-
if (result) return result;
|
3936 |
-
}
|
3937 |
-
return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
|
3938 |
-
|| lookupKey(name, cm.options.keyMap, handle, cm);
|
3939 |
-
}
|
3940 |
-
|
3941 |
-
var stopSeq = new Delayed;
|
3942 |
-
function dispatchKey(cm, name, e, handle) {
|
3943 |
-
var seq = cm.state.keySeq;
|
3944 |
-
if (seq) {
|
3945 |
-
if (isModifierKey(name)) return "handled";
|
3946 |
-
stopSeq.set(50, function() {
|
3947 |
-
if (cm.state.keySeq == seq) {
|
3948 |
-
cm.state.keySeq = null;
|
3949 |
-
cm.display.input.reset();
|
3950 |
-
}
|
3951 |
-
});
|
3952 |
-
name = seq + " " + name;
|
3953 |
-
}
|
3954 |
-
var result = lookupKeyForEditor(cm, name, handle);
|
3955 |
-
|
3956 |
-
if (result == "multi")
|
3957 |
-
cm.state.keySeq = name;
|
3958 |
-
if (result == "handled")
|
3959 |
-
signalLater(cm, "keyHandled", cm, name, e);
|
3960 |
-
|
3961 |
-
if (result == "handled" || result == "multi") {
|
3962 |
-
e_preventDefault(e);
|
3963 |
-
restartBlink(cm);
|
3964 |
-
}
|
3965 |
-
|
3966 |
-
if (seq && !result && /\'$/.test(name)) {
|
3967 |
-
e_preventDefault(e);
|
3968 |
-
return true;
|
3969 |
-
}
|
3970 |
-
return !!result;
|
3971 |
-
}
|
3972 |
-
|
3973 |
-
// Handle a key from the keydown event.
|
3974 |
-
function handleKeyBinding(cm, e) {
|
3975 |
-
var name = keyName(e, true);
|
3976 |
-
if (!name) return false;
|
3977 |
-
|
3978 |
-
if (e.shiftKey && !cm.state.keySeq) {
|
3979 |
-
// First try to resolve full name (including 'Shift-'). Failing
|
3980 |
-
// that, see if there is a cursor-motion command (starting with
|
3981 |
-
// 'go') bound to the keyname without 'Shift-'.
|
3982 |
-
return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);})
|
3983 |
-
|| dispatchKey(cm, name, e, function(b) {
|
3984 |
-
if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
|
3985 |
-
return doHandleBinding(cm, b);
|
3986 |
-
});
|
3987 |
-
} else {
|
3988 |
-
return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); });
|
3989 |
-
}
|
3990 |
-
}
|
3991 |
-
|
3992 |
-
// Handle a key from the keypress event
|
3993 |
-
function handleCharBinding(cm, e, ch) {
|
3994 |
-
return dispatchKey(cm, "'" + ch + "'", e,
|
3995 |
-
function(b) { return doHandleBinding(cm, b, true); });
|
3996 |
-
}
|
3997 |
-
|
3998 |
-
var lastStoppedKey = null;
|
3999 |
-
function onKeyDown(e) {
|
4000 |
-
var cm = this;
|
4001 |
-
ensureFocus(cm);
|
4002 |
-
if (signalDOMEvent(cm, e)) return;
|
4003 |
-
// IE does strange things with escape.
|
4004 |
-
if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
|
4005 |
-
var code = e.keyCode;
|
4006 |
-
cm.display.shift = code == 16 || e.shiftKey;
|
4007 |
-
var handled = handleKeyBinding(cm, e);
|
4008 |
-
if (presto) {
|
4009 |
-
lastStoppedKey = handled ? code : null;
|
4010 |
-
// Opera has no cut event... we try to at least catch the key combo
|
4011 |
-
if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
|
4012 |
-
cm.replaceSelection("", null, "cut");
|
4013 |
-
}
|
4014 |
-
|
4015 |
-
// Turn mouse into crosshair when Alt is held on Mac.
|
4016 |
-
if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
|
4017 |
-
showCrossHair(cm);
|
4018 |
-
}
|
4019 |
-
|
4020 |
-
function showCrossHair(cm) {
|
4021 |
-
var lineDiv = cm.display.lineDiv;
|
4022 |
-
addClass(lineDiv, "CodeMirror-crosshair");
|
4023 |
-
|
4024 |
-
function up(e) {
|
4025 |
-
if (e.keyCode == 18 || !e.altKey) {
|
4026 |
-
rmClass(lineDiv, "CodeMirror-crosshair");
|
4027 |
-
off(document, "keyup", up);
|
4028 |
-
off(document, "mouseover", up);
|
4029 |
-
}
|
4030 |
-
}
|
4031 |
-
on(document, "keyup", up);
|
4032 |
-
on(document, "mouseover", up);
|
4033 |
-
}
|
4034 |
-
|
4035 |
-
function onKeyUp(e) {
|
4036 |
-
if (e.keyCode == 16) this.doc.sel.shift = false;
|
4037 |
-
signalDOMEvent(this, e);
|
4038 |
-
}
|
4039 |
-
|
4040 |
-
function onKeyPress(e) {
|
4041 |
-
var cm = this;
|
4042 |
-
if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
|
4043 |
-
var keyCode = e.keyCode, charCode = e.charCode;
|
4044 |
-
if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
|
4045 |
-
if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return;
|
4046 |
-
var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
|
4047 |
-
if (handleCharBinding(cm, e, ch)) return;
|
4048 |
-
cm.display.input.onKeyPress(e);
|
4049 |
-
}
|
4050 |
-
|
4051 |
-
// FOCUS/BLUR EVENTS
|
4052 |
-
|
4053 |
-
function onFocus(cm) {
|
4054 |
-
if (cm.options.readOnly == "nocursor") return;
|
4055 |
-
if (!cm.state.focused) {
|
4056 |
-
signal(cm, "focus", cm);
|
4057 |
-
cm.state.focused = true;
|
4058 |
-
addClass(cm.display.wrapper, "CodeMirror-focused");
|
4059 |
-
// This test prevents this from firing when a context
|
4060 |
-
// menu is closed (since the input reset would kill the
|
4061 |
-
// select-all detection hack)
|
4062 |
-
if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
|
4063 |
-
cm.display.input.reset();
|
4064 |
-
if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730
|
4065 |
-
}
|
4066 |
-
cm.display.input.receivedFocus();
|
4067 |
-
}
|
4068 |
-
restartBlink(cm);
|
4069 |
-
}
|
4070 |
-
function onBlur(cm) {
|
4071 |
-
if (cm.state.focused) {
|
4072 |
-
signal(cm, "blur", cm);
|
4073 |
-
cm.state.focused = false;
|
4074 |
-
rmClass(cm.display.wrapper, "CodeMirror-focused");
|
4075 |
-
}
|
4076 |
-
clearInterval(cm.display.blinker);
|
4077 |
-
setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
|
4078 |
-
}
|
4079 |
-
|
4080 |
-
// CONTEXT MENU HANDLING
|
4081 |
-
|
4082 |
-
// To make the context menu work, we need to briefly unhide the
|
4083 |
-
// textarea (making it as unobtrusive as possible) to let the
|
4084 |
-
// right-click take effect on it.
|
4085 |
-
function onContextMenu(cm, e) {
|
4086 |
-
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
|
4087 |
-
cm.display.input.onContextMenu(e);
|
4088 |
-
}
|
4089 |
-
|
4090 |
-
function contextMenuInGutter(cm, e) {
|
4091 |
-
if (!hasHandler(cm, "gutterContextMenu")) return false;
|
4092 |
-
return gutterEvent(cm, e, "gutterContextMenu", false, signal);
|
4093 |
-
}
|
4094 |
-
|
4095 |
-
// UPDATING
|
4096 |
-
|
4097 |
-
// Compute the position of the end of a change (its 'to' property
|
4098 |
-
// refers to the pre-change end).
|
4099 |
-
var changeEnd = CodeMirror.changeEnd = function(change) {
|
4100 |
-
if (!change.text) return change.to;
|
4101 |
-
return Pos(change.from.line + change.text.length - 1,
|
4102 |
-
lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
|
4103 |
-
};
|
4104 |
-
|
4105 |
-
// Adjust a position to refer to the post-change position of the
|
4106 |
-
// same text, or the end of the change if the change covers it.
|
4107 |
-
function adjustForChange(pos, change) {
|
4108 |
-
if (cmp(pos, change.from) < 0) return pos;
|
4109 |
-
if (cmp(pos, change.to) <= 0) return changeEnd(change);
|
4110 |
-
|
4111 |
-
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
|
4112 |
-
if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
|
4113 |
-
return Pos(line, ch);
|
4114 |
-
}
|
4115 |
-
|
4116 |
-
function computeSelAfterChange(doc, change) {
|
4117 |
-
var out = [];
|
4118 |
-
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
4119 |
-
var range = doc.sel.ranges[i];
|
4120 |
-
out.push(new Range(adjustForChange(range.anchor, change),
|
4121 |
-
adjustForChange(range.head, change)));
|
4122 |
-
}
|
4123 |
-
return normalizeSelection(out, doc.sel.primIndex);
|
4124 |
-
}
|
4125 |
-
|
4126 |
-
function offsetPos(pos, old, nw) {
|
4127 |
-
if (pos.line == old.line)
|
4128 |
-
return Pos(nw.line, pos.ch - old.ch + nw.ch);
|
4129 |
-
else
|
4130 |
-
return Pos(nw.line + (pos.line - old.line), pos.ch);
|
4131 |
-
}
|
4132 |
-
|
4133 |
-
// Used by replaceSelections to allow moving the selection to the
|
4134 |
-
// start or around the replaced test. Hint may be "start" or "around".
|
4135 |
-
function computeReplacedSel(doc, changes, hint) {
|
4136 |
-
var out = [];
|
4137 |
-
var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
|
4138 |
-
for (var i = 0; i < changes.length; i++) {
|
4139 |
-
var change = changes[i];
|
4140 |
-
var from = offsetPos(change.from, oldPrev, newPrev);
|
4141 |
-
var to = offsetPos(changeEnd(change), oldPrev, newPrev);
|
4142 |
-
oldPrev = change.to;
|
4143 |
-
newPrev = to;
|
4144 |
-
if (hint == "around") {
|
4145 |
-
var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
|
4146 |
-
out[i] = new Range(inv ? to : from, inv ? from : to);
|
4147 |
-
} else {
|
4148 |
-
out[i] = new Range(from, from);
|
4149 |
-
}
|
4150 |
-
}
|
4151 |
-
return new Selection(out, doc.sel.primIndex);
|
4152 |
-
}
|
4153 |
-
|
4154 |
-
// Allow "beforeChange" event handlers to influence a change
|
4155 |
-
function filterChange(doc, change, update) {
|
4156 |
-
var obj = {
|
4157 |
-
canceled: false,
|
4158 |
-
from: change.from,
|
4159 |
-
to: change.to,
|
4160 |
-
text: change.text,
|
4161 |
-
origin: change.origin,
|
4162 |
-
cancel: function() { this.canceled = true; }
|
4163 |
-
};
|
4164 |
-
if (update) obj.update = function(from, to, text, origin) {
|
4165 |
-
if (from) this.from = clipPos(doc, from);
|
4166 |
-
if (to) this.to = clipPos(doc, to);
|
4167 |
-
if (text) this.text = text;
|
4168 |
-
if (origin !== undefined) this.origin = origin;
|
4169 |
-
};
|
4170 |
-
signal(doc, "beforeChange", doc, obj);
|
4171 |
-
if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
|
4172 |
-
|
4173 |
-
if (obj.canceled) return null;
|
4174 |
-
return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
|
4175 |
-
}
|
4176 |
-
|
4177 |
-
// Apply a change to a document, and add it to the document's
|
4178 |
-
// history, and propagating it to all linked documents.
|
4179 |
-
function makeChange(doc, change, ignoreReadOnly) {
|
4180 |
-
if (doc.cm) {
|
4181 |
-
if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
|
4182 |
-
if (doc.cm.state.suppressEdits) return;
|
4183 |
-
}
|
4184 |
-
|
4185 |
-
if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
|
4186 |
-
change = filterChange(doc, change, true);
|
4187 |
-
if (!change) return;
|
4188 |
-
}
|
4189 |
-
|
4190 |
-
// Possibly split or suppress the update based on the presence
|
4191 |
-
// of read-only spans in its range.
|
4192 |
-
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
|
4193 |
-
if (split) {
|
4194 |
-
for (var i = split.length - 1; i >= 0; --i)
|
4195 |
-
makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
|
4196 |
-
} else {
|
4197 |
-
makeChangeInner(doc, change);
|
4198 |
-
}
|
4199 |
-
}
|
4200 |
-
|
4201 |
-
function makeChangeInner(doc, change) {
|
4202 |
-
if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
|
4203 |
-
var selAfter = computeSelAfterChange(doc, change);
|
4204 |
-
addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
|
4205 |
-
|
4206 |
-
makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
|
4207 |
-
var rebased = [];
|
4208 |
-
|
4209 |
-
linkedDocs(doc, function(doc, sharedHist) {
|
4210 |
-
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
4211 |
-
rebaseHist(doc.history, change);
|
4212 |
-
rebased.push(doc.history);
|
4213 |
-
}
|
4214 |
-
makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
|
4215 |
-
});
|
4216 |
-
}
|
4217 |
-
|
4218 |
-
// Revert a change stored in a document's history.
|
4219 |
-
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
|
4220 |
-
if (doc.cm && doc.cm.state.suppressEdits) return;
|
4221 |
-
|
4222 |
-
var hist = doc.history, event, selAfter = doc.sel;
|
4223 |
-
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
|
4224 |
-
|
4225 |
-
// Verify that there is a useable event (so that ctrl-z won't
|
4226 |
-
// needlessly clear selection events)
|
4227 |
-
for (var i = 0; i < source.length; i++) {
|
4228 |
-
event = source[i];
|
4229 |
-
if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
|
4230 |
-
break;
|
4231 |
-
}
|
4232 |
-
if (i == source.length) return;
|
4233 |
-
hist.lastOrigin = hist.lastSelOrigin = null;
|
4234 |
-
|
4235 |
-
for (;;) {
|
4236 |
-
event = source.pop();
|
4237 |
-
if (event.ranges) {
|
4238 |
-
pushSelectionToHistory(event, dest);
|
4239 |
-
if (allowSelectionOnly && !event.equals(doc.sel)) {
|
4240 |
-
setSelection(doc, event, {clearRedo: false});
|
4241 |
-
return;
|
4242 |
-
}
|
4243 |
-
selAfter = event;
|
4244 |
-
}
|
4245 |
-
else break;
|
4246 |
-
}
|
4247 |
-
|
4248 |
-
// Build up a reverse change object to add to the opposite history
|
4249 |
-
// stack (redo when undoing, and vice versa).
|
4250 |
-
var antiChanges = [];
|
4251 |
-
pushSelectionToHistory(selAfter, dest);
|
4252 |
-
dest.push({changes: antiChanges, generation: hist.generation});
|
4253 |
-
hist.generation = event.generation || ++hist.maxGeneration;
|
4254 |
-
|
4255 |
-
var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
|
4256 |
-
|
4257 |
-
for (var i = event.changes.length - 1; i >= 0; --i) {
|
4258 |
-
var change = event.changes[i];
|
4259 |
-
change.origin = type;
|
4260 |
-
if (filter && !filterChange(doc, change, false)) {
|
4261 |
-
source.length = 0;
|
4262 |
-
return;
|
4263 |
-
}
|
4264 |
-
|
4265 |
-
antiChanges.push(historyChangeFromChange(doc, change));
|
4266 |
-
|
4267 |
-
var after = i ? computeSelAfterChange(doc, change) : lst(source);
|
4268 |
-
makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
|
4269 |
-
if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
|
4270 |
-
var rebased = [];
|
4271 |
-
|
4272 |
-
// Propagate to the linked documents
|
4273 |
-
linkedDocs(doc, function(doc, sharedHist) {
|
4274 |
-
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
4275 |
-
rebaseHist(doc.history, change);
|
4276 |
-
rebased.push(doc.history);
|
4277 |
-
}
|
4278 |
-
makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
|
4279 |
-
});
|
4280 |
-
}
|
4281 |
-
}
|
4282 |
-
|
4283 |
-
// Sub-views need their line numbers shifted when text is added
|
4284 |
-
// above or below them in the parent document.
|
4285 |
-
function shiftDoc(doc, distance) {
|
4286 |
-
if (distance == 0) return;
|
4287 |
-
doc.first += distance;
|
4288 |
-
doc.sel = new Selection(map(doc.sel.ranges, function(range) {
|
4289 |
-
return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
|
4290 |
-
Pos(range.head.line + distance, range.head.ch));
|
4291 |
-
}), doc.sel.primIndex);
|
4292 |
-
if (doc.cm) {
|
4293 |
-
regChange(doc.cm, doc.first, doc.first - distance, distance);
|
4294 |
-
for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
|
4295 |
-
regLineChange(doc.cm, l, "gutter");
|
4296 |
-
}
|
4297 |
-
}
|
4298 |
-
|
4299 |
-
// More lower-level change function, handling only a single document
|
4300 |
-
// (not linked ones).
|
4301 |
-
function makeChangeSingleDoc(doc, change, selAfter, spans) {
|
4302 |
-
if (doc.cm && !doc.cm.curOp)
|
4303 |
-
return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
|
4304 |
-
|
4305 |
-
if (change.to.line < doc.first) {
|
4306 |
-
shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
|
4307 |
-
return;
|
4308 |
-
}
|
4309 |
-
if (change.from.line > doc.lastLine()) return;
|
4310 |
-
|
4311 |
-
// Clip the change to the size of this doc
|
4312 |
-
if (change.from.line < doc.first) {
|
4313 |
-
var shift = change.text.length - 1 - (doc.first - change.from.line);
|
4314 |
-
shiftDoc(doc, shift);
|
4315 |
-
change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
|
4316 |
-
text: [lst(change.text)], origin: change.origin};
|
4317 |
-
}
|
4318 |
-
var last = doc.lastLine();
|
4319 |
-
if (change.to.line > last) {
|
4320 |
-
change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
|
4321 |
-
text: [change.text[0]], origin: change.origin};
|
4322 |
-
}
|
4323 |
-
|
4324 |
-
change.removed = getBetween(doc, change.from, change.to);
|
4325 |
-
|
4326 |
-
if (!selAfter) selAfter = computeSelAfterChange(doc, change);
|
4327 |
-
if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
|
4328 |
-
else updateDoc(doc, change, spans);
|
4329 |
-
setSelectionNoUndo(doc, selAfter, sel_dontScroll);
|
4330 |
-
}
|
4331 |
-
|
4332 |
-
// Handle the interaction of a change to a document with the editor
|
4333 |
-
// that this document is part of.
|
4334 |
-
function makeChangeSingleDocInEditor(cm, change, spans) {
|
4335 |
-
var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
|
4336 |
-
|
4337 |
-
var recomputeMaxLength = false, checkWidthStart = from.line;
|
4338 |
-
if (!cm.options.lineWrapping) {
|
4339 |
-
checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
|
4340 |
-
doc.iter(checkWidthStart, to.line + 1, function(line) {
|
4341 |
-
if (line == display.maxLine) {
|
4342 |
-
recomputeMaxLength = true;
|
4343 |
-
return true;
|
4344 |
-
}
|
4345 |
-
});
|
4346 |
-
}
|
4347 |
-
|
4348 |
-
if (doc.sel.contains(change.from, change.to) > -1)
|
4349 |
-
signalCursorActivity(cm);
|
4350 |
-
|
4351 |
-
updateDoc(doc, change, spans, estimateHeight(cm));
|
4352 |
-
|
4353 |
-
if (!cm.options.lineWrapping) {
|
4354 |
-
doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
|
4355 |
-
var len = lineLength(line);
|
4356 |
-
if (len > display.maxLineLength) {
|
4357 |
-
display.maxLine = line;
|
4358 |
-
display.maxLineLength = len;
|
4359 |
-
display.maxLineChanged = true;
|
4360 |
-
recomputeMaxLength = false;
|
4361 |
-
}
|
4362 |
-
});
|
4363 |
-
if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
|
4364 |
-
}
|
4365 |
-
|
4366 |
-
// Adjust frontier, schedule worker
|
4367 |
-
doc.frontier = Math.min(doc.frontier, from.line);
|
4368 |
-
startWorker(cm, 400);
|
4369 |
-
|
4370 |
-
var lendiff = change.text.length - (to.line - from.line) - 1;
|
4371 |
-
// Remember that these lines changed, for updating the display
|
4372 |
-
if (change.full)
|
4373 |
-
regChange(cm);
|
4374 |
-
else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
|
4375 |
-
regLineChange(cm, from.line, "text");
|
4376 |
-
else
|
4377 |
-
regChange(cm, from.line, to.line + 1, lendiff);
|
4378 |
-
|
4379 |
-
var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
|
4380 |
-
if (changeHandler || changesHandler) {
|
4381 |
-
var obj = {
|
4382 |
-
from: from, to: to,
|
4383 |
-
text: change.text,
|
4384 |
-
removed: change.removed,
|
4385 |
-
origin: change.origin
|
4386 |
-
};
|
4387 |
-
if (changeHandler) signalLater(cm, "change", cm, obj);
|
4388 |
-
if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
|
4389 |
-
}
|
4390 |
-
cm.display.selForContextMenu = null;
|
4391 |
-
}
|
4392 |
-
|
4393 |
-
function replaceRange(doc, code, from, to, origin) {
|
4394 |
-
if (!to) to = from;
|
4395 |
-
if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
|
4396 |
-
if (typeof code == "string") code = splitLines(code);
|
4397 |
-
makeChange(doc, {from: from, to: to, text: code, origin: origin});
|
4398 |
-
}
|
4399 |
-
|
4400 |
-
// SCROLLING THINGS INTO VIEW
|
4401 |
-
|
4402 |
-
// If an editor sits on the top or bottom of the window, partially
|
4403 |
-
// scrolled out of view, this ensures that the cursor is visible.
|
4404 |
-
function maybeScrollWindow(cm, coords) {
|
4405 |
-
if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
|
4406 |
-
|
4407 |
-
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
|
4408 |
-
if (coords.top + box.top < 0) doScroll = true;
|
4409 |
-
else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
|
4410 |
-
if (doScroll != null && !phantom) {
|
4411 |
-
var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
|
4412 |
-
(coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
|
4413 |
-
(coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
|
4414 |
-
coords.left + "px; width: 2px;");
|
4415 |
-
cm.display.lineSpace.appendChild(scrollNode);
|
4416 |
-
scrollNode.scrollIntoView(doScroll);
|
4417 |
-
cm.display.lineSpace.removeChild(scrollNode);
|
4418 |
-
}
|
4419 |
-
}
|
4420 |
-
|
4421 |
-
// Scroll a given position into view (immediately), verifying that
|
4422 |
-
// it actually became visible (as line heights are accurately
|
4423 |
-
// measured, the position of something may 'drift' during drawing).
|
4424 |
-
function scrollPosIntoView(cm, pos, end, margin) {
|
4425 |
-
if (margin == null) margin = 0;
|
4426 |
-
for (var limit = 0; limit < 5; limit++) {
|
4427 |
-
var changed = false, coords = cursorCoords(cm, pos);
|
4428 |
-
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
|
4429 |
-
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
|
4430 |
-
Math.min(coords.top, endCoords.top) - margin,
|
4431 |
-
Math.max(coords.left, endCoords.left),
|
4432 |
-
Math.max(coords.bottom, endCoords.bottom) + margin);
|
4433 |
-
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
|
4434 |
-
if (scrollPos.scrollTop != null) {
|
4435 |
-
setScrollTop(cm, scrollPos.scrollTop);
|
4436 |
-
if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
|
4437 |
-
}
|
4438 |
-
if (scrollPos.scrollLeft != null) {
|
4439 |
-
setScrollLeft(cm, scrollPos.scrollLeft);
|
4440 |
-
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
|
4441 |
-
}
|
4442 |
-
if (!changed) break;
|
4443 |
-
}
|
4444 |
-
return coords;
|
4445 |
-
}
|
4446 |
-
|
4447 |
-
// Scroll a given set of coordinates into view (immediately).
|
4448 |
-
function scrollIntoView(cm, x1, y1, x2, y2) {
|
4449 |
-
var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
|
4450 |
-
if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
|
4451 |
-
if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
|
4452 |
-
}
|
4453 |
-
|
4454 |
-
// Calculate a new scroll position needed to scroll the given
|
4455 |
-
// rectangle into view. Returns an object with scrollTop and
|
4456 |
-
// scrollLeft properties. When these are undefined, the
|
4457 |
-
// vertical/horizontal position does not need to be adjusted.
|
4458 |
-
function calculateScrollPos(cm, x1, y1, x2, y2) {
|
4459 |
-
var display = cm.display, snapMargin = textHeight(cm.display);
|
4460 |
-
if (y1 < 0) y1 = 0;
|
4461 |
-
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
|
4462 |
-
var screen = displayHeight(cm), result = {};
|
4463 |
-
if (y2 - y1 > screen) y2 = y1 + screen;
|
4464 |
-
var docBottom = cm.doc.height + paddingVert(display);
|
4465 |
-
var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
|
4466 |
-
if (y1 < screentop) {
|
4467 |
-
result.scrollTop = atTop ? 0 : y1;
|
4468 |
-
} else if (y2 > screentop + screen) {
|
4469 |
-
var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
|
4470 |
-
if (newTop != screentop) result.scrollTop = newTop;
|
4471 |
-
}
|
4472 |
-
|
4473 |
-
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
|
4474 |
-
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
|
4475 |
-
var tooWide = x2 - x1 > screenw;
|
4476 |
-
if (tooWide) x2 = x1 + screenw;
|
4477 |
-
if (x1 < 10)
|
4478 |
-
result.scrollLeft = 0;
|
4479 |
-
else if (x1 < screenleft)
|
4480 |
-
result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
|
4481 |
-
else if (x2 > screenw + screenleft - 3)
|
4482 |
-
result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
|
4483 |
-
return result;
|
4484 |
-
}
|
4485 |
-
|
4486 |
-
// Store a relative adjustment to the scroll position in the current
|
4487 |
-
// operation (to be applied when the operation finishes).
|
4488 |
-
function addToScrollPos(cm, left, top) {
|
4489 |
-
if (left != null || top != null) resolveScrollToPos(cm);
|
4490 |
-
if (left != null)
|
4491 |
-
cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
|
4492 |
-
if (top != null)
|
4493 |
-
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
|
4494 |
-
}
|
4495 |
-
|
4496 |
-
// Make sure that at the end of the operation the current cursor is
|
4497 |
-
// shown.
|
4498 |
-
function ensureCursorVisible(cm) {
|
4499 |
-
resolveScrollToPos(cm);
|
4500 |
-
var cur = cm.getCursor(), from = cur, to = cur;
|
4501 |
-
if (!cm.options.lineWrapping) {
|
4502 |
-
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
|
4503 |
-
to = Pos(cur.line, cur.ch + 1);
|
4504 |
-
}
|
4505 |
-
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
|
4506 |
-
}
|
4507 |
-
|
4508 |
-
// When an operation has its scrollToPos property set, and another
|
4509 |
-
// scroll action is applied before the end of the operation, this
|
4510 |
-
// 'simulates' scrolling that position into view in a cheap way, so
|
4511 |
-
// that the effect of intermediate scroll commands is not ignored.
|
4512 |
-
function resolveScrollToPos(cm) {
|
4513 |
-
var range = cm.curOp.scrollToPos;
|
4514 |
-
if (range) {
|
4515 |
-
cm.curOp.scrollToPos = null;
|
4516 |
-
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
|
4517 |
-
var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
|
4518 |
-
Math.min(from.top, to.top) - range.margin,
|
4519 |
-
Math.max(from.right, to.right),
|
4520 |
-
Math.max(from.bottom, to.bottom) + range.margin);
|
4521 |
-
cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
|
4522 |
-
}
|
4523 |
-
}
|
4524 |
-
|
4525 |
-
// API UTILITIES
|
4526 |
-
|
4527 |
-
// Indent the given line. The how parameter can be "smart",
|
4528 |
-
// "add"/null, "subtract", or "prev". When aggressive is false
|
4529 |
-
// (typically set to true for forced single-line indents), empty
|
4530 |
-
// lines are not indented, and places where the mode returns Pass
|
4531 |
-
// are left alone.
|
4532 |
-
function indentLine(cm, n, how, aggressive) {
|
4533 |
-
var doc = cm.doc, state;
|
4534 |
-
if (how == null) how = "add";
|
4535 |
-
if (how == "smart") {
|
4536 |
-
// Fall back to "prev" when the mode doesn't have an indentation
|
4537 |
-
// method.
|
4538 |
-
if (!doc.mode.indent) how = "prev";
|
4539 |
-
else state = getStateBefore(cm, n);
|
4540 |
-
}
|
4541 |
-
|
4542 |
-
var tabSize = cm.options.tabSize;
|
4543 |
-
var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
|
4544 |
-
if (line.stateAfter) line.stateAfter = null;
|
4545 |
-
var curSpaceString = line.text.match(/^\s*/)[0], indentation;
|
4546 |
-
if (!aggressive && !/\S/.test(line.text)) {
|
4547 |
-
indentation = 0;
|
4548 |
-
how = "not";
|
4549 |
-
} else if (how == "smart") {
|
4550 |
-
indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
|
4551 |
-
if (indentation == Pass || indentation > 150) {
|
4552 |
-
if (!aggressive) return;
|
4553 |
-
how = "prev";
|
4554 |
-
}
|
4555 |
-
}
|
4556 |
-
if (how == "prev") {
|
4557 |
-
if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
|
4558 |
-
else indentation = 0;
|
4559 |
-
} else if (how == "add") {
|
4560 |
-
indentation = curSpace + cm.options.indentUnit;
|
4561 |
-
} else if (how == "subtract") {
|
4562 |
-
indentation = curSpace - cm.options.indentUnit;
|
4563 |
-
} else if (typeof how == "number") {
|
4564 |
-
indentation = curSpace + how;
|
4565 |
-
}
|
4566 |
-
indentation = Math.max(0, indentation);
|
4567 |
-
|
4568 |
-
var indentString = "", pos = 0;
|
4569 |
-
if (cm.options.indentWithTabs)
|
4570 |
-
for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
|
4571 |
-
if (pos < indentation) indentString += spaceStr(indentation - pos);
|
4572 |
-
|
4573 |
-
if (indentString != curSpaceString) {
|
4574 |
-
replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
|
4575 |
-
} else {
|
4576 |
-
// Ensure that, if the cursor was in the whitespace at the start
|
4577 |
-
// of the line, it is moved to the end of that space.
|
4578 |
-
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
4579 |
-
var range = doc.sel.ranges[i];
|
4580 |
-
if (range.head.line == n && range.head.ch < curSpaceString.length) {
|
4581 |
-
var pos = Pos(n, curSpaceString.length);
|
4582 |
-
replaceOneSelection(doc, i, new Range(pos, pos));
|
4583 |
-
break;
|
4584 |
-
}
|
4585 |
-
}
|
4586 |
-
}
|
4587 |
-
line.stateAfter = null;
|
4588 |
-
}
|
4589 |
-
|
4590 |
-
// Utility for applying a change to a line by handle or number,
|
4591 |
-
// returning the number and optionally registering the line as
|
4592 |
-
// changed.
|
4593 |
-
function changeLine(doc, handle, changeType, op) {
|
4594 |
-
var no = handle, line = handle;
|
4595 |
-
if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
|
4596 |
-
else no = lineNo(handle);
|
4597 |
-
if (no == null) return null;
|
4598 |
-
if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
|
4599 |
-
return line;
|
4600 |
-
}
|
4601 |
-
|
4602 |
-
// Helper for deleting text near the selection(s), used to implement
|
4603 |
-
// backspace, delete, and similar functionality.
|
4604 |
-
function deleteNearSelection(cm, compute) {
|
4605 |
-
var ranges = cm.doc.sel.ranges, kill = [];
|
4606 |
-
// Build up a set of ranges to kill first, merging overlapping
|
4607 |
-
// ranges.
|
4608 |
-
for (var i = 0; i < ranges.length; i++) {
|
4609 |
-
var toKill = compute(ranges[i]);
|
4610 |
-
while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
|
4611 |
-
var replaced = kill.pop();
|
4612 |
-
if (cmp(replaced.from, toKill.from) < 0) {
|
4613 |
-
toKill.from = replaced.from;
|
4614 |
-
break;
|
4615 |
-
}
|
4616 |
-
}
|
4617 |
-
kill.push(toKill);
|
4618 |
-
}
|
4619 |
-
// Next, remove those actual ranges.
|
4620 |
-
runInOp(cm, function() {
|
4621 |
-
for (var i = kill.length - 1; i >= 0; i--)
|
4622 |
-
replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
|
4623 |
-
ensureCursorVisible(cm);
|
4624 |
-
});
|
4625 |
-
}
|
4626 |
-
|
4627 |
-
// Used for horizontal relative motion. Dir is -1 or 1 (left or
|
4628 |
-
// right), unit can be "char", "column" (like char, but doesn't
|
4629 |
-
// cross line boundaries), "word" (across next word), or "group" (to
|
4630 |
-
// the start of next group of word or non-word-non-whitespace
|
4631 |
-
// chars). The visually param controls whether, in right-to-left
|
4632 |
-
// text, direction 1 means to move towards the next index in the
|
4633 |
-
// string, or towards the character to the right of the current
|
4634 |
-
// position. The resulting position will have a hitSide=true
|
4635 |
-
// property if it reached the end of the document.
|
4636 |
-
function findPosH(doc, pos, dir, unit, visually) {
|
4637 |
-
var line = pos.line, ch = pos.ch, origDir = dir;
|
4638 |
-
var lineObj = getLine(doc, line);
|
4639 |
-
var possible = true;
|
4640 |
-
function findNextLine() {
|
4641 |
-
var l = line + dir;
|
4642 |
-
if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
|
4643 |
-
line = l;
|
4644 |
-
return lineObj = getLine(doc, l);
|
4645 |
-
}
|
4646 |
-
function moveOnce(boundToLine) {
|
4647 |
-
var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
|
4648 |
-
if (next == null) {
|
4649 |
-
if (!boundToLine && findNextLine()) {
|
4650 |
-
if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
|
4651 |
-
else ch = dir < 0 ? lineObj.text.length : 0;
|
4652 |
-
} else return (possible = false);
|
4653 |
-
} else ch = next;
|
4654 |
-
return true;
|
4655 |
-
}
|
4656 |
-
|
4657 |
-
if (unit == "char") moveOnce();
|
4658 |
-
else if (unit == "column") moveOnce(true);
|
4659 |
-
else if (unit == "word" || unit == "group") {
|
4660 |
-
var sawType = null, group = unit == "group";
|
4661 |
-
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
|
4662 |
-
for (var first = true;; first = false) {
|
4663 |
-
if (dir < 0 && !moveOnce(!first)) break;
|
4664 |
-
var cur = lineObj.text.charAt(ch) || "\n";
|
4665 |
-
var type = isWordChar(cur, helper) ? "w"
|
4666 |
-
: group && cur == "\n" ? "n"
|
4667 |
-
: !group || /\s/.test(cur) ? null
|
4668 |
-
: "p";
|
4669 |
-
if (group && !first && !type) type = "s";
|
4670 |
-
if (sawType && sawType != type) {
|
4671 |
-
if (dir < 0) {dir = 1; moveOnce();}
|
4672 |
-
break;
|
4673 |
-
}
|
4674 |
-
|
4675 |
-
if (type) sawType = type;
|
4676 |
-
if (dir > 0 && !moveOnce(!first)) break;
|
4677 |
-
}
|
4678 |
-
}
|
4679 |
-
var result = skipAtomic(doc, Pos(line, ch), origDir, true);
|
4680 |
-
if (!possible) result.hitSide = true;
|
4681 |
-
return result;
|
4682 |
-
}
|
4683 |
-
|
4684 |
-
// For relative vertical movement. Dir may be -1 or 1. Unit can be
|
4685 |
-
// "page" or "line". The resulting position will have a hitSide=true
|
4686 |
-
// property if it reached the end of the document.
|
4687 |
-
function findPosV(cm, pos, dir, unit) {
|
4688 |
-
var doc = cm.doc, x = pos.left, y;
|
4689 |
-
if (unit == "page") {
|
4690 |
-
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
4691 |
-
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
|
4692 |
-
} else if (unit == "line") {
|
4693 |
-
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
|
4694 |
-
}
|
4695 |
-
for (;;) {
|
4696 |
-
var target = coordsChar(cm, x, y);
|
4697 |
-
if (!target.outside) break;
|
4698 |
-
if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
|
4699 |
-
y += dir * 5;
|
4700 |
-
}
|
4701 |
-
return target;
|
4702 |
-
}
|
4703 |
-
|
4704 |
-
// EDITOR METHODS
|
4705 |
-
|
4706 |
-
// The publicly visible API. Note that methodOp(f) means
|
4707 |
-
// 'wrap f in an operation, performed on its `this` parameter'.
|
4708 |
-
|
4709 |
-
// This is not the complete set of editor methods. Most of the
|
4710 |
-
// methods defined on the Doc type are also injected into
|
4711 |
-
// CodeMirror.prototype, for backwards compatibility and
|
4712 |
-
// convenience.
|
4713 |
-
|
4714 |
-
CodeMirror.prototype = {
|
4715 |
-
constructor: CodeMirror,
|
4716 |
-
focus: function(){window.focus(); this.display.input.focus();},
|
4717 |
-
|
4718 |
-
setOption: function(option, value) {
|
4719 |
-
var options = this.options, old = options[option];
|
4720 |
-
if (options[option] == value && option != "mode") return;
|
4721 |
-
options[option] = value;
|
4722 |
-
if (optionHandlers.hasOwnProperty(option))
|
4723 |
-
operation(this, optionHandlers[option])(this, value, old);
|
4724 |
-
},
|
4725 |
-
|
4726 |
-
getOption: function(option) {return this.options[option];},
|
4727 |
-
getDoc: function() {return this.doc;},
|
4728 |
-
|
4729 |
-
addKeyMap: function(map, bottom) {
|
4730 |
-
this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
|
4731 |
-
},
|
4732 |
-
removeKeyMap: function(map) {
|
4733 |
-
var maps = this.state.keyMaps;
|
4734 |
-
for (var i = 0; i < maps.length; ++i)
|
4735 |
-
if (maps[i] == map || maps[i].name == map) {
|
4736 |
-
maps.splice(i, 1);
|
4737 |
-
return true;
|
4738 |
-
}
|
4739 |
-
},
|
4740 |
-
|
4741 |
-
addOverlay: methodOp(function(spec, options) {
|
4742 |
-
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
|
4743 |
-
if (mode.startState) throw new Error("Overlays may not be stateful.");
|
4744 |
-
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
|
4745 |
-
this.state.modeGen++;
|
4746 |
-
regChange(this);
|
4747 |
-
}),
|
4748 |
-
removeOverlay: methodOp(function(spec) {
|
4749 |
-
var overlays = this.state.overlays;
|
4750 |
-
for (var i = 0; i < overlays.length; ++i) {
|
4751 |
-
var cur = overlays[i].modeSpec;
|
4752 |
-
if (cur == spec || typeof spec == "string" && cur.name == spec) {
|
4753 |
-
overlays.splice(i, 1);
|
4754 |
-
this.state.modeGen++;
|
4755 |
-
regChange(this);
|
4756 |
-
return;
|
4757 |
-
}
|
4758 |
-
}
|
4759 |
-
}),
|
4760 |
-
|
4761 |
-
indentLine: methodOp(function(n, dir, aggressive) {
|
4762 |
-
if (typeof dir != "string" && typeof dir != "number") {
|
4763 |
-
if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
|
4764 |
-
else dir = dir ? "add" : "subtract";
|
4765 |
-
}
|
4766 |
-
if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
|
4767 |
-
}),
|
4768 |
-
indentSelection: methodOp(function(how) {
|
4769 |
-
var ranges = this.doc.sel.ranges, end = -1;
|
4770 |
-
for (var i = 0; i < ranges.length; i++) {
|
4771 |
-
var range = ranges[i];
|
4772 |
-
if (!range.empty()) {
|
4773 |
-
var from = range.from(), to = range.to();
|
4774 |
-
var start = Math.max(end, from.line);
|
4775 |
-
end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
|
4776 |
-
for (var j = start; j < end; ++j)
|
4777 |
-
indentLine(this, j, how);
|
4778 |
-
var newRanges = this.doc.sel.ranges;
|
4779 |
-
if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
|
4780 |
-
replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
|
4781 |
-
} else if (range.head.line > end) {
|
4782 |
-
indentLine(this, range.head.line, how, true);
|
4783 |
-
end = range.head.line;
|
4784 |
-
if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
|
4785 |
-
}
|
4786 |
-
}
|
4787 |
-
}),
|
4788 |
-
|
4789 |
-
// Fetch the parser token for a given character. Useful for hacks
|
4790 |
-
// that want to inspect the mode state (say, for completion).
|
4791 |
-
getTokenAt: function(pos, precise) {
|
4792 |
-
return takeToken(this, pos, precise);
|
4793 |
-
},
|
4794 |
-
|
4795 |
-
getLineTokens: function(line, precise) {
|
4796 |
-
return takeToken(this, Pos(line), precise, true);
|
4797 |
-
},
|
4798 |
-
|
4799 |
-
getTokenTypeAt: function(pos) {
|
4800 |
-
pos = clipPos(this.doc, pos);
|
4801 |
-
var styles = getLineStyles(this, getLine(this.doc, pos.line));
|
4802 |
-
var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
|
4803 |
-
var type;
|
4804 |
-
if (ch == 0) type = styles[2];
|
4805 |
-
else for (;;) {
|
4806 |
-
var mid = (before + after) >> 1;
|
4807 |
-
if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
|
4808 |
-
else if (styles[mid * 2 + 1] < ch) before = mid + 1;
|
4809 |
-
else { type = styles[mid * 2 + 2]; break; }
|
4810 |
-
}
|
4811 |
-
var cut = type ? type.indexOf("cm-overlay ") : -1;
|
4812 |
-
return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
|
4813 |
-
},
|
4814 |
-
|
4815 |
-
getModeAt: function(pos) {
|
4816 |
-
var mode = this.doc.mode;
|
4817 |
-
if (!mode.innerMode) return mode;
|
4818 |
-
return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
|
4819 |
-
},
|
4820 |
-
|
4821 |
-
getHelper: function(pos, type) {
|
4822 |
-
return this.getHelpers(pos, type)[0];
|
4823 |
-
},
|
4824 |
-
|
4825 |
-
getHelpers: function(pos, type) {
|
4826 |
-
var found = [];
|
4827 |
-
if (!helpers.hasOwnProperty(type)) return helpers;
|
4828 |
-
var help = helpers[type], mode = this.getModeAt(pos);
|
4829 |
-
if (typeof mode[type] == "string") {
|
4830 |
-
if (help[mode[type]]) found.push(help[mode[type]]);
|
4831 |
-
} else if (mode[type]) {
|
4832 |
-
for (var i = 0; i < mode[type].length; i++) {
|
4833 |
-
var val = help[mode[type][i]];
|
4834 |
-
if (val) found.push(val);
|
4835 |
-
}
|
4836 |
-
} else if (mode.helperType && help[mode.helperType]) {
|
4837 |
-
found.push(help[mode.helperType]);
|
4838 |
-
} else if (help[mode.name]) {
|
4839 |
-
found.push(help[mode.name]);
|
4840 |
-
}
|
4841 |
-
for (var i = 0; i < help._global.length; i++) {
|
4842 |
-
var cur = help._global[i];
|
4843 |
-
if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
|
4844 |
-
found.push(cur.val);
|
4845 |
-
}
|
4846 |
-
return found;
|
4847 |
-
},
|
4848 |
-
|
4849 |
-
getStateAfter: function(line, precise) {
|
4850 |
-
var doc = this.doc;
|
4851 |
-
line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
|
4852 |
-
return getStateBefore(this, line + 1, precise);
|
4853 |
-
},
|
4854 |
-
|
4855 |
-
cursorCoords: function(start, mode) {
|
4856 |
-
var pos, range = this.doc.sel.primary();
|
4857 |
-
if (start == null) pos = range.head;
|
4858 |
-
else if (typeof start == "object") pos = clipPos(this.doc, start);
|
4859 |
-
else pos = start ? range.from() : range.to();
|
4860 |
-
return cursorCoords(this, pos, mode || "page");
|
4861 |
-
},
|
4862 |
-
|
4863 |
-
charCoords: function(pos, mode) {
|
4864 |
-
return charCoords(this, clipPos(this.doc, pos), mode || "page");
|
4865 |
-
},
|
4866 |
-
|
4867 |
-
coordsChar: function(coords, mode) {
|
4868 |
-
coords = fromCoordSystem(this, coords, mode || "page");
|
4869 |
-
return coordsChar(this, coords.left, coords.top);
|
4870 |
-
},
|
4871 |
-
|
4872 |
-
lineAtHeight: function(height, mode) {
|
4873 |
-
height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
|
4874 |
-
return lineAtHeight(this.doc, height + this.display.viewOffset);
|
4875 |
-
},
|
4876 |
-
heightAtLine: function(line, mode) {
|
4877 |
-
var end = false, last = this.doc.first + this.doc.size - 1;
|
4878 |
-
if (line < this.doc.first) line = this.doc.first;
|
4879 |
-
else if (line > last) { line = last; end = true; }
|
4880 |
-
var lineObj = getLine(this.doc, line);
|
4881 |
-
return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
|
4882 |
-
(end ? this.doc.height - heightAtLine(lineObj) : 0);
|
4883 |
-
},
|
4884 |
-
|
4885 |
-
defaultTextHeight: function() { return textHeight(this.display); },
|
4886 |
-
defaultCharWidth: function() { return charWidth(this.display); },
|
4887 |
-
|
4888 |
-
setGutterMarker: methodOp(function(line, gutterID, value) {
|
4889 |
-
return changeLine(this.doc, line, "gutter", function(line) {
|
4890 |
-
var markers = line.gutterMarkers || (line.gutterMarkers = {});
|
4891 |
-
markers[gutterID] = value;
|
4892 |
-
if (!value && isEmpty(markers)) line.gutterMarkers = null;
|
4893 |
-
return true;
|
4894 |
-
});
|
4895 |
-
}),
|
4896 |
-
|
4897 |
-
clearGutter: methodOp(function(gutterID) {
|
4898 |
-
var cm = this, doc = cm.doc, i = doc.first;
|
4899 |
-
doc.iter(function(line) {
|
4900 |
-
if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
|
4901 |
-
line.gutterMarkers[gutterID] = null;
|
4902 |
-
regLineChange(cm, i, "gutter");
|
4903 |
-
if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
|
4904 |
-
}
|
4905 |
-
++i;
|
4906 |
-
});
|
4907 |
-
}),
|
4908 |
-
|
4909 |
-
addLineWidget: methodOp(function(handle, node, options) {
|
4910 |
-
return addLineWidget(this, handle, node, options);
|
4911 |
-
}),
|
4912 |
-
|
4913 |
-
removeLineWidget: function(widget) { widget.clear(); },
|
4914 |
-
|
4915 |
-
lineInfo: function(line) {
|
4916 |
-
if (typeof line == "number") {
|
4917 |
-
if (!isLine(this.doc, line)) return null;
|
4918 |
-
var n = line;
|
4919 |
-
line = getLine(this.doc, line);
|
4920 |
-
if (!line) return null;
|
4921 |
-
} else {
|
4922 |
-
var n = lineNo(line);
|
4923 |
-
if (n == null) return null;
|
4924 |
-
}
|
4925 |
-
return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
|
4926 |
-
textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
|
4927 |
-
widgets: line.widgets};
|
4928 |
-
},
|
4929 |
-
|
4930 |
-
getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
|
4931 |
-
|
4932 |
-
addWidget: function(pos, node, scroll, vert, horiz) {
|
4933 |
-
var display = this.display;
|
4934 |
-
pos = cursorCoords(this, clipPos(this.doc, pos));
|
4935 |
-
var top = pos.bottom, left = pos.left;
|
4936 |
-
node.style.position = "absolute";
|
4937 |
-
node.setAttribute("cm-ignore-events", "true");
|
4938 |
-
this.display.input.setUneditable(node);
|
4939 |
-
display.sizer.appendChild(node);
|
4940 |
-
if (vert == "over") {
|
4941 |
-
top = pos.top;
|
4942 |
-
} else if (vert == "above" || vert == "near") {
|
4943 |
-
var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
|
4944 |
-
hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
|
4945 |
-
// Default to positioning above (if specified and possible); otherwise default to positioning below
|
4946 |
-
if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
|
4947 |
-
top = pos.top - node.offsetHeight;
|
4948 |
-
else if (pos.bottom + node.offsetHeight <= vspace)
|
4949 |
-
top = pos.bottom;
|
4950 |
-
if (left + node.offsetWidth > hspace)
|
4951 |
-
left = hspace - node.offsetWidth;
|
4952 |
-
}
|
4953 |
-
node.style.top = top + "px";
|
4954 |
-
node.style.left = node.style.right = "";
|
4955 |
-
if (horiz == "right") {
|
4956 |
-
left = display.sizer.clientWidth - node.offsetWidth;
|
4957 |
-
node.style.right = "0px";
|
4958 |
-
} else {
|
4959 |
-
if (horiz == "left") left = 0;
|
4960 |
-
else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
|
4961 |
-
node.style.left = left + "px";
|
4962 |
-
}
|
4963 |
-
if (scroll)
|
4964 |
-
scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
|
4965 |
-
},
|
4966 |
-
|
4967 |
-
triggerOnKeyDown: methodOp(onKeyDown),
|
4968 |
-
triggerOnKeyPress: methodOp(onKeyPress),
|
4969 |
-
triggerOnKeyUp: onKeyUp,
|
4970 |
-
|
4971 |
-
execCommand: function(cmd) {
|
4972 |
-
if (commands.hasOwnProperty(cmd))
|
4973 |
-
return commands[cmd](this);
|
4974 |
-
},
|
4975 |
-
|
4976 |
-
findPosH: function(from, amount, unit, visually) {
|
4977 |
-
var dir = 1;
|
4978 |
-
if (amount < 0) { dir = -1; amount = -amount; }
|
4979 |
-
for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
|
4980 |
-
cur = findPosH(this.doc, cur, dir, unit, visually);
|
4981 |
-
if (cur.hitSide) break;
|
4982 |
-
}
|
4983 |
-
return cur;
|
4984 |
-
},
|
4985 |
-
|
4986 |
-
moveH: methodOp(function(dir, unit) {
|
4987 |
-
var cm = this;
|
4988 |
-
cm.extendSelectionsBy(function(range) {
|
4989 |
-
if (cm.display.shift || cm.doc.extend || range.empty())
|
4990 |
-
return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
|
4991 |
-
else
|
4992 |
-
return dir < 0 ? range.from() : range.to();
|
4993 |
-
}, sel_move);
|
4994 |
-
}),
|
4995 |
-
|
4996 |
-
deleteH: methodOp(function(dir, unit) {
|
4997 |
-
var sel = this.doc.sel, doc = this.doc;
|
4998 |
-
if (sel.somethingSelected())
|
4999 |
-
doc.replaceSelection("", null, "+delete");
|
5000 |
-
else
|
5001 |
-
deleteNearSelection(this, function(range) {
|
5002 |
-
var other = findPosH(doc, range.head, dir, unit, false);
|
5003 |
-
return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
|
5004 |
-
});
|
5005 |
-
}),
|
5006 |
-
|
5007 |
-
findPosV: function(from, amount, unit, goalColumn) {
|
5008 |
-
var dir = 1, x = goalColumn;
|
5009 |
-
if (amount < 0) { dir = -1; amount = -amount; }
|
5010 |
-
for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
|
5011 |
-
var coords = cursorCoords(this, cur, "div");
|
5012 |
-
if (x == null) x = coords.left;
|
5013 |
-
else coords.left = x;
|
5014 |
-
cur = findPosV(this, coords, dir, unit);
|
5015 |
-
if (cur.hitSide) break;
|
5016 |
-
}
|
5017 |
-
return cur;
|
5018 |
-
},
|
5019 |
-
|
5020 |
-
moveV: methodOp(function(dir, unit) {
|
5021 |
-
var cm = this, doc = this.doc, goals = [];
|
5022 |
-
var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
|
5023 |
-
doc.extendSelectionsBy(function(range) {
|
5024 |
-
if (collapse)
|
5025 |
-
return dir < 0 ? range.from() : range.to();
|
5026 |
-
var headPos = cursorCoords(cm, range.head, "div");
|
5027 |
-
if (range.goalColumn != null) headPos.left = range.goalColumn;
|
5028 |
-
goals.push(headPos.left);
|
5029 |
-
var pos = findPosV(cm, headPos, dir, unit);
|
5030 |
-
if (unit == "page" && range == doc.sel.primary())
|
5031 |
-
addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
|
5032 |
-
return pos;
|
5033 |
-
}, sel_move);
|
5034 |
-
if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
|
5035 |
-
doc.sel.ranges[i].goalColumn = goals[i];
|
5036 |
-
}),
|
5037 |
-
|
5038 |
-
// Find the word at the given position (as returned by coordsChar).
|
5039 |
-
findWordAt: function(pos) {
|
5040 |
-
var doc = this.doc, line = getLine(doc, pos.line).text;
|
5041 |
-
var start = pos.ch, end = pos.ch;
|
5042 |
-
if (line) {
|
5043 |
-
var helper = this.getHelper(pos, "wordChars");
|
5044 |
-
if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
|
5045 |
-
var startChar = line.charAt(start);
|
5046 |
-
var check = isWordChar(startChar, helper)
|
5047 |
-
? function(ch) { return isWordChar(ch, helper); }
|
5048 |
-
: /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
|
5049 |
-
: function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
|
5050 |
-
while (start > 0 && check(line.charAt(start - 1))) --start;
|
5051 |
-
while (end < line.length && check(line.charAt(end))) ++end;
|
5052 |
-
}
|
5053 |
-
return new Range(Pos(pos.line, start), Pos(pos.line, end));
|
5054 |
-
},
|
5055 |
-
|
5056 |
-
toggleOverwrite: function(value) {
|
5057 |
-
if (value != null && value == this.state.overwrite) return;
|
5058 |
-
if (this.state.overwrite = !this.state.overwrite)
|
5059 |
-
addClass(this.display.cursorDiv, "CodeMirror-overwrite");
|
5060 |
-
else
|
5061 |
-
rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
|
5062 |
-
|
5063 |
-
signal(this, "overwriteToggle", this, this.state.overwrite);
|
5064 |
-
},
|
5065 |
-
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
5066 |
-
|
5067 |
-
scrollTo: methodOp(function(x, y) {
|
5068 |
-
if (x != null || y != null) resolveScrollToPos(this);
|
5069 |
-
if (x != null) this.curOp.scrollLeft = x;
|
5070 |
-
if (y != null) this.curOp.scrollTop = y;
|
5071 |
-
}),
|
5072 |
-
getScrollInfo: function() {
|
5073 |
-
var scroller = this.display.scroller;
|
5074 |
-
return {left: scroller.scrollLeft, top: scroller.scrollTop,
|
5075 |
-
height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
|
5076 |
-
width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
|
5077 |
-
clientHeight: displayHeight(this), clientWidth: displayWidth(this)};
|
5078 |
-
},
|
5079 |
-
|
5080 |
-
scrollIntoView: methodOp(function(range, margin) {
|
5081 |
-
if (range == null) {
|
5082 |
-
range = {from: this.doc.sel.primary().head, to: null};
|
5083 |
-
if (margin == null) margin = this.options.cursorScrollMargin;
|
5084 |
-
} else if (typeof range == "number") {
|
5085 |
-
range = {from: Pos(range, 0), to: null};
|
5086 |
-
} else if (range.from == null) {
|
5087 |
-
range = {from: range, to: null};
|
5088 |
-
}
|
5089 |
-
if (!range.to) range.to = range.from;
|
5090 |
-
range.margin = margin || 0;
|
5091 |
-
|
5092 |
-
if (range.from.line != null) {
|
5093 |
-
resolveScrollToPos(this);
|
5094 |
-
this.curOp.scrollToPos = range;
|
5095 |
-
} else {
|
5096 |
-
var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
|
5097 |
-
Math.min(range.from.top, range.to.top) - range.margin,
|
5098 |
-
Math.max(range.from.right, range.to.right),
|
5099 |
-
Math.max(range.from.bottom, range.to.bottom) + range.margin);
|
5100 |
-
this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
|
5101 |
-
}
|
5102 |
-
}),
|
5103 |
-
|
5104 |
-
setSize: methodOp(function(width, height) {
|
5105 |
-
var cm = this;
|
5106 |
-
function interpret(val) {
|
5107 |
-
return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
|
5108 |
-
}
|
5109 |
-
if (width != null) cm.display.wrapper.style.width = interpret(width);
|
5110 |
-
if (height != null) cm.display.wrapper.style.height = interpret(height);
|
5111 |
-
if (cm.options.lineWrapping) clearLineMeasurementCache(this);
|
5112 |
-
var lineNo = cm.display.viewFrom;
|
5113 |
-
cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
|
5114 |
-
if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
|
5115 |
-
if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
|
5116 |
-
++lineNo;
|
5117 |
-
});
|
5118 |
-
cm.curOp.forceUpdate = true;
|
5119 |
-
signal(cm, "refresh", this);
|
5120 |
-
}),
|
5121 |
-
|
5122 |
-
operation: function(f){return runInOp(this, f);},
|
5123 |
-
|
5124 |
-
refresh: methodOp(function() {
|
5125 |
-
var oldHeight = this.display.cachedTextHeight;
|
5126 |
-
regChange(this);
|
5127 |
-
this.curOp.forceUpdate = true;
|
5128 |
-
clearCaches(this);
|
5129 |
-
this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
|
5130 |
-
updateGutterSpace(this);
|
5131 |
-
if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
|
5132 |
-
estimateLineHeights(this);
|
5133 |
-
signal(this, "refresh", this);
|
5134 |
-
}),
|
5135 |
-
|
5136 |
-
swapDoc: methodOp(function(doc) {
|
5137 |
-
var old = this.doc;
|
5138 |
-
old.cm = null;
|
5139 |
-
attachDoc(this, doc);
|
5140 |
-
clearCaches(this);
|
5141 |
-
this.display.input.reset();
|
5142 |
-
this.scrollTo(doc.scrollLeft, doc.scrollTop);
|
5143 |
-
this.curOp.forceScroll = true;
|
5144 |
-
signalLater(this, "swapDoc", this, old);
|
5145 |
-
return old;
|
5146 |
-
}),
|
5147 |
-
|
5148 |
-
getInputField: function(){return this.display.input.getField();},
|
5149 |
-
getWrapperElement: function(){return this.display.wrapper;},
|
5150 |
-
getScrollerElement: function(){return this.display.scroller;},
|
5151 |
-
getGutterElement: function(){return this.display.gutters;}
|
5152 |
-
};
|
5153 |
-
eventMixin(CodeMirror);
|
5154 |
-
|
5155 |
-
// OPTION DEFAULTS
|
5156 |
-
|
5157 |
-
// The default configuration options.
|
5158 |
-
var defaults = CodeMirror.defaults = {};
|
5159 |
-
// Functions to run when options are changed.
|
5160 |
-
var optionHandlers = CodeMirror.optionHandlers = {};
|
5161 |
-
|
5162 |
-
function option(name, deflt, handle, notOnInit) {
|
5163 |
-
CodeMirror.defaults[name] = deflt;
|
5164 |
-
if (handle) optionHandlers[name] =
|
5165 |
-
notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
|
5166 |
-
}
|
5167 |
-
|
5168 |
-
// Passed to option handlers when there is no old value.
|
5169 |
-
var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
|
5170 |
-
|
5171 |
-
// These two are, on init, called from the constructor because they
|
5172 |
-
// have to be initialized before the editor can start at all.
|
5173 |
-
option("value", "", function(cm, val) {
|
5174 |
-
cm.setValue(val);
|
5175 |
-
}, true);
|
5176 |
-
option("mode", null, function(cm, val) {
|
5177 |
-
cm.doc.modeOption = val;
|
5178 |
-
loadMode(cm);
|
5179 |
-
}, true);
|
5180 |
-
|
5181 |
-
option("indentUnit", 2, loadMode, true);
|
5182 |
-
option("indentWithTabs", false);
|
5183 |
-
option("smartIndent", true);
|
5184 |
-
option("tabSize", 4, function(cm) {
|
5185 |
-
resetModeState(cm);
|
5186 |
-
clearCaches(cm);
|
5187 |
-
regChange(cm);
|
5188 |
-
}, true);
|
5189 |
-
option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val) {
|
5190 |
-
cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
5191 |
-
cm.refresh();
|
5192 |
-
}, true);
|
5193 |
-
option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
|
5194 |
-
option("electricChars", true);
|
5195 |
-
option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
|
5196 |
-
throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
|
5197 |
-
}, true);
|
5198 |
-
option("rtlMoveVisually", !windows);
|
5199 |
-
option("wholeLineUpdateBefore", true);
|
5200 |
-
|
5201 |
-
option("theme", "default", function(cm) {
|
5202 |
-
themeChanged(cm);
|
5203 |
-
guttersChanged(cm);
|
5204 |
-
}, true);
|
5205 |
-
option("keyMap", "default", function(cm, val, old) {
|
5206 |
-
var next = getKeyMap(val);
|
5207 |
-
var prev = old != CodeMirror.Init && getKeyMap(old);
|
5208 |
-
if (prev && prev.detach) prev.detach(cm, next);
|
5209 |
-
if (next.attach) next.attach(cm, prev || null);
|
5210 |
-
});
|
5211 |
-
option("extraKeys", null);
|
5212 |
-
|
5213 |
-
option("lineWrapping", false, wrappingChanged, true);
|
5214 |
-
option("gutters", [], function(cm) {
|
5215 |
-
setGuttersForLineNumbers(cm.options);
|
5216 |
-
guttersChanged(cm);
|
5217 |
-
}, true);
|
5218 |
-
option("fixedGutter", true, function(cm, val) {
|
5219 |
-
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
|
5220 |
-
cm.refresh();
|
5221 |
-
}, true);
|
5222 |
-
option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true);
|
5223 |
-
option("scrollbarStyle", "native", function(cm) {
|
5224 |
-
initScrollbars(cm);
|
5225 |
-
updateScrollbars(cm);
|
5226 |
-
cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
|
5227 |
-
cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
|
5228 |
-
}, true);
|
5229 |
-
option("lineNumbers", false, function(cm) {
|
5230 |
-
setGuttersForLineNumbers(cm.options);
|
5231 |
-
guttersChanged(cm);
|
5232 |
-
}, true);
|
5233 |
-
option("firstLineNumber", 1, guttersChanged, true);
|
5234 |
-
option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
|
5235 |
-
option("showCursorWhenSelecting", false, updateSelection, true);
|
5236 |
-
|
5237 |
-
option("resetSelectionOnContextMenu", true);
|
5238 |
-
|
5239 |
-
option("readOnly", false, function(cm, val) {
|
5240 |
-
if (val == "nocursor") {
|
5241 |
-
onBlur(cm);
|
5242 |
-
cm.display.input.blur();
|
5243 |
-
cm.display.disabled = true;
|
5244 |
-
} else {
|
5245 |
-
cm.display.disabled = false;
|
5246 |
-
if (!val) cm.display.input.reset();
|
5247 |
-
}
|
5248 |
-
});
|
5249 |
-
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
5250 |
-
option("dragDrop", true);
|
5251 |
-
|
5252 |
-
option("cursorBlinkRate", 530);
|
5253 |
-
option("cursorScrollMargin", 0);
|
5254 |
-
option("cursorHeight", 1, updateSelection, true);
|
5255 |
-
option("singleCursorHeightPerLine", true, updateSelection, true);
|
5256 |
-
option("workTime", 100);
|
5257 |
-
option("workDelay", 100);
|
5258 |
-
option("flattenSpans", true, resetModeState, true);
|
5259 |
-
option("addModeClass", false, resetModeState, true);
|
5260 |
-
option("pollInterval", 100);
|
5261 |
-
option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
|
5262 |
-
option("historyEventDelay", 1250);
|
5263 |
-
option("viewportMargin", 10, function(cm){cm.refresh();}, true);
|
5264 |
-
option("maxHighlightLength", 10000, resetModeState, true);
|
5265 |
-
option("moveInputWithCursor", true, function(cm, val) {
|
5266 |
-
if (!val) cm.display.input.resetPosition();
|
5267 |
-
});
|
5268 |
-
|
5269 |
-
option("tabindex", null, function(cm, val) {
|
5270 |
-
cm.display.input.getField().tabIndex = val || "";
|
5271 |
-
});
|
5272 |
-
option("autofocus", null);
|
5273 |
-
|
5274 |
-
// MODE DEFINITION AND QUERYING
|
5275 |
-
|
5276 |
-
// Known modes, by name and by MIME
|
5277 |
-
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
|
5278 |
-
|
5279 |
-
// Extra arguments are stored as the mode's dependencies, which is
|
5280 |
-
// used by (legacy) mechanisms like loadmode.js to automatically
|
5281 |
-
// load a mode. (Preferred mechanism is the require/define calls.)
|
5282 |
-
CodeMirror.defineMode = function(name, mode) {
|
5283 |
-
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
|
5284 |
-
if (arguments.length > 2)
|
5285 |
-
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
5286 |
-
modes[name] = mode;
|
5287 |
-
};
|
5288 |
-
|
5289 |
-
CodeMirror.defineMIME = function(mime, spec) {
|
5290 |
-
mimeModes[mime] = spec;
|
5291 |
-
};
|
5292 |
-
|
5293 |
-
// Given a MIME type, a {name, ...options} config object, or a name
|
5294 |
-
// string, return a mode config object.
|
5295 |
-
CodeMirror.resolveMode = function(spec) {
|
5296 |
-
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
5297 |
-
spec = mimeModes[spec];
|
5298 |
-
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
5299 |
-
var found = mimeModes[spec.name];
|
5300 |
-
if (typeof found == "string") found = {name: found};
|
5301 |
-
spec = createObj(found, spec);
|
5302 |
-
spec.name = found.name;
|
5303 |
-
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
5304 |
-
return CodeMirror.resolveMode("application/xml");
|
5305 |
-
}
|
5306 |
-
if (typeof spec == "string") return {name: spec};
|
5307 |
-
else return spec || {name: "null"};
|
5308 |
-
};
|
5309 |
-
|
5310 |
-
// Given a mode spec (anything that resolveMode accepts), find and
|
5311 |
-
// initialize an actual mode object.
|
5312 |
-
CodeMirror.getMode = function(options, spec) {
|
5313 |
-
var spec = CodeMirror.resolveMode(spec);
|
5314 |
-
var mfactory = modes[spec.name];
|
5315 |
-
if (!mfactory) return CodeMirror.getMode(options, "text/plain");
|
5316 |
-
var modeObj = mfactory(options, spec);
|
5317 |
-
if (modeExtensions.hasOwnProperty(spec.name)) {
|
5318 |
-
var exts = modeExtensions[spec.name];
|
5319 |
-
for (var prop in exts) {
|
5320 |
-
if (!exts.hasOwnProperty(prop)) continue;
|
5321 |
-
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
|
5322 |
-
modeObj[prop] = exts[prop];
|
5323 |
-
}
|
5324 |
-
}
|
5325 |
-
modeObj.name = spec.name;
|
5326 |
-
if (spec.helperType) modeObj.helperType = spec.helperType;
|
5327 |
-
if (spec.modeProps) for (var prop in spec.modeProps)
|
5328 |
-
modeObj[prop] = spec.modeProps[prop];
|
5329 |
-
|
5330 |
-
return modeObj;
|
5331 |
-
};
|
5332 |
-
|
5333 |
-
// Minimal default mode.
|
5334 |
-
CodeMirror.defineMode("null", function() {
|
5335 |
-
return {token: function(stream) {stream.skipToEnd();}};
|
5336 |
-
});
|
5337 |
-
CodeMirror.defineMIME("text/plain", "null");
|
5338 |
-
|
5339 |
-
// This can be used to attach properties to mode objects from
|
5340 |
-
// outside the actual mode definition.
|
5341 |
-
var modeExtensions = CodeMirror.modeExtensions = {};
|
5342 |
-
CodeMirror.extendMode = function(mode, properties) {
|
5343 |
-
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
|
5344 |
-
copyObj(properties, exts);
|
5345 |
-
};
|
5346 |
-
|
5347 |
-
// EXTENSIONS
|
5348 |
-
|
5349 |
-
CodeMirror.defineExtension = function(name, func) {
|
5350 |
-
CodeMirror.prototype[name] = func;
|
5351 |
-
};
|
5352 |
-
CodeMirror.defineDocExtension = function(name, func) {
|
5353 |
-
Doc.prototype[name] = func;
|
5354 |
-
};
|
5355 |
-
CodeMirror.defineOption = option;
|
5356 |
-
|
5357 |
-
var initHooks = [];
|
5358 |
-
CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
|
5359 |
-
|
5360 |
-
var helpers = CodeMirror.helpers = {};
|
5361 |
-
CodeMirror.registerHelper = function(type, name, value) {
|
5362 |
-
if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
|
5363 |
-
helpers[type][name] = value;
|
5364 |
-
};
|
5365 |
-
CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
|
5366 |
-
CodeMirror.registerHelper(type, name, value);
|
5367 |
-
helpers[type]._global.push({pred: predicate, val: value});
|
5368 |
-
};
|
5369 |
-
|
5370 |
-
// MODE STATE HANDLING
|
5371 |
-
|
5372 |
-
// Utility functions for working with state. Exported because nested
|
5373 |
-
// modes need to do this for their inner modes.
|
5374 |
-
|
5375 |
-
var copyState = CodeMirror.copyState = function(mode, state) {
|
5376 |
-
if (state === true) return state;
|
5377 |
-
if (mode.copyState) return mode.copyState(state);
|
5378 |
-
var nstate = {};
|
5379 |
-
for (var n in state) {
|
5380 |
-
var val = state[n];
|
5381 |
-
if (val instanceof Array) val = val.concat([]);
|
5382 |
-
nstate[n] = val;
|
5383 |
-
}
|
5384 |
-
return nstate;
|
5385 |
-
};
|
5386 |
-
|
5387 |
-
var startState = CodeMirror.startState = function(mode, a1, a2) {
|
5388 |
-
return mode.startState ? mode.startState(a1, a2) : true;
|
5389 |
-
};
|
5390 |
-
|
5391 |
-
// Given a mode and a state (for that mode), find the inner mode and
|
5392 |
-
// state at the position that the state refers to.
|
5393 |
-
CodeMirror.innerMode = function(mode, state) {
|
5394 |
-
while (mode.innerMode) {
|
5395 |
-
var info = mode.innerMode(state);
|
5396 |
-
if (!info || info.mode == mode) break;
|
5397 |
-
state = info.state;
|
5398 |
-
mode = info.mode;
|
5399 |
-
}
|
5400 |
-
return info || {mode: mode, state: state};
|
5401 |
-
};
|
5402 |
-
|
5403 |
-
// STANDARD COMMANDS
|
5404 |
-
|
5405 |
-
// Commands are parameter-less actions that can be performed on an
|
5406 |
-
// editor, mostly used for keybindings.
|
5407 |
-
var commands = CodeMirror.commands = {
|
5408 |
-
selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
|
5409 |
-
singleSelection: function(cm) {
|
5410 |
-
cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
|
5411 |
-
},
|
5412 |
-
killLine: function(cm) {
|
5413 |
-
deleteNearSelection(cm, function(range) {
|
5414 |
-
if (range.empty()) {
|
5415 |
-
var len = getLine(cm.doc, range.head.line).text.length;
|
5416 |
-
if (range.head.ch == len && range.head.line < cm.lastLine())
|
5417 |
-
return {from: range.head, to: Pos(range.head.line + 1, 0)};
|
5418 |
-
else
|
5419 |
-
return {from: range.head, to: Pos(range.head.line, len)};
|
5420 |
-
} else {
|
5421 |
-
return {from: range.from(), to: range.to()};
|
5422 |
-
}
|
5423 |
-
});
|
5424 |
-
},
|
5425 |
-
deleteLine: function(cm) {
|
5426 |
-
deleteNearSelection(cm, function(range) {
|
5427 |
-
return {from: Pos(range.from().line, 0),
|
5428 |
-
to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
|
5429 |
-
});
|
5430 |
-
},
|
5431 |
-
delLineLeft: function(cm) {
|
5432 |
-
deleteNearSelection(cm, function(range) {
|
5433 |
-
return {from: Pos(range.from().line, 0), to: range.from()};
|
5434 |
-
});
|
5435 |
-
},
|
5436 |
-
delWrappedLineLeft: function(cm) {
|
5437 |
-
deleteNearSelection(cm, function(range) {
|
5438 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5439 |
-
var leftPos = cm.coordsChar({left: 0, top: top}, "div");
|
5440 |
-
return {from: leftPos, to: range.from()};
|
5441 |
-
});
|
5442 |
-
},
|
5443 |
-
delWrappedLineRight: function(cm) {
|
5444 |
-
deleteNearSelection(cm, function(range) {
|
5445 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5446 |
-
var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
|
5447 |
-
return {from: range.from(), to: rightPos };
|
5448 |
-
});
|
5449 |
-
},
|
5450 |
-
undo: function(cm) {cm.undo();},
|
5451 |
-
redo: function(cm) {cm.redo();},
|
5452 |
-
undoSelection: function(cm) {cm.undoSelection();},
|
5453 |
-
redoSelection: function(cm) {cm.redoSelection();},
|
5454 |
-
goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
|
5455 |
-
goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
|
5456 |
-
goLineStart: function(cm) {
|
5457 |
-
cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
|
5458 |
-
{origin: "+move", bias: 1});
|
5459 |
-
},
|
5460 |
-
goLineStartSmart: function(cm) {
|
5461 |
-
cm.extendSelectionsBy(function(range) {
|
5462 |
-
return lineStartSmart(cm, range.head);
|
5463 |
-
}, {origin: "+move", bias: 1});
|
5464 |
-
},
|
5465 |
-
goLineEnd: function(cm) {
|
5466 |
-
cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
|
5467 |
-
{origin: "+move", bias: -1});
|
5468 |
-
},
|
5469 |
-
goLineRight: function(cm) {
|
5470 |
-
cm.extendSelectionsBy(function(range) {
|
5471 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5472 |
-
return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
|
5473 |
-
}, sel_move);
|
5474 |
-
},
|
5475 |
-
goLineLeft: function(cm) {
|
5476 |
-
cm.extendSelectionsBy(function(range) {
|
5477 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5478 |
-
return cm.coordsChar({left: 0, top: top}, "div");
|
5479 |
-
}, sel_move);
|
5480 |
-
},
|
5481 |
-
goLineLeftSmart: function(cm) {
|
5482 |
-
cm.extendSelectionsBy(function(range) {
|
5483 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5484 |
-
var pos = cm.coordsChar({left: 0, top: top}, "div");
|
5485 |
-
if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
|
5486 |
-
return pos;
|
5487 |
-
}, sel_move);
|
5488 |
-
},
|
5489 |
-
goLineUp: function(cm) {cm.moveV(-1, "line");},
|
5490 |
-
goLineDown: function(cm) {cm.moveV(1, "line");},
|
5491 |
-
goPageUp: function(cm) {cm.moveV(-1, "page");},
|
5492 |
-
goPageDown: function(cm) {cm.moveV(1, "page");},
|
5493 |
-
goCharLeft: function(cm) {cm.moveH(-1, "char");},
|
5494 |
-
goCharRight: function(cm) {cm.moveH(1, "char");},
|
5495 |
-
goColumnLeft: function(cm) {cm.moveH(-1, "column");},
|
5496 |
-
goColumnRight: function(cm) {cm.moveH(1, "column");},
|
5497 |
-
goWordLeft: function(cm) {cm.moveH(-1, "word");},
|
5498 |
-
goGroupRight: function(cm) {cm.moveH(1, "group");},
|
5499 |
-
goGroupLeft: function(cm) {cm.moveH(-1, "group");},
|
5500 |
-
goWordRight: function(cm) {cm.moveH(1, "word");},
|
5501 |
-
delCharBefore: function(cm) {cm.deleteH(-1, "char");},
|
5502 |
-
delCharAfter: function(cm) {cm.deleteH(1, "char");},
|
5503 |
-
delWordBefore: function(cm) {cm.deleteH(-1, "word");},
|
5504 |
-
delWordAfter: function(cm) {cm.deleteH(1, "word");},
|
5505 |
-
delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
|
5506 |
-
delGroupAfter: function(cm) {cm.deleteH(1, "group");},
|
5507 |
-
indentAuto: function(cm) {cm.indentSelection("smart");},
|
5508 |
-
indentMore: function(cm) {cm.indentSelection("add");},
|
5509 |
-
indentLess: function(cm) {cm.indentSelection("subtract");},
|
5510 |
-
insertTab: function(cm) {cm.replaceSelection("\t");},
|
5511 |
-
insertSoftTab: function(cm) {
|
5512 |
-
var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
|
5513 |
-
for (var i = 0; i < ranges.length; i++) {
|
5514 |
-
var pos = ranges[i].from();
|
5515 |
-
var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
|
5516 |
-
spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
|
5517 |
-
}
|
5518 |
-
cm.replaceSelections(spaces);
|
5519 |
-
},
|
5520 |
-
defaultTab: function(cm) {
|
5521 |
-
if (cm.somethingSelected()) cm.indentSelection("add");
|
5522 |
-
else cm.execCommand("insertTab");
|
5523 |
-
},
|
5524 |
-
transposeChars: function(cm) {
|
5525 |
-
runInOp(cm, function() {
|
5526 |
-
var ranges = cm.listSelections(), newSel = [];
|
5527 |
-
for (var i = 0; i < ranges.length; i++) {
|
5528 |
-
var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
|
5529 |
-
if (line) {
|
5530 |
-
if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
|
5531 |
-
if (cur.ch > 0) {
|
5532 |
-
cur = new Pos(cur.line, cur.ch + 1);
|
5533 |
-
cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
|
5534 |
-
Pos(cur.line, cur.ch - 2), cur, "+transpose");
|
5535 |
-
} else if (cur.line > cm.doc.first) {
|
5536 |
-
var prev = getLine(cm.doc, cur.line - 1).text;
|
5537 |
-
if (prev)
|
5538 |
-
cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1),
|
5539 |
-
Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
|
5540 |
-
}
|
5541 |
-
}
|
5542 |
-
newSel.push(new Range(cur, cur));
|
5543 |
-
}
|
5544 |
-
cm.setSelections(newSel);
|
5545 |
-
});
|
5546 |
-
},
|
5547 |
-
newlineAndIndent: function(cm) {
|
5548 |
-
runInOp(cm, function() {
|
5549 |
-
var len = cm.listSelections().length;
|
5550 |
-
for (var i = 0; i < len; i++) {
|
5551 |
-
var range = cm.listSelections()[i];
|
5552 |
-
cm.replaceRange("\n", range.anchor, range.head, "+input");
|
5553 |
-
cm.indentLine(range.from().line + 1, null, true);
|
5554 |
-
ensureCursorVisible(cm);
|
5555 |
-
}
|
5556 |
-
});
|
5557 |
-
},
|
5558 |
-
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
5559 |
-
};
|
5560 |
-
|
5561 |
-
|
5562 |
-
// STANDARD KEYMAPS
|
5563 |
-
|
5564 |
-
var keyMap = CodeMirror.keyMap = {};
|
5565 |
-
|
5566 |
-
keyMap.basic = {
|
5567 |
-
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
|
5568 |
-
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
|
5569 |
-
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
|
5570 |
-
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
|
5571 |
-
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
|
5572 |
-
"Esc": "singleSelection"
|
5573 |
-
};
|
5574 |
-
// Note that the save and find-related commands aren't defined by
|
5575 |
-
// default. User code or addons can define them. Unknown commands
|
5576 |
-
// are simply ignored.
|
5577 |
-
keyMap.pcDefault = {
|
5578 |
-
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
|
5579 |
-
"Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
|
5580 |
-
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
|
5581 |
-
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
|
5582 |
-
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
|
5583 |
-
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
|
5584 |
-
"Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
|
5585 |
-
fallthrough: "basic"
|
5586 |
-
};
|
5587 |
-
// Very basic readline/emacs-style bindings, which are standard on Mac.
|
5588 |
-
keyMap.emacsy = {
|
5589 |
-
"Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
|
5590 |
-
"Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
|
5591 |
-
"Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
|
5592 |
-
"Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
|
5593 |
-
};
|
5594 |
-
keyMap.macDefault = {
|
5595 |
-
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
|
5596 |
-
"Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
|
5597 |
-
"Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
|
5598 |
-
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
|
5599 |
-
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
|
5600 |
-
"Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
|
5601 |
-
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
|
5602 |
-
fallthrough: ["basic", "emacsy"]
|
5603 |
-
};
|
5604 |
-
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
|
5605 |
-
|
5606 |
-
// KEYMAP DISPATCH
|
5607 |
-
|
5608 |
-
function normalizeKeyName(name) {
|
5609 |
-
var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
|
5610 |
-
var alt, ctrl, shift, cmd;
|
5611 |
-
for (var i = 0; i < parts.length - 1; i++) {
|
5612 |
-
var mod = parts[i];
|
5613 |
-
if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
|
5614 |
-
else if (/^a(lt)?$/i.test(mod)) alt = true;
|
5615 |
-
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
|
5616 |
-
else if (/^s(hift)$/i.test(mod)) shift = true;
|
5617 |
-
else throw new Error("Unrecognized modifier name: " + mod);
|
5618 |
-
}
|
5619 |
-
if (alt) name = "Alt-" + name;
|
5620 |
-
if (ctrl) name = "Ctrl-" + name;
|
5621 |
-
if (cmd) name = "Cmd-" + name;
|
5622 |
-
if (shift) name = "Shift-" + name;
|
5623 |
-
return name;
|
5624 |
-
}
|
5625 |
-
|
5626 |
-
// This is a kludge to keep keymaps mostly working as raw objects
|
5627 |
-
// (backwards compatibility) while at the same time support features
|
5628 |
-
// like normalization and multi-stroke key bindings. It compiles a
|
5629 |
-
// new normalized keymap, and then updates the old object to reflect
|
5630 |
-
// this.
|
5631 |
-
CodeMirror.normalizeKeyMap = function(keymap) {
|
5632 |
-
var copy = {};
|
5633 |
-
for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
|
5634 |
-
var value = keymap[keyname];
|
5635 |
-
if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
|
5636 |
-
if (value == "...") { delete keymap[keyname]; continue; }
|
5637 |
-
|
5638 |
-
var keys = map(keyname.split(" "), normalizeKeyName);
|
5639 |
-
for (var i = 0; i < keys.length; i++) {
|
5640 |
-
var val, name;
|
5641 |
-
if (i == keys.length - 1) {
|
5642 |
-
name = keyname;
|
5643 |
-
val = value;
|
5644 |
-
} else {
|
5645 |
-
name = keys.slice(0, i + 1).join(" ");
|
5646 |
-
val = "...";
|
5647 |
-
}
|
5648 |
-
var prev = copy[name];
|
5649 |
-
if (!prev) copy[name] = val;
|
5650 |
-
else if (prev != val) throw new Error("Inconsistent bindings for " + name);
|
5651 |
-
}
|
5652 |
-
delete keymap[keyname];
|
5653 |
-
}
|
5654 |
-
for (var prop in copy) keymap[prop] = copy[prop];
|
5655 |
-
return keymap;
|
5656 |
-
};
|
5657 |
-
|
5658 |
-
var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
|
5659 |
-
map = getKeyMap(map);
|
5660 |
-
var found = map.call ? map.call(key, context) : map[key];
|
5661 |
-
if (found === false) return "nothing";
|
5662 |
-
if (found === "...") return "multi";
|
5663 |
-
if (found != null && handle(found)) return "handled";
|
5664 |
-
|
5665 |
-
if (map.fallthrough) {
|
5666 |
-
if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
|
5667 |
-
return lookupKey(key, map.fallthrough, handle, context);
|
5668 |
-
for (var i = 0; i < map.fallthrough.length; i++) {
|
5669 |
-
var result = lookupKey(key, map.fallthrough[i], handle, context);
|
5670 |
-
if (result) return result;
|
5671 |
-
}
|
5672 |
-
}
|
5673 |
-
};
|
5674 |
-
|
5675 |
-
// Modifier key presses don't count as 'real' key presses for the
|
5676 |
-
// purpose of keymap fallthrough.
|
5677 |
-
var isModifierKey = CodeMirror.isModifierKey = function(value) {
|
5678 |
-
var name = typeof value == "string" ? value : keyNames[value.keyCode];
|
5679 |
-
return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
|
5680 |
-
};
|
5681 |
-
|
5682 |
-
// Look up the name of a key as indicated by an event object.
|
5683 |
-
var keyName = CodeMirror.keyName = function(event, noShift) {
|
5684 |
-
if (presto && event.keyCode == 34 && event["char"]) return false;
|
5685 |
-
var base = keyNames[event.keyCode], name = base;
|
5686 |
-
if (name == null || event.altGraphKey) return false;
|
5687 |
-
if (event.altKey && base != "Alt") name = "Alt-" + name;
|
5688 |
-
if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
|
5689 |
-
if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
|
5690 |
-
if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
|
5691 |
-
return name;
|
5692 |
-
};
|
5693 |
-
|
5694 |
-
function getKeyMap(val) {
|
5695 |
-
return typeof val == "string" ? keyMap[val] : val;
|
5696 |
-
}
|
5697 |
-
|
5698 |
-
// FROMTEXTAREA
|
5699 |
-
|
5700 |
-
CodeMirror.fromTextArea = function(textarea, options) {
|
5701 |
-
options = options ? copyObj(options) : {};
|
5702 |
-
options.value = textarea.value;
|
5703 |
-
if (!options.tabindex && textarea.tabIndex)
|
5704 |
-
options.tabindex = textarea.tabIndex;
|
5705 |
-
if (!options.placeholder && textarea.placeholder)
|
5706 |
-
options.placeholder = textarea.placeholder;
|
5707 |
-
// Set autofocus to true if this textarea is focused, or if it has
|
5708 |
-
// autofocus and no other element is focused.
|
5709 |
-
if (options.autofocus == null) {
|
5710 |
-
var hasFocus = activeElt();
|
5711 |
-
options.autofocus = hasFocus == textarea ||
|
5712 |
-
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
|
5713 |
-
}
|
5714 |
-
|
5715 |
-
function save() {textarea.value = cm.getValue();}
|
5716 |
-
if (textarea.form) {
|
5717 |
-
on(textarea.form, "submit", save);
|
5718 |
-
// Deplorable hack to make the submit method do the right thing.
|
5719 |
-
if (!options.leaveSubmitMethodAlone) {
|
5720 |
-
var form = textarea.form, realSubmit = form.submit;
|
5721 |
-
try {
|
5722 |
-
var wrappedSubmit = form.submit = function() {
|
5723 |
-
save();
|
5724 |
-
form.submit = realSubmit;
|
5725 |
-
form.submit();
|
5726 |
-
form.submit = wrappedSubmit;
|
5727 |
-
};
|
5728 |
-
} catch(e) {}
|
5729 |
-
}
|
5730 |
-
}
|
5731 |
-
|
5732 |
-
options.finishInit = function(cm) {
|
5733 |
-
cm.save = save;
|
5734 |
-
cm.getTextArea = function() { return textarea; };
|
5735 |
-
cm.toTextArea = function() {
|
5736 |
-
cm.toTextArea = isNaN; // Prevent this from being ran twice
|
5737 |
-
save();
|
5738 |
-
textarea.parentNode.removeChild(cm.getWrapperElement());
|
5739 |
-
textarea.style.display = "";
|
5740 |
-
if (textarea.form) {
|
5741 |
-
off(textarea.form, "submit", save);
|
5742 |
-
if (typeof textarea.form.submit == "function")
|
5743 |
-
textarea.form.submit = realSubmit;
|
5744 |
-
}
|
5745 |
-
};
|
5746 |
-
};
|
5747 |
-
|
5748 |
-
textarea.style.display = "none";
|
5749 |
-
var cm = CodeMirror(function(node) {
|
5750 |
-
textarea.parentNode.insertBefore(node, textarea.nextSibling);
|
5751 |
-
}, options);
|
5752 |
-
return cm;
|
5753 |
-
};
|
5754 |
-
|
5755 |
-
// STRING STREAM
|
5756 |
-
|
5757 |
-
// Fed to the mode parsers, provides helper functions to make
|
5758 |
-
// parsers more succinct.
|
5759 |
-
|
5760 |
-
var StringStream = CodeMirror.StringStream = function(string, tabSize) {
|
5761 |
-
this.pos = this.start = 0;
|
5762 |
-
this.string = string;
|
5763 |
-
this.tabSize = tabSize || 8;
|
5764 |
-
this.lastColumnPos = this.lastColumnValue = 0;
|
5765 |
-
this.lineStart = 0;
|
5766 |
-
};
|
5767 |
-
|
5768 |
-
StringStream.prototype = {
|
5769 |
-
eol: function() {return this.pos >= this.string.length;},
|
5770 |
-
sol: function() {return this.pos == this.lineStart;},
|
5771 |
-
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
5772 |
-
next: function() {
|
5773 |
-
if (this.pos < this.string.length)
|
5774 |
-
return this.string.charAt(this.pos++);
|
5775 |
-
},
|
5776 |
-
eat: function(match) {
|
5777 |
-
var ch = this.string.charAt(this.pos);
|
5778 |
-
if (typeof match == "string") var ok = ch == match;
|
5779 |
-
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
5780 |
-
if (ok) {++this.pos; return ch;}
|
5781 |
-
},
|
5782 |
-
eatWhile: function(match) {
|
5783 |
-
var start = this.pos;
|
5784 |
-
while (this.eat(match)){}
|
5785 |
-
return this.pos > start;
|
5786 |
-
},
|
5787 |
-
eatSpace: function() {
|
5788 |
-
var start = this.pos;
|
5789 |
-
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
5790 |
-
return this.pos > start;
|
5791 |
-
},
|
5792 |
-
skipToEnd: function() {this.pos = this.string.length;},
|
5793 |
-
skipTo: function(ch) {
|
5794 |
-
var found = this.string.indexOf(ch, this.pos);
|
5795 |
-
if (found > -1) {this.pos = found; return true;}
|
5796 |
-
},
|
5797 |
-
backUp: function(n) {this.pos -= n;},
|
5798 |
-
column: function() {
|
5799 |
-
if (this.lastColumnPos < this.start) {
|
5800 |
-
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
5801 |
-
this.lastColumnPos = this.start;
|
5802 |
-
}
|
5803 |
-
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
5804 |
-
},
|
5805 |
-
indentation: function() {
|
5806 |
-
return countColumn(this.string, null, this.tabSize) -
|
5807 |
-
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
5808 |
-
},
|
5809 |
-
match: function(pattern, consume, caseInsensitive) {
|
5810 |
-
if (typeof pattern == "string") {
|
5811 |
-
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
5812 |
-
var substr = this.string.substr(this.pos, pattern.length);
|
5813 |
-
if (cased(substr) == cased(pattern)) {
|
5814 |
-
if (consume !== false) this.pos += pattern.length;
|
5815 |
-
return true;
|
5816 |
-
}
|
5817 |
-
} else {
|
5818 |
-
var match = this.string.slice(this.pos).match(pattern);
|
5819 |
-
if (match && match.index > 0) return null;
|
5820 |
-
if (match && consume !== false) this.pos += match[0].length;
|
5821 |
-
return match;
|
5822 |
-
}
|
5823 |
-
},
|
5824 |
-
current: function(){return this.string.slice(this.start, this.pos);},
|
5825 |
-
hideFirstChars: function(n, inner) {
|
5826 |
-
this.lineStart += n;
|
5827 |
-
try { return inner(); }
|
5828 |
-
finally { this.lineStart -= n; }
|
5829 |
-
}
|
5830 |
-
};
|
5831 |
-
|
5832 |
-
// TEXTMARKERS
|
5833 |
-
|
5834 |
-
// Created with markText and setBookmark methods. A TextMarker is a
|
5835 |
-
// handle that can be used to clear or find a marked position in the
|
5836 |
-
// document. Line objects hold arrays (markedSpans) containing
|
5837 |
-
// {from, to, marker} object pointing to such marker objects, and
|
5838 |
-
// indicating that such a marker is present on that line. Multiple
|
5839 |
-
// lines may point to the same marker when it spans across lines.
|
5840 |
-
// The spans will have null for their from/to properties when the
|
5841 |
-
// marker continues beyond the start/end of the line. Markers have
|
5842 |
-
// links back to the lines they currently touch.
|
5843 |
-
|
5844 |
-
var nextMarkerId = 0;
|
5845 |
-
|
5846 |
-
var TextMarker = CodeMirror.TextMarker = function(doc, type) {
|
5847 |
-
this.lines = [];
|
5848 |
-
this.type = type;
|
5849 |
-
this.doc = doc;
|
5850 |
-
this.id = ++nextMarkerId;
|
5851 |
-
};
|
5852 |
-
eventMixin(TextMarker);
|
5853 |
-
|
5854 |
-
// Clear the marker.
|
5855 |
-
TextMarker.prototype.clear = function() {
|
5856 |
-
if (this.explicitlyCleared) return;
|
5857 |
-
var cm = this.doc.cm, withOp = cm && !cm.curOp;
|
5858 |
-
if (withOp) startOperation(cm);
|
5859 |
-
if (hasHandler(this, "clear")) {
|
5860 |
-
var found = this.find();
|
5861 |
-
if (found) signalLater(this, "clear", found.from, found.to);
|
5862 |
-
}
|
5863 |
-
var min = null, max = null;
|
5864 |
-
for (var i = 0; i < this.lines.length; ++i) {
|
5865 |
-
var line = this.lines[i];
|
5866 |
-
var span = getMarkedSpanFor(line.markedSpans, this);
|
5867 |
-
if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
|
5868 |
-
else if (cm) {
|
5869 |
-
if (span.to != null) max = lineNo(line);
|
5870 |
-
if (span.from != null) min = lineNo(line);
|
5871 |
-
}
|
5872 |
-
line.markedSpans = removeMarkedSpan(line.markedSpans, span);
|
5873 |
-
if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
|
5874 |
-
updateLineHeight(line, textHeight(cm.display));
|
5875 |
-
}
|
5876 |
-
if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
|
5877 |
-
var visual = visualLine(this.lines[i]), len = lineLength(visual);
|
5878 |
-
if (len > cm.display.maxLineLength) {
|
5879 |
-
cm.display.maxLine = visual;
|
5880 |
-
cm.display.maxLineLength = len;
|
5881 |
-
cm.display.maxLineChanged = true;
|
5882 |
-
}
|
5883 |
-
}
|
5884 |
-
|
5885 |
-
if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
|
5886 |
-
this.lines.length = 0;
|
5887 |
-
this.explicitlyCleared = true;
|
5888 |
-
if (this.atomic && this.doc.cantEdit) {
|
5889 |
-
this.doc.cantEdit = false;
|
5890 |
-
if (cm) reCheckSelection(cm.doc);
|
5891 |
-
}
|
5892 |
-
if (cm) signalLater(cm, "markerCleared", cm, this);
|
5893 |
-
if (withOp) endOperation(cm);
|
5894 |
-
if (this.parent) this.parent.clear();
|
5895 |
-
};
|
5896 |
-
|
5897 |
-
// Find the position of the marker in the document. Returns a {from,
|
5898 |
-
// to} object by default. Side can be passed to get a specific side
|
5899 |
-
// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
|
5900 |
-
// Pos objects returned contain a line object, rather than a line
|
5901 |
-
// number (used to prevent looking up the same line twice).
|
5902 |
-
TextMarker.prototype.find = function(side, lineObj) {
|
5903 |
-
if (side == null && this.type == "bookmark") side = 1;
|
5904 |
-
var from, to;
|
5905 |
-
for (var i = 0; i < this.lines.length; ++i) {
|
5906 |
-
var line = this.lines[i];
|
5907 |
-
var span = getMarkedSpanFor(line.markedSpans, this);
|
5908 |
-
if (span.from != null) {
|
5909 |
-
from = Pos(lineObj ? line : lineNo(line), span.from);
|
5910 |
-
if (side == -1) return from;
|
5911 |
-
}
|
5912 |
-
if (span.to != null) {
|
5913 |
-
to = Pos(lineObj ? line : lineNo(line), span.to);
|
5914 |
-
if (side == 1) return to;
|
5915 |
-
}
|
5916 |
-
}
|
5917 |
-
return from && {from: from, to: to};
|
5918 |
-
};
|
5919 |
-
|
5920 |
-
// Signals that the marker's widget changed, and surrounding layout
|
5921 |
-
// should be recomputed.
|
5922 |
-
TextMarker.prototype.changed = function() {
|
5923 |
-
var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
|
5924 |
-
if (!pos || !cm) return;
|
5925 |
-
runInOp(cm, function() {
|
5926 |
-
var line = pos.line, lineN = lineNo(pos.line);
|
5927 |
-
var view = findViewForLine(cm, lineN);
|
5928 |
-
if (view) {
|
5929 |
-
clearLineMeasurementCacheFor(view);
|
5930 |
-
cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
|
5931 |
-
}
|
5932 |
-
cm.curOp.updateMaxLine = true;
|
5933 |
-
if (!lineIsHidden(widget.doc, line) && widget.height != null) {
|
5934 |
-
var oldHeight = widget.height;
|
5935 |
-
widget.height = null;
|
5936 |
-
var dHeight = widgetHeight(widget) - oldHeight;
|
5937 |
-
if (dHeight)
|
5938 |
-
updateLineHeight(line, line.height + dHeight);
|
5939 |
-
}
|
5940 |
-
});
|
5941 |
-
};
|
5942 |
-
|
5943 |
-
TextMarker.prototype.attachLine = function(line) {
|
5944 |
-
if (!this.lines.length && this.doc.cm) {
|
5945 |
-
var op = this.doc.cm.curOp;
|
5946 |
-
if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
|
5947 |
-
(op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
|
5948 |
-
}
|
5949 |
-
this.lines.push(line);
|
5950 |
-
};
|
5951 |
-
TextMarker.prototype.detachLine = function(line) {
|
5952 |
-
this.lines.splice(indexOf(this.lines, line), 1);
|
5953 |
-
if (!this.lines.length && this.doc.cm) {
|
5954 |
-
var op = this.doc.cm.curOp;
|
5955 |
-
(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
|
5956 |
-
}
|
5957 |
-
};
|
5958 |
-
|
5959 |
-
// Collapsed markers have unique ids, in order to be able to order
|
5960 |
-
// them, which is needed for uniquely determining an outer marker
|
5961 |
-
// when they overlap (they may nest, but not partially overlap).
|
5962 |
-
var nextMarkerId = 0;
|
5963 |
-
|
5964 |
-
// Create a marker, wire it up to the right lines, and
|
5965 |
-
function markText(doc, from, to, options, type) {
|
5966 |
-
// Shared markers (across linked documents) are handled separately
|
5967 |
-
// (markTextShared will call out to this again, once per
|
5968 |
-
// document).
|
5969 |
-
if (options && options.shared) return markTextShared(doc, from, to, options, type);
|
5970 |
-
// Ensure we are in an operation.
|
5971 |
-
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
|
5972 |
-
|
5973 |
-
var marker = new TextMarker(doc, type), diff = cmp(from, to);
|
5974 |
-
if (options) copyObj(options, marker, false);
|
5975 |
-
// Don't connect empty markers unless clearWhenEmpty is false
|
5976 |
-
if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
|
5977 |
-
return marker;
|
5978 |
-
if (marker.replacedWith) {
|
5979 |
-
// Showing up as a widget implies collapsed (widget replaces text)
|
5980 |
-
marker.collapsed = true;
|
5981 |
-
marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
|
5982 |
-
if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
|
5983 |
-
if (options.insertLeft) marker.widgetNode.insertLeft = true;
|
5984 |
-
}
|
5985 |
-
if (marker.collapsed) {
|
5986 |
-
if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
|
5987 |
-
from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
|
5988 |
-
throw new Error("Inserting collapsed marker partially overlapping an existing one");
|
5989 |
-
sawCollapsedSpans = true;
|
5990 |
-
}
|
5991 |
-
|
5992 |
-
if (marker.addToHistory)
|
5993 |
-
addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
|
5994 |
-
|
5995 |
-
var curLine = from.line, cm = doc.cm, updateMaxLine;
|
5996 |
-
doc.iter(curLine, to.line + 1, function(line) {
|
5997 |
-
if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
|
5998 |
-
updateMaxLine = true;
|
5999 |
-
if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
|
6000 |
-
addMarkedSpan(line, new MarkedSpan(marker,
|
6001 |
-
curLine == from.line ? from.ch : null,
|
6002 |
-
curLine == to.line ? to.ch : null));
|
6003 |
-
++curLine;
|
6004 |
-
});
|
6005 |
-
// lineIsHidden depends on the presence of the spans, so needs a second pass
|
6006 |
-
if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
|
6007 |
-
if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
|
6008 |
-
});
|
6009 |
-
|
6010 |
-
if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
|
6011 |
-
|
6012 |
-
if (marker.readOnly) {
|
6013 |
-
sawReadOnlySpans = true;
|
6014 |
-
if (doc.history.done.length || doc.history.undone.length)
|
6015 |
-
doc.clearHistory();
|
6016 |
-
}
|
6017 |
-
if (marker.collapsed) {
|
6018 |
-
marker.id = ++nextMarkerId;
|
6019 |
-
marker.atomic = true;
|
6020 |
-
}
|
6021 |
-
if (cm) {
|
6022 |
-
// Sync editor state
|
6023 |
-
if (updateMaxLine) cm.curOp.updateMaxLine = true;
|
6024 |
-
if (marker.collapsed)
|
6025 |
-
regChange(cm, from.line, to.line + 1);
|
6026 |
-
else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
|
6027 |
-
for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
|
6028 |
-
if (marker.atomic) reCheckSelection(cm.doc);
|
6029 |
-
signalLater(cm, "markerAdded", cm, marker);
|
6030 |
-
}
|
6031 |
-
return marker;
|
6032 |
-
}
|
6033 |
-
|
6034 |
-
// SHARED TEXTMARKERS
|
6035 |
-
|
6036 |
-
// A shared marker spans multiple linked documents. It is
|
6037 |
-
// implemented as a meta-marker-object controlling multiple normal
|
6038 |
-
// markers.
|
6039 |
-
var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
|
6040 |
-
this.markers = markers;
|
6041 |
-
this.primary = primary;
|
6042 |
-
for (var i = 0; i < markers.length; ++i)
|
6043 |
-
markers[i].parent = this;
|
6044 |
-
};
|
6045 |
-
eventMixin(SharedTextMarker);
|
6046 |
-
|
6047 |
-
SharedTextMarker.prototype.clear = function() {
|
6048 |
-
if (this.explicitlyCleared) return;
|
6049 |
-
this.explicitlyCleared = true;
|
6050 |
-
for (var i = 0; i < this.markers.length; ++i)
|
6051 |
-
this.markers[i].clear();
|
6052 |
-
signalLater(this, "clear");
|
6053 |
-
};
|
6054 |
-
SharedTextMarker.prototype.find = function(side, lineObj) {
|
6055 |
-
return this.primary.find(side, lineObj);
|
6056 |
-
};
|
6057 |
-
|
6058 |
-
function markTextShared(doc, from, to, options, type) {
|
6059 |
-
options = copyObj(options);
|
6060 |
-
options.shared = false;
|
6061 |
-
var markers = [markText(doc, from, to, options, type)], primary = markers[0];
|
6062 |
-
var widget = options.widgetNode;
|
6063 |
-
linkedDocs(doc, function(doc) {
|
6064 |
-
if (widget) options.widgetNode = widget.cloneNode(true);
|
6065 |
-
markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
|
6066 |
-
for (var i = 0; i < doc.linked.length; ++i)
|
6067 |
-
if (doc.linked[i].isParent) return;
|
6068 |
-
primary = lst(markers);
|
6069 |
-
});
|
6070 |
-
return new SharedTextMarker(markers, primary);
|
6071 |
-
}
|
6072 |
-
|
6073 |
-
function findSharedMarkers(doc) {
|
6074 |
-
return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
|
6075 |
-
function(m) { return m.parent; });
|
6076 |
-
}
|
6077 |
-
|
6078 |
-
function copySharedMarkers(doc, markers) {
|
6079 |
-
for (var i = 0; i < markers.length; i++) {
|
6080 |
-
var marker = markers[i], pos = marker.find();
|
6081 |
-
var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
|
6082 |
-
if (cmp(mFrom, mTo)) {
|
6083 |
-
var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
|
6084 |
-
marker.markers.push(subMark);
|
6085 |
-
subMark.parent = marker;
|
6086 |
-
}
|
6087 |
-
}
|
6088 |
-
}
|
6089 |
-
|
6090 |
-
function detachSharedMarkers(markers) {
|
6091 |
-
for (var i = 0; i < markers.length; i++) {
|
6092 |
-
var marker = markers[i], linked = [marker.primary.doc];;
|
6093 |
-
linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
|
6094 |
-
for (var j = 0; j < marker.markers.length; j++) {
|
6095 |
-
var subMarker = marker.markers[j];
|
6096 |
-
if (indexOf(linked, subMarker.doc) == -1) {
|
6097 |
-
subMarker.parent = null;
|
6098 |
-
marker.markers.splice(j--, 1);
|
6099 |
-
}
|
6100 |
-
}
|
6101 |
-
}
|
6102 |
-
}
|
6103 |
-
|
6104 |
-
// TEXTMARKER SPANS
|
6105 |
-
|
6106 |
-
function MarkedSpan(marker, from, to) {
|
6107 |
-
this.marker = marker;
|
6108 |
-
this.from = from; this.to = to;
|
6109 |
-
}
|
6110 |
-
|
6111 |
-
// Search an array of spans for a span matching the given marker.
|
6112 |
-
function getMarkedSpanFor(spans, marker) {
|
6113 |
-
if (spans) for (var i = 0; i < spans.length; ++i) {
|
6114 |
-
var span = spans[i];
|
6115 |
-
if (span.marker == marker) return span;
|
6116 |
-
}
|
6117 |
-
}
|
6118 |
-
// Remove a span from an array, returning undefined if no spans are
|
6119 |
-
// left (we don't store arrays for lines without spans).
|
6120 |
-
function removeMarkedSpan(spans, span) {
|
6121 |
-
for (var r, i = 0; i < spans.length; ++i)
|
6122 |
-
if (spans[i] != span) (r || (r = [])).push(spans[i]);
|
6123 |
-
return r;
|
6124 |
-
}
|
6125 |
-
// Add a span to a line.
|
6126 |
-
function addMarkedSpan(line, span) {
|
6127 |
-
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
|
6128 |
-
span.marker.attachLine(line);
|
6129 |
-
}
|
6130 |
-
|
6131 |
-
// Used for the algorithm that adjusts markers for a change in the
|
6132 |
-
// document. These functions cut an array of spans at a given
|
6133 |
-
// character position, returning an array of remaining chunks (or
|
6134 |
-
// undefined if nothing remains).
|
6135 |
-
function markedSpansBefore(old, startCh, isInsert) {
|
6136 |
-
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
6137 |
-
var span = old[i], marker = span.marker;
|
6138 |
-
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
|
6139 |
-
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
|
6140 |
-
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
|
6141 |
-
(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
|
6142 |
-
}
|
6143 |
-
}
|
6144 |
-
return nw;
|
6145 |
-
}
|
6146 |
-
function markedSpansAfter(old, endCh, isInsert) {
|
6147 |
-
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
6148 |
-
var span = old[i], marker = span.marker;
|
6149 |
-
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
|
6150 |
-
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
|
6151 |
-
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
|
6152 |
-
(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
|
6153 |
-
span.to == null ? null : span.to - endCh));
|
6154 |
-
}
|
6155 |
-
}
|
6156 |
-
return nw;
|
6157 |
-
}
|
6158 |
-
|
6159 |
-
// Given a change object, compute the new set of marker spans that
|
6160 |
-
// cover the line in which the change took place. Removes spans
|
6161 |
-
// entirely within the change, reconnects spans belonging to the
|
6162 |
-
// same marker that appear on both sides of the change, and cuts off
|
6163 |
-
// spans partially within the change. Returns an array of span
|
6164 |
-
// arrays with one element for each line in (after) the change.
|
6165 |
-
function stretchSpansOverChange(doc, change) {
|
6166 |
-
if (change.full) return null;
|
6167 |
-
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
|
6168 |
-
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
|
6169 |
-
if (!oldFirst && !oldLast) return null;
|
6170 |
-
|
6171 |
-
var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
|
6172 |
-
// Get the spans that 'stick out' on both sides
|
6173 |
-
var first = markedSpansBefore(oldFirst, startCh, isInsert);
|
6174 |
-
var last = markedSpansAfter(oldLast, endCh, isInsert);
|
6175 |
-
|
6176 |
-
// Next, merge those two ends
|
6177 |
-
var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
|
6178 |
-
if (first) {
|
6179 |
-
// Fix up .to properties of first
|
6180 |
-
for (var i = 0; i < first.length; ++i) {
|
6181 |
-
var span = first[i];
|
6182 |
-
if (span.to == null) {
|
6183 |
-
var found = getMarkedSpanFor(last, span.marker);
|
6184 |
-
if (!found) span.to = startCh;
|
6185 |
-
else if (sameLine) span.to = found.to == null ? null : found.to + offset;
|
6186 |
-
}
|
6187 |
-
}
|
6188 |
-
}
|
6189 |
-
if (last) {
|
6190 |
-
// Fix up .from in last (or move them into first in case of sameLine)
|
6191 |
-
for (var i = 0; i < last.length; ++i) {
|
6192 |
-
var span = last[i];
|
6193 |
-
if (span.to != null) span.to += offset;
|
6194 |
-
if (span.from == null) {
|
6195 |
-
var found = getMarkedSpanFor(first, span.marker);
|
6196 |
-
if (!found) {
|
6197 |
-
span.from = offset;
|
6198 |
-
if (sameLine) (first || (first = [])).push(span);
|
6199 |
-
}
|
6200 |
-
} else {
|
6201 |
-
span.from += offset;
|
6202 |
-
if (sameLine) (first || (first = [])).push(span);
|
6203 |
-
}
|
6204 |
-
}
|
6205 |
-
}
|
6206 |
-
// Make sure we didn't create any zero-length spans
|
6207 |
-
if (first) first = clearEmptySpans(first);
|
6208 |
-
if (last && last != first) last = clearEmptySpans(last);
|
6209 |
-
|
6210 |
-
var newMarkers = [first];
|
6211 |
-
if (!sameLine) {
|
6212 |
-
// Fill gap with whole-line-spans
|
6213 |
-
var gap = change.text.length - 2, gapMarkers;
|
6214 |
-
if (gap > 0 && first)
|
6215 |
-
for (var i = 0; i < first.length; ++i)
|
6216 |
-
if (first[i].to == null)
|
6217 |
-
(gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
|
6218 |
-
for (var i = 0; i < gap; ++i)
|
6219 |
-
newMarkers.push(gapMarkers);
|
6220 |
-
newMarkers.push(last);
|
6221 |
-
}
|
6222 |
-
return newMarkers;
|
6223 |
-
}
|
6224 |
-
|
6225 |
-
// Remove spans that are empty and don't have a clearWhenEmpty
|
6226 |
-
// option of false.
|
6227 |
-
function clearEmptySpans(spans) {
|
6228 |
-
for (var i = 0; i < spans.length; ++i) {
|
6229 |
-
var span = spans[i];
|
6230 |
-
if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
|
6231 |
-
spans.splice(i--, 1);
|
6232 |
-
}
|
6233 |
-
if (!spans.length) return null;
|
6234 |
-
return spans;
|
6235 |
-
}
|
6236 |
-
|
6237 |
-
// Used for un/re-doing changes from the history. Combines the
|
6238 |
-
// result of computing the existing spans with the set of spans that
|
6239 |
-
// existed in the history (so that deleting around a span and then
|
6240 |
-
// undoing brings back the span).
|
6241 |
-
function mergeOldSpans(doc, change) {
|
6242 |
-
var old = getOldSpans(doc, change);
|
6243 |
-
var stretched = stretchSpansOverChange(doc, change);
|
6244 |
-
if (!old) return stretched;
|
6245 |
-
if (!stretched) return old;
|
6246 |
-
|
6247 |
-
for (var i = 0; i < old.length; ++i) {
|
6248 |
-
var oldCur = old[i], stretchCur = stretched[i];
|
6249 |
-
if (oldCur && stretchCur) {
|
6250 |
-
spans: for (var j = 0; j < stretchCur.length; ++j) {
|
6251 |
-
var span = stretchCur[j];
|
6252 |
-
for (var k = 0; k < oldCur.length; ++k)
|
6253 |
-
if (oldCur[k].marker == span.marker) continue spans;
|
6254 |
-
oldCur.push(span);
|
6255 |
-
}
|
6256 |
-
} else if (stretchCur) {
|
6257 |
-
old[i] = stretchCur;
|
6258 |
-
}
|
6259 |
-
}
|
6260 |
-
return old;
|
6261 |
-
}
|
6262 |
-
|
6263 |
-
// Used to 'clip' out readOnly ranges when making a change.
|
6264 |
-
function removeReadOnlyRanges(doc, from, to) {
|
6265 |
-
var markers = null;
|
6266 |
-
doc.iter(from.line, to.line + 1, function(line) {
|
6267 |
-
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
|
6268 |
-
var mark = line.markedSpans[i].marker;
|
6269 |
-
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
|
6270 |
-
(markers || (markers = [])).push(mark);
|
6271 |
-
}
|
6272 |
-
});
|
6273 |
-
if (!markers) return null;
|
6274 |
-
var parts = [{from: from, to: to}];
|
6275 |
-
for (var i = 0; i < markers.length; ++i) {
|
6276 |
-
var mk = markers[i], m = mk.find(0);
|
6277 |
-
for (var j = 0; j < parts.length; ++j) {
|
6278 |
-
var p = parts[j];
|
6279 |
-
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
|
6280 |
-
var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
|
6281 |
-
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
|
6282 |
-
newParts.push({from: p.from, to: m.from});
|
6283 |
-
if (dto > 0 || !mk.inclusiveRight && !dto)
|
6284 |
-
newParts.push({from: m.to, to: p.to});
|
6285 |
-
parts.splice.apply(parts, newParts);
|
6286 |
-
j += newParts.length - 1;
|
6287 |
-
}
|
6288 |
-
}
|
6289 |
-
return parts;
|
6290 |
-
}
|
6291 |
-
|
6292 |
-
// Connect or disconnect spans from a line.
|
6293 |
-
function detachMarkedSpans(line) {
|
6294 |
-
var spans = line.markedSpans;
|
6295 |
-
if (!spans) return;
|
6296 |
-
for (var i = 0; i < spans.length; ++i)
|
6297 |
-
spans[i].marker.detachLine(line);
|
6298 |
-
line.markedSpans = null;
|
6299 |
-
}
|
6300 |
-
function attachMarkedSpans(line, spans) {
|
6301 |
-
if (!spans) return;
|
6302 |
-
for (var i = 0; i < spans.length; ++i)
|
6303 |
-
spans[i].marker.attachLine(line);
|
6304 |
-
line.markedSpans = spans;
|
6305 |
-
}
|
6306 |
-
|
6307 |
-
// Helpers used when computing which overlapping collapsed span
|
6308 |
-
// counts as the larger one.
|
6309 |
-
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
|
6310 |
-
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
|
6311 |
-
|
6312 |
-
// Returns a number indicating which of two overlapping collapsed
|
6313 |
-
// spans is larger (and thus includes the other). Falls back to
|
6314 |
-
// comparing ids when the spans cover exactly the same range.
|
6315 |
-
function compareCollapsedMarkers(a, b) {
|
6316 |
-
var lenDiff = a.lines.length - b.lines.length;
|
6317 |
-
if (lenDiff != 0) return lenDiff;
|
6318 |
-
var aPos = a.find(), bPos = b.find();
|
6319 |
-
var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
|
6320 |
-
if (fromCmp) return -fromCmp;
|
6321 |
-
var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
|
6322 |
-
if (toCmp) return toCmp;
|
6323 |
-
return b.id - a.id;
|
6324 |
-
}
|
6325 |
-
|
6326 |
-
// Find out whether a line ends or starts in a collapsed span. If
|
6327 |
-
// so, return the marker for that span.
|
6328 |
-
function collapsedSpanAtSide(line, start) {
|
6329 |
-
var sps = sawCollapsedSpans && line.markedSpans, found;
|
6330 |
-
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
|
6331 |
-
sp = sps[i];
|
6332 |
-
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
|
6333 |
-
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
|
6334 |
-
found = sp.marker;
|
6335 |
-
}
|
6336 |
-
return found;
|
6337 |
-
}
|
6338 |
-
function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
|
6339 |
-
function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
|
6340 |
-
|
6341 |
-
// Test whether there exists a collapsed span that partially
|
6342 |
-
// overlaps (covers the start or end, but not both) of a new span.
|
6343 |
-
// Such overlap is not allowed.
|
6344 |
-
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
|
6345 |
-
var line = getLine(doc, lineNo);
|
6346 |
-
var sps = sawCollapsedSpans && line.markedSpans;
|
6347 |
-
if (sps) for (var i = 0; i < sps.length; ++i) {
|
6348 |
-
var sp = sps[i];
|
6349 |
-
if (!sp.marker.collapsed) continue;
|
6350 |
-
var found = sp.marker.find(0);
|
6351 |
-
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
|
6352 |
-
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
|
6353 |
-
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
|
6354 |
-
if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
|
6355 |
-
fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
|
6356 |
-
return true;
|
6357 |
-
}
|
6358 |
-
}
|
6359 |
-
|
6360 |
-
// A visual line is a line as drawn on the screen. Folding, for
|
6361 |
-
// example, can cause multiple logical lines to appear on the same
|
6362 |
-
// visual line. This finds the start of the visual line that the
|
6363 |
-
// given line is part of (usually that is the line itself).
|
6364 |
-
function visualLine(line) {
|
6365 |
-
var merged;
|
6366 |
-
while (merged = collapsedSpanAtStart(line))
|
6367 |
-
line = merged.find(-1, true).line;
|
6368 |
-
return line;
|
6369 |
-
}
|
6370 |
-
|
6371 |
-
// Returns an array of logical lines that continue the visual line
|
6372 |
-
// started by the argument, or undefined if there are no such lines.
|
6373 |
-
function visualLineContinued(line) {
|
6374 |
-
var merged, lines;
|
6375 |
-
while (merged = collapsedSpanAtEnd(line)) {
|
6376 |
-
line = merged.find(1, true).line;
|
6377 |
-
(lines || (lines = [])).push(line);
|
6378 |
-
}
|
6379 |
-
return lines;
|
6380 |
-
}
|
6381 |
-
|
6382 |
-
// Get the line number of the start of the visual line that the
|
6383 |
-
// given line number is part of.
|
6384 |
-
function visualLineNo(doc, lineN) {
|
6385 |
-
var line = getLine(doc, lineN), vis = visualLine(line);
|
6386 |
-
if (line == vis) return lineN;
|
6387 |
-
return lineNo(vis);
|
6388 |
-
}
|
6389 |
-
// Get the line number of the start of the next visual line after
|
6390 |
-
// the given line.
|
6391 |
-
function visualLineEndNo(doc, lineN) {
|
6392 |
-
if (lineN > doc.lastLine()) return lineN;
|
6393 |
-
var line = getLine(doc, lineN), merged;
|
6394 |
-
if (!lineIsHidden(doc, line)) return lineN;
|
6395 |
-
while (merged = collapsedSpanAtEnd(line))
|
6396 |
-
line = merged.find(1, true).line;
|
6397 |
-
return lineNo(line) + 1;
|
6398 |
-
}
|
6399 |
-
|
6400 |
-
// Compute whether a line is hidden. Lines count as hidden when they
|
6401 |
-
// are part of a visual line that starts with another line, or when
|
6402 |
-
// they are entirely covered by collapsed, non-widget span.
|
6403 |
-
function lineIsHidden(doc, line) {
|
6404 |
-
var sps = sawCollapsedSpans && line.markedSpans;
|
6405 |
-
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
|
6406 |
-
sp = sps[i];
|
6407 |
-
if (!sp.marker.collapsed) continue;
|
6408 |
-
if (sp.from == null) return true;
|
6409 |
-
if (sp.marker.widgetNode) continue;
|
6410 |
-
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
|
6411 |
-
return true;
|
6412 |
-
}
|
6413 |
-
}
|
6414 |
-
function lineIsHiddenInner(doc, line, span) {
|
6415 |
-
if (span.to == null) {
|
6416 |
-
var end = span.marker.find(1, true);
|
6417 |
-
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
|
6418 |
-
}
|
6419 |
-
if (span.marker.inclusiveRight && span.to == line.text.length)
|
6420 |
-
return true;
|
6421 |
-
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
|
6422 |
-
sp = line.markedSpans[i];
|
6423 |
-
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
|
6424 |
-
(sp.to == null || sp.to != span.from) &&
|
6425 |
-
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
6426 |
-
lineIsHiddenInner(doc, line, sp)) return true;
|
6427 |
-
}
|
6428 |
-
}
|
6429 |
-
|
6430 |
-
// LINE WIDGETS
|
6431 |
-
|
6432 |
-
// Line widgets are block elements displayed above or below a line.
|
6433 |
-
|
6434 |
-
var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
|
6435 |
-
if (options) for (var opt in options) if (options.hasOwnProperty(opt))
|
6436 |
-
this[opt] = options[opt];
|
6437 |
-
this.cm = cm;
|
6438 |
-
this.node = node;
|
6439 |
-
};
|
6440 |
-
eventMixin(LineWidget);
|
6441 |
-
|
6442 |
-
function adjustScrollWhenAboveVisible(cm, line, diff) {
|
6443 |
-
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
|
6444 |
-
addToScrollPos(cm, null, diff);
|
6445 |
-
}
|
6446 |
-
|
6447 |
-
LineWidget.prototype.clear = function() {
|
6448 |
-
var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
|
6449 |
-
if (no == null || !ws) return;
|
6450 |
-
for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
|
6451 |
-
if (!ws.length) line.widgets = null;
|
6452 |
-
var height = widgetHeight(this);
|
6453 |
-
runInOp(cm, function() {
|
6454 |
-
adjustScrollWhenAboveVisible(cm, line, -height);
|
6455 |
-
regLineChange(cm, no, "widget");
|
6456 |
-
updateLineHeight(line, Math.max(0, line.height - height));
|
6457 |
-
});
|
6458 |
-
};
|
6459 |
-
LineWidget.prototype.changed = function() {
|
6460 |
-
var oldH = this.height, cm = this.cm, line = this.line;
|
6461 |
-
this.height = null;
|
6462 |
-
var diff = widgetHeight(this) - oldH;
|
6463 |
-
if (!diff) return;
|
6464 |
-
runInOp(cm, function() {
|
6465 |
-
cm.curOp.forceUpdate = true;
|
6466 |
-
adjustScrollWhenAboveVisible(cm, line, diff);
|
6467 |
-
updateLineHeight(line, line.height + diff);
|
6468 |
-
});
|
6469 |
-
};
|
6470 |
-
|
6471 |
-
function widgetHeight(widget) {
|
6472 |
-
if (widget.height != null) return widget.height;
|
6473 |
-
if (!contains(document.body, widget.node)) {
|
6474 |
-
var parentStyle = "position: relative;";
|
6475 |
-
if (widget.coverGutter)
|
6476 |
-
parentStyle += "margin-left: -" + widget.cm.display.gutters.offsetWidth + "px;";
|
6477 |
-
if (widget.noHScroll)
|
6478 |
-
parentStyle += "width: " + widget.cm.display.wrapper.clientWidth + "px;";
|
6479 |
-
removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, parentStyle));
|
6480 |
-
}
|
6481 |
-
return widget.height = widget.node.offsetHeight;
|
6482 |
-
}
|
6483 |
-
|
6484 |
-
function addLineWidget(cm, handle, node, options) {
|
6485 |
-
var widget = new LineWidget(cm, node, options);
|
6486 |
-
if (widget.noHScroll) cm.display.alignWidgets = true;
|
6487 |
-
changeLine(cm.doc, handle, "widget", function(line) {
|
6488 |
-
var widgets = line.widgets || (line.widgets = []);
|
6489 |
-
if (widget.insertAt == null) widgets.push(widget);
|
6490 |
-
else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
|
6491 |
-
widget.line = line;
|
6492 |
-
if (!lineIsHidden(cm.doc, line)) {
|
6493 |
-
var aboveVisible = heightAtLine(line) < cm.doc.scrollTop;
|
6494 |
-
updateLineHeight(line, line.height + widgetHeight(widget));
|
6495 |
-
if (aboveVisible) addToScrollPos(cm, null, widget.height);
|
6496 |
-
cm.curOp.forceUpdate = true;
|
6497 |
-
}
|
6498 |
-
return true;
|
6499 |
-
});
|
6500 |
-
return widget;
|
6501 |
-
}
|
6502 |
-
|
6503 |
-
// LINE DATA STRUCTURE
|
6504 |
-
|
6505 |
-
// Line objects. These hold state related to a line, including
|
6506 |
-
// highlighting info (the styles array).
|
6507 |
-
var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
|
6508 |
-
this.text = text;
|
6509 |
-
attachMarkedSpans(this, markedSpans);
|
6510 |
-
this.height = estimateHeight ? estimateHeight(this) : 1;
|
6511 |
-
};
|
6512 |
-
eventMixin(Line);
|
6513 |
-
Line.prototype.lineNo = function() { return lineNo(this); };
|
6514 |
-
|
6515 |
-
// Change the content (text, markers) of a line. Automatically
|
6516 |
-
// invalidates cached information and tries to re-estimate the
|
6517 |
-
// line's height.
|
6518 |
-
function updateLine(line, text, markedSpans, estimateHeight) {
|
6519 |
-
line.text = text;
|
6520 |
-
if (line.stateAfter) line.stateAfter = null;
|
6521 |
-
if (line.styles) line.styles = null;
|
6522 |
-
if (line.order != null) line.order = null;
|
6523 |
-
detachMarkedSpans(line);
|
6524 |
-
attachMarkedSpans(line, markedSpans);
|
6525 |
-
var estHeight = estimateHeight ? estimateHeight(line) : 1;
|
6526 |
-
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
6527 |
-
}
|
6528 |
-
|
6529 |
-
// Detach a line from the document tree and its markers.
|
6530 |
-
function cleanUpLine(line) {
|
6531 |
-
line.parent = null;
|
6532 |
-
detachMarkedSpans(line);
|
6533 |
-
}
|
6534 |
-
|
6535 |
-
function extractLineClasses(type, output) {
|
6536 |
-
if (type) for (;;) {
|
6537 |
-
var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
|
6538 |
-
if (!lineClass) break;
|
6539 |
-
type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
|
6540 |
-
var prop = lineClass[1] ? "bgClass" : "textClass";
|
6541 |
-
if (output[prop] == null)
|
6542 |
-
output[prop] = lineClass[2];
|
6543 |
-
else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
|
6544 |
-
output[prop] += " " + lineClass[2];
|
6545 |
-
}
|
6546 |
-
return type;
|
6547 |
-
}
|
6548 |
-
|
6549 |
-
function callBlankLine(mode, state) {
|
6550 |
-
if (mode.blankLine) return mode.blankLine(state);
|
6551 |
-
if (!mode.innerMode) return;
|
6552 |
-
var inner = CodeMirror.innerMode(mode, state);
|
6553 |
-
if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
|
6554 |
-
}
|
6555 |
-
|
6556 |
-
function readToken(mode, stream, state, inner) {
|
6557 |
-
for (var i = 0; i < 10; i++) {
|
6558 |
-
if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
|
6559 |
-
var style = mode.token(stream, state);
|
6560 |
-
if (stream.pos > stream.start) return style;
|
6561 |
-
}
|
6562 |
-
throw new Error("Mode " + mode.name + " failed to advance stream.");
|
6563 |
-
}
|
6564 |
-
|
6565 |
-
// Utility for getTokenAt and getLineTokens
|
6566 |
-
function takeToken(cm, pos, precise, asArray) {
|
6567 |
-
function getObj(copy) {
|
6568 |
-
return {start: stream.start, end: stream.pos,
|
6569 |
-
string: stream.current(),
|
6570 |
-
type: style || null,
|
6571 |
-
state: copy ? copyState(doc.mode, state) : state};
|
6572 |
-
}
|
6573 |
-
|
6574 |
-
var doc = cm.doc, mode = doc.mode, style;
|
6575 |
-
pos = clipPos(doc, pos);
|
6576 |
-
var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
|
6577 |
-
var stream = new StringStream(line.text, cm.options.tabSize), tokens;
|
6578 |
-
if (asArray) tokens = [];
|
6579 |
-
while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
|
6580 |
-
stream.start = stream.pos;
|
6581 |
-
style = readToken(mode, stream, state);
|
6582 |
-
if (asArray) tokens.push(getObj(true));
|
6583 |
-
}
|
6584 |
-
return asArray ? tokens : getObj();
|
6585 |
-
}
|
6586 |
-
|
6587 |
-
// Run the given mode's parser over a line, calling f for each token.
|
6588 |
-
function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
|
6589 |
-
var flattenSpans = mode.flattenSpans;
|
6590 |
-
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
|
6591 |
-
var curStart = 0, curStyle = null;
|
6592 |
-
var stream = new StringStream(text, cm.options.tabSize), style;
|
6593 |
-
var inner = cm.options.addModeClass && [null];
|
6594 |
-
if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
|
6595 |
-
while (!stream.eol()) {
|
6596 |
-
if (stream.pos > cm.options.maxHighlightLength) {
|
6597 |
-
flattenSpans = false;
|
6598 |
-
if (forceToEnd) processLine(cm, text, state, stream.pos);
|
6599 |
-
stream.pos = text.length;
|
6600 |
-
style = null;
|
6601 |
-
} else {
|
6602 |
-
style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
|
6603 |
-
}
|
6604 |
-
if (inner) {
|
6605 |
-
var mName = inner[0].name;
|
6606 |
-
if (mName) style = "m-" + (style ? mName + " " + style : mName);
|
6607 |
-
}
|
6608 |
-
if (!flattenSpans || curStyle != style) {
|
6609 |
-
while (curStart < stream.start) {
|
6610 |
-
curStart = Math.min(stream.start, curStart + 50000);
|
6611 |
-
f(curStart, curStyle);
|
6612 |
-
}
|
6613 |
-
curStyle = style;
|
6614 |
-
}
|
6615 |
-
stream.start = stream.pos;
|
6616 |
-
}
|
6617 |
-
while (curStart < stream.pos) {
|
6618 |
-
// Webkit seems to refuse to render text nodes longer than 57444 characters
|
6619 |
-
var pos = Math.min(stream.pos, curStart + 50000);
|
6620 |
-
f(pos, curStyle);
|
6621 |
-
curStart = pos;
|
6622 |
-
}
|
6623 |
-
}
|
6624 |
-
|
6625 |
-
// Compute a style array (an array starting with a mode generation
|
6626 |
-
// -- for invalidation -- followed by pairs of end positions and
|
6627 |
-
// style strings), which is used to highlight the tokens on the
|
6628 |
-
// line.
|
6629 |
-
function highlightLine(cm, line, state, forceToEnd) {
|
6630 |
-
// A styles array always starts with a number identifying the
|
6631 |
-
// mode/overlays that it is based on (for easy invalidation).
|
6632 |
-
var st = [cm.state.modeGen], lineClasses = {};
|
6633 |
-
// Compute the base array of styles
|
6634 |
-
runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
|
6635 |
-
st.push(end, style);
|
6636 |
-
}, lineClasses, forceToEnd);
|
6637 |
-
|
6638 |
-
// Run overlays, adjust style array.
|
6639 |
-
for (var o = 0; o < cm.state.overlays.length; ++o) {
|
6640 |
-
var overlay = cm.state.overlays[o], i = 1, at = 0;
|
6641 |
-
runMode(cm, line.text, overlay.mode, true, function(end, style) {
|
6642 |
-
var start = i;
|
6643 |
-
// Ensure there's a token end at the current position, and that i points at it
|
6644 |
-
while (at < end) {
|
6645 |
-
var i_end = st[i];
|
6646 |
-
if (i_end > end)
|
6647 |
-
st.splice(i, 1, end, st[i+1], i_end);
|
6648 |
-
i += 2;
|
6649 |
-
at = Math.min(end, i_end);
|
6650 |
-
}
|
6651 |
-
if (!style) return;
|
6652 |
-
if (overlay.opaque) {
|
6653 |
-
st.splice(start, i - start, end, "cm-overlay " + style);
|
6654 |
-
i = start + 2;
|
6655 |
-
} else {
|
6656 |
-
for (; start < i; start += 2) {
|
6657 |
-
var cur = st[start+1];
|
6658 |
-
st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
|
6659 |
-
}
|
6660 |
-
}
|
6661 |
-
}, lineClasses);
|
6662 |
-
}
|
6663 |
-
|
6664 |
-
return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
|
6665 |
-
}
|
6666 |
-
|
6667 |
-
function getLineStyles(cm, line, updateFrontier) {
|
6668 |
-
if (!line.styles || line.styles[0] != cm.state.modeGen) {
|
6669 |
-
var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
|
6670 |
-
line.styles = result.styles;
|
6671 |
-
if (result.classes) line.styleClasses = result.classes;
|
6672 |
-
else if (line.styleClasses) line.styleClasses = null;
|
6673 |
-
if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
|
6674 |
-
}
|
6675 |
-
return line.styles;
|
6676 |
-
}
|
6677 |
-
|
6678 |
-
// Lightweight form of highlight -- proceed over this line and
|
6679 |
-
// update state, but don't save a style array. Used for lines that
|
6680 |
-
// aren't currently visible.
|
6681 |
-
function processLine(cm, text, state, startAt) {
|
6682 |
-
var mode = cm.doc.mode;
|
6683 |
-
var stream = new StringStream(text, cm.options.tabSize);
|
6684 |
-
stream.start = stream.pos = startAt || 0;
|
6685 |
-
if (text == "") callBlankLine(mode, state);
|
6686 |
-
while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
|
6687 |
-
readToken(mode, stream, state);
|
6688 |
-
stream.start = stream.pos;
|
6689 |
-
}
|
6690 |
-
}
|
6691 |
-
|
6692 |
-
// Convert a style as returned by a mode (either null, or a string
|
6693 |
-
// containing one or more styles) to a CSS style. This is cached,
|
6694 |
-
// and also looks for line-wide styles.
|
6695 |
-
var styleToClassCache = {}, styleToClassCacheWithMode = {};
|
6696 |
-
function interpretTokenStyle(style, options) {
|
6697 |
-
if (!style || /^\s*$/.test(style)) return null;
|
6698 |
-
var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
|
6699 |
-
return cache[style] ||
|
6700 |
-
(cache[style] = style.replace(/\S+/g, "cm-$&"));
|
6701 |
-
}
|
6702 |
-
|
6703 |
-
// Render the DOM representation of the text of a line. Also builds
|
6704 |
-
// up a 'line map', which points at the DOM nodes that represent
|
6705 |
-
// specific stretches of text, and is used by the measuring code.
|
6706 |
-
// The returned object contains the DOM node, this map, and
|
6707 |
-
// information about line-wide styles that were set by the mode.
|
6708 |
-
function buildLineContent(cm, lineView) {
|
6709 |
-
// The padding-right forces the element to have a 'border', which
|
6710 |
-
// is needed on Webkit to be able to get line-level bounding
|
6711 |
-
// rectangles for it (in measureChar).
|
6712 |
-
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
|
6713 |
-
var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm};
|
6714 |
-
lineView.measure = {};
|
6715 |
-
|
6716 |
-
// Iterate over the logical lines that make up this visual line.
|
6717 |
-
for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
|
6718 |
-
var line = i ? lineView.rest[i - 1] : lineView.line, order;
|
6719 |
-
builder.pos = 0;
|
6720 |
-
builder.addToken = buildToken;
|
6721 |
-
// Optionally wire in some hacks into the token-rendering
|
6722 |
-
// algorithm, to deal with browser quirks.
|
6723 |
-
if ((ie || webkit) && cm.getOption("lineWrapping"))
|
6724 |
-
builder.addToken = buildTokenSplitSpaces(builder.addToken);
|
6725 |
-
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
|
6726 |
-
builder.addToken = buildTokenBadBidi(builder.addToken, order);
|
6727 |
-
builder.map = [];
|
6728 |
-
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
|
6729 |
-
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
|
6730 |
-
if (line.styleClasses) {
|
6731 |
-
if (line.styleClasses.bgClass)
|
6732 |
-
builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
|
6733 |
-
if (line.styleClasses.textClass)
|
6734 |
-
builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
|
6735 |
-
}
|
6736 |
-
|
6737 |
-
// Ensure at least a single node is present, for measuring.
|
6738 |
-
if (builder.map.length == 0)
|
6739 |
-
builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
|
6740 |
-
|
6741 |
-
// Store the map and a cache object for the current logical line
|
6742 |
-
if (i == 0) {
|
6743 |
-
lineView.measure.map = builder.map;
|
6744 |
-
lineView.measure.cache = {};
|
6745 |
-
} else {
|
6746 |
-
(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
|
6747 |
-
(lineView.measure.caches || (lineView.measure.caches = [])).push({});
|
6748 |
-
}
|
6749 |
-
}
|
6750 |
-
|
6751 |
-
// See issue #2901
|
6752 |
-
if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
|
6753 |
-
builder.content.className = "cm-tab-wrap-hack";
|
6754 |
-
|
6755 |
-
signal(cm, "renderLine", cm, lineView.line, builder.pre);
|
6756 |
-
if (builder.pre.className)
|
6757 |
-
builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
|
6758 |
-
|
6759 |
-
return builder;
|
6760 |
-
}
|
6761 |
-
|
6762 |
-
function defaultSpecialCharPlaceholder(ch) {
|
6763 |
-
var token = elt("span", "\u2022", "cm-invalidchar");
|
6764 |
-
token.title = "\\u" + ch.charCodeAt(0).toString(16);
|
6765 |
-
token.setAttribute("aria-label", token.title);
|
6766 |
-
return token;
|
6767 |
-
}
|
6768 |
-
|
6769 |
-
// Build up the DOM representation for a single token, and add it to
|
6770 |
-
// the line map. Takes care to render special characters separately.
|
6771 |
-
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
|
6772 |
-
if (!text) return;
|
6773 |
-
var special = builder.cm.options.specialChars, mustWrap = false;
|
6774 |
-
if (!special.test(text)) {
|
6775 |
-
builder.col += text.length;
|
6776 |
-
var content = document.createTextNode(text);
|
6777 |
-
builder.map.push(builder.pos, builder.pos + text.length, content);
|
6778 |
-
if (ie && ie_version < 9) mustWrap = true;
|
6779 |
-
builder.pos += text.length;
|
6780 |
-
} else {
|
6781 |
-
var content = document.createDocumentFragment(), pos = 0;
|
6782 |
-
while (true) {
|
6783 |
-
special.lastIndex = pos;
|
6784 |
-
var m = special.exec(text);
|
6785 |
-
var skipped = m ? m.index - pos : text.length - pos;
|
6786 |
-
if (skipped) {
|
6787 |
-
var txt = document.createTextNode(text.slice(pos, pos + skipped));
|
6788 |
-
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
|
6789 |
-
else content.appendChild(txt);
|
6790 |
-
builder.map.push(builder.pos, builder.pos + skipped, txt);
|
6791 |
-
builder.col += skipped;
|
6792 |
-
builder.pos += skipped;
|
6793 |
-
}
|
6794 |
-
if (!m) break;
|
6795 |
-
pos += skipped + 1;
|
6796 |
-
if (m[0] == "\t") {
|
6797 |
-
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
|
6798 |
-
var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
|
6799 |
-
txt.setAttribute("role", "presentation");
|
6800 |
-
txt.setAttribute("cm-text", "\t");
|
6801 |
-
builder.col += tabWidth;
|
6802 |
-
} else {
|
6803 |
-
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
|
6804 |
-
txt.setAttribute("cm-text", m[0]);
|
6805 |
-
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
|
6806 |
-
else content.appendChild(txt);
|
6807 |
-
builder.col += 1;
|
6808 |
-
}
|
6809 |
-
builder.map.push(builder.pos, builder.pos + 1, txt);
|
6810 |
-
builder.pos++;
|
6811 |
-
}
|
6812 |
-
}
|
6813 |
-
if (style || startStyle || endStyle || mustWrap || css) {
|
6814 |
-
var fullStyle = style || "";
|
6815 |
-
if (startStyle) fullStyle += startStyle;
|
6816 |
-
if (endStyle) fullStyle += endStyle;
|
6817 |
-
var token = elt("span", [content], fullStyle, css);
|
6818 |
-
if (title) token.title = title;
|
6819 |
-
return builder.content.appendChild(token);
|
6820 |
-
}
|
6821 |
-
builder.content.appendChild(content);
|
6822 |
-
}
|
6823 |
-
|
6824 |
-
function buildTokenSplitSpaces(inner) {
|
6825 |
-
function split(old) {
|
6826 |
-
var out = " ";
|
6827 |
-
for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
|
6828 |
-
out += " ";
|
6829 |
-
return out;
|
6830 |
-
}
|
6831 |
-
return function(builder, text, style, startStyle, endStyle, title) {
|
6832 |
-
inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
|
6833 |
-
};
|
6834 |
-
}
|
6835 |
-
|
6836 |
-
// Work around nonsense dimensions being reported for stretches of
|
6837 |
-
// right-to-left text.
|
6838 |
-
function buildTokenBadBidi(inner, order) {
|
6839 |
-
return function(builder, text, style, startStyle, endStyle, title) {
|
6840 |
-
style = style ? style + " cm-force-border" : "cm-force-border";
|
6841 |
-
var start = builder.pos, end = start + text.length;
|
6842 |
-
for (;;) {
|
6843 |
-
// Find the part that overlaps with the start of this text
|
6844 |
-
for (var i = 0; i < order.length; i++) {
|
6845 |
-
var part = order[i];
|
6846 |
-
if (part.to > start && part.from <= start) break;
|
6847 |
-
}
|
6848 |
-
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title);
|
6849 |
-
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title);
|
6850 |
-
startStyle = null;
|
6851 |
-
text = text.slice(part.to - start);
|
6852 |
-
start = part.to;
|
6853 |
-
}
|
6854 |
-
};
|
6855 |
-
}
|
6856 |
-
|
6857 |
-
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
|
6858 |
-
var widget = !ignoreWidget && marker.widgetNode;
|
6859 |
-
if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
|
6860 |
-
if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
|
6861 |
-
if (!widget)
|
6862 |
-
widget = builder.content.appendChild(document.createElement("span"));
|
6863 |
-
widget.setAttribute("cm-marker", marker.id);
|
6864 |
-
}
|
6865 |
-
if (widget) {
|
6866 |
-
builder.cm.display.input.setUneditable(widget);
|
6867 |
-
builder.content.appendChild(widget);
|
6868 |
-
}
|
6869 |
-
builder.pos += size;
|
6870 |
-
}
|
6871 |
-
|
6872 |
-
// Outputs a number of spans to make up a line, taking highlighting
|
6873 |
-
// and marked text into account.
|
6874 |
-
function insertLineContent(line, builder, styles) {
|
6875 |
-
var spans = line.markedSpans, allText = line.text, at = 0;
|
6876 |
-
if (!spans) {
|
6877 |
-
for (var i = 1; i < styles.length; i+=2)
|
6878 |
-
builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
|
6879 |
-
return;
|
6880 |
-
}
|
6881 |
-
|
6882 |
-
var len = allText.length, pos = 0, i = 1, text = "", style, css;
|
6883 |
-
var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
|
6884 |
-
for (;;) {
|
6885 |
-
if (nextChange == pos) { // Update current marker set
|
6886 |
-
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
6887 |
-
collapsed = null; nextChange = Infinity;
|
6888 |
-
var foundBookmarks = [];
|
6889 |
-
for (var j = 0; j < spans.length; ++j) {
|
6890 |
-
var sp = spans[j], m = sp.marker;
|
6891 |
-
if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
|
6892 |
-
if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
|
6893 |
-
if (m.className) spanStyle += " " + m.className;
|
6894 |
-
if (m.css) css = m.css;
|
6895 |
-
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
6896 |
-
if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
|
6897 |
-
if (m.title && !title) title = m.title;
|
6898 |
-
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
6899 |
-
collapsed = sp;
|
6900 |
-
} else if (sp.from > pos && nextChange > sp.from) {
|
6901 |
-
nextChange = sp.from;
|
6902 |
-
}
|
6903 |
-
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);
|
6904 |
-
}
|
6905 |
-
if (collapsed && (collapsed.from || 0) == pos) {
|
6906 |
-
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
6907 |
-
collapsed.marker, collapsed.from == null);
|
6908 |
-
if (collapsed.to == null) return;
|
6909 |
-
}
|
6910 |
-
if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
|
6911 |
-
buildCollapsedSpan(builder, 0, foundBookmarks[j]);
|
6912 |
-
}
|
6913 |
-
if (pos >= len) break;
|
6914 |
-
|
6915 |
-
var upto = Math.min(len, nextChange);
|
6916 |
-
while (true) {
|
6917 |
-
if (text) {
|
6918 |
-
var end = pos + text.length;
|
6919 |
-
if (!collapsed) {
|
6920 |
-
var tokenText = end > upto ? text.slice(0, upto - pos) : text;
|
6921 |
-
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
|
6922 |
-
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
|
6923 |
-
}
|
6924 |
-
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
|
6925 |
-
pos = end;
|
6926 |
-
spanStartStyle = "";
|
6927 |
-
}
|
6928 |
-
text = allText.slice(at, at = styles[i++]);
|
6929 |
-
style = interpretTokenStyle(styles[i++], builder.cm.options);
|
6930 |
-
}
|
6931 |
-
}
|
6932 |
-
}
|
6933 |
-
|
6934 |
-
// DOCUMENT DATA STRUCTURE
|
6935 |
-
|
6936 |
-
// By default, updates that start and end at the beginning of a line
|
6937 |
-
// are treated specially, in order to make the association of line
|
6938 |
-
// widgets and marker elements with the text behave more intuitive.
|
6939 |
-
function isWholeLineUpdate(doc, change) {
|
6940 |
-
return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
|
6941 |
-
(!doc.cm || doc.cm.options.wholeLineUpdateBefore);
|
6942 |
-
}
|
6943 |
-
|
6944 |
-
// Perform a change on the document data structure.
|
6945 |
-
function updateDoc(doc, change, markedSpans, estimateHeight) {
|
6946 |
-
function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
|
6947 |
-
function update(line, text, spans) {
|
6948 |
-
updateLine(line, text, spans, estimateHeight);
|
6949 |
-
signalLater(line, "change", line, change);
|
6950 |
-
}
|
6951 |
-
function linesFor(start, end) {
|
6952 |
-
for (var i = start, result = []; i < end; ++i)
|
6953 |
-
result.push(new Line(text[i], spansFor(i), estimateHeight));
|
6954 |
-
return result;
|
6955 |
-
}
|
6956 |
-
|
6957 |
-
var from = change.from, to = change.to, text = change.text;
|
6958 |
-
var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
|
6959 |
-
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
|
6960 |
-
|
6961 |
-
// Adjust the line structure
|
6962 |
-
if (change.full) {
|
6963 |
-
doc.insert(0, linesFor(0, text.length));
|
6964 |
-
doc.remove(text.length, doc.size - text.length);
|
6965 |
-
} else if (isWholeLineUpdate(doc, change)) {
|
6966 |
-
// This is a whole-line replace. Treated specially to make
|
6967 |
-
// sure line objects move the way they are supposed to.
|
6968 |
-
var added = linesFor(0, text.length - 1);
|
6969 |
-
update(lastLine, lastLine.text, lastSpans);
|
6970 |
-
if (nlines) doc.remove(from.line, nlines);
|
6971 |
-
if (added.length) doc.insert(from.line, added);
|
6972 |
-
} else if (firstLine == lastLine) {
|
6973 |
-
if (text.length == 1) {
|
6974 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
|
6975 |
-
} else {
|
6976 |
-
var added = linesFor(1, text.length - 1);
|
6977 |
-
added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
|
6978 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
|
6979 |
-
doc.insert(from.line + 1, added);
|
6980 |
-
}
|
6981 |
-
} else if (text.length == 1) {
|
6982 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
|
6983 |
-
doc.remove(from.line + 1, nlines);
|
6984 |
-
} else {
|
6985 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
|
6986 |
-
update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
|
6987 |
-
var added = linesFor(1, text.length - 1);
|
6988 |
-
if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
|
6989 |
-
doc.insert(from.line + 1, added);
|
6990 |
-
}
|
6991 |
-
|
6992 |
-
signalLater(doc, "change", doc, change);
|
6993 |
-
}
|
6994 |
-
|
6995 |
-
// The document is represented as a BTree consisting of leaves, with
|
6996 |
-
// chunk of lines in them, and branches, with up to ten leaves or
|
6997 |
-
// other branch nodes below them. The top node is always a branch
|
6998 |
-
// node, and is the document object itself (meaning it has
|
6999 |
-
// additional methods and properties).
|
7000 |
-
//
|
7001 |
-
// All nodes have parent links. The tree is used both to go from
|
7002 |
-
// line numbers to line objects, and to go from objects to numbers.
|
7003 |
-
// It also indexes by height, and is used to convert between height
|
7004 |
-
// and line object, and to find the total height of the document.
|
7005 |
-
//
|
7006 |
-
// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
|
7007 |
-
|
7008 |
-
function LeafChunk(lines) {
|
7009 |
-
this.lines = lines;
|
7010 |
-
this.parent = null;
|
7011 |
-
for (var i = 0, height = 0; i < lines.length; ++i) {
|
7012 |
-
lines[i].parent = this;
|
7013 |
-
height += lines[i].height;
|
7014 |
-
}
|
7015 |
-
this.height = height;
|
7016 |
-
}
|
7017 |
-
|
7018 |
-
LeafChunk.prototype = {
|
7019 |
-
chunkSize: function() { return this.lines.length; },
|
7020 |
-
// Remove the n lines at offset 'at'.
|
7021 |
-
removeInner: function(at, n) {
|
7022 |
-
for (var i = at, e = at + n; i < e; ++i) {
|
7023 |
-
var line = this.lines[i];
|
7024 |
-
this.height -= line.height;
|
7025 |
-
cleanUpLine(line);
|
7026 |
-
signalLater(line, "delete");
|
7027 |
-
}
|
7028 |
-
this.lines.splice(at, n);
|
7029 |
-
},
|
7030 |
-
// Helper used to collapse a small branch into a single leaf.
|
7031 |
-
collapse: function(lines) {
|
7032 |
-
lines.push.apply(lines, this.lines);
|
7033 |
-
},
|
7034 |
-
// Insert the given array of lines at offset 'at', count them as
|
7035 |
-
// having the given height.
|
7036 |
-
insertInner: function(at, lines, height) {
|
7037 |
-
this.height += height;
|
7038 |
-
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
|
7039 |
-
for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
|
7040 |
-
},
|
7041 |
-
// Used to iterate over a part of the tree.
|
7042 |
-
iterN: function(at, n, op) {
|
7043 |
-
for (var e = at + n; at < e; ++at)
|
7044 |
-
if (op(this.lines[at])) return true;
|
7045 |
-
}
|
7046 |
-
};
|
7047 |
-
|
7048 |
-
function BranchChunk(children) {
|
7049 |
-
this.children = children;
|
7050 |
-
var size = 0, height = 0;
|
7051 |
-
for (var i = 0; i < children.length; ++i) {
|
7052 |
-
var ch = children[i];
|
7053 |
-
size += ch.chunkSize(); height += ch.height;
|
7054 |
-
ch.parent = this;
|
7055 |
-
}
|
7056 |
-
this.size = size;
|
7057 |
-
this.height = height;
|
7058 |
-
this.parent = null;
|
7059 |
-
}
|
7060 |
-
|
7061 |
-
BranchChunk.prototype = {
|
7062 |
-
chunkSize: function() { return this.size; },
|
7063 |
-
removeInner: function(at, n) {
|
7064 |
-
this.size -= n;
|
7065 |
-
for (var i = 0; i < this.children.length; ++i) {
|
7066 |
-
var child = this.children[i], sz = child.chunkSize();
|
7067 |
-
if (at < sz) {
|
7068 |
-
var rm = Math.min(n, sz - at), oldHeight = child.height;
|
7069 |
-
child.removeInner(at, rm);
|
7070 |
-
this.height -= oldHeight - child.height;
|
7071 |
-
if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
|
7072 |
-
if ((n -= rm) == 0) break;
|
7073 |
-
at = 0;
|
7074 |
-
} else at -= sz;
|
7075 |
-
}
|
7076 |
-
// If the result is smaller than 25 lines, ensure that it is a
|
7077 |
-
// single leaf node.
|
7078 |
-
if (this.size - n < 25 &&
|
7079 |
-
(this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
|
7080 |
-
var lines = [];
|
7081 |
-
this.collapse(lines);
|
7082 |
-
this.children = [new LeafChunk(lines)];
|
7083 |
-
this.children[0].parent = this;
|
7084 |
-
}
|
7085 |
-
},
|
7086 |
-
collapse: function(lines) {
|
7087 |
-
for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
|
7088 |
-
},
|
7089 |
-
insertInner: function(at, lines, height) {
|
7090 |
-
this.size += lines.length;
|
7091 |
-
this.height += height;
|
7092 |
-
for (var i = 0; i < this.children.length; ++i) {
|
7093 |
-
var child = this.children[i], sz = child.chunkSize();
|
7094 |
-
if (at <= sz) {
|
7095 |
-
child.insertInner(at, lines, height);
|
7096 |
-
if (child.lines && child.lines.length > 50) {
|
7097 |
-
while (child.lines.length > 50) {
|
7098 |
-
var spilled = child.lines.splice(child.lines.length - 25, 25);
|
7099 |
-
var newleaf = new LeafChunk(spilled);
|
7100 |
-
child.height -= newleaf.height;
|
7101 |
-
this.children.splice(i + 1, 0, newleaf);
|
7102 |
-
newleaf.parent = this;
|
7103 |
-
}
|
7104 |
-
this.maybeSpill();
|
7105 |
-
}
|
7106 |
-
break;
|
7107 |
-
}
|
7108 |
-
at -= sz;
|
7109 |
-
}
|
7110 |
-
},
|
7111 |
-
// When a node has grown, check whether it should be split.
|
7112 |
-
maybeSpill: function() {
|
7113 |
-
if (this.children.length <= 10) return;
|
7114 |
-
var me = this;
|
7115 |
-
do {
|
7116 |
-
var spilled = me.children.splice(me.children.length - 5, 5);
|
7117 |
-
var sibling = new BranchChunk(spilled);
|
7118 |
-
if (!me.parent) { // Become the parent node
|
7119 |
-
var copy = new BranchChunk(me.children);
|
7120 |
-
copy.parent = me;
|
7121 |
-
me.children = [copy, sibling];
|
7122 |
-
me = copy;
|
7123 |
-
} else {
|
7124 |
-
me.size -= sibling.size;
|
7125 |
-
me.height -= sibling.height;
|
7126 |
-
var myIndex = indexOf(me.parent.children, me);
|
7127 |
-
me.parent.children.splice(myIndex + 1, 0, sibling);
|
7128 |
-
}
|
7129 |
-
sibling.parent = me.parent;
|
7130 |
-
} while (me.children.length > 10);
|
7131 |
-
me.parent.maybeSpill();
|
7132 |
-
},
|
7133 |
-
iterN: function(at, n, op) {
|
7134 |
-
for (var i = 0; i < this.children.length; ++i) {
|
7135 |
-
var child = this.children[i], sz = child.chunkSize();
|
7136 |
-
if (at < sz) {
|
7137 |
-
var used = Math.min(n, sz - at);
|
7138 |
-
if (child.iterN(at, used, op)) return true;
|
7139 |
-
if ((n -= used) == 0) break;
|
7140 |
-
at = 0;
|
7141 |
-
} else at -= sz;
|
7142 |
-
}
|
7143 |
-
}
|
7144 |
-
};
|
7145 |
-
|
7146 |
-
var nextDocId = 0;
|
7147 |
-
var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
|
7148 |
-
if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
|
7149 |
-
if (firstLine == null) firstLine = 0;
|
7150 |
-
|
7151 |
-
BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
|
7152 |
-
this.first = firstLine;
|
7153 |
-
this.scrollTop = this.scrollLeft = 0;
|
7154 |
-
this.cantEdit = false;
|
7155 |
-
this.cleanGeneration = 1;
|
7156 |
-
this.frontier = firstLine;
|
7157 |
-
var start = Pos(firstLine, 0);
|
7158 |
-
this.sel = simpleSelection(start);
|
7159 |
-
this.history = new History(null);
|
7160 |
-
this.id = ++nextDocId;
|
7161 |
-
this.modeOption = mode;
|
7162 |
-
|
7163 |
-
if (typeof text == "string") text = splitLines(text);
|
7164 |
-
updateDoc(this, {from: start, to: start, text: text});
|
7165 |
-
setSelection(this, simpleSelection(start), sel_dontScroll);
|
7166 |
-
};
|
7167 |
-
|
7168 |
-
Doc.prototype = createObj(BranchChunk.prototype, {
|
7169 |
-
constructor: Doc,
|
7170 |
-
// Iterate over the document. Supports two forms -- with only one
|
7171 |
-
// argument, it calls that for each line in the document. With
|
7172 |
-
// three, it iterates over the range given by the first two (with
|
7173 |
-
// the second being non-inclusive).
|
7174 |
-
iter: function(from, to, op) {
|
7175 |
-
if (op) this.iterN(from - this.first, to - from, op);
|
7176 |
-
else this.iterN(this.first, this.first + this.size, from);
|
7177 |
-
},
|
7178 |
-
|
7179 |
-
// Non-public interface for adding and removing lines.
|
7180 |
-
insert: function(at, lines) {
|
7181 |
-
var height = 0;
|
7182 |
-
for (var i = 0; i < lines.length; ++i) height += lines[i].height;
|
7183 |
-
this.insertInner(at - this.first, lines, height);
|
7184 |
-
},
|
7185 |
-
remove: function(at, n) { this.removeInner(at - this.first, n); },
|
7186 |
-
|
7187 |
-
// From here, the methods are part of the public interface. Most
|
7188 |
-
// are also available from CodeMirror (editor) instances.
|
7189 |
-
|
7190 |
-
getValue: function(lineSep) {
|
7191 |
-
var lines = getLines(this, this.first, this.first + this.size);
|
7192 |
-
if (lineSep === false) return lines;
|
7193 |
-
return lines.join(lineSep || "\n");
|
7194 |
-
},
|
7195 |
-
setValue: docMethodOp(function(code) {
|
7196 |
-
var top = Pos(this.first, 0), last = this.first + this.size - 1;
|
7197 |
-
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
7198 |
-
text: splitLines(code), origin: "setValue", full: true}, true);
|
7199 |
-
setSelection(this, simpleSelection(top));
|
7200 |
-
}),
|
7201 |
-
replaceRange: function(code, from, to, origin) {
|
7202 |
-
from = clipPos(this, from);
|
7203 |
-
to = to ? clipPos(this, to) : from;
|
7204 |
-
replaceRange(this, code, from, to, origin);
|
7205 |
-
},
|
7206 |
-
getRange: function(from, to, lineSep) {
|
7207 |
-
var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
|
7208 |
-
if (lineSep === false) return lines;
|
7209 |
-
return lines.join(lineSep || "\n");
|
7210 |
-
},
|
7211 |
-
|
7212 |
-
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
|
7213 |
-
|
7214 |
-
getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
|
7215 |
-
getLineNumber: function(line) {return lineNo(line);},
|
7216 |
-
|
7217 |
-
getLineHandleVisualStart: function(line) {
|
7218 |
-
if (typeof line == "number") line = getLine(this, line);
|
7219 |
-
return visualLine(line);
|
7220 |
-
},
|
7221 |
-
|
7222 |
-
lineCount: function() {return this.size;},
|
7223 |
-
firstLine: function() {return this.first;},
|
7224 |
-
lastLine: function() {return this.first + this.size - 1;},
|
7225 |
-
|
7226 |
-
clipPos: function(pos) {return clipPos(this, pos);},
|
7227 |
-
|
7228 |
-
getCursor: function(start) {
|
7229 |
-
var range = this.sel.primary(), pos;
|
7230 |
-
if (start == null || start == "head") pos = range.head;
|
7231 |
-
else if (start == "anchor") pos = range.anchor;
|
7232 |
-
else if (start == "end" || start == "to" || start === false) pos = range.to();
|
7233 |
-
else pos = range.from();
|
7234 |
-
return pos;
|
7235 |
-
},
|
7236 |
-
listSelections: function() { return this.sel.ranges; },
|
7237 |
-
somethingSelected: function() {return this.sel.somethingSelected();},
|
7238 |
-
|
7239 |
-
setCursor: docMethodOp(function(line, ch, options) {
|
7240 |
-
setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
|
7241 |
-
}),
|
7242 |
-
setSelection: docMethodOp(function(anchor, head, options) {
|
7243 |
-
setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
|
7244 |
-
}),
|
7245 |
-
extendSelection: docMethodOp(function(head, other, options) {
|
7246 |
-
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
7247 |
-
}),
|
7248 |
-
extendSelections: docMethodOp(function(heads, options) {
|
7249 |
-
extendSelections(this, clipPosArray(this, heads, options));
|
7250 |
-
}),
|
7251 |
-
extendSelectionsBy: docMethodOp(function(f, options) {
|
7252 |
-
extendSelections(this, map(this.sel.ranges, f), options);
|
7253 |
-
}),
|
7254 |
-
setSelections: docMethodOp(function(ranges, primary, options) {
|
7255 |
-
if (!ranges.length) return;
|
7256 |
-
for (var i = 0, out = []; i < ranges.length; i++)
|
7257 |
-
out[i] = new Range(clipPos(this, ranges[i].anchor),
|
7258 |
-
clipPos(this, ranges[i].head));
|
7259 |
-
if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
|
7260 |
-
setSelection(this, normalizeSelection(out, primary), options);
|
7261 |
-
}),
|
7262 |
-
addSelection: docMethodOp(function(anchor, head, options) {
|
7263 |
-
var ranges = this.sel.ranges.slice(0);
|
7264 |
-
ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
|
7265 |
-
setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
|
7266 |
-
}),
|
7267 |
-
|
7268 |
-
getSelection: function(lineSep) {
|
7269 |
-
var ranges = this.sel.ranges, lines;
|
7270 |
-
for (var i = 0; i < ranges.length; i++) {
|
7271 |
-
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
7272 |
-
lines = lines ? lines.concat(sel) : sel;
|
7273 |
-
}
|
7274 |
-
if (lineSep === false) return lines;
|
7275 |
-
else return lines.join(lineSep || "\n");
|
7276 |
-
},
|
7277 |
-
getSelections: function(lineSep) {
|
7278 |
-
var parts = [], ranges = this.sel.ranges;
|
7279 |
-
for (var i = 0; i < ranges.length; i++) {
|
7280 |
-
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
7281 |
-
if (lineSep !== false) sel = sel.join(lineSep || "\n");
|
7282 |
-
parts[i] = sel;
|
7283 |
-
}
|
7284 |
-
return parts;
|
7285 |
-
},
|
7286 |
-
replaceSelection: function(code, collapse, origin) {
|
7287 |
-
var dup = [];
|
7288 |
-
for (var i = 0; i < this.sel.ranges.length; i++)
|
7289 |
-
dup[i] = code;
|
7290 |
-
this.replaceSelections(dup, collapse, origin || "+input");
|
7291 |
-
},
|
7292 |
-
replaceSelections: docMethodOp(function(code, collapse, origin) {
|
7293 |
-
var changes = [], sel = this.sel;
|
7294 |
-
for (var i = 0; i < sel.ranges.length; i++) {
|
7295 |
-
var range = sel.ranges[i];
|
7296 |
-
changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
|
7297 |
-
}
|
7298 |
-
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
|
7299 |
-
for (var i = changes.length - 1; i >= 0; i--)
|
7300 |
-
makeChange(this, changes[i]);
|
7301 |
-
if (newSel) setSelectionReplaceHistory(this, newSel);
|
7302 |
-
else if (this.cm) ensureCursorVisible(this.cm);
|
7303 |
-
}),
|
7304 |
-
undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
|
7305 |
-
redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
|
7306 |
-
undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
|
7307 |
-
redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
|
7308 |
-
|
7309 |
-
setExtending: function(val) {this.extend = val;},
|
7310 |
-
getExtending: function() {return this.extend;},
|
7311 |
-
|
7312 |
-
historySize: function() {
|
7313 |
-
var hist = this.history, done = 0, undone = 0;
|
7314 |
-
for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
|
7315 |
-
for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
|
7316 |
-
return {undo: done, redo: undone};
|
7317 |
-
},
|
7318 |
-
clearHistory: function() {this.history = new History(this.history.maxGeneration);},
|
7319 |
-
|
7320 |
-
markClean: function() {
|
7321 |
-
this.cleanGeneration = this.changeGeneration(true);
|
7322 |
-
},
|
7323 |
-
changeGeneration: function(forceSplit) {
|
7324 |
-
if (forceSplit)
|
7325 |
-
this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
|
7326 |
-
return this.history.generation;
|
7327 |
-
},
|
7328 |
-
isClean: function (gen) {
|
7329 |
-
return this.history.generation == (gen || this.cleanGeneration);
|
7330 |
-
},
|
7331 |
-
|
7332 |
-
getHistory: function() {
|
7333 |
-
return {done: copyHistoryArray(this.history.done),
|
7334 |
-
undone: copyHistoryArray(this.history.undone)};
|
7335 |
-
},
|
7336 |
-
setHistory: function(histData) {
|
7337 |
-
var hist = this.history = new History(this.history.maxGeneration);
|
7338 |
-
hist.done = copyHistoryArray(histData.done.slice(0), null, true);
|
7339 |
-
hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
|
7340 |
-
},
|
7341 |
-
|
7342 |
-
addLineClass: docMethodOp(function(handle, where, cls) {
|
7343 |
-
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
|
7344 |
-
var prop = where == "text" ? "textClass"
|
7345 |
-
: where == "background" ? "bgClass"
|
7346 |
-
: where == "gutter" ? "gutterClass" : "wrapClass";
|
7347 |
-
if (!line[prop]) line[prop] = cls;
|
7348 |
-
else if (classTest(cls).test(line[prop])) return false;
|
7349 |
-
else line[prop] += " " + cls;
|
7350 |
-
return true;
|
7351 |
-
});
|
7352 |
-
}),
|
7353 |
-
removeLineClass: docMethodOp(function(handle, where, cls) {
|
7354 |
-
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
|
7355 |
-
var prop = where == "text" ? "textClass"
|
7356 |
-
: where == "background" ? "bgClass"
|
7357 |
-
: where == "gutter" ? "gutterClass" : "wrapClass";
|
7358 |
-
var cur = line[prop];
|
7359 |
-
if (!cur) return false;
|
7360 |
-
else if (cls == null) line[prop] = null;
|
7361 |
-
else {
|
7362 |
-
var found = cur.match(classTest(cls));
|
7363 |
-
if (!found) return false;
|
7364 |
-
var end = found.index + found[0].length;
|
7365 |
-
line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
|
7366 |
-
}
|
7367 |
-
return true;
|
7368 |
-
});
|
7369 |
-
}),
|
7370 |
-
|
7371 |
-
markText: function(from, to, options) {
|
7372 |
-
return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
|
7373 |
-
},
|
7374 |
-
setBookmark: function(pos, options) {
|
7375 |
-
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
7376 |
-
insertLeft: options && options.insertLeft,
|
7377 |
-
clearWhenEmpty: false, shared: options && options.shared};
|
7378 |
-
pos = clipPos(this, pos);
|
7379 |
-
return markText(this, pos, pos, realOpts, "bookmark");
|
7380 |
-
},
|
7381 |
-
findMarksAt: function(pos) {
|
7382 |
-
pos = clipPos(this, pos);
|
7383 |
-
var markers = [], spans = getLine(this, pos.line).markedSpans;
|
7384 |
-
if (spans) for (var i = 0; i < spans.length; ++i) {
|
7385 |
-
var span = spans[i];
|
7386 |
-
if ((span.from == null || span.from <= pos.ch) &&
|
7387 |
-
(span.to == null || span.to >= pos.ch))
|
7388 |
-
markers.push(span.marker.parent || span.marker);
|
7389 |
-
}
|
7390 |
-
return markers;
|
7391 |
-
},
|
7392 |
-
findMarks: function(from, to, filter) {
|
7393 |
-
from = clipPos(this, from); to = clipPos(this, to);
|
7394 |
-
var found = [], lineNo = from.line;
|
7395 |
-
this.iter(from.line, to.line + 1, function(line) {
|
7396 |
-
var spans = line.markedSpans;
|
7397 |
-
if (spans) for (var i = 0; i < spans.length; i++) {
|
7398 |
-
var span = spans[i];
|
7399 |
-
if (!(lineNo == from.line && from.ch > span.to ||
|
7400 |
-
span.from == null && lineNo != from.line||
|
7401 |
-
lineNo == to.line && span.from > to.ch) &&
|
7402 |
-
(!filter || filter(span.marker)))
|
7403 |
-
found.push(span.marker.parent || span.marker);
|
7404 |
-
}
|
7405 |
-
++lineNo;
|
7406 |
-
});
|
7407 |
-
return found;
|
7408 |
-
},
|
7409 |
-
getAllMarks: function() {
|
7410 |
-
var markers = [];
|
7411 |
-
this.iter(function(line) {
|
7412 |
-
var sps = line.markedSpans;
|
7413 |
-
if (sps) for (var i = 0; i < sps.length; ++i)
|
7414 |
-
if (sps[i].from != null) markers.push(sps[i].marker);
|
7415 |
-
});
|
7416 |
-
return markers;
|
7417 |
-
},
|
7418 |
-
|
7419 |
-
posFromIndex: function(off) {
|
7420 |
-
var ch, lineNo = this.first;
|
7421 |
-
this.iter(function(line) {
|
7422 |
-
var sz = line.text.length + 1;
|
7423 |
-
if (sz > off) { ch = off; return true; }
|
7424 |
-
off -= sz;
|
7425 |
-
++lineNo;
|
7426 |
-
});
|
7427 |
-
return clipPos(this, Pos(lineNo, ch));
|
7428 |
-
},
|
7429 |
-
indexFromPos: function (coords) {
|
7430 |
-
coords = clipPos(this, coords);
|
7431 |
-
var index = coords.ch;
|
7432 |
-
if (coords.line < this.first || coords.ch < 0) return 0;
|
7433 |
-
this.iter(this.first, coords.line, function (line) {
|
7434 |
-
index += line.text.length + 1;
|
7435 |
-
});
|
7436 |
-
return index;
|
7437 |
-
},
|
7438 |
-
|
7439 |
-
copy: function(copyHistory) {
|
7440 |
-
var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
|
7441 |
-
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
|
7442 |
-
doc.sel = this.sel;
|
7443 |
-
doc.extend = false;
|
7444 |
-
if (copyHistory) {
|
7445 |
-
doc.history.undoDepth = this.history.undoDepth;
|
7446 |
-
doc.setHistory(this.getHistory());
|
7447 |
-
}
|
7448 |
-
return doc;
|
7449 |
-
},
|
7450 |
-
|
7451 |
-
linkedDoc: function(options) {
|
7452 |
-
if (!options) options = {};
|
7453 |
-
var from = this.first, to = this.first + this.size;
|
7454 |
-
if (options.from != null && options.from > from) from = options.from;
|
7455 |
-
if (options.to != null && options.to < to) to = options.to;
|
7456 |
-
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
|
7457 |
-
if (options.sharedHist) copy.history = this.history;
|
7458 |
-
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
|
7459 |
-
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
|
7460 |
-
copySharedMarkers(copy, findSharedMarkers(this));
|
7461 |
-
return copy;
|
7462 |
-
},
|
7463 |
-
unlinkDoc: function(other) {
|
7464 |
-
if (other instanceof CodeMirror) other = other.doc;
|
7465 |
-
if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
|
7466 |
-
var link = this.linked[i];
|
7467 |
-
if (link.doc != other) continue;
|
7468 |
-
this.linked.splice(i, 1);
|
7469 |
-
other.unlinkDoc(this);
|
7470 |
-
detachSharedMarkers(findSharedMarkers(this));
|
7471 |
-
break;
|
7472 |
-
}
|
7473 |
-
// If the histories were shared, split them again
|
7474 |
-
if (other.history == this.history) {
|
7475 |
-
var splitIds = [other.id];
|
7476 |
-
linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
|
7477 |
-
other.history = new History(null);
|
7478 |
-
other.history.done = copyHistoryArray(this.history.done, splitIds);
|
7479 |
-
other.history.undone = copyHistoryArray(this.history.undone, splitIds);
|
7480 |
-
}
|
7481 |
-
},
|
7482 |
-
iterLinkedDocs: function(f) {linkedDocs(this, f);},
|
7483 |
-
|
7484 |
-
getMode: function() {return this.mode;},
|
7485 |
-
getEditor: function() {return this.cm;}
|
7486 |
-
});
|
7487 |
-
|
7488 |
-
// Public alias.
|
7489 |
-
Doc.prototype.eachLine = Doc.prototype.iter;
|
7490 |
-
|
7491 |
-
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
|
7492 |
-
var dontDelegate = "iter insert remove copy getEditor".split(" ");
|
7493 |
-
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
|
7494 |
-
CodeMirror.prototype[prop] = (function(method) {
|
7495 |
-
return function() {return method.apply(this.doc, arguments);};
|
7496 |
-
})(Doc.prototype[prop]);
|
7497 |
-
|
7498 |
-
eventMixin(Doc);
|
7499 |
-
|
7500 |
-
// Call f for all linked documents.
|
7501 |
-
function linkedDocs(doc, f, sharedHistOnly) {
|
7502 |
-
function propagate(doc, skip, sharedHist) {
|
7503 |
-
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
|
7504 |
-
var rel = doc.linked[i];
|
7505 |
-
if (rel.doc == skip) continue;
|
7506 |
-
var shared = sharedHist && rel.sharedHist;
|
7507 |
-
if (sharedHistOnly && !shared) continue;
|
7508 |
-
f(rel.doc, shared);
|
7509 |
-
propagate(rel.doc, doc, shared);
|
7510 |
-
}
|
7511 |
-
}
|
7512 |
-
propagate(doc, null, true);
|
7513 |
-
}
|
7514 |
-
|
7515 |
-
// Attach a document to an editor.
|
7516 |
-
function attachDoc(cm, doc) {
|
7517 |
-
if (doc.cm) throw new Error("This document is already in use.");
|
7518 |
-
cm.doc = doc;
|
7519 |
-
doc.cm = cm;
|
7520 |
-
estimateLineHeights(cm);
|
7521 |
-
loadMode(cm);
|
7522 |
-
if (!cm.options.lineWrapping) findMaxLine(cm);
|
7523 |
-
cm.options.mode = doc.modeOption;
|
7524 |
-
regChange(cm);
|
7525 |
-
}
|
7526 |
-
|
7527 |
-
// LINE UTILITIES
|
7528 |
-
|
7529 |
-
// Find the line object corresponding to the given line number.
|
7530 |
-
function getLine(doc, n) {
|
7531 |
-
n -= doc.first;
|
7532 |
-
if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
|
7533 |
-
for (var chunk = doc; !chunk.lines;) {
|
7534 |
-
for (var i = 0;; ++i) {
|
7535 |
-
var child = chunk.children[i], sz = child.chunkSize();
|
7536 |
-
if (n < sz) { chunk = child; break; }
|
7537 |
-
n -= sz;
|
7538 |
-
}
|
7539 |
-
}
|
7540 |
-
return chunk.lines[n];
|
7541 |
-
}
|
7542 |
-
|
7543 |
-
// Get the part of a document between two positions, as an array of
|
7544 |
-
// strings.
|
7545 |
-
function getBetween(doc, start, end) {
|
7546 |
-
var out = [], n = start.line;
|
7547 |
-
doc.iter(start.line, end.line + 1, function(line) {
|
7548 |
-
var text = line.text;
|
7549 |
-
if (n == end.line) text = text.slice(0, end.ch);
|
7550 |
-
if (n == start.line) text = text.slice(start.ch);
|
7551 |
-
out.push(text);
|
7552 |
-
++n;
|
7553 |
-
});
|
7554 |
-
return out;
|
7555 |
-
}
|
7556 |
-
// Get the lines between from and to, as array of strings.
|
7557 |
-
function getLines(doc, from, to) {
|
7558 |
-
var out = [];
|
7559 |
-
doc.iter(from, to, function(line) { out.push(line.text); });
|
7560 |
-
return out;
|
7561 |
-
}
|
7562 |
-
|
7563 |
-
// Update the height of a line, propagating the height change
|
7564 |
-
// upwards to parent nodes.
|
7565 |
-
function updateLineHeight(line, height) {
|
7566 |
-
var diff = height - line.height;
|
7567 |
-
if (diff) for (var n = line; n; n = n.parent) n.height += diff;
|
7568 |
-
}
|
7569 |
-
|
7570 |
-
// Given a line object, find its line number by walking up through
|
7571 |
-
// its parent links.
|
7572 |
-
function lineNo(line) {
|
7573 |
-
if (line.parent == null) return null;
|
7574 |
-
var cur = line.parent, no = indexOf(cur.lines, line);
|
7575 |
-
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
|
7576 |
-
for (var i = 0;; ++i) {
|
7577 |
-
if (chunk.children[i] == cur) break;
|
7578 |
-
no += chunk.children[i].chunkSize();
|
7579 |
-
}
|
7580 |
-
}
|
7581 |
-
return no + cur.first;
|
7582 |
-
}
|
7583 |
-
|
7584 |
-
// Find the line at the given vertical position, using the height
|
7585 |
-
// information in the document tree.
|
7586 |
-
function lineAtHeight(chunk, h) {
|
7587 |
-
var n = chunk.first;
|
7588 |
-
outer: do {
|
7589 |
-
for (var i = 0; i < chunk.children.length; ++i) {
|
7590 |
-
var child = chunk.children[i], ch = child.height;
|
7591 |
-
if (h < ch) { chunk = child; continue outer; }
|
7592 |
-
h -= ch;
|
7593 |
-
n += child.chunkSize();
|
7594 |
-
}
|
7595 |
-
return n;
|
7596 |
-
} while (!chunk.lines);
|
7597 |
-
for (var i = 0; i < chunk.lines.length; ++i) {
|
7598 |
-
var line = chunk.lines[i], lh = line.height;
|
7599 |
-
if (h < lh) break;
|
7600 |
-
h -= lh;
|
7601 |
-
}
|
7602 |
-
return n + i;
|
7603 |
-
}
|
7604 |
-
|
7605 |
-
|
7606 |
-
// Find the height above the given line.
|
7607 |
-
function heightAtLine(lineObj) {
|
7608 |
-
lineObj = visualLine(lineObj);
|
7609 |
-
|
7610 |
-
var h = 0, chunk = lineObj.parent;
|
7611 |
-
for (var i = 0; i < chunk.lines.length; ++i) {
|
7612 |
-
var line = chunk.lines[i];
|
7613 |
-
if (line == lineObj) break;
|
7614 |
-
else h += line.height;
|
7615 |
-
}
|
7616 |
-
for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
|
7617 |
-
for (var i = 0; i < p.children.length; ++i) {
|
7618 |
-
var cur = p.children[i];
|
7619 |
-
if (cur == chunk) break;
|
7620 |
-
else h += cur.height;
|
7621 |
-
}
|
7622 |
-
}
|
7623 |
-
return h;
|
7624 |
-
}
|
7625 |
-
|
7626 |
-
// Get the bidi ordering for the given line (and cache it). Returns
|
7627 |
-
// false for lines that are fully left-to-right, and an array of
|
7628 |
-
// BidiSpan objects otherwise.
|
7629 |
-
function getOrder(line) {
|
7630 |
-
var order = line.order;
|
7631 |
-
if (order == null) order = line.order = bidiOrdering(line.text);
|
7632 |
-
return order;
|
7633 |
-
}
|
7634 |
-
|
7635 |
-
// HISTORY
|
7636 |
-
|
7637 |
-
function History(startGen) {
|
7638 |
-
// Arrays of change events and selections. Doing something adds an
|
7639 |
-
// event to done and clears undo. Undoing moves events from done
|
7640 |
-
// to undone, redoing moves them in the other direction.
|
7641 |
-
this.done = []; this.undone = [];
|
7642 |
-
this.undoDepth = Infinity;
|
7643 |
-
// Used to track when changes can be merged into a single undo
|
7644 |
-
// event
|
7645 |
-
this.lastModTime = this.lastSelTime = 0;
|
7646 |
-
this.lastOp = this.lastSelOp = null;
|
7647 |
-
this.lastOrigin = this.lastSelOrigin = null;
|
7648 |
-
// Used by the isClean() method
|
7649 |
-
this.generation = this.maxGeneration = startGen || 1;
|
7650 |
-
}
|
7651 |
-
|
7652 |
-
// Create a history change event from an updateDoc-style change
|
7653 |
-
// object.
|
7654 |
-
function historyChangeFromChange(doc, change) {
|
7655 |
-
var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
|
7656 |
-
attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
|
7657 |
-
linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
|
7658 |
-
return histChange;
|
7659 |
-
}
|
7660 |
-
|
7661 |
-
// Pop all selection events off the end of a history array. Stop at
|
7662 |
-
// a change event.
|
7663 |
-
function clearSelectionEvents(array) {
|
7664 |
-
while (array.length) {
|
7665 |
-
var last = lst(array);
|
7666 |
-
if (last.ranges) array.pop();
|
7667 |
-
else break;
|
7668 |
-
}
|
7669 |
-
}
|
7670 |
-
|
7671 |
-
// Find the top change event in the history. Pop off selection
|
7672 |
-
// events that are in the way.
|
7673 |
-
function lastChangeEvent(hist, force) {
|
7674 |
-
if (force) {
|
7675 |
-
clearSelectionEvents(hist.done);
|
7676 |
-
return lst(hist.done);
|
7677 |
-
} else if (hist.done.length && !lst(hist.done).ranges) {
|
7678 |
-
return lst(hist.done);
|
7679 |
-
} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
|
7680 |
-
hist.done.pop();
|
7681 |
-
return lst(hist.done);
|
7682 |
-
}
|
7683 |
-
}
|
7684 |
-
|
7685 |
-
// Register a change in the history. Merges changes that are within
|
7686 |
-
// a single operation, ore are close together with an origin that
|
7687 |
-
// allows merging (starting with "+") into a single event.
|
7688 |
-
function addChangeToHistory(doc, change, selAfter, opId) {
|
7689 |
-
var hist = doc.history;
|
7690 |
-
hist.undone.length = 0;
|
7691 |
-
var time = +new Date, cur;
|
7692 |
-
|
7693 |
-
if ((hist.lastOp == opId ||
|
7694 |
-
hist.lastOrigin == change.origin && change.origin &&
|
7695 |
-
((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
|
7696 |
-
change.origin.charAt(0) == "*")) &&
|
7697 |
-
(cur = lastChangeEvent(hist, hist.lastOp == opId))) {
|
7698 |
-
// Merge this change into the last event
|
7699 |
-
var last = lst(cur.changes);
|
7700 |
-
if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
|
7701 |
-
// Optimized case for simple insertion -- don't want to add
|
7702 |
-
// new changesets for every character typed
|
7703 |
-
last.to = changeEnd(change);
|
7704 |
-
} else {
|
7705 |
-
// Add new sub-event
|
7706 |
-
cur.changes.push(historyChangeFromChange(doc, change));
|
7707 |
-
}
|
7708 |
-
} else {
|
7709 |
-
// Can not be merged, start a new event.
|
7710 |
-
var before = lst(hist.done);
|
7711 |
-
if (!before || !before.ranges)
|
7712 |
-
pushSelectionToHistory(doc.sel, hist.done);
|
7713 |
-
cur = {changes: [historyChangeFromChange(doc, change)],
|
7714 |
-
generation: hist.generation};
|
7715 |
-
hist.done.push(cur);
|
7716 |
-
while (hist.done.length > hist.undoDepth) {
|
7717 |
-
hist.done.shift();
|
7718 |
-
if (!hist.done[0].ranges) hist.done.shift();
|
7719 |
-
}
|
7720 |
-
}
|
7721 |
-
hist.done.push(selAfter);
|
7722 |
-
hist.generation = ++hist.maxGeneration;
|
7723 |
-
hist.lastModTime = hist.lastSelTime = time;
|
7724 |
-
hist.lastOp = hist.lastSelOp = opId;
|
7725 |
-
hist.lastOrigin = hist.lastSelOrigin = change.origin;
|
7726 |
-
|
7727 |
-
if (!last) signal(doc, "historyAdded");
|
7728 |
-
}
|
7729 |
-
|
7730 |
-
function selectionEventCanBeMerged(doc, origin, prev, sel) {
|
7731 |
-
var ch = origin.charAt(0);
|
7732 |
-
return ch == "*" ||
|
7733 |
-
ch == "+" &&
|
7734 |
-
prev.ranges.length == sel.ranges.length &&
|
7735 |
-
prev.somethingSelected() == sel.somethingSelected() &&
|
7736 |
-
new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
|
7737 |
-
}
|
7738 |
-
|
7739 |
-
// Called whenever the selection changes, sets the new selection as
|
7740 |
-
// the pending selection in the history, and pushes the old pending
|
7741 |
-
// selection into the 'done' array when it was significantly
|
7742 |
-
// different (in number of selected ranges, emptiness, or time).
|
7743 |
-
function addSelectionToHistory(doc, sel, opId, options) {
|
7744 |
-
var hist = doc.history, origin = options && options.origin;
|
7745 |
-
|
7746 |
-
// A new event is started when the previous origin does not match
|
7747 |
-
// the current, or the origins don't allow matching. Origins
|
7748 |
-
// starting with * are always merged, those starting with + are
|
7749 |
-
// merged when similar and close together in time.
|
7750 |
-
if (opId == hist.lastSelOp ||
|
7751 |
-
(origin && hist.lastSelOrigin == origin &&
|
7752 |
-
(hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
|
7753 |
-
selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
|
7754 |
-
hist.done[hist.done.length - 1] = sel;
|
7755 |
-
else
|
7756 |
-
pushSelectionToHistory(sel, hist.done);
|
7757 |
-
|
7758 |
-
hist.lastSelTime = +new Date;
|
7759 |
-
hist.lastSelOrigin = origin;
|
7760 |
-
hist.lastSelOp = opId;
|
7761 |
-
if (options && options.clearRedo !== false)
|
7762 |
-
clearSelectionEvents(hist.undone);
|
7763 |
-
}
|
7764 |
-
|
7765 |
-
function pushSelectionToHistory(sel, dest) {
|
7766 |
-
var top = lst(dest);
|
7767 |
-
if (!(top && top.ranges && top.equals(sel)))
|
7768 |
-
dest.push(sel);
|
7769 |
-
}
|
7770 |
-
|
7771 |
-
// Used to store marked span information in the history.
|
7772 |
-
function attachLocalSpans(doc, change, from, to) {
|
7773 |
-
var existing = change["spans_" + doc.id], n = 0;
|
7774 |
-
doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
|
7775 |
-
if (line.markedSpans)
|
7776 |
-
(existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
|
7777 |
-
++n;
|
7778 |
-
});
|
7779 |
-
}
|
7780 |
-
|
7781 |
-
// When un/re-doing restores text containing marked spans, those
|
7782 |
-
// that have been explicitly cleared should not be restored.
|
7783 |
-
function removeClearedSpans(spans) {
|
7784 |
-
if (!spans) return null;
|
7785 |
-
for (var i = 0, out; i < spans.length; ++i) {
|
7786 |
-
if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
|
7787 |
-
else if (out) out.push(spans[i]);
|
7788 |
-
}
|
7789 |
-
return !out ? spans : out.length ? out : null;
|
7790 |
-
}
|
7791 |
-
|
7792 |
-
// Retrieve and filter the old marked spans stored in a change event.
|
7793 |
-
function getOldSpans(doc, change) {
|
7794 |
-
var found = change["spans_" + doc.id];
|
7795 |
-
if (!found) return null;
|
7796 |
-
for (var i = 0, nw = []; i < change.text.length; ++i)
|
7797 |
-
nw.push(removeClearedSpans(found[i]));
|
7798 |
-
return nw;
|
7799 |
-
}
|
7800 |
-
|
7801 |
-
// Used both to provide a JSON-safe object in .getHistory, and, when
|
7802 |
-
// detaching a document, to split the history in two
|
7803 |
-
function copyHistoryArray(events, newGroup, instantiateSel) {
|
7804 |
-
for (var i = 0, copy = []; i < events.length; ++i) {
|
7805 |
-
var event = events[i];
|
7806 |
-
if (event.ranges) {
|
7807 |
-
copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
|
7808 |
-
continue;
|
7809 |
-
}
|
7810 |
-
var changes = event.changes, newChanges = [];
|
7811 |
-
copy.push({changes: newChanges});
|
7812 |
-
for (var j = 0; j < changes.length; ++j) {
|
7813 |
-
var change = changes[j], m;
|
7814 |
-
newChanges.push({from: change.from, to: change.to, text: change.text});
|
7815 |
-
if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
|
7816 |
-
if (indexOf(newGroup, Number(m[1])) > -1) {
|
7817 |
-
lst(newChanges)[prop] = change[prop];
|
7818 |
-
delete change[prop];
|
7819 |
-
}
|
7820 |
-
}
|
7821 |
-
}
|
7822 |
-
}
|
7823 |
-
return copy;
|
7824 |
-
}
|
7825 |
-
|
7826 |
-
// Rebasing/resetting history to deal with externally-sourced changes
|
7827 |
-
|
7828 |
-
function rebaseHistSelSingle(pos, from, to, diff) {
|
7829 |
-
if (to < pos.line) {
|
7830 |
-
pos.line += diff;
|
7831 |
-
} else if (from < pos.line) {
|
7832 |
-
pos.line = from;
|
7833 |
-
pos.ch = 0;
|
7834 |
-
}
|
7835 |
-
}
|
7836 |
-
|
7837 |
-
// Tries to rebase an array of history events given a change in the
|
7838 |
-
// document. If the change touches the same lines as the event, the
|
7839 |
-
// event, and everything 'behind' it, is discarded. If the change is
|
7840 |
-
// before the event, the event's positions are updated. Uses a
|
7841 |
-
// copy-on-write scheme for the positions, to avoid having to
|
7842 |
-
// reallocate them all on every rebase, but also avoid problems with
|
7843 |
-
// shared position objects being unsafely updated.
|
7844 |
-
function rebaseHistArray(array, from, to, diff) {
|
7845 |
-
for (var i = 0; i < array.length; ++i) {
|
7846 |
-
var sub = array[i], ok = true;
|
7847 |
-
if (sub.ranges) {
|
7848 |
-
if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
|
7849 |
-
for (var j = 0; j < sub.ranges.length; j++) {
|
7850 |
-
rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
|
7851 |
-
rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
|
7852 |
-
}
|
7853 |
-
continue;
|
7854 |
-
}
|
7855 |
-
for (var j = 0; j < sub.changes.length; ++j) {
|
7856 |
-
var cur = sub.changes[j];
|
7857 |
-
if (to < cur.from.line) {
|
7858 |
-
cur.from = Pos(cur.from.line + diff, cur.from.ch);
|
7859 |
-
cur.to = Pos(cur.to.line + diff, cur.to.ch);
|
7860 |
-
} else if (from <= cur.to.line) {
|
7861 |
-
ok = false;
|
7862 |
-
break;
|
7863 |
-
}
|
7864 |
-
}
|
7865 |
-
if (!ok) {
|
7866 |
-
array.splice(0, i + 1);
|
7867 |
-
i = 0;
|
7868 |
-
}
|
7869 |
-
}
|
7870 |
-
}
|
7871 |
-
|
7872 |
-
function rebaseHist(hist, change) {
|
7873 |
-
var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
|
7874 |
-
rebaseHistArray(hist.done, from, to, diff);
|
7875 |
-
rebaseHistArray(hist.undone, from, to, diff);
|
7876 |
-
}
|
7877 |
-
|
7878 |
-
// EVENT UTILITIES
|
7879 |
-
|
7880 |
-
// Due to the fact that we still support jurassic IE versions, some
|
7881 |
-
// compatibility wrappers are needed.
|
7882 |
-
|
7883 |
-
var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
|
7884 |
-
if (e.preventDefault) e.preventDefault();
|
7885 |
-
else e.returnValue = false;
|
7886 |
-
};
|
7887 |
-
var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
|
7888 |
-
if (e.stopPropagation) e.stopPropagation();
|
7889 |
-
else e.cancelBubble = true;
|
7890 |
-
};
|
7891 |
-
function e_defaultPrevented(e) {
|
7892 |
-
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
|
7893 |
-
}
|
7894 |
-
var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
|
7895 |
-
|
7896 |
-
function e_target(e) {return e.target || e.srcElement;}
|
7897 |
-
function e_button(e) {
|
7898 |
-
var b = e.which;
|
7899 |
-
if (b == null) {
|
7900 |
-
if (e.button & 1) b = 1;
|
7901 |
-
else if (e.button & 2) b = 3;
|
7902 |
-
else if (e.button & 4) b = 2;
|
7903 |
-
}
|
7904 |
-
if (mac && e.ctrlKey && b == 1) b = 3;
|
7905 |
-
return b;
|
7906 |
-
}
|
7907 |
-
|
7908 |
-
// EVENT HANDLING
|
7909 |
-
|
7910 |
-
// Lightweight event framework. on/off also work on DOM nodes,
|
7911 |
-
// registering native DOM handlers.
|
7912 |
-
|
7913 |
-
var on = CodeMirror.on = function(emitter, type, f) {
|
7914 |
-
if (emitter.addEventListener)
|
7915 |
-
emitter.addEventListener(type, f, false);
|
7916 |
-
else if (emitter.attachEvent)
|
7917 |
-
emitter.attachEvent("on" + type, f);
|
7918 |
-
else {
|
7919 |
-
var map = emitter._handlers || (emitter._handlers = {});
|
7920 |
-
var arr = map[type] || (map[type] = []);
|
7921 |
-
arr.push(f);
|
7922 |
-
}
|
7923 |
-
};
|
7924 |
-
|
7925 |
-
var off = CodeMirror.off = function(emitter, type, f) {
|
7926 |
-
if (emitter.removeEventListener)
|
7927 |
-
emitter.removeEventListener(type, f, false);
|
7928 |
-
else if (emitter.detachEvent)
|
7929 |
-
emitter.detachEvent("on" + type, f);
|
7930 |
-
else {
|
7931 |
-
var arr = emitter._handlers && emitter._handlers[type];
|
7932 |
-
if (!arr) return;
|
7933 |
-
for (var i = 0; i < arr.length; ++i)
|
7934 |
-
if (arr[i] == f) { arr.splice(i, 1); break; }
|
7935 |
-
}
|
7936 |
-
};
|
7937 |
-
|
7938 |
-
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
7939 |
-
var arr = emitter._handlers && emitter._handlers[type];
|
7940 |
-
if (!arr) return;
|
7941 |
-
var args = Array.prototype.slice.call(arguments, 2);
|
7942 |
-
for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
|
7943 |
-
};
|
7944 |
-
|
7945 |
-
var orphanDelayedCallbacks = null;
|
7946 |
-
|
7947 |
-
// Often, we want to signal events at a point where we are in the
|
7948 |
-
// middle of some work, but don't want the handler to start calling
|
7949 |
-
// other methods on the editor, which might be in an inconsistent
|
7950 |
-
// state or simply not expect any other events to happen.
|
7951 |
-
// signalLater looks whether there are any handlers, and schedules
|
7952 |
-
// them to be executed when the last operation ends, or, if no
|
7953 |
-
// operation is active, when a timeout fires.
|
7954 |
-
function signalLater(emitter, type /*, values...*/) {
|
7955 |
-
var arr = emitter._handlers && emitter._handlers[type];
|
7956 |
-
if (!arr) return;
|
7957 |
-
var args = Array.prototype.slice.call(arguments, 2), list;
|
7958 |
-
if (operationGroup) {
|
7959 |
-
list = operationGroup.delayedCallbacks;
|
7960 |
-
} else if (orphanDelayedCallbacks) {
|
7961 |
-
list = orphanDelayedCallbacks;
|
7962 |
-
} else {
|
7963 |
-
list = orphanDelayedCallbacks = [];
|
7964 |
-
setTimeout(fireOrphanDelayed, 0);
|
7965 |
-
}
|
7966 |
-
function bnd(f) {return function(){f.apply(null, args);};};
|
7967 |
-
for (var i = 0; i < arr.length; ++i)
|
7968 |
-
list.push(bnd(arr[i]));
|
7969 |
-
}
|
7970 |
-
|
7971 |
-
function fireOrphanDelayed() {
|
7972 |
-
var delayed = orphanDelayedCallbacks;
|
7973 |
-
orphanDelayedCallbacks = null;
|
7974 |
-
for (var i = 0; i < delayed.length; ++i) delayed[i]();
|
7975 |
-
}
|
7976 |
-
|
7977 |
-
// The DOM events that CodeMirror handles can be overridden by
|
7978 |
-
// registering a (non-DOM) handler on the editor for the event name,
|
7979 |
-
// and preventDefault-ing the event in that handler.
|
7980 |
-
function signalDOMEvent(cm, e, override) {
|
7981 |
-
if (typeof e == "string")
|
7982 |
-
e = {type: e, preventDefault: function() { this.defaultPrevented = true; }};
|
7983 |
-
signal(cm, override || e.type, cm, e);
|
7984 |
-
return e_defaultPrevented(e) || e.codemirrorIgnore;
|
7985 |
-
}
|
7986 |
-
|
7987 |
-
function signalCursorActivity(cm) {
|
7988 |
-
var arr = cm._handlers && cm._handlers.cursorActivity;
|
7989 |
-
if (!arr) return;
|
7990 |
-
var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
|
7991 |
-
for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
|
7992 |
-
set.push(arr[i]);
|
7993 |
-
}
|
7994 |
-
|
7995 |
-
function hasHandler(emitter, type) {
|
7996 |
-
var arr = emitter._handlers && emitter._handlers[type];
|
7997 |
-
return arr && arr.length > 0;
|
7998 |
-
}
|
7999 |
-
|
8000 |
-
// Add on and off methods to a constructor's prototype, to make
|
8001 |
-
// registering events on such objects more convenient.
|
8002 |
-
function eventMixin(ctor) {
|
8003 |
-
ctor.prototype.on = function(type, f) {on(this, type, f);};
|
8004 |
-
ctor.prototype.off = function(type, f) {off(this, type, f);};
|
8005 |
-
}
|
8006 |
-
|
8007 |
-
// MISC UTILITIES
|
8008 |
-
|
8009 |
-
// Number of pixels added to scroller and sizer to hide scrollbar
|
8010 |
-
var scrollerGap = 30;
|
8011 |
-
|
8012 |
-
// Returned or thrown by various protocols to signal 'I'm not
|
8013 |
-
// handling this'.
|
8014 |
-
var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
|
8015 |
-
|
8016 |
-
// Reused option objects for setSelection & friends
|
8017 |
-
var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
|
8018 |
-
|
8019 |
-
function Delayed() {this.id = null;}
|
8020 |
-
Delayed.prototype.set = function(ms, f) {
|
8021 |
-
clearTimeout(this.id);
|
8022 |
-
this.id = setTimeout(f, ms);
|
8023 |
-
};
|
8024 |
-
|
8025 |
-
// Counts the column offset in a string, taking tabs into account.
|
8026 |
-
// Used mostly to find indentation.
|
8027 |
-
var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
|
8028 |
-
if (end == null) {
|
8029 |
-
end = string.search(/[^\s\u00a0]/);
|
8030 |
-
if (end == -1) end = string.length;
|
8031 |
-
}
|
8032 |
-
for (var i = startIndex || 0, n = startValue || 0;;) {
|
8033 |
-
var nextTab = string.indexOf("\t", i);
|
8034 |
-
if (nextTab < 0 || nextTab >= end)
|
8035 |
-
return n + (end - i);
|
8036 |
-
n += nextTab - i;
|
8037 |
-
n += tabSize - (n % tabSize);
|
8038 |
-
i = nextTab + 1;
|
8039 |
-
}
|
8040 |
-
};
|
8041 |
-
|
8042 |
-
// The inverse of countColumn -- find the offset that corresponds to
|
8043 |
-
// a particular column.
|
8044 |
-
function findColumn(string, goal, tabSize) {
|
8045 |
-
for (var pos = 0, col = 0;;) {
|
8046 |
-
var nextTab = string.indexOf("\t", pos);
|
8047 |
-
if (nextTab == -1) nextTab = string.length;
|
8048 |
-
var skipped = nextTab - pos;
|
8049 |
-
if (nextTab == string.length || col + skipped >= goal)
|
8050 |
-
return pos + Math.min(skipped, goal - col);
|
8051 |
-
col += nextTab - pos;
|
8052 |
-
col += tabSize - (col % tabSize);
|
8053 |
-
pos = nextTab + 1;
|
8054 |
-
if (col >= goal) return pos;
|
8055 |
-
}
|
8056 |
-
}
|
8057 |
-
|
8058 |
-
var spaceStrs = [""];
|
8059 |
-
function spaceStr(n) {
|
8060 |
-
while (spaceStrs.length <= n)
|
8061 |
-
spaceStrs.push(lst(spaceStrs) + " ");
|
8062 |
-
return spaceStrs[n];
|
8063 |
-
}
|
8064 |
-
|
8065 |
-
function lst(arr) { return arr[arr.length-1]; }
|
8066 |
-
|
8067 |
-
var selectInput = function(node) { node.select(); };
|
8068 |
-
if (ios) // Mobile Safari apparently has a bug where select() is broken.
|
8069 |
-
selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
|
8070 |
-
else if (ie) // Suppress mysterious IE10 errors
|
8071 |
-
selectInput = function(node) { try { node.select(); } catch(_e) {} };
|
8072 |
-
|
8073 |
-
function indexOf(array, elt) {
|
8074 |
-
for (var i = 0; i < array.length; ++i)
|
8075 |
-
if (array[i] == elt) return i;
|
8076 |
-
return -1;
|
8077 |
-
}
|
8078 |
-
function map(array, f) {
|
8079 |
-
var out = [];
|
8080 |
-
for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
|
8081 |
-
return out;
|
8082 |
-
}
|
8083 |
-
|
8084 |
-
function nothing() {}
|
8085 |
-
|
8086 |
-
function createObj(base, props) {
|
8087 |
-
var inst;
|
8088 |
-
if (Object.create) {
|
8089 |
-
inst = Object.create(base);
|
8090 |
-
} else {
|
8091 |
-
nothing.prototype = base;
|
8092 |
-
inst = new nothing();
|
8093 |
-
}
|
8094 |
-
if (props) copyObj(props, inst);
|
8095 |
-
return inst;
|
8096 |
-
};
|
8097 |
-
|
8098 |
-
function copyObj(obj, target, overwrite) {
|
8099 |
-
if (!target) target = {};
|
8100 |
-
for (var prop in obj)
|
8101 |
-
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
8102 |
-
target[prop] = obj[prop];
|
8103 |
-
return target;
|
8104 |
-
}
|
8105 |
-
|
8106 |
-
function bind(f) {
|
8107 |
-
var args = Array.prototype.slice.call(arguments, 1);
|
8108 |
-
return function(){return f.apply(null, args);};
|
8109 |
-
}
|
8110 |
-
|
8111 |
-
var nonASCIISingleCaseWordChar = /[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
|
8112 |
-
var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
|
8113 |
-
return /\w/.test(ch) || ch > "\x80" &&
|
8114 |
-
(ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
|
8115 |
-
};
|
8116 |
-
function isWordChar(ch, helper) {
|
8117 |
-
if (!helper) return isWordCharBasic(ch);
|
8118 |
-
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
|
8119 |
-
return helper.test(ch);
|
8120 |
-
}
|
8121 |
-
|
8122 |
-
function isEmpty(obj) {
|
8123 |
-
for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
|
8124 |
-
return true;
|
8125 |
-
}
|
8126 |
-
|
8127 |
-
// Extending unicode characters. A series of a non-extending char +
|
8128 |
-
// any number of extending chars is treated as a single unit as far
|
8129 |
-
// as editing and measuring is concerned. This is not fully correct,
|
8130 |
-
// since some scripts/fonts/browsers also treat other configurations
|
8131 |
-
// of code points as a group.
|
8132 |
-
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]/;
|
8133 |
-
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
|
8134 |
-
|
8135 |
-
// DOM UTILITIES
|
8136 |
-
|
8137 |
-
function elt(tag, content, className, style) {
|
8138 |
-
var e = document.createElement(tag);
|
8139 |
-
if (className) e.className = className;
|
8140 |
-
if (style) e.style.cssText = style;
|
8141 |
-
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
8142 |
-
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
8143 |
-
return e;
|
8144 |
-
}
|
8145 |
-
|
8146 |
-
var range;
|
8147 |
-
if (document.createRange) range = function(node, start, end, endNode) {
|
8148 |
-
var r = document.createRange();
|
8149 |
-
r.setEnd(endNode || node, end);
|
8150 |
-
r.setStart(node, start);
|
8151 |
-
return r;
|
8152 |
-
};
|
8153 |
-
else range = function(node, start, end) {
|
8154 |
-
var r = document.body.createTextRange();
|
8155 |
-
try { r.moveToElementText(node.parentNode); }
|
8156 |
-
catch(e) { return r; }
|
8157 |
-
r.collapse(true);
|
8158 |
-
r.moveEnd("character", end);
|
8159 |
-
r.moveStart("character", start);
|
8160 |
-
return r;
|
8161 |
-
};
|
8162 |
-
|
8163 |
-
function removeChildren(e) {
|
8164 |
-
for (var count = e.childNodes.length; count > 0; --count)
|
8165 |
-
e.removeChild(e.firstChild);
|
8166 |
-
return e;
|
8167 |
-
}
|
8168 |
-
|
8169 |
-
function removeChildrenAndAdd(parent, e) {
|
8170 |
-
return removeChildren(parent).appendChild(e);
|
8171 |
-
}
|
8172 |
-
|
8173 |
-
var contains = CodeMirror.contains = function(parent, child) {
|
8174 |
-
if (child.nodeType == 3) // Android browser always returns false when child is a textnode
|
8175 |
-
child = child.parentNode;
|
8176 |
-
if (parent.contains)
|
8177 |
-
return parent.contains(child);
|
8178 |
-
do {
|
8179 |
-
if (child.nodeType == 11) child = child.host;
|
8180 |
-
if (child == parent) return true;
|
8181 |
-
} while (child = child.parentNode);
|
8182 |
-
};
|
8183 |
-
|
8184 |
-
function activeElt() { return document.activeElement; }
|
8185 |
-
// Older versions of IE throws unspecified error when touching
|
8186 |
-
// document.activeElement in some cases (during loading, in iframe)
|
8187 |
-
if (ie && ie_version < 11) activeElt = function() {
|
8188 |
-
try { return document.activeElement; }
|
8189 |
-
catch(e) { return document.body; }
|
8190 |
-
};
|
8191 |
-
|
8192 |
-
function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); }
|
8193 |
-
var rmClass = CodeMirror.rmClass = function(node, cls) {
|
8194 |
-
var current = node.className;
|
8195 |
-
var match = classTest(cls).exec(current);
|
8196 |
-
if (match) {
|
8197 |
-
var after = current.slice(match.index + match[0].length);
|
8198 |
-
node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
|
8199 |
-
}
|
8200 |
-
};
|
8201 |
-
var addClass = CodeMirror.addClass = function(node, cls) {
|
8202 |
-
var current = node.className;
|
8203 |
-
if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
|
8204 |
-
};
|
8205 |
-
function joinClasses(a, b) {
|
8206 |
-
var as = a.split(" ");
|
8207 |
-
for (var i = 0; i < as.length; i++)
|
8208 |
-
if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
|
8209 |
-
return b;
|
8210 |
-
}
|
8211 |
-
|
8212 |
-
// WINDOW-WIDE EVENTS
|
8213 |
-
|
8214 |
-
// These must be handled carefully, because naively registering a
|
8215 |
-
// handler for each editor will cause the editors to never be
|
8216 |
-
// garbage collected.
|
8217 |
-
|
8218 |
-
function forEachCodeMirror(f) {
|
8219 |
-
if (!document.body.getElementsByClassName) return;
|
8220 |
-
var byClass = document.body.getElementsByClassName("CodeMirror");
|
8221 |
-
for (var i = 0; i < byClass.length; i++) {
|
8222 |
-
var cm = byClass[i].CodeMirror;
|
8223 |
-
if (cm) f(cm);
|
8224 |
-
}
|
8225 |
-
}
|
8226 |
-
|
8227 |
-
var globalsRegistered = false;
|
8228 |
-
function ensureGlobalHandlers() {
|
8229 |
-
if (globalsRegistered) return;
|
8230 |
-
registerGlobalHandlers();
|
8231 |
-
globalsRegistered = true;
|
8232 |
-
}
|
8233 |
-
function registerGlobalHandlers() {
|
8234 |
-
// When the window resizes, we need to refresh active editors.
|
8235 |
-
var resizeTimer;
|
8236 |
-
on(window, "resize", function() {
|
8237 |
-
if (resizeTimer == null) resizeTimer = setTimeout(function() {
|
8238 |
-
resizeTimer = null;
|
8239 |
-
forEachCodeMirror(onResize);
|
8240 |
-
}, 100);
|
8241 |
-
});
|
8242 |
-
// When the window loses focus, we want to show the editor as blurred
|
8243 |
-
on(window, "blur", function() {
|
8244 |
-
forEachCodeMirror(onBlur);
|
8245 |
-
});
|
8246 |
-
}
|
8247 |
-
|
8248 |
-
// FEATURE DETECTION
|
8249 |
-
|
8250 |
-
// Detect drag-and-drop
|
8251 |
-
var dragAndDrop = function() {
|
8252 |
-
// There is *some* kind of drag-and-drop support in IE6-8, but I
|
8253 |
-
// couldn't get it to work yet.
|
8254 |
-
if (ie && ie_version < 9) return false;
|
8255 |
-
var div = elt('div');
|
8256 |
-
return "draggable" in div || "dragDrop" in div;
|
8257 |
-
}();
|
8258 |
-
|
8259 |
-
var zwspSupported;
|
8260 |
-
function zeroWidthElement(measure) {
|
8261 |
-
if (zwspSupported == null) {
|
8262 |
-
var test = elt("span", "\u200b");
|
8263 |
-
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
|
8264 |
-
if (measure.firstChild.offsetHeight != 0)
|
8265 |
-
zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
|
8266 |
-
}
|
8267 |
-
var node = zwspSupported ? elt("span", "\u200b") :
|
8268 |
-
elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
|
8269 |
-
node.setAttribute("cm-text", "");
|
8270 |
-
return node;
|
8271 |
-
}
|
8272 |
-
|
8273 |
-
// Feature-detect IE's crummy client rect reporting for bidi text
|
8274 |
-
var badBidiRects;
|
8275 |
-
function hasBadBidiRects(measure) {
|
8276 |
-
if (badBidiRects != null) return badBidiRects;
|
8277 |
-
var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
|
8278 |
-
var r0 = range(txt, 0, 1).getBoundingClientRect();
|
8279 |
-
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
|
8280 |
-
var r1 = range(txt, 1, 2).getBoundingClientRect();
|
8281 |
-
return badBidiRects = (r1.right - r0.right < 3);
|
8282 |
-
}
|
8283 |
-
|
8284 |
-
// See if "".split is the broken IE version, if so, provide an
|
8285 |
-
// alternative way to split lines.
|
8286 |
-
var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
|
8287 |
-
var pos = 0, result = [], l = string.length;
|
8288 |
-
while (pos <= l) {
|
8289 |
-
var nl = string.indexOf("\n", pos);
|
8290 |
-
if (nl == -1) nl = string.length;
|
8291 |
-
var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
|
8292 |
-
var rt = line.indexOf("\r");
|
8293 |
-
if (rt != -1) {
|
8294 |
-
result.push(line.slice(0, rt));
|
8295 |
-
pos += rt + 1;
|
8296 |
-
} else {
|
8297 |
-
result.push(line);
|
8298 |
-
pos = nl + 1;
|
8299 |
-
}
|
8300 |
-
}
|
8301 |
-
return result;
|
8302 |
-
} : function(string){return string.split(/\r\n?|\n/);};
|
8303 |
-
|
8304 |
-
var hasSelection = window.getSelection ? function(te) {
|
8305 |
-
try { return te.selectionStart != te.selectionEnd; }
|
8306 |
-
catch(e) { return false; }
|
8307 |
-
} : function(te) {
|
8308 |
-
try {var range = te.ownerDocument.selection.createRange();}
|
8309 |
-
catch(e) {}
|
8310 |
-
if (!range || range.parentElement() != te) return false;
|
8311 |
-
return range.compareEndPoints("StartToEnd", range) != 0;
|
8312 |
-
};
|
8313 |
-
|
8314 |
-
var hasCopyEvent = (function() {
|
8315 |
-
var e = elt("div");
|
8316 |
-
if ("oncopy" in e) return true;
|
8317 |
-
e.setAttribute("oncopy", "return;");
|
8318 |
-
return typeof e.oncopy == "function";
|
8319 |
-
})();
|
8320 |
-
|
8321 |
-
var badZoomedRects = null;
|
8322 |
-
function hasBadZoomedRects(measure) {
|
8323 |
-
if (badZoomedRects != null) return badZoomedRects;
|
8324 |
-
var node = removeChildrenAndAdd(measure, elt("span", "x"));
|
8325 |
-
var normal = node.getBoundingClientRect();
|
8326 |
-
var fromRange = range(node, 0, 1).getBoundingClientRect();
|
8327 |
-
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
|
8328 |
-
}
|
8329 |
-
|
8330 |
-
// KEY NAMES
|
8331 |
-
|
8332 |
-
var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
|
8333 |
-
19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
|
8334 |
-
36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
|
8335 |
-
46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
|
8336 |
-
173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
|
8337 |
-
221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
|
8338 |
-
63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
|
8339 |
-
CodeMirror.keyNames = keyNames;
|
8340 |
-
(function() {
|
8341 |
-
// Number keys
|
8342 |
-
for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
|
8343 |
-
// Alphabetic keys
|
8344 |
-
for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
|
8345 |
-
// Function keys
|
8346 |
-
for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
|
8347 |
-
})();
|
8348 |
-
|
8349 |
-
// BIDI HELPERS
|
8350 |
-
|
8351 |
-
function iterateBidiSections(order, from, to, f) {
|
8352 |
-
if (!order) return f(from, to, "ltr");
|
8353 |
-
var found = false;
|
8354 |
-
for (var i = 0; i < order.length; ++i) {
|
8355 |
-
var part = order[i];
|
8356 |
-
if (part.from < to && part.to > from || from == to && part.to == from) {
|
8357 |
-
f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
|
8358 |
-
found = true;
|
8359 |
-
}
|
8360 |
-
}
|
8361 |
-
if (!found) f(from, to, "ltr");
|
8362 |
-
}
|
8363 |
-
|
8364 |
-
function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
|
8365 |
-
function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
|
8366 |
-
|
8367 |
-
function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
|
8368 |
-
function lineRight(line) {
|
8369 |
-
var order = getOrder(line);
|
8370 |
-
if (!order) return line.text.length;
|
8371 |
-
return bidiRight(lst(order));
|
8372 |
-
}
|
8373 |
-
|
8374 |
-
function lineStart(cm, lineN) {
|
8375 |
-
var line = getLine(cm.doc, lineN);
|
8376 |
-
var visual = visualLine(line);
|
8377 |
-
if (visual != line) lineN = lineNo(visual);
|
8378 |
-
var order = getOrder(visual);
|
8379 |
-
var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
|
8380 |
-
return Pos(lineN, ch);
|
8381 |
-
}
|
8382 |
-
function lineEnd(cm, lineN) {
|
8383 |
-
var merged, line = getLine(cm.doc, lineN);
|
8384 |
-
while (merged = collapsedSpanAtEnd(line)) {
|
8385 |
-
line = merged.find(1, true).line;
|
8386 |
-
lineN = null;
|
8387 |
-
}
|
8388 |
-
var order = getOrder(line);
|
8389 |
-
var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
|
8390 |
-
return Pos(lineN == null ? lineNo(line) : lineN, ch);
|
8391 |
-
}
|
8392 |
-
function lineStartSmart(cm, pos) {
|
8393 |
-
var start = lineStart(cm, pos.line);
|
8394 |
-
var line = getLine(cm.doc, start.line);
|
8395 |
-
var order = getOrder(line);
|
8396 |
-
if (!order || order[0].level == 0) {
|
8397 |
-
var firstNonWS = Math.max(0, line.text.search(/\S/));
|
8398 |
-
var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
|
8399 |
-
return Pos(start.line, inWS ? 0 : firstNonWS);
|
8400 |
-
}
|
8401 |
-
return start;
|
8402 |
-
}
|
8403 |
-
|
8404 |
-
function compareBidiLevel(order, a, b) {
|
8405 |
-
var linedir = order[0].level;
|
8406 |
-
if (a == linedir) return true;
|
8407 |
-
if (b == linedir) return false;
|
8408 |
-
return a < b;
|
8409 |
-
}
|
8410 |
-
var bidiOther;
|
8411 |
-
function getBidiPartAt(order, pos) {
|
8412 |
-
bidiOther = null;
|
8413 |
-
for (var i = 0, found; i < order.length; ++i) {
|
8414 |
-
var cur = order[i];
|
8415 |
-
if (cur.from < pos && cur.to > pos) return i;
|
8416 |
-
if ((cur.from == pos || cur.to == pos)) {
|
8417 |
-
if (found == null) {
|
8418 |
-
found = i;
|
8419 |
-
} else if (compareBidiLevel(order, cur.level, order[found].level)) {
|
8420 |
-
if (cur.from != cur.to) bidiOther = found;
|
8421 |
-
return i;
|
8422 |
-
} else {
|
8423 |
-
if (cur.from != cur.to) bidiOther = i;
|
8424 |
-
return found;
|
8425 |
-
}
|
8426 |
-
}
|
8427 |
-
}
|
8428 |
-
return found;
|
8429 |
-
}
|
8430 |
-
|
8431 |
-
function moveInLine(line, pos, dir, byUnit) {
|
8432 |
-
if (!byUnit) return pos + dir;
|
8433 |
-
do pos += dir;
|
8434 |
-
while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
|
8435 |
-
return pos;
|
8436 |
-
}
|
8437 |
-
|
8438 |
-
// This is needed in order to move 'visually' through bi-directional
|
8439 |
-
// text -- i.e., pressing left should make the cursor go left, even
|
8440 |
-
// when in RTL text. The tricky part is the 'jumps', where RTL and
|
8441 |
-
// LTR text touch each other. This often requires the cursor offset
|
8442 |
-
// to move more than one unit, in order to visually move one unit.
|
8443 |
-
function moveVisually(line, start, dir, byUnit) {
|
8444 |
-
var bidi = getOrder(line);
|
8445 |
-
if (!bidi) return moveLogically(line, start, dir, byUnit);
|
8446 |
-
var pos = getBidiPartAt(bidi, start), part = bidi[pos];
|
8447 |
-
var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
|
8448 |
-
|
8449 |
-
for (;;) {
|
8450 |
-
if (target > part.from && target < part.to) return target;
|
8451 |
-
if (target == part.from || target == part.to) {
|
8452 |
-
if (getBidiPartAt(bidi, target) == pos) return target;
|
8453 |
-
part = bidi[pos += dir];
|
8454 |
-
return (dir > 0) == part.level % 2 ? part.to : part.from;
|
8455 |
-
} else {
|
8456 |
-
part = bidi[pos += dir];
|
8457 |
-
if (!part) return null;
|
8458 |
-
if ((dir > 0) == part.level % 2)
|
8459 |
-
target = moveInLine(line, part.to, -1, byUnit);
|
8460 |
-
else
|
8461 |
-
target = moveInLine(line, part.from, 1, byUnit);
|
8462 |
-
}
|
8463 |
-
}
|
8464 |
-
}
|
8465 |
-
|
8466 |
-
function moveLogically(line, start, dir, byUnit) {
|
8467 |
-
var target = start + dir;
|
8468 |
-
if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
|
8469 |
-
return target < 0 || target > line.text.length ? null : target;
|
8470 |
-
}
|
8471 |
-
|
8472 |
-
// Bidirectional ordering algorithm
|
8473 |
-
// See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
|
8474 |
-
// that this (partially) implements.
|
8475 |
-
|
8476 |
-
// One-char codes used for character types:
|
8477 |
-
// L (L): Left-to-Right
|
8478 |
-
// R (R): Right-to-Left
|
8479 |
-
// r (AL): Right-to-Left Arabic
|
8480 |
-
// 1 (EN): European Number
|
8481 |
-
// + (ES): European Number Separator
|
8482 |
-
// % (ET): European Number Terminator
|
8483 |
-
// n (AN): Arabic Number
|
8484 |
-
// , (CS): Common Number Separator
|
8485 |
-
// m (NSM): Non-Spacing Mark
|
8486 |
-
// b (BN): Boundary Neutral
|
8487 |
-
// s (B): Paragraph Separator
|
8488 |
-
// t (S): Segment Separator
|
8489 |
-
// w (WS): Whitespace
|
8490 |
-
// N (ON): Other Neutrals
|
8491 |
-
|
8492 |
-
// Returns null if characters are ordered as they appear
|
8493 |
-
// (left-to-right), or an array of sections ({from, to, level}
|
8494 |
-
// objects) in the order in which they occur visually.
|
8495 |
-
var bidiOrdering = (function() {
|
8496 |
-
// Character types for codepoints 0 to 0xff
|
8497 |
-
var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
|
8498 |
-
// Character types for codepoints 0x600 to 0x6ff
|
8499 |
-
var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
|
8500 |
-
function charType(code) {
|
8501 |
-
if (code <= 0xf7) return lowTypes.charAt(code);
|
8502 |
-
else if (0x590 <= code && code <= 0x5f4) return "R";
|
8503 |
-
else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
|
8504 |
-
else if (0x6ee <= code && code <= 0x8ac) return "r";
|
8505 |
-
else if (0x2000 <= code && code <= 0x200b) return "w";
|
8506 |
-
else if (code == 0x200c) return "b";
|
8507 |
-
else return "L";
|
8508 |
-
}
|
8509 |
-
|
8510 |
-
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
8511 |
-
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
|
8512 |
-
// Browsers seem to always treat the boundaries of block elements as being L.
|
8513 |
-
var outerType = "L";
|
8514 |
-
|
8515 |
-
function BidiSpan(level, from, to) {
|
8516 |
-
this.level = level;
|
8517 |
-
this.from = from; this.to = to;
|
8518 |
-
}
|
8519 |
-
|
8520 |
-
return function(str) {
|
8521 |
-
if (!bidiRE.test(str)) return false;
|
8522 |
-
var len = str.length, types = [];
|
8523 |
-
for (var i = 0, type; i < len; ++i)
|
8524 |
-
types.push(type = charType(str.charCodeAt(i)));
|
8525 |
-
|
8526 |
-
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
8527 |
-
// change the type of the NSM to the type of the previous
|
8528 |
-
// character. If the NSM is at the start of the level run, it will
|
8529 |
-
// get the type of sor.
|
8530 |
-
for (var i = 0, prev = outerType; i < len; ++i) {
|
8531 |
-
var type = types[i];
|
8532 |
-
if (type == "m") types[i] = prev;
|
8533 |
-
else prev = type;
|
8534 |
-
}
|
8535 |
-
|
8536 |
-
// W2. Search backwards from each instance of a European number
|
8537 |
-
// until the first strong type (R, L, AL, or sor) is found. If an
|
8538 |
-
// AL is found, change the type of the European number to Arabic
|
8539 |
-
// number.
|
8540 |
-
// W3. Change all ALs to R.
|
8541 |
-
for (var i = 0, cur = outerType; i < len; ++i) {
|
8542 |
-
var type = types[i];
|
8543 |
-
if (type == "1" && cur == "r") types[i] = "n";
|
8544 |
-
else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
|
8545 |
-
}
|
8546 |
-
|
8547 |
-
// W4. A single European separator between two European numbers
|
8548 |
-
// changes to a European number. A single common separator between
|
8549 |
-
// two numbers of the same type changes to that type.
|
8550 |
-
for (var i = 1, prev = types[0]; i < len - 1; ++i) {
|
8551 |
-
var type = types[i];
|
8552 |
-
if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
|
8553 |
-
else if (type == "," && prev == types[i+1] &&
|
8554 |
-
(prev == "1" || prev == "n")) types[i] = prev;
|
8555 |
-
prev = type;
|
8556 |
-
}
|
8557 |
-
|
8558 |
-
// W5. A sequence of European terminators adjacent to European
|
8559 |
-
// numbers changes to all European numbers.
|
8560 |
-
// W6. Otherwise, separators and terminators change to Other
|
8561 |
-
// Neutral.
|
8562 |
-
for (var i = 0; i < len; ++i) {
|
8563 |
-
var type = types[i];
|
8564 |
-
if (type == ",") types[i] = "N";
|
8565 |
-
else if (type == "%") {
|
8566 |
-
for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
|
8567 |
-
var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
|
8568 |
-
for (var j = i; j < end; ++j) types[j] = replace;
|
8569 |
-
i = end - 1;
|
8570 |
-
}
|
8571 |
-
}
|
8572 |
-
|
8573 |
-
// W7. Search backwards from each instance of a European number
|
8574 |
-
// until the first strong type (R, L, or sor) is found. If an L is
|
8575 |
-
// found, then change the type of the European number to L.
|
8576 |
-
for (var i = 0, cur = outerType; i < len; ++i) {
|
8577 |
-
var type = types[i];
|
8578 |
-
if (cur == "L" && type == "1") types[i] = "L";
|
8579 |
-
else if (isStrong.test(type)) cur = type;
|
8580 |
-
}
|
8581 |
-
|
8582 |
-
// N1. A sequence of neutrals takes the direction of the
|
8583 |
-
// surrounding strong text if the text on both sides has the same
|
8584 |
-
// direction. European and Arabic numbers act as if they were R in
|
8585 |
-
// terms of their influence on neutrals. Start-of-level-run (sor)
|
8586 |
-
// and end-of-level-run (eor) are used at level run boundaries.
|
8587 |
-
// N2. Any remaining neutrals take the embedding direction.
|
8588 |
-
for (var i = 0; i < len; ++i) {
|
8589 |
-
if (isNeutral.test(types[i])) {
|
8590 |
-
for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
|
8591 |
-
var before = (i ? types[i-1] : outerType) == "L";
|
8592 |
-
var after = (end < len ? types[end] : outerType) == "L";
|
8593 |
-
var replace = before || after ? "L" : "R";
|
8594 |
-
for (var j = i; j < end; ++j) types[j] = replace;
|
8595 |
-
i = end - 1;
|
8596 |
-
}
|
8597 |
-
}
|
8598 |
-
|
8599 |
-
// Here we depart from the documented algorithm, in order to avoid
|
8600 |
-
// building up an actual levels array. Since there are only three
|
8601 |
-
// levels (0, 1, 2) in an implementation that doesn't take
|
8602 |
-
// explicit embedding into account, we can build up the order on
|
8603 |
-
// the fly, without following the level-based algorithm.
|
8604 |
-
var order = [], m;
|
8605 |
-
for (var i = 0; i < len;) {
|
8606 |
-
if (countsAsLeft.test(types[i])) {
|
8607 |
-
var start = i;
|
8608 |
-
for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
|
8609 |
-
order.push(new BidiSpan(0, start, i));
|
8610 |
-
} else {
|
8611 |
-
var pos = i, at = order.length;
|
8612 |
-
for (++i; i < len && types[i] != "L"; ++i) {}
|
8613 |
-
for (var j = pos; j < i;) {
|
8614 |
-
if (countsAsNum.test(types[j])) {
|
8615 |
-
if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
|
8616 |
-
var nstart = j;
|
8617 |
-
for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
|
8618 |
-
order.splice(at, 0, new BidiSpan(2, nstart, j));
|
8619 |
-
pos = j;
|
8620 |
-
} else ++j;
|
8621 |
-
}
|
8622 |
-
if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
|
8623 |
-
}
|
8624 |
-
}
|
8625 |
-
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
|
8626 |
-
order[0].from = m[0].length;
|
8627 |
-
order.unshift(new BidiSpan(0, 0, m[0].length));
|
8628 |
-
}
|
8629 |
-
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
|
8630 |
-
lst(order).to -= m[0].length;
|
8631 |
-
order.push(new BidiSpan(0, len - m[0].length, len));
|
8632 |
-
}
|
8633 |
-
if (order[0].level != lst(order).level)
|
8634 |
-
order.push(new BidiSpan(order[0].level, len, len));
|
8635 |
-
|
8636 |
-
return order;
|
8637 |
-
};
|
8638 |
-
})();
|
8639 |
-
|
8640 |
-
// THE END
|
8641 |
-
|
8642 |
-
CodeMirror.version = "5.0.0";
|
8643 |
-
|
8644 |
-
return CodeMirror;
|
8645 |
-
});
|
1 |
+
!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Wi(n):{},Wi(Ko,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new pl(i,n.mode)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!wo&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Ci,keySeq:null};var a=this;uo&&11>co&&setTimeout(function(){a.display.input.reset(!0)},20),Rt(this),Ui(),mt(this),this.curOp.forceUpdate=!0,Vn(this,i),n.autofocus&&!wo||a.hasFocus()?setTimeout(Oi(ur,this),20):cr(this);for(var c in jo)jo.hasOwnProperty(c)&&jo[c](this,n[c],Xo);C(this),n.finishInit&&n.finishInit(this);for(var f=0;f<qo.length;++f)qo[f](this);bt(this),fo&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=Pi("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=Pi("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=Pi("div",null,"CodeMirror-code"),n.selectionDiv=Pi("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Pi("div",null,"CodeMirror-cursors"),n.measure=Pi("div",null,"CodeMirror-measure"),n.lineMeasure=Pi("div",null,"CodeMirror-measure"),n.lineSpace=Pi("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Pi("div",[Pi("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Pi("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=Pi("div",null,null,"position: absolute; height: "+Ll+"px; width: 1px;"),n.gutters=Pi("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Pi("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Pi("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),uo&&8>co&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),fo||lo&&wo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,ze(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Bl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Rl(e.display.wrapper,"CodeMirror-wrap"),h(e)),l(e),Dt(e),it(e),setTimeout(function(){y(e)},100)}function o(e){var t=gt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vt(e.display)-3);return function(i){if(gn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&_n(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),it(e)}function a(e){u(e),Dt(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;zi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(Pi("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function f(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=an(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=un(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function h(e){var t=e.display,r=e.doc;t.maxLine=Kn(r,r.first),t.maxLineLength=f(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=f(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Ti(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ge(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Ve(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=Pi("div",[Pi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Pi("div",[Pi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),wl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),wl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,uo&&8>co&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Rl(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),wl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?Qt(t,e):Zt(t,e)},t),t.display.scrollbars.addClass&&Bl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Be(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=$n(t,n),l=$n(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=$n(t,qn(Kn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=$n(t,qn(Kn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(Pi("div",[Pi("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l),n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ke(e),this.force=r,this.dims=H(e),this.events=[]}function T(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ve(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ve(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return It(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Ft(e))return!1;C(e)&&(It(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Mo&&(o=dn(e.doc,o),l=pn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Et(e,o,l),r.viewOffset=qn(Kn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Ft(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Fi();return a>4&&(r.lineDiv.style.display="none"),I(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Fi()!=u&&u.offsetHeight&&u.focus(),zi(r.cursorDiv),zi(r.selectionDiv),r.gutters.style.height=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,ze(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.force,n=t.viewport,i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Ke(e))r=!0;else if(r=!1,n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ge(e.display)-je(e),n.top)}),t.visible=w(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!M(e,t))break;O(e);var o=p(e);Oe(e),W(e,o),y(e,o)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new k(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Oe(e),W(e,n),y(e,n),r.finish()}}function W(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Ve(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(uo&&8>co){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=gt(t)),(a>.001||-.001>a)&&(_n(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function I(e,t,r){function n(t){var r=t.nextSibling;return fo&&xo&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var f=a[c];if(f.hidden);else if(f.node&&f.node.parentNode==l){for(;s!=f.node;)s=n(s);var h=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(Ti(f.changes,"gutter")>-1&&(h=!1),P(e,f,u,r)),h&&(zi(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=f.node.nextSibling}else{var d=V(e,f,u,r);l.insertBefore(d,s)}u+=f.size}for(;s;)s=n(s)}function P(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function z(e){return e.node==e.text&&(e.node=Pi("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),uo&&8>co&&(e.node.style.zIndex=2)),e.node}function E(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=z(e);e.background=r.insertBefore(Pi("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):On(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){E(e),e.line.wrapClass?z(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=z(t),l=t.gutter=Pi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Pi("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=i.hasOwnProperty(a)&&i[a];u&&l.appendChild(Pi("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=z(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=Pi("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),vi(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function _(e){return No(e.line,e.ch)}function Y(e,t){return Ao(e,t)<0?t:e}function $(e,t){return Ao(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),ur(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n){var i=e.doc;e.display.shift=!1,n||(n=i.sel);var o=Vl(t),l=null;e.state.pasteIncoming&&n.ranges.length>1&&(Wo&&Wo.join("\n")==t?l=n.ranges.length%Wo.length==0&&Mi(Wo,Vl):o.length==n.ranges.length&&(l=Mi(o,function(e){return[e]})));for(var s=n.ranges.length-1;s>=0;s--){var a=n.ranges[s],u=a.from(),c=a.to();a.empty()&&(r&&r>0?u=No(u.line,u.ch-r):e.state.overwrite&&!e.state.pasteIncoming&&(c=No(c.line,Math.min(Kn(i,c.line).text.length,c.ch+ki(o).length))));var f=e.curOp.updateInput,h={from:u,to:c,text:l?l[s%l.length]:o,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};if(yr(e.doc,h),vi(e,"inputRead",e,h),t&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&a.head.ch<100&&(!s||n.ranges[s-1].head.line!=a.head.line)){var d=e.getModeAt(a.head),p=Vo(h);if(d.electricChars){for(var g=0;g<d.electricChars.length;g++)if(t.indexOf(d.electricChars.charAt(g))>-1){Dr(e,p.line,"smart");break}}else d.electricInput&&d.electricInput.test(Kn(i,p.line).text.slice(0,p.ch))&&Dr(e,p.line,"smart")}}Wr(e),e.curOp.updateInput=f,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:No(i,0),head:No(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function ee(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function te(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ci,this.inaccurateSelection=!1,this.hasSelection=!1}function re(){var e=Pi("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Pi("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return fo?e.style.width="1000px":e.setAttribute("wrap","off"),bo&&(e.style.border="1px solid black"),ee(e),t}function ne(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ci}function ie(e,t){var r=qe(e,t.line);if(!r||r.hidden)return null;var n=Kn(e.doc,t.line),i=_e(r,n,t.line),o=Zn(n),l="left";if(o){var s=ro(o,t.ch);l=s%2?"right":"left"}var a=Je(i.map,t.ch,"left");return a.offset="right"==a.collapse?a.end:a.start,a}function oe(e,t){return t&&(e.bad=!0),e}function le(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return oe(e.clipPos(No(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return se(o,t,r)}}function se(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=Yn(0>i?e.line:e.rest[i]),f=o[l]+n;return(0>n||s!=t)&&(f=o[l+(n?1:0)]),No(a,f)}}}var i=e.text.firstChild,o=!1;if(!t||!zl(i,t))return oe(No(Yn(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?ki(e.rest):e.line;return oe(No(Yn(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,f=n(s,a,r);if(f)return oe(f,o);for(var h=a.nextSibling,d=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return oe(No(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(f=n(p,p.firstChild,-1))return oe(No(f.line,f.ch+d),o);d+=h.textContent.length}}function ae(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,c=t.getAttribute("cm-marker");if(c){var f=e.findMarks(No(n,0),No(i+1,0),o(+c));return void(f.length&&(u=f[0].find())&&(s+=jn(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)l(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var d=t.nodeValue;if(!d)return;a&&(s+="\n",a=!1),s+=d}}for(var s="",a=!1;l(t),t!=r;)t=t.nextSibling;return s}function ue(e,t){this.ranges=e,this.primIndex=t}function ce(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Ao(e.from(),t.from())}),t=Ti(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Ao(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=Y(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new ce(a?s:l,a?l:s))}}return new ue(e,t)}function he(e,t){return new ue([new ce(e,t||e)],0)}function de(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pe(e,t){if(t.line<e.first)return No(e.first,0);var r=e.first+e.size-1;return t.line>r?No(r,Kn(e,r).text.length):ge(t,Kn(e,t.line).text.length)}function ge(e,t){var r=e.ch;return null==r||r>t?No(e.line,t):0>r?No(e.line,0):e}function ve(e,t){return t>=e.first&&t<e.first+e.size}function me(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=pe(e,t[n]);return r}function ye(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Ao(r,i)<0;o!=Ao(n,i)<0?(i=r,r=n):o!=Ao(r,n)<0&&(r=n)}return new ce(i,r)}return new ce(n||r,r)}function be(e,t,r,n){ke(e,new ue([ye(e,e.sel.primary(),t,r)],0),n)}function we(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ye(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function xe(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Ce(e,t,r,n){ke(e,he(t,r),n)}function Se(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new ce(pe(e,t[r].anchor),pe(e,t[r].head))}};return Cl(e,"beforeSelectionChange",e,r),e.cm&&Cl(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?fe(r.ranges,r.ranges.length-1):t}function Le(e,t,r){var n=e.history.done,i=ki(n);i&&i.ranges?(n[n.length-1]=t,Te(e,t,r)):ke(e,t,r)}function ke(e,t,r){Te(e,t,r),ii(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Te(e,t,r){(wi(e,"beforeSelectionChange")||e.cm&&wi(e.cm,"beforeSelectionChange"))&&(t=Se(e,t));var n=r&&r.bias||(Ao(t.primary().head,e.sel.primary().head)<0?-1:1);Me(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Wr(e.cm)}function Me(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,bi(e.cm)),vi(e,"cursorActivity",e))}function Ne(e){Me(e,Ae(e,e.sel,null,!1),Tl)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=We(e,l.anchor,r,n),a=We(e,l.head,r,n);(i||s!=l.anchor||a!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new ce(s,a))}return i?fe(i,t.primIndex):t}function We(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var s=Kn(e,o.line);if(s.markedSpans)for(var a=0;a<s.markedSpans.length;++a){var u=s.markedSpans[a],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Cl(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var f=c.find(0>l?-1:1);if(0==Ao(f,o)&&(f.ch+=l,f.ch<0?f=f.line>e.first?pe(e,No(f.line-1)):null:f.ch>s.text.length&&(f=f.line<e.first+e.size-1?No(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,No(e.first,0)):We(e,t,r,!0);i=!0,f=t,l=-l}o=f;continue e}}return o}}function Oe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function De(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&He(e,s,i),a||Ie(e,s,o)}return n}function He(e,t,r){var n=ct(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Pi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Pi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Ie(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Pi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ut(e,No(t,r),"div",f,n)}var s,a,f=Kn(l,t),h=f.text.length;return _i(Zn(f),r||0,null==i?h:i,function(e,t,l){var f,d,p,g=o(e,"left");if(e==t)f=g,d=p=g.left;else{if(f=o(t-1,"right"),"rtl"==l){var v=g;g=f,f=v}d=g.left,p=f.right}null==r&&0==e&&(d=u),f.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<f.top&&n(d,g.bottom,null,f.top)),null==i&&t==h&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||f.bottom>a.bottom||f.bottom==a.bottom&&f.right>a.right)&&(a=f),u+1>d&&(d=u),n(d,f.top,p-d,f.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Ue(e.display),u=a.left,c=Math.max(o.sizerWidth,Ke(e)-o.sizer.offsetLeft)-a.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Kn(l,f.line),p=Kn(l,h.line),g=fn(d)==fn(p),v=i(f.line,f.ch,g?d.text.length+1:null).end,m=i(h.line,g?0:null,h.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ze(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Oi(Ee,e))}function Ee(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=Qo(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=Mn(e,o,n,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),f=0;!c&&f<l.length;++f)c=l[f]!=o.styles[f];c&&i.push(t.frontier),o.stateAfter=Qo(t.mode,n)}else An(e,o.text,n),o.stateAfter=t.frontier%5==0?Qo(t.mode,n):null;return++t.frontier,+new Date>r?(ze(e,e.options.workDelay),!0):void 0}),i.length&&Tt(e,function(){for(var t=0;t<i.length;t++)Ht(e,i[t],"text")})}}function Fe(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Kn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Al(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Re(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Fe(e,t,r),l=o>n.first&&Kn(n,o-1).stateAfter;return l=l?Qo(n.mode,l):Jo(n.mode),n.iter(o,t,function(r){An(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?Qo(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Be(e){return e.lineSpace.offsetTop}function Ge(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ue(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ei(e.measure,Pi("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Ve(e){return Ll-e.display.nativeBarWidth}function Ke(e){return e.display.scroller.clientWidth-Ve(e)-e.display.barWidth}function je(e){return e.display.scroller.clientHeight-Ve(e)-e.display.barHeight}function Xe(e,t,r){var n=e.options.lineWrapping,i=n&&Ke(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function _e(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(Yn(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ye(e,t){t=fn(t);var r=Yn(t),n=e.display.externalMeasured=new Wt(e.doc,t,r);n.lineN=r;var i=n.built=On(e,n);return n.text=i.pre,Ei(e.display.lineMeasure,i.pre),n}function $e(e,t,r,n){return Qe(e,Ze(e,t),r,n)}function qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Pt(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ze(e,t){var r=Yn(t),n=qe(e,r);n&&!n.text?n=null:n&&n.changes&&P(e,n,r,H(e)),n||(n=Ye(e,t));var i=_e(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qe(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Xe(e,t.view,t.rect),t.hasHeights=!0),o=et(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Je(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function et(e,t,r,n){var i,o=Je(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Ii(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Ii(t.line.text.charAt(o.coverStart+a));)++a;if(uo&&9>co&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(uo&&e.options.lineWrapping){var f=Dl(l,s,a).getClientRects();i=f.length?f["right"==n?f.length-1:0]:Io}else i=Dl(l,s,a).getBoundingClientRect()||Io;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}uo&&11>co&&(i=tt(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(uo&&9>co&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+vt(e.display),top:h.top,bottom:h.bottom}:Io}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,
|
2 |
+
b.rbottom=p),b}function tt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Xi(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nt(e){e.display.externalMeasure=null,zi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rt(e.display.view[t])}function it(e){nt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ot(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function st(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=yn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=qn(t);if("local"==n?l+=Be(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:lt());var a=s.left+("window"==n?0:ot());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function at(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ot(),i-=lt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ut(e,t,r,n,i){return n||(n=Kn(e.doc,t.line)),st(e,n,$e(e,n,t.ch,i),r)}function ct(e,t,r,n,i,o){function l(t,l){var s=Qe(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,st(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==Yi(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=$i(r)-(r.level%2?0:1),n=!0):e==$i(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=Yi(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Kn(e.doc,t.line),i||(i=Ze(e,n));var a=Zn(n),u=t.ch;if(!a)return l(u);var c=ro(a,u),f=s(u,c);return null!=Yl&&(f.other=s(u,Yl)),f}function ft(e,t){var r=0,t=pe(e.doc,t);e.options.lineWrapping||(r=vt(e.display)*t.ch);var n=Kn(e.doc,t.line),i=qn(n)+Be(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function ht(e,t,r,n){var i=No(e,t);return i.xRel=n,r&&(i.outside=!0),i}function dt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return ht(n.first,0,!0,-1);var i=$n(n,r),o=n.first+n.size-1;if(i>o)return ht(n.first+n.size-1,Kn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Kn(n,i);;){var s=pt(e,l,i,t,r),a=un(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=Yn(l=u.to.line)}}function pt(e,t,r,n,i){function o(n){var i=ct(e,No(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-qn(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Ze(e,t),c=Zn(t),f=t.text.length,h=qi(t),d=Zi(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return ht(r,d,m,1);for(;;){if(c?d==h||d==io(t,h,1):1>=d-h){for(var y=p>n||v-n>=n-p?h:d,b=n-(y==h?p:v);Ii(t.text.charAt(y));)++y;var w=ht(r,y,y==h?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),C=h+x;if(c){C=h;for(var S=0;x>S;++S)C=io(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),f=x):(h=C,p=L,g=s,f-=x)}}function gt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Oo){Oo=Pi("pre");for(var t=0;49>t;++t)Oo.appendChild(document.createTextNode("x")),Oo.appendChild(Pi("br"));Oo.appendChild(document.createTextNode("x"))}Ei(e.measure,Oo);var r=Oo.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),zi(e.measure),r||1}function vt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Pi("span","xxxxxxxxxx"),r=Pi("pre",[t]);Ei(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function mt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++zo},Po?Po.ops.push(e.curOp):e.curOp.ownsGroup=Po={ops:[e.curOp],delayedCallbacks:[]}}function yt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r]();for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(r<t.length)}function bt(e){var t=e.curOp,r=t.ownsGroup;if(r)try{yt(r)}finally{Po=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;wt(r)}}function wt(e){for(var t=e.ops,r=0;r<t.length;r++)xt(t[r]);for(var r=0;r<t.length;r++)Ct(t[r]);for(var r=0;r<t.length;r++)St(t[r]);for(var r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)kt(t[r])}function xt(e){var t=e.cm,r=t.display;T(t),e.updateMaxLine&&h(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new k(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ct(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function St(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$e(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ve(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ke(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Lt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Qt(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&W(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Pe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing)}function kt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ke(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Tr(t,pe(n,e.scrollToPos.from),pe(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&kr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Cl(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Cl(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Cl(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Tt(e,t){if(e.curOp)return t();mt(e);try{return t()}finally{bt(e)}}function Mt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mt(e);try{return t.apply(e,arguments)}finally{bt(e)}}}function Nt(e){return function(){if(this.curOp)return e.apply(this,arguments);mt(this);try{return e.apply(this,arguments)}finally{bt(this)}}}function At(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mt(t);try{return e.apply(this,arguments)}finally{bt(t)}}}function Wt(e,t,r){this.line=t,this.rest=hn(t),this.size=this.rest?Yn(ki(this.rest))-r+1:1,this.node=this.text=null,this.hidden=gn(e,t)}function Ot(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Wt(e.doc,Kn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Dt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Mo&&dn(e.doc,t)<i.viewTo&&It(e);else if(r<=i.viewFrom)Mo&&pn(e.doc,r+n)>i.viewFrom?It(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)It(e);else if(t<=i.viewFrom){var o=zt(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):It(e)}else if(r>=i.viewTo){var o=zt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):It(e)}else{var l=zt(e,t,t,-1),s=zt(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Ot(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):It(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function Ht(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Pt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Ti(l,r)&&l.push(r)}}}function It(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function zt(e,t,r,n){var i,o=Pt(e,t),l=e.display.view;if(!Mo||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;dn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Et(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ot(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ot(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Pt(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Ot(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Pt(e,r)))),n.viewTo=r}function Ft(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rt(e){function t(){o.activeTouch&&(l=setTimeout(function(){o.activeTouch=null},1e3),s=o.activeTouch,s.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}function i(t){yi(e,t)||bl(t)}var o=e.display;wl(o.scroller,"mousedown",Mt(e,Vt)),uo&&11>co?wl(o.scroller,"dblclick",Mt(e,function(t){if(!yi(e,t)){var r=Ut(e,t);if(r&&!Yt(e,t)&&!Gt(e.display,t)){ml(t);var n=e.findWordAt(r);be(e.doc,n.anchor,n.head)}}})):wl(o.scroller,"dblclick",function(t){yi(e,t)||ml(t)}),ko||wl(o.scroller,"contextmenu",function(t){fr(e,t)});var l,s={end:0};wl(o.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(l);var t=+new Date;o.activeTouch={start:t,moved:!1,prev:t-s.end<=300?s:null},1==e.touches.length&&(o.activeTouch.left=e.touches[0].pageX,o.activeTouch.top=e.touches[0].pageY)}}),wl(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),wl(o.scroller,"touchend",function(r){var i=o.activeTouch;if(i&&!Gt(o,r)&&null!=i.left&&!i.moved&&new Date-i.start<300){var l,s=e.coordsChar(o.activeTouch,"page");l=!i.prev||n(i,i.prev)?new ce(s,s):!i.prev.prev||n(i,i.prev.prev)?e.findWordAt(s):new ce(No(s.line,0),pe(e.doc,No(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),ml(r)}t()}),wl(o.scroller,"touchcancel",t),wl(o.scroller,"scroll",function(){o.scroller.clientHeight&&(Zt(e,o.scroller.scrollTop),Qt(e,o.scroller.scrollLeft,!0),Cl(e,"scroll",e))}),wl(o.scroller,"mousewheel",function(t){Jt(e,t)}),wl(o.scroller,"DOMMouseScroll",function(t){Jt(e,t)}),wl(o.wrapper,"scroll",function(){o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),e.options.dragDrop&&(wl(o.scroller,"dragstart",function(t){qt(e,t)}),wl(o.scroller,"dragenter",i),wl(o.scroller,"dragover",i),wl(o.scroller,"drop",Mt(e,$t)));var a=o.input.getField();wl(a,"keyup",function(t){sr.call(e,t)}),wl(a,"keydown",Mt(e,or)),wl(a,"keypress",Mt(e,ar)),wl(a,"focus",Oi(ur,e)),wl(a,"blur",Oi(cr,e))}function Bt(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var r=pi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Ut(e,t,r,n){var i=e.display;if(!r&&"true"==pi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=dt(e,o,l);if(n&&1==u.xRel&&(a=Kn(e.doc,u.line).text).length==u.ch){var c=Al(a,a.length,e.options.tabSize)-a.length;u=No(u.line,Math.max(0,Math.round((o-Ue(e.display).left)/vt(e.display))-c))}return u}function Vt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||yi(t,e))){if(r.shift=e.shiftKey,Gt(r,e))return void(fo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Yt(t,e)){var n=Ut(t,e);switch(window.focus(),gi(e)){case 1:n?Kt(t,e,n):pi(e)==r.scroller&&ml(e);break;case 2:fo&&(t.state.lastMiddleDown=+new Date),n&&be(t.doc,n),setTimeout(function(){r.input.focus()},20),ml(e);break;case 3:ko&&fr(t,e)}}}}function Kt(e,t,r){uo?setTimeout(Oi(q,e),0):q(e);var n,i=+new Date;Ho&&Ho.time>i-400&&0==Ao(Ho.pos,r)?n="triple":Do&&Do.time>i-400&&0==Ao(Do.pos,r)?(n="double",Ho={time:i,pos:r}):(n="single",Do={time:i,pos:r});var o,l=e.doc.sel,s=xo?t.metaKey:t.ctrlKey;e.options.dragDrop&&Ul&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&!l.ranges[o].empty()?jt(e,t,r,s):Xt(e,t,r,n,s)}function jt(e,t,r,n){var i=e.display,o=Mt(e,function(l){fo&&(i.scroller.draggable=!1),e.state.draggingText=!1,xl(document,"mouseup",o),xl(i.scroller,"drop",o),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(ml(l),n||be(e.doc,r),i.input.focus(),uo&&9==co&&setTimeout(function(){document.body.focus(),i.input.focus()},20))});fo&&(i.scroller.draggable=!0),e.state.draggingText=o,i.scroller.dragDrop&&i.scroller.dragDrop(),wl(document,"mouseup",o),wl(i.scroller,"drop",o)}function Xt(e,t,r,n,i){function o(t){if(0!=Ao(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Al(Kn(u,r.line).text,r.ch,o),s=Al(Kn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Kn(u,p).text,y=Si(m,a,o);a==d?i.push(new ce(No(p,y),No(p,y))):m.length>y&&i.push(new ce(No(p,y),No(p,Si(m,d,o))))}i.length||i.push(new ce(r,r)),ke(u,fe(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new ce(No(t.line,0),pe(u,No(t.line+1,0)));Ao(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=Y(b.to(),C.head))}var i=h.ranges.slice(0);i[f]=new ce(pe(u,w),x),ke(u,fe(i,f),Ml)}}function l(t){var r=++y,i=Ut(e,t,!0,"rect"==n);if(i)if(0!=Ao(i,v)){q(e),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(Mt(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(Mt(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,ml(e),a.input.focus(),xl(document,"mousemove",b),xl(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;ml(t);var c,f,h=u.sel,d=h.ranges;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?d[f]:new ce(r,r)):c=u.sel.primary(),t.altKey)n="rect",i||(c=new ce(r,r)),r=Ut(e,t,!0,!0),f=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?ye(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new ce(No(r.line,0),pe(u,No(r.line+1,0)));c=e.display.shift||u.extend?ye(u,c,g.anchor,g.head):g}else c=ye(u,c,r);i?-1==f?(f=d.length,ke(u,fe(d.concat([c]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==n?(ke(u,fe(d.slice(0,f).concat(d.slice(f+1)),0)),h=u.sel):xe(u,f,c,Ml):(f=0,ke(u,new ue([c],0),Ml),h=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=Mt(e,function(e){gi(e)?l(e):s(e)}),x=Mt(e,s);wl(document,"mousemove",b),wl(document,"mouseup",x)}function _t(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&ml(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!wi(e,r))return di(t);l-=a.top-s.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=s.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=$n(e.doc,l),h=e.options.gutters[u];return i(e,r,e,f,h,t),di(t)}}}function Yt(e,t){return _t(e,t,"gutterClick",!0,vi)}function $t(e){var t=this;if(!yi(t,e)&&!Gt(t.display,e)){ml(e),uo&&(Eo=+new Date);var r=Ut(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){var s=new FileReader;s.onload=Mt(t,function(){if(o[n]=s.result,++l==i){r=pe(t.doc,r);var e={from:r,to:r,text:Vl(o.join("\n")),origin:"paste"};yr(t.doc,e),Le(t.doc,he(r,Vo(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(xo?e.metaKey:e.ctrlKey))var u=t.listSelections();if(Te(t.doc,he(r,r)),u)for(var a=0;a<u.length;++a)Lr(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function qt(e,t){if(uo&&(!e.state.draggingText||+new Date-Eo<100))return void bl(t);if(!yi(e,t)&&!Gt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!vo)){var r=Pi("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",go&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),go&&r.parentNode.removeChild(r)}}function Zt(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,lo||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),lo&&A(e),ze(e,100))}function Qt(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Jt(e,t){var r=Bo(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&xo&&fo)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;u<a.length;u++)if(a[u].node==s){e.display.currentWheelTarget=s;break e}if(n&&!lo&&!go&&null!=Ro)return i&&Zt(e,Math.max(0,Math.min(l.scrollTop+i*Ro,l.scrollHeight-l.clientHeight))),Qt(e,Math.max(0,Math.min(l.scrollLeft+n*Ro,l.scrollWidth-l.clientWidth))),ml(t),void(o.wheelStartX=null);if(i&&null!=Ro){var c=i*Ro,f=e.doc.scrollTop,h=f+o.wrapper.clientHeight;0>c?f=Math.max(0,f+c-50):h=Math.min(e.doc.height,h+c+50),A(e,{top:f,bottom:h})}20>Fo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Ro=(Ro*Fo+r)/(Fo+1),++Fo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function er(e,t,r){if("string"==typeof t&&(t=el[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=kl}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function tr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=rl(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&rl(t,e.options.extraKeys,r,e)||rl(t,e.options.keyMap,r,e)}function rr(e,t,r,n){var i=e.state.keySeq;if(i){if(nl(t))return"handled";Go.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=tr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&vi(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(ml(r),Pe(e)),i&&!o&&/\'$/.test(t)?(ml(r),!0):!!o}function nr(e,t){var r=il(t,!0);return r?t.shiftKey&&!e.state.keySeq?rr(e,"Shift-"+r,t,function(t){return er(e,t,!0)})||rr(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?er(e,t):void 0}):rr(e,r,t,function(t){return er(e,t)}):!1}function ir(e,t,r){return rr(e,"'"+r+"'",t,function(t){return er(e,t,!0)})}function or(e){var t=this;if(q(t),!yi(t,e)){uo&&11>co&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=nr(t,e);go&&(Uo=n?r:null,!n&&88==r&&!jl&&(xo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||lr(t)}}function lr(e){function t(e){18!=e.keyCode&&e.altKey||(Rl(r,"CodeMirror-crosshair"),xl(document,"keyup",t),xl(document,"mouseover",t))}var r=e.display.lineDiv;Bl(r,"CodeMirror-crosshair"),wl(document,"keyup",t),wl(document,"mouseover",t)}function sr(e){16==e.keyCode&&(this.doc.sel.shift=!1),yi(this,e)}function ar(e){var t=this;if(!(Gt(t.display,e)||yi(t,e)||e.ctrlKey&&!e.altKey||xo&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(go&&r==Uo)return Uo=null,void ml(e);if(!go||e.which&&!(e.which<10)||!nr(t,e)){var i=String.fromCharCode(null==n?r:n);ir(t,e,i)||t.display.input.onKeyPress(e)}}}function ur(e){"nocursor"!=e.options.readOnly&&(e.state.focused||(Cl(e,"focus",e),e.state.focused=!0,Bl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),fo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function cr(e){e.state.focused&&(Cl(e,"blur",e),e.state.focused=!1,Rl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function fr(e,t){Gt(e.display,t)||hr(e,t)||e.display.input.onContextMenu(t)}function hr(e,t){return wi(e,"gutterContextMenu")?_t(e,t,"gutterContextMenu",!1,Cl):!1}function dr(e,t){if(Ao(e,t.from)<0)return e;if(Ao(e,t.to)<=0)return Vo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Vo(t).ch-t.to.ch),No(r,n)}function pr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new ce(dr(i.anchor,t),dr(i.head,t)))}return fe(r,e.sel.primIndex)}function gr(e,t,r){return e.line==t.line?No(r.line,e.ch-t.ch+r.ch):No(r.line+(e.line-t.line),e.ch)}function vr(e,t,r){for(var n=[],i=No(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=gr(s.from,i,o),u=gr(Vo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=Ao(c.head,c.anchor)<0;n[l]=new ce(f?u:a,f?a:u)}else n[l]=new ce(a,a)}return new ue(n,e.sel.primIndex)}function mr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=pe(e,t)),r&&(this.to=pe(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Cl(e,"beforeChange",e,n),e.cm&&Cl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function yr(e,t,r){if(e.cm){if(!e.cm.curOp)return Mt(e.cm,yr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(wi(e,"beforeChange")||e.cm&&wi(e.cm,"beforeChange"))||(t=mr(e,t,!0))){var n=To&&!r&&en(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)br(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else br(e,t)}}function br(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Ao(t.from,t.to)){var r=pr(e,t);ri(e,t,r,e.cm?e.cm.curOp.id:NaN),Cr(e,t,r,Zr(e,t));var n=[];Un(e,function(e,r){r||-1!=Ti(n,e.history)||(hi(e.history,t),n.push(e.history)),Cr(e,t,null,Zr(e,t))})}}function wr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(oi(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];oi(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=wi(e,"beforeChange")||e.cm&&wi(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var f=n.changes[a];if(f.origin=t,c&&!mr(e,f,!1))return void(l.length=0);u.push(Jn(e,f));var h=a?pr(e,f):ki(l);Cr(e,f,h,Jr(e,f)),!a&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Vo(f)});var d=[];Un(e,function(e,t){t||-1!=Ti(d,e.history)||(hi(e.history,f),d.push(e.history)),Cr(e,f,null,Jr(e,f))})}}}}function xr(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Mi(e.sel.ranges,function(e){return new ce(No(e.anchor.line+t,e.anchor.ch),No(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)Ht(e.cm,n,"gutter")}}function Cr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Mt(e.cm,Cr)(e,t,r,n);if(t.to.line<e.first)return void xr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);xr(e,i),t={from:No(e.first,0),to:No(t.to.line+i,t.to.ch),text:[ki(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:No(o,Kn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=jn(e,t.from,t.to),r||(r=pr(e,t)),e.cm?Sr(e.cm,t,n):Rn(e,t,n),Te(e,r,Tl)}}function Sr(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=Yn(fn(Kn(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&bi(e),Rn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),ze(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Dt(e):l.line!=s.line||1!=t.text.length||Fn(e.doc,t)?Dt(e,l.line,s.line+1,c):Ht(e,l.line,"text");var h=wi(e,"changes"),d=wi(e,"change");if(d||h){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&vi(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Lr(e,t,r,n,i){if(n||(n=r),Ao(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=Vl(t)),yr(e,{from:r,to:n,text:t,origin:i})}function kr(e,t){if(!yi(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!yo){var o=Pi("div","",null,"position: absolute; top: "+(t.top-r.viewOffset-Be(e.display))+"px; height: "+(t.bottom-t.top+Ve(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Tr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=ct(e,t),s=r&&r!=t?ct(e,r):l,a=Nr(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Zt(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(Qt(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Mr(e,t,r,n,i){var o=Nr(e,t,r,n,i);null!=o.scrollTop&&Zt(e,o.scrollTop),null!=o.scrollLeft&&Qt(e,o.scrollLeft)}function Nr(e,t,r,n,i){var o=e.display,l=gt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=je(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ge(o),f=l>r,h=i>c-l;if(s>r)u.scrollTop=f?0:r;else if(i>s+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ke(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Ar(e,t,r){(null!=t||null!=r)&&Or(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Wr(e){Or(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?No(t.line,t.ch-1):t,n=No(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Or(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ft(e,t.from),n=ft(e,t.to),i=Nr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Dr(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Re(e,t):r="prev");var l=e.options.tabSize,s=Kn(o,t),a=Al(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==kl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Al(Kn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)h+=l,f+=" ";if(u>h&&(f+=Li(u-h)),f!=c)Lr(o,f,No(t,0),No(t,c.length),"+input");else for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var h=No(t,c.length);xe(o,d,new ce(h,h));break}}s.stateAfter=null}function Hr(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Kn(e,de(e,t)):i=Yn(t),null==i?null:(n(o,i)&&e.cm&&Ht(e.cm,i,r),o)}function Ir(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Ao(o.from,ki(n).to)<=0;){var l=n.pop();if(Ao(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Tt(e,function(){for(var t=n.length-1;t>=0;t--)Lr(e.doc,"",n[t].from,n[t].to,"+delete");Wr(e)})}function Pr(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?f=!1:(s=t,c=Kn(e,t))}function l(e){var t=(i?io:oo)(c,a,r,!0);if(null==t){if(e||!o())return f=!1;a=i?(0>r?Zi:qi)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Kn(e,s),f=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var h=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Di(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),h&&h!=m){0>r&&(r=1,l());break}if(m&&(h=m),r>0&&!l(!g))break}var y=We(e,No(s,a),u,!0);return f||(y.hitSide=!0),y}function zr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(0>r?1.5:.5)*gt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=dt(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Er(t,r,n,i){e.defaults[t]=r,n&&(jo[t]=i?function(e,t,r){r!=Xo&&n(e,t,r)}:n)}function Fr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Rr(e){return"string"==typeof e?tl[e]:e;
|
3 |
+
}function Br(e,t,r,n,i){if(n&&n.shared)return Gr(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Mt(e.cm,Br)(e,t,r,n,i);var o=new sl(e,i),l=Ao(t,r);if(n&&Wi(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Pi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(cn(e,t.line,t,r,o)||t.line!=r.line&&cn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Mo=!0}o.addToHistory&&ri(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&fn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&_n(e,0),Yr(e,new jr(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){gn(e,t)&&_n(t,0)}),o.clearOnEnter&&wl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(To=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ll,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dt(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)Ht(u,c,"text");o.atomic&&Ne(u.doc),vi(u,"markerAdded",u,o)}return o}function Gr(e,t,r,n,i){n=Wi(n),n.shared=!1;var o=[Br(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Un(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Br(e,pe(e,t),pe(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=ki(o)}),new al(o,l)}function Ur(e){return e.findMarks(No(e.first,0),e.clipPos(No(e.lastLine())),function(e){return e.parent})}function Vr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Ao(o,l)){var s=Br(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Kr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];Un(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Ti(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function jr(e,t,r){this.marker=e,this.from=t,this.to=r}function Xr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function _r(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Yr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function $r(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new jr(l,o.from,a?null:o.to))}}return n}function qr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new jr(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Zr(e,t){if(t.full)return null;var r=ve(e,t.from.line)&&Kn(e,t.from.line).markedSpans,n=ve(e,t.to.line)&&Kn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Ao(t.from,t.to),s=$r(r,i,l),a=qr(n,o,l),u=1==t.text.length,c=ki(t.text).length+(u?i:0);if(s)for(var f=0;f<s.length;++f){var h=s[f];if(null==h.to){var d=Xr(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var f=0;f<a.length;++f){var h=a[f];if(null!=h.to&&(h.to+=c),null==h.from){var d=Xr(s,h.marker);d||(h.from=c,u&&(s||(s=[])).push(h))}else h.from+=c,u&&(s||(s=[])).push(h)}s&&(s=Qr(s)),a&&a!=s&&(a=Qr(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var f=0;f<s.length;++f)null==s[f].to&&(g||(g=[])).push(new jr(s[f].marker,null,null));for(var f=0;v>f;++f)p.push(g);p.push(a)}return p}function Qr(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Jr(e,t){var r=ai(e,t),n=Zr(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function en(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Ti(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Ao(u.to,s.from)<0||Ao(u.from,s.to)>0)){var c=[a,1],f=Ao(u.from,s.from),h=Ao(u.to,s.to);(0>f||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(h>0||!l.inclusiveRight&&!h)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function tn(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function rn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function nn(e){return e.inclusiveLeft?-1:0}function on(e){return e.inclusiveRight?1:0}function ln(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Ao(n.from,i.from)||nn(e)-nn(t);if(o)return-o;var l=Ao(n.to,i.to)||on(e)-on(t);return l?l:t.id-e.id}function sn(e,t){var r,n=Mo&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||ln(r,i.marker)<0)&&(r=i.marker);return r}function an(e){return sn(e,!0)}function un(e){return sn(e,!1)}function cn(e,t,r,n,i){var o=Kn(e,t),l=Mo&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Ao(u.from,r)||nn(a.marker)-nn(i),f=Ao(u.to,n)||on(a.marker)-on(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(Ao(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Ao(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function fn(e){for(var t;t=an(e);)e=t.find(-1,!0).line;return e}function hn(e){for(var t,r;t=un(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function dn(e,t){var r=Kn(e,t),n=fn(r);return r==n?t:Yn(n)}function pn(e,t){if(t>e.lastLine())return t;var r,n=Kn(e,t);if(!gn(e,n))return t;for(;r=un(n);)n=r.find(1,!0).line;return Yn(n)+1}function gn(e,t){var r=Mo&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&vn(e,t,n))return!0}}function vn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return vn(e,n.line,Xr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&vn(e,t,i))return!0}function mn(e,t,r){qn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ar(e,null,r)}function yn(e){if(null!=e.height)return e.height;if(!zl(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.display.gutters.offsetWidth+"px;"),e.noHScroll&&(t+="width: "+e.cm.display.wrapper.clientWidth+"px;"),Ei(e.cm.display.measure,Pi("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function bn(e,t,r,n){var i=new ul(e,r,n);return i.noHScroll&&(e.display.alignWidgets=!0),Hr(e.doc,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,!gn(e.doc,t)){var n=qn(t)<e.doc.scrollTop;_n(t,t.height+yn(i)),n&&Ar(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function wn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),tn(e),rn(e,r);var i=n?n(e):1;i!=e.height&&_n(e,i)}function xn(e){e.parent=null,tn(e)}function Cn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function Sn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Ln(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function kn(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?Qo(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=pe(l,t);var a,u=Kn(l,t.line),c=Re(e,t.line,r),f=new ol(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,o=Ln(s,f,c),n&&a.push(i(!0));return n?a:i()}function Tn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,f=new ol(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&Cn(Sn(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&An(e,t,n,f.pos),f.pos=t.length,a=null):a=Cn(Ln(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<f.start;)u=Math.min(f.start,u+5e4),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);i(p,c),u=p}}function Mn(e,t,r,n){var i=[e.state.modeGen],o={};Tn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Tn(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Nn(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Mn(e,t,t.stateAfter=Re(e,Yn(t)));t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function An(e,t,r,n){var i=e.doc.mode,o=new ol(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&Sn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Ln(i,o,r),o.start=o.pos}function Wn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?hl:fl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function On(e,t){var r=Pi("span",null,null,fo?"padding-right: .1px":null),n={pre:Pi("pre",[r]),content:r,col:0,pos:0,cm:e};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Hn,(uo||fo)&&e.getOption("lineWrapping")&&(n.addToken=In(n.addToken)),ji(e.display.measure)&&(o=Zn(l))&&(n.addToken=Pn(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&Yn(l);En(l,n,Nn(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Bi(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Bi(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Ki(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return fo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Cl(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Bi(n.pre.className,n.textClass||"")),n}function Dn(e){var t=Pi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Hn(e,t,r,n,i,o,l){if(t){var s=e.cm.options.specialChars,a=!1;if(s.test(t))for(var u=document.createDocumentFragment(),c=0;;){s.lastIndex=c;var f=s.exec(t),h=f?f.index-c:t.length-c;if(h){var d=document.createTextNode(t.slice(c,c+h));uo&&9>co?u.appendChild(Pi("span",[d])):u.appendChild(d),e.map.push(e.pos,e.pos+h,d),e.col+=h,e.pos+=h}if(!f)break;if(c+=h+1," "==f[0]){var p=e.cm.options.tabSize,g=p-e.col%p,d=u.appendChild(Pi("span",Li(g),"cm-tab"));d.setAttribute("role","presentation"),d.setAttribute("cm-text"," "),e.col+=g}else{var d=e.cm.options.specialCharPlaceholder(f[0]);d.setAttribute("cm-text",f[0]),uo&&9>co?u.appendChild(Pi("span",[d])):u.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}else{e.col+=t.length;var u=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,u),uo&&9>co&&(a=!0),e.pos+=t.length}if(r||n||i||a||l){var v=r||"";n&&(v+=n),i&&(v+=i);var m=Pi("span",[u],v,l);return o&&(m.title=o),e.content.appendChild(m)}e.content.appendChild(u)}}function In(e){function t(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}return function(r,n,i,o,l,s){e(r,n.replace(/ {3,}/g,t),i,o,l,s)}}function Pn(e,t){return function(r,n,i,o,l,s){i=i?i+" cm-force-border":"cm-force-border";for(var a=r.pos,u=a+n.length;;){for(var c=0;c<t.length;c++){var f=t[c];if(f.to>a&&f.from<=a)break}if(f.to>=u)return e(r,n,i,o,l,s);e(r,n.slice(0,f.to-a),i,o,null,s),o=null,n=n.slice(f.to-a),a=f.to}}}function zn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function En(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=0;b<n.length;++b){var w=n[b],x=w.marker;w.from<=p&&(null==w.to||w.to>p)?(null!=w.to&&m>w.to&&(m=w.to,u=""),x.className&&(a+=" "+x.className),x.css&&(s=x.css),x.startStyle&&w.from==p&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(u+=" "+x.endStyle),x.title&&!f&&(f=x.title),x.collapsed&&(!h||ln(h.marker,x)<0)&&(h=w)):w.from>p&&m>w.from&&(m=w.from),"bookmark"==x.type&&w.from==p&&x.widgetNode&&y.push(x)}if(h&&(h.from||0)==p&&(zn(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to))return;if(!h&&y.length)for(var b=0;b<y.length;++b)zn(t,0,y[b])}if(p>=d)break;for(var C=Math.min(d,m);;){if(v){var S=p+v.length;if(!h){var L=S>C?v.slice(0,C-p):v;t.addToken(t,L,l?l+a:a,c,p+L.length==m?u:"",f,s)}if(S>=C){v=v.slice(C-p),p=C;break}p=S,c=""}v=i.slice(o,o=r[g++]),l=Wn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Wn(r[g+1],t.cm.options))}function Fn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==ki(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Rn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){wn(e,r,i,n),vi(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new cl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Kn(e,s.line),f=Kn(e,a.line),h=ki(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Fn(e,t)){var g=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==f)if(1==u.length)o(c,c.text.slice(0,s.ch)+h+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new cl(h+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+f.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(f,h+f.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}vi(e,"change",e,t)}function Bn(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function Gn(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function Un(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function Vn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,Dt(e)}function Kn(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function jn(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Xn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function _n(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function Yn(e){if(null==e.parent)return null;for(var t=e.parent,r=Ti(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function $n(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function qn(e){e=fn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function Zn(e){var t=e.order;return null==t&&(t=e.order=$l(e.text)),t}function Qn(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Jn(e,t){var r={from:_(t.from),to:Vo(t),text:jn(e,t.from,t.to)};return li(e,r,t.from.line,t.to.line+1),Un(e,function(e){li(e,r,t.from.line,t.to.line+1)},!0),r}function ei(e){for(;e.length;){var t=ki(e);if(!t.ranges)break;e.pop()}}function ti(e,t){return t?(ei(e.done),ki(e.done)):e.done.length&&!ki(e.done).ranges?ki(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),ki(e.done)):void 0}function ri(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ti(i,i.lastOp==n))){var s=ki(o.changes);0==Ao(t.from,t.to)&&0==Ao(t.from,s.to)?s.to=Vo(t):o.changes.push(Jn(e,t))}else{var a=ki(i.done);for(a&&a.ranges||oi(e.sel,i.done),o={changes:[Jn(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Cl(e,"historyAdded")}function ni(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function ii(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ni(e,o,ki(i.done),t))?i.done[i.done.length-1]=t:oi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&ei(i.undone)}function oi(e,t){var r=ki(t);r&&r.ranges&&r.equals(e)||t.push(e)}function li(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function si(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ai(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(si(r[n]));return i}function ui(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ue.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&Ti(t,Number(u[1]))>-1&&(ki(s)[f]=c[f],delete c[f])}}}return i}function ci(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function fi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)ci(o.ranges[s].anchor,t,r,n),ci(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=No(a.from.line+n,a.from.ch),a.to=No(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function hi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;fi(e.done,r,n,i),fi(e.undone,r,n,i)}function di(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function pi(e){return e.target||e.srcElement}function gi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),xo&&e.ctrlKey&&1==t&&(t=3),t}function vi(e,t){function r(e){return function(){e.apply(null,o)}}var n=e._handlers&&e._handlers[t];if(n){var i,o=Array.prototype.slice.call(arguments,2);Po?i=Po.delayedCallbacks:Sl?i=Sl:(i=Sl=[],setTimeout(mi,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function mi(){var e=Sl;Sl=null;for(var t=0;t<e.length;++t)e[t]()}function yi(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Cl(e,r||t.type,e,t),di(t)||t.codemirrorIgnore}function bi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Ti(r,t[n])&&r.push(t[n])}function wi(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function xi(e){e.prototype.on=function(e,t){wl(this,e,t)},e.prototype.off=function(e,t){xl(this,e,t)}}function Ci(){this.id=null}function Si(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Li(e){for(;Wl.length<=e;)Wl.push(ki(Wl)+" ");return Wl[e]}function ki(e){return e[e.length-1]}function Ti(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Mi(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Ni(){}function Ai(e,t){var r;return Object.create?r=Object.create(e):(Ni.prototype=e,r=new Ni),t&&Wi(t,r),r}function Wi(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Oi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Di(e,t){return t?t.source.indexOf("\\w")>-1&&Il(e)?!0:t.test(e):Il(e)}function Hi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Ii(e){return e.charCodeAt(0)>=768&&Pl.test(e)}function Pi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function zi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ei(e,t){return zi(e).appendChild(t)}function Fi(){return document.activeElement}function Ri(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Bi(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Ri(r[n]).test(t)&&(t+=" "+r[n]);return t}function Gi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Ui(){Gl||(Vi(),Gl=!0)}function Vi(){var e;wl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Gi(Bt)},100))}),wl(window,"blur",function(){Gi(cr)})}function Ki(e){if(null==El){var t=Pi("span","");Ei(e,Pi("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(El=t.offsetWidth<=1&&t.offsetHeight>2&&!(uo&&8>co))}var r=El?Pi("span",""):Pi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function ji(e){if(null!=Fl)return Fl;var t=Ei(e,document.createTextNode("AخA")),r=Dl(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Dl(t,1,2).getBoundingClientRect();return Fl=n.right-r.right<3}function Xi(e){if(null!=Xl)return Xl;var t=Ei(e,Pi("span","x")),r=t.getBoundingClientRect(),n=Dl(t,0,1).getBoundingClientRect();return Xl=Math.abs(r.left-n.left)>1}function _i(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function Yi(e){return e.level%2?e.to:e.from}function $i(e){return e.level%2?e.from:e.to}function qi(e){var t=Zn(e);return t?Yi(t[0]):0}function Zi(e){var t=Zn(e);return t?$i(ki(t)):e.text.length}function Qi(e,t){var r=Kn(e.doc,t),n=fn(r);n!=r&&(t=Yn(n));var i=Zn(n),o=i?i[0].level%2?Zi(n):qi(n):0;return No(t,o)}function Ji(e,t){for(var r,n=Kn(e.doc,t);r=un(n);)n=r.find(1,!0).line,t=null;var i=Zn(n),o=i?i[0].level%2?qi(n):Zi(n):n.text.length;return No(null==t?Yn(n):t,o)}function eo(e,t){var r=Qi(e,t.line),n=Kn(e.doc,r.line),i=Zn(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return No(r.line,l?0:o)}return r}function to(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function ro(e,t){Yl=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return to(e,i.level,e[r].level)?(i.from!=i.to&&(Yl=r),n):(i.from!=i.to&&(Yl=n),r);r=n}}return r}function no(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Ii(e.text.charAt(t)));return t}function io(e,t,r,n){var i=Zn(e);if(!i)return oo(e,t,r,n);for(var o=ro(i,t),l=i[o],s=no(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return ro(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?no(e,l.to,-1,n):no(e,l.from,1,n)}}function oo(e,t,r,n){var i=t+r;if(n)for(;i>0&&Ii(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var lo=/gecko\/\d/i.test(navigator.userAgent),so=/MSIE \d/.test(navigator.userAgent),ao=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),uo=so||ao,co=uo&&(so?document.documentMode||6:ao[1]),fo=/WebKit\//.test(navigator.userAgent),ho=fo&&/Qt\/\d+\.\d+/.test(navigator.userAgent),po=/Chrome\//.test(navigator.userAgent),go=/Opera\//.test(navigator.userAgent),vo=/Apple Computer/.test(navigator.vendor),mo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),yo=/PhantomJS/.test(navigator.userAgent),bo=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),wo=bo||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),xo=bo||/Mac/.test(navigator.platform),Co=/win/i.test(navigator.platform),So=go&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);So&&(So=Number(So[1])),So&&So>=15&&(go=!1,fo=!0);var Lo=xo&&(ho||go&&(null==So||12.11>So)),ko=lo||uo&&co>=9,To=!1,Mo=!1;g.prototype=Wi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==n&&this.overlayHack(),this.checkedOverlay=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=xo&&!mo?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,r=function(e){pi(e)!=t.vert&&pi(e)!=t.horiz&&Mt(t.cm,Vt)(e)};wl(this.vert,"mousedown",r),wl(this.horiz,"mousedown",r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=Wi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},k.prototype.signal=function(e,t){wi(e,t)&&this.events.push(arguments)},k.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Cl.apply(null,this.events[e])};var No=e.Pos=function(e,t){return this instanceof No?(this.line=e,void(this.ch=t)):new No(e,t)},Ao=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Wo=null;te.prototype=Wi({init:function(e){function t(e){if(n.somethingSelected())Wo=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Wo.join("\n"),Ol(o));else{var t=J(n);Wo=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Tl):(r.prevInput="",o.value=t.text.join("\n"),Ol(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=re(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),bo&&(o.style.width="0px"),wl(o,"input",function(){uo&&co>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),wl(o,"paste",function(){if(fo&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var e=o.selectionStart,t=o.selectionEnd;o.value+="$",o.selectionEnd=t,o.selectionStart=e,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,r.fastPoll()}),wl(o,"cut",t),wl(o,"copy",t),wl(e.scroller,"paste",function(t){Gt(e,t)||(n.state.pasteIncoming=!0,r.focus())}),wl(e.lineSpace,"selectstart",function(t){Gt(e,t)||ml(t)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=De(e);if(e.options.moveInputWithCursor){var i=ct(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ei(r.cursorDiv,e.cursors),Ei(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=jl&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Ol(this.textarea),uo&&co>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",uo&&co>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!wo||Fi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(!e.state.focused||Kl(t)&&!r||Z(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(uo&&co>=9&&this.hasSelection===n||xo&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;8203!=n.charCodeAt(0)||e.doc.sel!=e.display.selForContextMenu||r||(r="");for(var i=0,o=Math.min(r.length,n.length);o>i&&r.charCodeAt(i)==n.charCodeAt(i);)++i;var l=this;
|
4 |
+
return Tt(e,function(){Q(e,n.slice(i),r.length-i),n.length>1e3||n.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=n}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){uo&&co>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=l.value=""+(e?l.value:"");n.prevInput=e?"":"",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,uo&&9>co&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!uo||uo&&9>co)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart?Mt(i,el.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Ut(i,e),a=o.scroller.scrollTop;if(s&&!go){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&Mt(i,ke)(i.doc,he(s),Tl);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(uo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",fo)var f=window.scrollY;if(o.input.focus(),fo&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),uo&&co>=9&&t(),ko){bl(e);var h=function(){xl(window,"mouseup",h),setTimeout(r,20)};wl(window,"mouseup",h)}else setTimeout(r,50)}},setUneditable:Ni,needsContentAttribute:!1},te.prototype),ne.prototype=Wi({init:function(e){function t(e){if(n.somethingSelected())Wo=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{var t=J(n);Wo=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Tl),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!bo)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Wo.join("\n"));else{var r=re(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Wo.join("\n");var o=document.activeElement;Ol(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;i.contentEditable="true",ee(i),wl(i,"paste",function(e){var t=e.clipboardData&&e.clipboardData.getData("text/plain");t&&(e.preventDefault(),n.replaceSelection(t,null,"paste"))}),wl(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=he(No(i.head.line,l),No(i.head.line,l+t.length)))}}),wl(i,"compositionupdate",function(e){r.composing.data=e.data}),wl(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),wl(i,"touchstart",function(){r.forceCompositionEnd()}),wl(i,"input",function(){r.composing||r.pollContent()||Tt(r.cm,function(){Dt(n)})}),wl(i,"copy",t),wl(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=le(this.cm,e.anchorNode,e.anchorOffset),n=le(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Ao($(r,n),t.from())||0!=Ao(Y(r,n),t.to())){var i=ie(this.cm,t.from()),o=ie(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Dl(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode&&e.addRange(s)),this.rememberSelection()}}},showMultipleSelections:function(e){Ei(this.cm.display.cursorDiv,e.cursors),Ei(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return zl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Tt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},pollSelection:function(){if(!this.composing){var e=window.getSelection(),t=this.cm;if(e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset){this.rememberSelection();var r=le(t,e.anchorNode,e.anchorOffset),n=le(t,e.focusNode,e.focusOffset);r&&n&&Tt(t,function(){ke(t.doc,he(r,n),Tl),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Pt(e,n.line)))var l=Yn(t.view[0].line),s=t.view[0].node;else var l=Yn(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Pt(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.view[a].node;else var u=Yn(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var f=Vl(ae(e,s,c,l,u)),h=jn(e.doc,No(l,0),No(u,Kn(e.doc,u).text.length));f.length>1&&h.length>1;)if(ki(f)==ki(h))f.pop(),h.pop(),u--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,g=f[0],v=h[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=ki(f),b=ki(h),w=Math.min(y.length-(1==f.length?d:0),b.length-(1==h.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var x=No(l,d),C=No(u,h.length?ki(h).length-p:0);return f.length>1||f[0]||Ao(x,C)?(Lr(e.doc,f,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){e.data&&e.data!=e.startData&&Mt(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),Mt(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:Ni,resetPosition:Ni,needsContentAttribute:!0},ne.prototype),e.inputStyles={textarea:te,contenteditable:ne},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Ao(r.anchor,n.anchor)||0!=Ao(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ce(_(this.ranges[t].anchor),_(this.ranges[t].head));return new ue(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Ao(t,n.from())>=0&&Ao(e,n.to())<=0)return r}return-1}},ce.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return Y(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Oo,Do,Ho,Io={left:0,right:0,top:0,bottom:0},Po=null,zo=0,Eo=0,Fo=0,Ro=null;uo?Ro=-.53:lo?Ro=15:po?Ro=-.7:vo&&(Ro=-1/3);var Bo=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Bo(e);return t.x*=Ro,t.y*=Ro,t};var Go=new Ci,Uo=null,Vo=e.changeEnd=function(e){return e.text?No(e.from.line+e.text.length-1,ki(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,jo.hasOwnProperty(e)&&Mt(this,jo[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Rr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Nt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Dt(this)}),removeOverlay:Nt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Dt(this)}}),indentLine:Nt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ve(this.doc,e)&&Dr(this,e,t,r)}),indentSelection:Nt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Dr(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&Wr(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Dr(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&xe(this.doc,n,new ce(o,u[n].to()),Tl)}}}),getTokenAt:function(e,t){return kn(this,e,t)},getLineTokens:function(e,t){return kn(this,No(e),t,!0)},getTokenTypeAt:function(e){e=pe(this.doc,e);var t,r=Nn(this,Kn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Zo.hasOwnProperty(t))return Zo;var n=Zo[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Ti(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=de(r,null==e?r.first+r.size-1:e),Re(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?pe(this.doc,e):e?n.from():n.to(),ct(this,r,t||"page")},charCoords:function(e,t){return ut(this,pe(this.doc,e),t||"page")},coordsChar:function(e,t){return e=at(this,e,t||"page"),dt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=at(this,{top:e,left:0},t||"page").top,$n(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r=!1,n=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>n&&(e=n,r=!0);var i=Kn(this.doc,e);return st(this,i,{top:0,left:0},t||"page").top+(r?this.doc.height-qn(i):0)},defaultTextHeight:function(){return gt(this.display)},defaultCharWidth:function(){return vt(this.display)},setGutterMarker:Nt(function(e,t,r){return Hr(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Hi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Nt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Ht(t,n,"gutter"),Hi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),addLineWidget:Nt(function(e,t,r){return bn(this,e,t,r)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Kn(this.doc,e),!e)return null}else{var t=Yn(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ct(this,pe(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Mr(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Nt(or),triggerOnKeyPress:Nt(ar),triggerOnKeyUp:sr,execCommand:function(e){return el.hasOwnProperty(e)?el[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=pe(this.doc,e);t>o&&(l=Pr(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Nt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Pr(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},Nl)}),deleteH:Nt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Ir(this,function(r){var i=Pr(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=pe(this.doc,e);t>l;++l){var a=ct(this,s,"div");if(null==o?o=a.left:a.left=o,s=zr(this,a,i,r),s.hitSide)break}return s},moveV:Nt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=ct(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=zr(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Ar(r,null,ut(r,a,"div").top-s.top),a},Nl),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Kn(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Di(l,o)?function(e){return Di(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Di(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new ce(No(e.line,n),No(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Bl(this.display.cursorDiv,"CodeMirror-overwrite"):Rl(this.display.cursorDiv,"CodeMirror-overwrite"),Cl(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Fi()},scrollTo:Nt(function(e,t){(null!=e||null!=t)&&Or(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Ve(this)-this.display.barHeight,width:e.scrollWidth-Ve(this)-this.display.barWidth,clientHeight:je(this),clientWidth:Ke(this)}},scrollIntoView:Nt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:No(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Or(this),this.curOp.scrollToPos=e;else{var r=Nr(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Nt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&nt(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Ht(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Cl(n,"refresh",this)}),operation:function(e){return Tt(this,e)},refresh:Nt(function(){var e=this.display.cachedTextHeight;Dt(this),this.curOp.forceUpdate=!0,it(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-gt(this.display))>.5)&&l(this),Cl(this,"refresh",this)}),swapDoc:Nt(function(e){var t=this.doc;return t.cm=null,Vn(this,e),it(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,vi(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},xi(e);var Ko=e.defaults={},jo=e.optionHandlers={},Xo=e.Init={toString:function(){return"CodeMirror.Init"}};Er("value","",function(e,t){e.setValue(t)},!0),Er("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Er("indentUnit",2,r,!0),Er("indentWithTabs",!1),Er("smartIndent",!0),Er("tabSize",4,function(e){n(e),it(e),Dt(e)},!0),Er("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),e.refresh()},!0),Er("specialCharPlaceholder",Dn,function(e){e.refresh()},!0),Er("electricChars",!0),Er("inputStyle",wo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Er("rtlMoveVisually",!Co),Er("wholeLineUpdateBefore",!0),Er("theme","default",function(e){s(e),a(e)},!0),Er("keyMap","default",function(t,r,n){var i=Rr(r),o=n!=e.Init&&Rr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Er("extraKeys",null),Er("lineWrapping",!1,i,!0),Er("gutters",[],function(e){d(e.options),a(e)},!0),Er("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Er("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Er("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Er("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Er("firstLineNumber",1,a,!0),Er("lineNumberFormatter",function(e){return e},a,!0),Er("showCursorWhenSelecting",!1,Oe,!0),Er("resetSelectionOnContextMenu",!0),Er("readOnly",!1,function(e,t){"nocursor"==t?(cr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),Er("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Er("dragDrop",!0),Er("cursorBlinkRate",530),Er("cursorScrollMargin",0),Er("cursorHeight",1,Oe,!0),Er("singleCursorHeightPerLine",!0,Oe,!0),Er("workTime",100),Er("workDelay",100),Er("flattenSpans",!0,n,!0),Er("addModeClass",!1,n,!0),Er("pollInterval",100),Er("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Er("historyEventDelay",1250),Er("viewportMargin",10,function(e){e.refresh()},!0),Er("maxHighlightLength",1e4,n,!0),Er("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Er("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Er("autofocus",null);var _o=e.modes={},Yo=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),_o[t]=r},e.defineMIME=function(e,t){Yo[e]=t},e.resolveMode=function(t){if("string"==typeof t&&Yo.hasOwnProperty(t))t=Yo[t];else if(t&&"string"==typeof t.name&&Yo.hasOwnProperty(t.name)){var r=Yo[t.name];"string"==typeof r&&(r={name:r}),t=Ai(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=_o[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if($o.hasOwnProperty(r.name)){var o=$o[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var $o=e.modeExtensions={};e.extendMode=function(e,t){var r=$o.hasOwnProperty(e)?$o[e]:$o[e]={};Wi(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){pl.prototype[e]=t},e.defineOption=Er;var qo=[];e.defineInitHook=function(e){qo.push(e)};var Zo=e.helpers={};e.registerHelper=function(t,r,n){Zo.hasOwnProperty(t)||(Zo[t]=e[t]={_global:[]}),Zo[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Zo[t]._global.push({pred:n,val:i})};var Qo=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},Jo=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var el=e.commands={selectAll:function(e){e.setSelection(No(e.firstLine(),0),No(e.lastLine()),Tl)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Tl)},killLine:function(e){Ir(e,function(t){if(t.empty()){var r=Kn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:No(t.head.line+1,0)}:{from:t.head,to:No(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Ir(e,function(t){return{from:No(t.from().line,0),to:pe(e.doc,No(t.to().line+1,0))}})},delLineLeft:function(e){Ir(e,function(e){return{from:No(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Ir(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Ir(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(No(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(No(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Qi(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return eo(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ji(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Nl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Nl)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?eo(e,t.head):n},Nl)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Al(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Tt(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Kn(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new No(i.line,i.ch-1)),i.ch>0)i=new No(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),No(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Kn(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),No(i.line-1,l.length-1),No(i.line,1),"+transpose")}r.push(new ce(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Tt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),Wr(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},tl=e.keyMap={};tl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},tl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},tl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},tl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},tl["default"]=xo?tl.macDefault:tl.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Mi(r.split(" "),Fr),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=r,l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var rl=e.lookupKey=function(e,t,r,n){t=Rr(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return rl(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=rl(e,t.fallthrough[o],r,n);if(l)return l}}},nl=e.isModifierKey=function(e){var t="string"==typeof e?e:_l[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},il=e.keyName=function(e,t){if(go&&34==e.keyCode&&e["char"])return!1;var r=_l[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(Lo?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(Lo?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?Wi(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=Fi();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(wl(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(xl(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var ol=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ol.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Al(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),
|
5 |
+
this.lastColumnValue-(this.lineStart?Al(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Al(this.string,null,this.tabSize)-(this.lineStart?Al(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ll=0,sl=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ll};xi(sl),sl.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&mt(e),wi(this,"clear")){var r=this.find();r&&vi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Xr(l.markedSpans,this);e&&!this.collapsed?Ht(e,Yn(l),"text"):e&&(null!=s.to&&(i=Yn(l)),null!=s.from&&(n=Yn(l))),l.markedSpans=_r(l.markedSpans,s),null==s.from&&this.collapsed&&!gn(this.doc,l)&&e&&_n(l,gt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=fn(this.lines[o]),u=f(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Dt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ne(e.doc)),e&&vi(e,"markerCleared",e,this),t&&bt(e),this.parent&&this.parent.clear()}},sl.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Xr(o.markedSpans,this);if(null!=l.from&&(r=No(t?o:Yn(o),l.from),-1==e))return r;if(null!=l.to&&(n=No(t?o:Yn(o),l.to),1==e))return n}return r&&{from:r,to:n}},sl.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Tt(r,function(){var n=e.line,i=Yn(e.line),o=qe(r,i);if(o&&(rt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!gn(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=yn(t)-l;s&&_n(n,n.height+s)}})},sl.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Ti(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},sl.prototype.detachLine=function(e){if(this.lines.splice(Ti(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var ll=0,al=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};xi(al),al.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();vi(this,"clear")}},al.prototype.find=function(e,t){return this.primary.find(e,t)};var ul=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.cm=e,this.node=t};xi(ul),ul.prototype.clear=function(){var e=this.cm,t=this.line.widgets,r=this.line,n=Yn(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=yn(this);Tt(e,function(){mn(e,r,-o),Ht(e,n,"widget"),_n(r,Math.max(0,r.height-o))})}},ul.prototype.changed=function(){var e=this.height,t=this.cm,r=this.line;this.height=null;var n=yn(this)-e;n&&Tt(t,function(){t.curOp.forceUpdate=!0,mn(t,r,n),_n(r,r.height+n)})};var cl=e.Line=function(e,t,r){this.text=e,rn(this,t),this.height=r?r(this):1};xi(cl),cl.prototype.lineNo=function(){return Yn(this)};var fl={},hl={};Bn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,xn(i),vi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},Gn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Bn))){var s=[];this.collapse(s),this.children=[new Bn(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Bn(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Gn(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Ti(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Gn(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var dl=0,pl=e.Doc=function(e,t,r){if(!(this instanceof pl))return new pl(e,t,r);null==r&&(r=0),Gn.call(this,[new Bn([new cl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=No(r,0);this.sel=he(n),this.history=new Qn(null),this.id=++dl,this.modeOption=t,"string"==typeof e&&(e=Vl(e)),Rn(this,{from:n,to:n,text:e}),ke(this,he(n),Tl)};pl.prototype=Ai(Gn.prototype,{constructor:pl,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Xn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:At(function(e){var t=No(this.first,0),r=this.first+this.size-1;yr(this,{from:t,to:No(r,Kn(this,r).text.length),text:Vl(e),origin:"setValue",full:!0},!0),ke(this,he(t))}),replaceRange:function(e,t,r,n){t=pe(this,t),r=r?pe(this,r):t,Lr(this,e,t,r,n)},getRange:function(e,t,r){var n=jn(this,pe(this,e),pe(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return ve(this,e)?Kn(this,e):void 0},getLineNumber:function(e){return Yn(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Kn(this,e)),fn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return pe(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:At(function(e,t,r){Ce(this,pe(this,"number"==typeof e?No(e,t||0):e),null,r)}),setSelection:At(function(e,t,r){Ce(this,pe(this,e),pe(this,t||e),r)}),extendSelection:At(function(e,t,r){be(this,pe(this,e),t&&pe(this,t),r)}),extendSelections:At(function(e,t){we(this,me(this,e,t))}),extendSelectionsBy:At(function(e,t){we(this,Mi(this.sel.ranges,e),t)}),setSelections:At(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new ce(pe(this,e[n].anchor),pe(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ke(this,fe(i,t),r)}}),addSelection:At(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new ce(pe(this,e),pe(this,t||e))),ke(this,fe(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=jn(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=jn(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:At(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:Vl(e[o]),origin:r}}for(var s=t&&"end"!=t&&vr(this,n,t),o=n.length-1;o>=0;o--)yr(this,n[o]);s?Le(this,s):this.cm&&Wr(this.cm)}),undo:At(function(){wr(this,"undo")}),redo:At(function(){wr(this,"redo")}),undoSelection:At(function(){wr(this,"undo",!0)}),redoSelection:At(function(){wr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Qn(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:ui(this.history.done),undone:ui(this.history.undone)}},setHistory:function(e){var t=this.history=new Qn(this.history.maxGeneration);t.done=ui(e.done.slice(0),null,!0),t.undone=ui(e.undone.slice(0),null,!0)},addLineClass:At(function(e,t,r){return Hr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Ri(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:At(function(e,t,r){return Hr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Ri(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),markText:function(e,t,r){return Br(this,pe(this,e),pe(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=pe(this,e),Br(this,e,e,r,"bookmark")},findMarksAt:function(e){e=pe(this,e);var t=[],r=Kn(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=pe(this,e),t=pe(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),pe(this,No(r,t))},indexFromPos:function(e){e=pe(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new pl(Xn(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new pl(Xn(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Vr(n,Ur(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),Kr(Ur(this));break}}if(t.history==this.history){var i=[t.id];Un(t,function(e){i.push(e.id)},!0),t.history=new Qn(null),t.history.done=ui(this.history.done,i),t.history.undone=ui(this.history.undone,i)}},iterLinkedDocs:function(e){Un(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),pl.prototype.eachLine=pl.prototype.iter;var gl="iter insert remove copy getEditor".split(" ");for(var vl in pl.prototype)pl.prototype.hasOwnProperty(vl)&&Ti(gl,vl)<0&&(e.prototype[vl]=function(e){return function(){return e.apply(this.doc,arguments)}}(pl.prototype[vl]));xi(pl);var ml=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},yl=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},bl=e.e_stop=function(e){ml(e),yl(e)},wl=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},xl=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},Cl=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Sl=null,Ll=30,kl=e.Pass={toString:function(){return"CodeMirror.Pass"}},Tl={scroll:!1},Ml={origin:"*mouse"},Nl={origin:"+move"};Ci.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Al=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Wl=[""],Ol=function(e){e.select()};bo?Ol=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:uo&&(Ol=function(e){try{e.select()}catch(t){}});var Dl,Hl=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Il=e.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Hl.test(e))},Pl=/[\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]/;Dl=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var zl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};uo&&11>co&&(Fi=function(){try{return document.activeElement}catch(e){return document.body}});var El,Fl,Rl=e.rmClass=function(e,t){var r=e.className,n=Ri(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Bl=e.addClass=function(e,t){var r=e.className;Ri(t).test(r)||(e.className+=(r?" ":"")+t)},Gl=!1,Ul=function(){if(uo&&9>co)return!1;var e=Pi("div");return"draggable"in e||"dragDrop"in e}(),Vl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Kl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},jl=function(){var e=Pi("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Xl=null,_l={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};e.keyNames=_l,function(){for(var e=0;10>e;e++)_l[e+48]=_l[e+96]=String(e);for(var e=65;90>=e;e++)_l[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)_l[e+111]=_l[e+63235]="F"+e}();var Yl,$l=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,f=[],h=0;c>h;++h)f.push(n=e(r.charCodeAt(h)));for(var h=0,d=u;c>h;++h){var n=f[h];"m"==n?f[h]=d:d=n}for(var h=0,p=u;c>h;++h){var n=f[h];"1"==n&&"r"==p?f[h]="n":l.test(n)&&(p=n,"r"==n&&(f[h]="R"))}for(var h=1,d=f[0];c-1>h;++h){var n=f[h];"+"==n&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=n||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=n}for(var h=0;c>h;++h){var n=f[h];if(","==n)f[h]="N";else if("%"==n){for(var g=h+1;c>g&&"%"==f[g];++g);for(var v=h&&"!"==f[h-1]||c>g&&"1"==f[g]?"1":"N",m=h;g>m;++m)f[m]=v;h=g-1}}for(var h=0,p=u;c>h;++h){var n=f[h];"L"==p&&"1"==n?f[h]="L":l.test(n)&&(p=n)}for(var h=0;c>h;++h)if(o.test(f[h])){for(var g=h+1;c>g&&o.test(f[g]);++g);for(var y="L"==(h?f[h-1]:u),b="L"==(c>g?f[g]:u),v=y||b?"L":"R",m=h;g>m;++m)f[m]=v;h=g-1}for(var w,x=[],h=0;c>h;)if(s.test(f[h])){var C=h;for(++h;c>h&&s.test(f[h]);++h);x.push(new t(0,C,h))}else{var S=h,L=x.length;for(++h;c>h&&"L"!=f[h];++h);for(var m=S;h>m;)if(a.test(f[m])){m>S&&x.splice(L,0,new t(1,S,m));var k=m;for(++m;h>m&&a.test(f[m]);++m);x.splice(L,0,new t(2,k,m)),S=m}else++m;h>S&&x.splice(L,0,new t(1,S,h))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==ki(x).level&&(w=r.match(/\s+$/))&&(ki(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),x[0].level!=ki(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.0.0",e});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/js/color.picker.js
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function( $ ) {
|
2 |
-
|
3 |
-
// Define color picker
|
4 |
-
$('.wp-color-picker-field').wpColorPicker();
|
5 |
-
});
|
|
|
|
|
|
|
|
|
|
admin/js/mode/css/css.js
CHANGED
@@ -1,766 +1 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineMode("css", function(config, parserConfig) {
|
15 |
-
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
16 |
-
|
17 |
-
var indentUnit = config.indentUnit,
|
18 |
-
tokenHooks = parserConfig.tokenHooks,
|
19 |
-
documentTypes = parserConfig.documentTypes || {},
|
20 |
-
mediaTypes = parserConfig.mediaTypes || {},
|
21 |
-
mediaFeatures = parserConfig.mediaFeatures || {},
|
22 |
-
propertyKeywords = parserConfig.propertyKeywords || {},
|
23 |
-
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
24 |
-
fontProperties = parserConfig.fontProperties || {},
|
25 |
-
counterDescriptors = parserConfig.counterDescriptors || {},
|
26 |
-
colorKeywords = parserConfig.colorKeywords || {},
|
27 |
-
valueKeywords = parserConfig.valueKeywords || {},
|
28 |
-
allowNested = parserConfig.allowNested;
|
29 |
-
|
30 |
-
var type, override;
|
31 |
-
function ret(style, tp) { type = tp; return style; }
|
32 |
-
|
33 |
-
// Tokenizers
|
34 |
-
|
35 |
-
function tokenBase(stream, state) {
|
36 |
-
var ch = stream.next();
|
37 |
-
if (tokenHooks[ch]) {
|
38 |
-
var result = tokenHooks[ch](stream, state);
|
39 |
-
if (result !== false) return result;
|
40 |
-
}
|
41 |
-
if (ch == "@") {
|
42 |
-
stream.eatWhile(/[\w\\\-]/);
|
43 |
-
return ret("def", stream.current());
|
44 |
-
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
|
45 |
-
return ret(null, "compare");
|
46 |
-
} else if (ch == "\"" || ch == "'") {
|
47 |
-
state.tokenize = tokenString(ch);
|
48 |
-
return state.tokenize(stream, state);
|
49 |
-
} else if (ch == "#") {
|
50 |
-
stream.eatWhile(/[\w\\\-]/);
|
51 |
-
return ret("atom", "hash");
|
52 |
-
} else if (ch == "!") {
|
53 |
-
stream.match(/^\s*\w*/);
|
54 |
-
return ret("keyword", "important");
|
55 |
-
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
|
56 |
-
stream.eatWhile(/[\w.%]/);
|
57 |
-
return ret("number", "unit");
|
58 |
-
} else if (ch === "-") {
|
59 |
-
if (/[\d.]/.test(stream.peek())) {
|
60 |
-
stream.eatWhile(/[\w.%]/);
|
61 |
-
return ret("number", "unit");
|
62 |
-
} else if (stream.match(/^-[\w\\\-]+/)) {
|
63 |
-
stream.eatWhile(/[\w\\\-]/);
|
64 |
-
if (stream.match(/^\s*:/, false))
|
65 |
-
return ret("variable-2", "variable-definition");
|
66 |
-
return ret("variable-2", "variable");
|
67 |
-
} else if (stream.match(/^\w+-/)) {
|
68 |
-
return ret("meta", "meta");
|
69 |
-
}
|
70 |
-
} else if (/[,+>*\/]/.test(ch)) {
|
71 |
-
return ret(null, "select-op");
|
72 |
-
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
|
73 |
-
return ret("qualifier", "qualifier");
|
74 |
-
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
75 |
-
return ret(null, ch);
|
76 |
-
} else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) ||
|
77 |
-
(ch == "d" && stream.match("omain(")) ||
|
78 |
-
(ch == "r" && stream.match("egexp("))) {
|
79 |
-
stream.backUp(1);
|
80 |
-
state.tokenize = tokenParenthesized;
|
81 |
-
return ret("property", "word");
|
82 |
-
} else if (/[\w\\\-]/.test(ch)) {
|
83 |
-
stream.eatWhile(/[\w\\\-]/);
|
84 |
-
return ret("property", "word");
|
85 |
-
} else {
|
86 |
-
return ret(null, null);
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
function tokenString(quote) {
|
91 |
-
return function(stream, state) {
|
92 |
-
var escaped = false, ch;
|
93 |
-
while ((ch = stream.next()) != null) {
|
94 |
-
if (ch == quote && !escaped) {
|
95 |
-
if (quote == ")") stream.backUp(1);
|
96 |
-
break;
|
97 |
-
}
|
98 |
-
escaped = !escaped && ch == "\\";
|
99 |
-
}
|
100 |
-
if (ch == quote || !escaped && quote != ")") state.tokenize = null;
|
101 |
-
return ret("string", "string");
|
102 |
-
};
|
103 |
-
}
|
104 |
-
|
105 |
-
function tokenParenthesized(stream, state) {
|
106 |
-
stream.next(); // Must be '('
|
107 |
-
if (!stream.match(/\s*[\"\')]/, false))
|
108 |
-
state.tokenize = tokenString(")");
|
109 |
-
else
|
110 |
-
state.tokenize = null;
|
111 |
-
return ret(null, "(");
|
112 |
-
}
|
113 |
-
|
114 |
-
// Context management
|
115 |
-
|
116 |
-
function Context(type, indent, prev) {
|
117 |
-
this.type = type;
|
118 |
-
this.indent = indent;
|
119 |
-
this.prev = prev;
|
120 |
-
}
|
121 |
-
|
122 |
-
function pushContext(state, stream, type) {
|
123 |
-
state.context = new Context(type, stream.indentation() + indentUnit, state.context);
|
124 |
-
return type;
|
125 |
-
}
|
126 |
-
|
127 |
-
function popContext(state) {
|
128 |
-
state.context = state.context.prev;
|
129 |
-
return state.context.type;
|
130 |
-
}
|
131 |
-
|
132 |
-
function pass(type, stream, state) {
|
133 |
-
return states[state.context.type](type, stream, state);
|
134 |
-
}
|
135 |
-
function popAndPass(type, stream, state, n) {
|
136 |
-
for (var i = n || 1; i > 0; i--)
|
137 |
-
state.context = state.context.prev;
|
138 |
-
return pass(type, stream, state);
|
139 |
-
}
|
140 |
-
|
141 |
-
// Parser
|
142 |
-
|
143 |
-
function wordAsValue(stream) {
|
144 |
-
var word = stream.current().toLowerCase();
|
145 |
-
if (valueKeywords.hasOwnProperty(word))
|
146 |
-
override = "atom";
|
147 |
-
else if (colorKeywords.hasOwnProperty(word))
|
148 |
-
override = "keyword";
|
149 |
-
else
|
150 |
-
override = "variable";
|
151 |
-
}
|
152 |
-
|
153 |
-
var states = {};
|
154 |
-
|
155 |
-
states.top = function(type, stream, state) {
|
156 |
-
if (type == "{") {
|
157 |
-
return pushContext(state, stream, "block");
|
158 |
-
} else if (type == "}" && state.context.prev) {
|
159 |
-
return popContext(state);
|
160 |
-
} else if (/@(media|supports|(-moz-)?document)/.test(type)) {
|
161 |
-
return pushContext(state, stream, "atBlock");
|
162 |
-
} else if (/@(font-face|counter-style)/.test(type)) {
|
163 |
-
state.stateArg = type;
|
164 |
-
return "restricted_atBlock_before";
|
165 |
-
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
166 |
-
return "keyframes";
|
167 |
-
} else if (type && type.charAt(0) == "@") {
|
168 |
-
return pushContext(state, stream, "at");
|
169 |
-
} else if (type == "hash") {
|
170 |
-
override = "builtin";
|
171 |
-
} else if (type == "word") {
|
172 |
-
override = "tag";
|
173 |
-
} else if (type == "variable-definition") {
|
174 |
-
return "maybeprop";
|
175 |
-
} else if (type == "interpolation") {
|
176 |
-
return pushContext(state, stream, "interpolation");
|
177 |
-
} else if (type == ":") {
|
178 |
-
return "pseudo";
|
179 |
-
} else if (allowNested && type == "(") {
|
180 |
-
return pushContext(state, stream, "parens");
|
181 |
-
}
|
182 |
-
return state.context.type;
|
183 |
-
};
|
184 |
-
|
185 |
-
states.block = function(type, stream, state) {
|
186 |
-
if (type == "word") {
|
187 |
-
var word = stream.current().toLowerCase();
|
188 |
-
if (propertyKeywords.hasOwnProperty(word)) {
|
189 |
-
override = "property";
|
190 |
-
return "maybeprop";
|
191 |
-
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
|
192 |
-
override = "string-2";
|
193 |
-
return "maybeprop";
|
194 |
-
} else if (allowNested) {
|
195 |
-
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
|
196 |
-
return "block";
|
197 |
-
} else {
|
198 |
-
override += " error";
|
199 |
-
return "maybeprop";
|
200 |
-
}
|
201 |
-
} else if (type == "meta") {
|
202 |
-
return "block";
|
203 |
-
} else if (!allowNested && (type == "hash" || type == "qualifier")) {
|
204 |
-
override = "error";
|
205 |
-
return "block";
|
206 |
-
} else {
|
207 |
-
return states.top(type, stream, state);
|
208 |
-
}
|
209 |
-
};
|
210 |
-
|
211 |
-
states.maybeprop = function(type, stream, state) {
|
212 |
-
if (type == ":") return pushContext(state, stream, "prop");
|
213 |
-
return pass(type, stream, state);
|
214 |
-
};
|
215 |
-
|
216 |
-
states.prop = function(type, stream, state) {
|
217 |
-
if (type == ";") return popContext(state);
|
218 |
-
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
|
219 |
-
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
220 |
-
if (type == "(") return pushContext(state, stream, "parens");
|
221 |
-
|
222 |
-
if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
|
223 |
-
override += " error";
|
224 |
-
} else if (type == "word") {
|
225 |
-
wordAsValue(stream);
|
226 |
-
} else if (type == "interpolation") {
|
227 |
-
return pushContext(state, stream, "interpolation");
|
228 |
-
}
|
229 |
-
return "prop";
|
230 |
-
};
|
231 |
-
|
232 |
-
states.propBlock = function(type, _stream, state) {
|
233 |
-
if (type == "}") return popContext(state);
|
234 |
-
if (type == "word") { override = "property"; return "maybeprop"; }
|
235 |
-
return state.context.type;
|
236 |
-
};
|
237 |
-
|
238 |
-
states.parens = function(type, stream, state) {
|
239 |
-
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
240 |
-
if (type == ")") return popContext(state);
|
241 |
-
if (type == "(") return pushContext(state, stream, "parens");
|
242 |
-
if (type == "word") wordAsValue(stream);
|
243 |
-
return "parens";
|
244 |
-
};
|
245 |
-
|
246 |
-
states.pseudo = function(type, stream, state) {
|
247 |
-
if (type == "word") {
|
248 |
-
override = "variable-3";
|
249 |
-
return state.context.type;
|
250 |
-
}
|
251 |
-
return pass(type, stream, state);
|
252 |
-
};
|
253 |
-
|
254 |
-
states.atBlock = function(type, stream, state) {
|
255 |
-
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
256 |
-
if (type == "}") return popAndPass(type, stream, state);
|
257 |
-
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
258 |
-
|
259 |
-
if (type == "word") {
|
260 |
-
var word = stream.current().toLowerCase();
|
261 |
-
if (word == "only" || word == "not" || word == "and" || word == "or")
|
262 |
-
override = "keyword";
|
263 |
-
else if (documentTypes.hasOwnProperty(word))
|
264 |
-
override = "tag";
|
265 |
-
else if (mediaTypes.hasOwnProperty(word))
|
266 |
-
override = "attribute";
|
267 |
-
else if (mediaFeatures.hasOwnProperty(word))
|
268 |
-
override = "property";
|
269 |
-
else if (propertyKeywords.hasOwnProperty(word))
|
270 |
-
override = "property";
|
271 |
-
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
272 |
-
override = "string-2";
|
273 |
-
else if (valueKeywords.hasOwnProperty(word))
|
274 |
-
override = "atom";
|
275 |
-
else
|
276 |
-
override = "error";
|
277 |
-
}
|
278 |
-
return state.context.type;
|
279 |
-
};
|
280 |
-
|
281 |
-
states.atBlock_parens = function(type, stream, state) {
|
282 |
-
if (type == ")") return popContext(state);
|
283 |
-
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
284 |
-
return states.atBlock(type, stream, state);
|
285 |
-
};
|
286 |
-
|
287 |
-
states.restricted_atBlock_before = function(type, stream, state) {
|
288 |
-
if (type == "{")
|
289 |
-
return pushContext(state, stream, "restricted_atBlock");
|
290 |
-
if (type == "word" && state.stateArg == "@counter-style") {
|
291 |
-
override = "variable";
|
292 |
-
return "restricted_atBlock_before";
|
293 |
-
}
|
294 |
-
return pass(type, stream, state);
|
295 |
-
};
|
296 |
-
|
297 |
-
states.restricted_atBlock = function(type, stream, state) {
|
298 |
-
if (type == "}") {
|
299 |
-
state.stateArg = null;
|
300 |
-
return popContext(state);
|
301 |
-
}
|
302 |
-
if (type == "word") {
|
303 |
-
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
|
304 |
-
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
|
305 |
-
override = "error";
|
306 |
-
else
|
307 |
-
override = "property";
|
308 |
-
return "maybeprop";
|
309 |
-
}
|
310 |
-
return "restricted_atBlock";
|
311 |
-
};
|
312 |
-
|
313 |
-
states.keyframes = function(type, stream, state) {
|
314 |
-
if (type == "word") { override = "variable"; return "keyframes"; }
|
315 |
-
if (type == "{") return pushContext(state, stream, "top");
|
316 |
-
return pass(type, stream, state);
|
317 |
-
};
|
318 |
-
|
319 |
-
states.at = function(type, stream, state) {
|
320 |
-
if (type == ";") return popContext(state);
|
321 |
-
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
322 |
-
if (type == "word") override = "tag";
|
323 |
-
else if (type == "hash") override = "builtin";
|
324 |
-
return "at";
|
325 |
-
};
|
326 |
-
|
327 |
-
states.interpolation = function(type, stream, state) {
|
328 |
-
if (type == "}") return popContext(state);
|
329 |
-
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
330 |
-
if (type != "variable") override = "error";
|
331 |
-
return "interpolation";
|
332 |
-
};
|
333 |
-
|
334 |
-
return {
|
335 |
-
startState: function(base) {
|
336 |
-
return {tokenize: null,
|
337 |
-
state: "top",
|
338 |
-
stateArg: null,
|
339 |
-
context: new Context("top", base || 0, null)};
|
340 |
-
},
|
341 |
-
|
342 |
-
token: function(stream, state) {
|
343 |
-
if (!state.tokenize && stream.eatSpace()) return null;
|
344 |
-
var style = (state.tokenize || tokenBase)(stream, state);
|
345 |
-
if (style && typeof style == "object") {
|
346 |
-
type = style[1];
|
347 |
-
style = style[0];
|
348 |
-
}
|
349 |
-
override = style;
|
350 |
-
state.state = states[state.state](type, stream, state);
|
351 |
-
return override;
|
352 |
-
},
|
353 |
-
|
354 |
-
indent: function(state, textAfter) {
|
355 |
-
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
356 |
-
var indent = cx.indent;
|
357 |
-
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
358 |
-
if (cx.prev &&
|
359 |
-
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock") ||
|
360 |
-
ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
361 |
-
ch == "{" && (cx.type == "at" || cx.type == "atBlock"))) {
|
362 |
-
indent = cx.indent - indentUnit;
|
363 |
-
cx = cx.prev;
|
364 |
-
}
|
365 |
-
return indent;
|
366 |
-
},
|
367 |
-
|
368 |
-
electricChars: "}",
|
369 |
-
blockCommentStart: "/*",
|
370 |
-
blockCommentEnd: "*/",
|
371 |
-
fold: "brace"
|
372 |
-
};
|
373 |
-
});
|
374 |
-
|
375 |
-
function keySet(array) {
|
376 |
-
var keys = {};
|
377 |
-
for (var i = 0; i < array.length; ++i) {
|
378 |
-
keys[array[i]] = true;
|
379 |
-
}
|
380 |
-
return keys;
|
381 |
-
}
|
382 |
-
|
383 |
-
var documentTypes_ = [
|
384 |
-
"domain", "regexp", "url", "url-prefix"
|
385 |
-
], documentTypes = keySet(documentTypes_);
|
386 |
-
|
387 |
-
var mediaTypes_ = [
|
388 |
-
"all", "aural", "braille", "handheld", "print", "projection", "screen",
|
389 |
-
"tty", "tv", "embossed"
|
390 |
-
], mediaTypes = keySet(mediaTypes_);
|
391 |
-
|
392 |
-
var mediaFeatures_ = [
|
393 |
-
"width", "min-width", "max-width", "height", "min-height", "max-height",
|
394 |
-
"device-width", "min-device-width", "max-device-width", "device-height",
|
395 |
-
"min-device-height", "max-device-height", "aspect-ratio",
|
396 |
-
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
|
397 |
-
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
398 |
-
"max-color", "color-index", "min-color-index", "max-color-index",
|
399 |
-
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
400 |
-
"min-resolution", "max-resolution", "scan", "grid"
|
401 |
-
], mediaFeatures = keySet(mediaFeatures_);
|
402 |
-
|
403 |
-
var propertyKeywords_ = [
|
404 |
-
"align-content", "align-items", "align-self", "alignment-adjust",
|
405 |
-
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
406 |
-
"animation-direction", "animation-duration", "animation-fill-mode",
|
407 |
-
"animation-iteration-count", "animation-name", "animation-play-state",
|
408 |
-
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
409 |
-
"background", "background-attachment", "background-clip", "background-color",
|
410 |
-
"background-image", "background-origin", "background-position",
|
411 |
-
"background-repeat", "background-size", "baseline-shift", "binding",
|
412 |
-
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
413 |
-
"bookmark-target", "border", "border-bottom", "border-bottom-color",
|
414 |
-
"border-bottom-left-radius", "border-bottom-right-radius",
|
415 |
-
"border-bottom-style", "border-bottom-width", "border-collapse",
|
416 |
-
"border-color", "border-image", "border-image-outset",
|
417 |
-
"border-image-repeat", "border-image-slice", "border-image-source",
|
418 |
-
"border-image-width", "border-left", "border-left-color",
|
419 |
-
"border-left-style", "border-left-width", "border-radius", "border-right",
|
420 |
-
"border-right-color", "border-right-style", "border-right-width",
|
421 |
-
"border-spacing", "border-style", "border-top", "border-top-color",
|
422 |
-
"border-top-left-radius", "border-top-right-radius", "border-top-style",
|
423 |
-
"border-top-width", "border-width", "bottom", "box-decoration-break",
|
424 |
-
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
|
425 |
-
"caption-side", "clear", "clip", "color", "color-profile", "column-count",
|
426 |
-
"column-fill", "column-gap", "column-rule", "column-rule-color",
|
427 |
-
"column-rule-style", "column-rule-width", "column-span", "column-width",
|
428 |
-
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
|
429 |
-
"cue-after", "cue-before", "cursor", "direction", "display",
|
430 |
-
"dominant-baseline", "drop-initial-after-adjust",
|
431 |
-
"drop-initial-after-align", "drop-initial-before-adjust",
|
432 |
-
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
|
433 |
-
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
|
434 |
-
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
|
435 |
-
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
|
436 |
-
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
|
437 |
-
"font-stretch", "font-style", "font-synthesis", "font-variant",
|
438 |
-
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
439 |
-
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
440 |
-
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
441 |
-
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
|
442 |
-
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
|
443 |
-
"grid-template", "grid-template-areas", "grid-template-columns",
|
444 |
-
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
445 |
-
"icon", "image-orientation", "image-rendering", "image-resolution",
|
446 |
-
"inline-box-align", "justify-content", "left", "letter-spacing",
|
447 |
-
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
448 |
-
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
449 |
-
"list-style-image", "list-style-position", "list-style-type", "margin",
|
450 |
-
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
451 |
-
"marker-offset", "marks", "marquee-direction", "marquee-loop",
|
452 |
-
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
453 |
-
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
|
454 |
-
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
455 |
-
"opacity", "order", "orphans", "outline",
|
456 |
-
"outline-color", "outline-offset", "outline-style", "outline-width",
|
457 |
-
"overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
|
458 |
-
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
|
459 |
-
"page", "page-break-after", "page-break-before", "page-break-inside",
|
460 |
-
"page-policy", "pause", "pause-after", "pause-before", "perspective",
|
461 |
-
"perspective-origin", "pitch", "pitch-range", "play-during", "position",
|
462 |
-
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
|
463 |
-
"region-break-before", "region-break-inside", "region-fragment",
|
464 |
-
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
|
465 |
-
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
|
466 |
-
"ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
|
467 |
-
"shape-outside", "size", "speak", "speak-as", "speak-header",
|
468 |
-
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
|
469 |
-
"tab-size", "table-layout", "target", "target-name", "target-new",
|
470 |
-
"target-position", "text-align", "text-align-last", "text-decoration",
|
471 |
-
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
|
472 |
-
"text-decoration-style", "text-emphasis", "text-emphasis-color",
|
473 |
-
"text-emphasis-position", "text-emphasis-style", "text-height",
|
474 |
-
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
|
475 |
-
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
|
476 |
-
"text-wrap", "top", "transform", "transform-origin", "transform-style",
|
477 |
-
"transition", "transition-delay", "transition-duration",
|
478 |
-
"transition-property", "transition-timing-function", "unicode-bidi",
|
479 |
-
"vertical-align", "visibility", "voice-balance", "voice-duration",
|
480 |
-
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
|
481 |
-
"voice-volume", "volume", "white-space", "widows", "width", "word-break",
|
482 |
-
"word-spacing", "word-wrap", "z-index",
|
483 |
-
// SVG-specific
|
484 |
-
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
|
485 |
-
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
|
486 |
-
"color-interpolation", "color-interpolation-filters",
|
487 |
-
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
|
488 |
-
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
|
489 |
-
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
|
490 |
-
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
|
491 |
-
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
|
492 |
-
"glyph-orientation-vertical", "text-anchor", "writing-mode"
|
493 |
-
], propertyKeywords = keySet(propertyKeywords_);
|
494 |
-
|
495 |
-
var nonStandardPropertyKeywords_ = [
|
496 |
-
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
|
497 |
-
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
|
498 |
-
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
|
499 |
-
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
|
500 |
-
"searchfield-results-decoration", "zoom"
|
501 |
-
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
502 |
-
|
503 |
-
var fontProperties_ = [
|
504 |
-
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
505 |
-
"font-stretch", "font-weight", "font-style"
|
506 |
-
], fontProperties = keySet(fontProperties_);
|
507 |
-
|
508 |
-
var counterDescriptors_ = [
|
509 |
-
"additive-symbols", "fallback", "negative", "pad", "prefix", "range",
|
510 |
-
"speak-as", "suffix", "symbols", "system"
|
511 |
-
], counterDescriptors = keySet(counterDescriptors_);
|
512 |
-
|
513 |
-
var colorKeywords_ = [
|
514 |
-
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
515 |
-
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
516 |
-
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
|
517 |
-
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
|
518 |
-
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
|
519 |
-
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
520 |
-
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
|
521 |
-
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
|
522 |
-
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
523 |
-
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
|
524 |
-
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
|
525 |
-
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
|
526 |
-
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
|
527 |
-
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
|
528 |
-
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
|
529 |
-
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
|
530 |
-
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
531 |
-
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
532 |
-
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
|
533 |
-
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
|
534 |
-
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
535 |
-
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
|
536 |
-
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
|
537 |
-
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
|
538 |
-
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
|
539 |
-
"whitesmoke", "yellow", "yellowgreen"
|
540 |
-
], colorKeywords = keySet(colorKeywords_);
|
541 |
-
|
542 |
-
var valueKeywords_ = [
|
543 |
-
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
|
544 |
-
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
|
545 |
-
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
546 |
-
"arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page",
|
547 |
-
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
|
548 |
-
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
549 |
-
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
550 |
-
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
|
551 |
-
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
552 |
-
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
553 |
-
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
554 |
-
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
|
555 |
-
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
556 |
-
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
|
557 |
-
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
558 |
-
"destination-in", "destination-out", "destination-over", "devanagari",
|
559 |
-
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
|
560 |
-
"dot-dash", "dot-dot-dash",
|
561 |
-
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
|
562 |
-
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
|
563 |
-
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
|
564 |
-
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
|
565 |
-
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
|
566 |
-
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
|
567 |
-
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
568 |
-
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
569 |
-
"ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
|
570 |
-
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "footnotes",
|
571 |
-
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
572 |
-
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
|
573 |
-
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
574 |
-
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
|
575 |
-
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
576 |
-
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
577 |
-
"inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
|
578 |
-
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
|
579 |
-
"katakana", "katakana-iroha", "keep-all", "khmer",
|
580 |
-
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
|
581 |
-
"landscape", "lao", "large", "larger", "left", "level", "lighter",
|
582 |
-
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
|
583 |
-
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
|
584 |
-
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
|
585 |
-
"lower-roman", "lowercase", "ltr", "malayalam", "match", "matrix", "matrix3d",
|
586 |
-
"media-controls-background", "media-current-time-display",
|
587 |
-
"media-fullscreen-button", "media-mute-button", "media-play-button",
|
588 |
-
"media-return-to-realtime-button", "media-rewind-button",
|
589 |
-
"media-seek-back-button", "media-seek-forward-button", "media-slider",
|
590 |
-
"media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
|
591 |
-
"media-volume-slider-container", "media-volume-sliderthumb", "medium",
|
592 |
-
"menu", "menulist", "menulist-button", "menulist-text",
|
593 |
-
"menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
|
594 |
-
"mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
|
595 |
-
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
|
596 |
-
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
|
597 |
-
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
|
598 |
-
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
|
599 |
-
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
|
600 |
-
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
|
601 |
-
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
|
602 |
-
"progress", "push-button", "radial-gradient", "radio", "read-only",
|
603 |
-
"read-write", "read-write-plaintext-only", "rectangle", "region",
|
604 |
-
"relative", "repeat", "repeating-linear-gradient",
|
605 |
-
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
606 |
-
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
607 |
-
"rotateZ", "round", "row-resize", "rtl", "run-in", "running",
|
608 |
-
"s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
|
609 |
-
"scroll", "scrollbar", "se-resize", "searchfield",
|
610 |
-
"searchfield-cancel-button", "searchfield-decoration",
|
611 |
-
"searchfield-results-button", "searchfield-results-decoration",
|
612 |
-
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
613 |
-
"simp-chinese-formal", "simp-chinese-informal", "single",
|
614 |
-
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
615 |
-
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
616 |
-
"small", "small-caps", "small-caption", "smaller", "solid", "somali",
|
617 |
-
"source-atop", "source-in", "source-out", "source-over", "space", "spell-out", "square",
|
618 |
-
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
619 |
-
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
620 |
-
"table-caption", "table-cell", "table-column", "table-column-group",
|
621 |
-
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
622 |
-
"tamil",
|
623 |
-
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
|
624 |
-
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
|
625 |
-
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
|
626 |
-
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
|
627 |
-
"trad-chinese-formal", "trad-chinese-informal",
|
628 |
-
"translate", "translate3d", "translateX", "translateY", "translateZ",
|
629 |
-
"transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
|
630 |
-
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
631 |
-
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
632 |
-
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
633 |
-
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
634 |
-
"window", "windowframe", "windowtext", "words", "x-large", "x-small", "xor",
|
635 |
-
"xx-large", "xx-small"
|
636 |
-
], valueKeywords = keySet(valueKeywords_);
|
637 |
-
|
638 |
-
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(propertyKeywords_)
|
639 |
-
.concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
|
640 |
-
CodeMirror.registerHelper("hintWords", "css", allWords);
|
641 |
-
|
642 |
-
function tokenCComment(stream, state) {
|
643 |
-
var maybeEnd = false, ch;
|
644 |
-
while ((ch = stream.next()) != null) {
|
645 |
-
if (maybeEnd && ch == "/") {
|
646 |
-
state.tokenize = null;
|
647 |
-
break;
|
648 |
-
}
|
649 |
-
maybeEnd = (ch == "*");
|
650 |
-
}
|
651 |
-
return ["comment", "comment"];
|
652 |
-
}
|
653 |
-
|
654 |
-
function tokenSGMLComment(stream, state) {
|
655 |
-
if (stream.skipTo("-->")) {
|
656 |
-
stream.match("-->");
|
657 |
-
state.tokenize = null;
|
658 |
-
} else {
|
659 |
-
stream.skipToEnd();
|
660 |
-
}
|
661 |
-
return ["comment", "comment"];
|
662 |
-
}
|
663 |
-
|
664 |
-
CodeMirror.defineMIME("text/css", {
|
665 |
-
documentTypes: documentTypes,
|
666 |
-
mediaTypes: mediaTypes,
|
667 |
-
mediaFeatures: mediaFeatures,
|
668 |
-
propertyKeywords: propertyKeywords,
|
669 |
-
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
670 |
-
fontProperties: fontProperties,
|
671 |
-
counterDescriptors: counterDescriptors,
|
672 |
-
colorKeywords: colorKeywords,
|
673 |
-
valueKeywords: valueKeywords,
|
674 |
-
tokenHooks: {
|
675 |
-
"<": function(stream, state) {
|
676 |
-
if (!stream.match("!--")) return false;
|
677 |
-
state.tokenize = tokenSGMLComment;
|
678 |
-
return tokenSGMLComment(stream, state);
|
679 |
-
},
|
680 |
-
"/": function(stream, state) {
|
681 |
-
if (!stream.eat("*")) return false;
|
682 |
-
state.tokenize = tokenCComment;
|
683 |
-
return tokenCComment(stream, state);
|
684 |
-
}
|
685 |
-
},
|
686 |
-
name: "css"
|
687 |
-
});
|
688 |
-
|
689 |
-
CodeMirror.defineMIME("text/x-scss", {
|
690 |
-
mediaTypes: mediaTypes,
|
691 |
-
mediaFeatures: mediaFeatures,
|
692 |
-
propertyKeywords: propertyKeywords,
|
693 |
-
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
694 |
-
colorKeywords: colorKeywords,
|
695 |
-
valueKeywords: valueKeywords,
|
696 |
-
fontProperties: fontProperties,
|
697 |
-
allowNested: true,
|
698 |
-
tokenHooks: {
|
699 |
-
"/": function(stream, state) {
|
700 |
-
if (stream.eat("/")) {
|
701 |
-
stream.skipToEnd();
|
702 |
-
return ["comment", "comment"];
|
703 |
-
} else if (stream.eat("*")) {
|
704 |
-
state.tokenize = tokenCComment;
|
705 |
-
return tokenCComment(stream, state);
|
706 |
-
} else {
|
707 |
-
return ["operator", "operator"];
|
708 |
-
}
|
709 |
-
},
|
710 |
-
":": function(stream) {
|
711 |
-
if (stream.match(/\s*\{/))
|
712 |
-
return [null, "{"];
|
713 |
-
return false;
|
714 |
-
},
|
715 |
-
"$": function(stream) {
|
716 |
-
stream.match(/^[\w-]+/);
|
717 |
-
if (stream.match(/^\s*:/, false))
|
718 |
-
return ["variable-2", "variable-definition"];
|
719 |
-
return ["variable-2", "variable"];
|
720 |
-
},
|
721 |
-
"#": function(stream) {
|
722 |
-
if (!stream.eat("{")) return false;
|
723 |
-
return [null, "interpolation"];
|
724 |
-
}
|
725 |
-
},
|
726 |
-
name: "css",
|
727 |
-
helperType: "scss"
|
728 |
-
});
|
729 |
-
|
730 |
-
CodeMirror.defineMIME("text/x-less", {
|
731 |
-
mediaTypes: mediaTypes,
|
732 |
-
mediaFeatures: mediaFeatures,
|
733 |
-
propertyKeywords: propertyKeywords,
|
734 |
-
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
735 |
-
colorKeywords: colorKeywords,
|
736 |
-
valueKeywords: valueKeywords,
|
737 |
-
fontProperties: fontProperties,
|
738 |
-
allowNested: true,
|
739 |
-
tokenHooks: {
|
740 |
-
"/": function(stream, state) {
|
741 |
-
if (stream.eat("/")) {
|
742 |
-
stream.skipToEnd();
|
743 |
-
return ["comment", "comment"];
|
744 |
-
} else if (stream.eat("*")) {
|
745 |
-
state.tokenize = tokenCComment;
|
746 |
-
return tokenCComment(stream, state);
|
747 |
-
} else {
|
748 |
-
return ["operator", "operator"];
|
749 |
-
}
|
750 |
-
},
|
751 |
-
"@": function(stream) {
|
752 |
-
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
|
753 |
-
stream.eatWhile(/[\w\\\-]/);
|
754 |
-
if (stream.match(/^\s*:/, false))
|
755 |
-
return ["variable-2", "variable-definition"];
|
756 |
-
return ["variable-2", "variable"];
|
757 |
-
},
|
758 |
-
"&": function() {
|
759 |
-
return ["atom", "atom"];
|
760 |
-
}
|
761 |
-
},
|
762 |
-
name: "css",
|
763 |
-
helperType: "less"
|
764 |
-
});
|
765 |
-
|
766 |
-
});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=!0;return t}function r(e,t){for(var r,o=!1;null!=(r=e.next());){if(o&&"/"==r){t.tokenize=null;break}o="*"==r}return["comment","comment"]}function o(e,t){return e.skipTo("-->")?(e.match("-->"),t.tokenize=null):e.skipToEnd(),["comment","comment"]}e.defineMode("css",function(t,r){function o(e,t){return m=t,e}function a(e,t){var r=e.next();if(b[r]){var a=b[r](e,t);if(a!==!1)return a}return"@"==r?(e.eatWhile(/[\w\\\-]/),o("def",e.current())):"="==r||("~"==r||"|"==r)&&e.eat("=")?o(null,"compare"):'"'==r||"'"==r?(t.tokenize=i(r),t.tokenize(e,t)):"#"==r?(e.eatWhile(/[\w\\\-]/),o("atom","hash")):"!"==r?(e.match(/^\s*\w*/),o("keyword","important")):/\d/.test(r)||"."==r&&e.eat(/\d/)?(e.eatWhile(/[\w.%]/),o("number","unit")):"-"!==r?/[,+>*\/]/.test(r)?o(null,"select-op"):"."==r&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?o("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(r)?o(null,r):"u"==r&&e.match(/rl(-prefix)?\(/)||"d"==r&&e.match("omain(")||"r"==r&&e.match("egexp(")?(e.backUp(1),t.tokenize=n,o("property","word")):/[\w\\\-]/.test(r)?(e.eatWhile(/[\w\\\-]/),o("property","word")):o(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),o("number","unit")):e.match(/^-[\w\\\-]+/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?o("variable-2","variable-definition"):o("variable-2","variable")):e.match(/^\w+-/)?o("meta","meta"):void 0}function i(e){return function(t,r){for(var a,i=!1;null!=(a=t.next());){if(a==e&&!i){")"==e&&t.backUp(1);break}i=!i&&"\\"==a}return(a==e||!i&&")"!=e)&&(r.tokenize=null),o("string","string")}}function n(e,t){return e.next(),e.match(/\s*[\"\')]/,!1)?t.tokenize=null:t.tokenize=i(")"),o(null,"(")}function l(e,t,r){this.type=e,this.indent=t,this.prev=r}function s(e,t,r){return e.context=new l(r,t.indentation()+g,e.context),r}function c(e){return e.context=e.context.prev,e.context.type}function d(e,t,r){return K[r.context.type](e,t,r)}function u(e,t,r,o){for(var a=o||1;a>0;a--)r.context=r.context.prev;return d(e,t,r)}function p(e){var t=e.current().toLowerCase();h=j.hasOwnProperty(t)?"atom":q.hasOwnProperty(t)?"keyword":"variable"}r.propertyKeywords||(r=e.resolveMode("text/css"));var m,h,g=t.indentUnit,b=r.tokenHooks,f=r.documentTypes||{},k=r.mediaTypes||{},y=r.mediaFeatures||{},w=r.propertyKeywords||{},v=r.nonStandardPropertyKeywords||{},x=r.fontProperties||{},z=r.counterDescriptors||{},q=r.colorKeywords||{},j=r.valueKeywords||{},P=r.allowNested,K={};return K.top=function(e,t,r){if("{"==e)return s(r,t,"block");if("}"==e&&r.context.prev)return c(r);if(/@(media|supports|(-moz-)?document)/.test(e))return s(r,t,"atBlock");if(/@(font-face|counter-style)/.test(e))return r.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return s(r,t,"at");if("hash"==e)h="builtin";else if("word"==e)h="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return s(r,t,"interpolation");if(":"==e)return"pseudo";if(P&&"("==e)return s(r,t,"parens")}return r.context.type},K.block=function(e,t,r){if("word"==e){var o=t.current().toLowerCase();return w.hasOwnProperty(o)?(h="property","maybeprop"):v.hasOwnProperty(o)?(h="string-2","maybeprop"):P?(h=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(h+=" error","maybeprop")}return"meta"==e?"block":P||"hash"!=e&&"qualifier"!=e?K.top(e,t,r):(h="error","block")},K.maybeprop=function(e,t,r){return":"==e?s(r,t,"prop"):d(e,t,r)},K.prop=function(e,t,r){if(";"==e)return c(r);if("{"==e&&P)return s(r,t,"propBlock");if("}"==e||"{"==e)return u(e,t,r);if("("==e)return s(r,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t.current())){if("word"==e)p(t);else if("interpolation"==e)return s(r,t,"interpolation")}else h+=" error";return"prop"},K.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(h="property","maybeprop"):r.context.type},K.parens=function(e,t,r){return"{"==e||"}"==e?u(e,t,r):")"==e?c(r):"("==e?s(r,t,"parens"):("word"==e&&p(t),"parens")},K.pseudo=function(e,t,r){return"word"==e?(h="variable-3",r.context.type):d(e,t,r)},K.atBlock=function(e,t,r){if("("==e)return s(r,t,"atBlock_parens");if("}"==e)return u(e,t,r);if("{"==e)return c(r)&&s(r,t,P?"block":"top");if("word"==e){var o=t.current().toLowerCase();h="only"==o||"not"==o||"and"==o||"or"==o?"keyword":f.hasOwnProperty(o)?"tag":k.hasOwnProperty(o)?"attribute":y.hasOwnProperty(o)?"property":w.hasOwnProperty(o)?"property":v.hasOwnProperty(o)?"string-2":j.hasOwnProperty(o)?"atom":"error"}return r.context.type},K.atBlock_parens=function(e,t,r){return")"==e?c(r):"{"==e||"}"==e?u(e,t,r,2):K.atBlock(e,t,r)},K.restricted_atBlock_before=function(e,t,r){return"{"==e?s(r,t,"restricted_atBlock"):"word"==e&&"@counter-style"==r.stateArg?(h="variable","restricted_atBlock_before"):d(e,t,r)},K.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(h="@font-face"==r.stateArg&&!x.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==r.stateArg&&!z.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},K.keyframes=function(e,t,r){return"word"==e?(h="variable","keyframes"):"{"==e?s(r,t,"top"):d(e,t,r)},K.at=function(e,t,r){return";"==e?c(r):"{"==e||"}"==e?u(e,t,r):("word"==e?h="tag":"hash"==e&&(h="builtin"),"at")},K.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?u(e,t,r):("variable"!=e&&(h="error"),"interpolation")},{startState:function(e){return{tokenize:null,state:"top",stateArg:null,context:new l("top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var r=(t.tokenize||a)(e,t);return r&&"object"==typeof r&&(m=r[1],r=r[0]),h=r,t.state=K[t.state](m,e,t),h},indent:function(e,t){var r=e.context,o=t&&t.charAt(0),a=r.indent;return"prop"!=r.type||"}"!=o&&")"!=o||(r=r.prev),!r.prev||("}"!=o||"block"!=r.type&&"top"!=r.type&&"interpolation"!=r.type&&"restricted_atBlock"!=r.type)&&(")"!=o||"parens"!=r.type&&"atBlock_parens"!=r.type)&&("{"!=o||"at"!=r.type&&"atBlock"!=r.type)||(a=r.indent-g,r=r.prev),a},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var a=["domain","regexp","url","url-prefix"],i=t(a),n=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],l=t(n),s=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"],c=t(s),d=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],u=t(d),p=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],m=t(p),h=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],g=t(h),b=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],f=t(b),k=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],y=t(k),w=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small"],v=t(w),x=a.concat(n).concat(s).concat(d).concat(p).concat(k).concat(w);e.registerHelper("hintWords","css",x),e.defineMIME("text/css",{documentTypes:i,mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,fontProperties:g,counterDescriptors:f,colorKeywords:y,valueKeywords:v,tokenHooks:{"<":function(e,t){return e.match("!--")?(t.tokenize=o,o(e,t)):!1},"/":function(e,t){return e.eat("*")?(t.tokenize=r,r(e,t)):!1}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,colorKeywords:y,valueKeywords:v,fontProperties:g,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},":":function(e){return e.match(/\s*\{/)?[null,"{"]:!1},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return e.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,colorKeywords:y,valueKeywords:v,fontProperties:g,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},"@":function(e){return e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/js/quick.edit.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
( function( $ ) {
|
2 |
-
|
3 |
// we create a copy of the WP inline edit post function
|
4 |
var $wp_inline_edit = inlineEditPost.edit;
|
5 |
|
@@ -66,5 +65,6 @@
|
|
66 |
var url = window.location.href;
|
67 |
$( ".cf7-quick-edit" ).load( url + " .cf7-quick-edit >" );
|
68 |
} );
|
|
|
69 |
|
70 |
} )( jQuery );
|
1 |
( function( $ ) {
|
|
|
2 |
// we create a copy of the WP inline edit post function
|
3 |
var $wp_inline_edit = inlineEditPost.edit;
|
4 |
|
65 |
var url = window.location.href;
|
66 |
$( ".cf7-quick-edit" ).load( url + " .cf7-quick-edit >" );
|
67 |
} );
|
68 |
+
|
69 |
|
70 |
} )( jQuery );
|
cf7-style-match-old.php
ADDED
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function get_new_styler_data($a){
|
3 |
+
$t = array();
|
4 |
+
$u = "px";
|
5 |
+
foreach ( $a as $k => $d ) {
|
6 |
+
if( $d != 'Default' && $d != ''){
|
7 |
+
if($k=="form-padding" || $k=="form-margin" ||$k=="input-margin" ||$k=="input-padding" ){
|
8 |
+
$d = str_replace("px", "", $d);
|
9 |
+
$da = explode(" ", $d);
|
10 |
+
$nr = count($da);
|
11 |
+
$tfn = "";
|
12 |
+
}
|
13 |
+
switch($k){
|
14 |
+
case 'form-background' :
|
15 |
+
$t['form_background-color'] = $d;
|
16 |
+
break;
|
17 |
+
case 'form-width' : $t['form_width'] = $d;
|
18 |
+
$t['form_width_unit'] = $u;
|
19 |
+
break;
|
20 |
+
case 'form-border-width' :
|
21 |
+
$t['form_border-top-width'] = $d;
|
22 |
+
$t['form_border-top-width_unit'] = $u;
|
23 |
+
$t['form_border-right-width'] = $d;
|
24 |
+
$t['form_border-right-width_unit'] = $u;
|
25 |
+
$t['form_border-bottom-width'] = $d;
|
26 |
+
$t['form_border-bottom-width_unit'] = $u;
|
27 |
+
$t['form_border-left-width'] = $d;
|
28 |
+
$t['form_border-left-width_unit'] = $u;
|
29 |
+
break;
|
30 |
+
case 'form-border-style' :
|
31 |
+
$t['form_border-style'] = $d;
|
32 |
+
break;
|
33 |
+
case 'form-padding' :
|
34 |
+
$tfn = "form_padding";
|
35 |
+
break;
|
36 |
+
case 'form-margin' :
|
37 |
+
$tfn = "form_margin";
|
38 |
+
break;
|
39 |
+
case 'form-border-color' :
|
40 |
+
$t['form_border-color'] = $d;
|
41 |
+
break;
|
42 |
+
case 'form-border-radius' :
|
43 |
+
$t['form_border-top-left-radius'] = $d;
|
44 |
+
$t['form_border-top-left-radius_unit'] = $u;
|
45 |
+
$t['form_border-top-right-radius'] = $d;
|
46 |
+
$t['form_border-top-right-radius_unit'] = $u;
|
47 |
+
$t['form_border-bottom-left-radius'] = $d;
|
48 |
+
$t['form_border-bottom-left-radius_unit'] = $u;
|
49 |
+
$t['form_border-bottom-right-radius'] = $d;
|
50 |
+
$t['form_border-bottom-right-radius_unit'] = $u;
|
51 |
+
break;
|
52 |
+
case 'form-line-height' :
|
53 |
+
$t['form_line-height']= $d;
|
54 |
+
$t['form_line-height_unit']= $u;
|
55 |
+
break;
|
56 |
+
case 'input-background' :
|
57 |
+
$t['input_background-color'] = $d;
|
58 |
+
break;
|
59 |
+
case 'input-color' :
|
60 |
+
$t['input_color'] = $d;
|
61 |
+
break;
|
62 |
+
case 'input-border-color' :
|
63 |
+
$t['input_border-color'] = $d;
|
64 |
+
break;
|
65 |
+
case 'input-font-size' :
|
66 |
+
$t['input_font-size'] = $d;
|
67 |
+
$t['input_font-size_unit'] = $u;
|
68 |
+
break;
|
69 |
+
case 'input-line-height' :
|
70 |
+
$t['input_line-height'] = $d;
|
71 |
+
$t['input_line-height_unit'] = $u;
|
72 |
+
break;
|
73 |
+
case 'input-border-width' :
|
74 |
+
$t['input_border-top-width'] = $d;
|
75 |
+
$t['input_border-top-width_unit'] = $u;
|
76 |
+
$t['input_border-right-width'] = $d;
|
77 |
+
$t['input_border-right-width_unit'] = $u;
|
78 |
+
$t['input_border-bottom-width'] = $d;
|
79 |
+
$t['input_border-bottom-width_unit'] = $u;
|
80 |
+
$t['input_border-left-width'] = $d;
|
81 |
+
$t['input_border-left-width_unit'] = $u;
|
82 |
+
break;
|
83 |
+
case 'input-border-style' :
|
84 |
+
$t['input_border-style'] = $d;
|
85 |
+
break;
|
86 |
+
case 'input-border-radius' :
|
87 |
+
$t['input_border-top-left-radius'] = $d;
|
88 |
+
$t['input_border-top-left-radius_unit'] = $u;
|
89 |
+
$t['input_border-top-right-radius'] = $d;
|
90 |
+
$t['input_border-top-right-radius_unit'] = $u;
|
91 |
+
$t['input_border-bottom-left-radius'] = $d;
|
92 |
+
$t['input_border-bottom-left-radius_unit'] = $u;
|
93 |
+
$t['input_border-bottom-right-radius'] = $d;
|
94 |
+
$t['input_border-bottom-right-radius_unit'] = $u;
|
95 |
+
break;
|
96 |
+
case 'input-font-style' :
|
97 |
+
$t['input_font-style'] = $d;
|
98 |
+
break;
|
99 |
+
case 'input-font-weight' :
|
100 |
+
$t['input_font-weight'] = $d;
|
101 |
+
break;
|
102 |
+
case 'input-width' : $t['input_width'] = $d;
|
103 |
+
$t['input_width_unit'] = $u;
|
104 |
+
break;
|
105 |
+
case 'input-box-sizing' :
|
106 |
+
$t['input_box-sizing']= $d;
|
107 |
+
break;
|
108 |
+
case 'input-height' :
|
109 |
+
$t['input_height'] = $d;
|
110 |
+
$t['input_height_unit'] = $u;
|
111 |
+
break;
|
112 |
+
case 'input-padding' :
|
113 |
+
$tfn = "input_padding";
|
114 |
+
break;
|
115 |
+
case 'input-margin' :
|
116 |
+
$tfn = "input_margin";
|
117 |
+
break;
|
118 |
+
case 'textarea-background-color' :
|
119 |
+
$t['textarea_background-color'] = $d;
|
120 |
+
break;
|
121 |
+
case 'textarea-height' :
|
122 |
+
$t['textarea_height'] = $d;
|
123 |
+
$t['textarea_height_unit'] = $u;
|
124 |
+
break;
|
125 |
+
case 'textarea-width' :
|
126 |
+
$t['textarea_width'] = $d;
|
127 |
+
$t['textarea_width_unit'] = $u;
|
128 |
+
break;
|
129 |
+
case 'textarea-box-sizing' :
|
130 |
+
$t['textarea_box-sizing'] = $d;
|
131 |
+
break;
|
132 |
+
case 'textarea-border-size' :
|
133 |
+
$t['textarea_border-top-width'] = $d;
|
134 |
+
$t['textarea_border-top-width_unit'] = $u;
|
135 |
+
$t['textarea_border-right-width'] = $d;
|
136 |
+
$t['textarea_border-right-width_unit'] = $u;
|
137 |
+
$t['textarea_border-bottom-width'] = $d;
|
138 |
+
$t['textarea_border-bottom-width_unit'] = $u;
|
139 |
+
$t['textarea_border-left-width'] = $d;
|
140 |
+
$t['textarea_border-left-width_unit'] = $u;
|
141 |
+
break;
|
142 |
+
case 'textarea-border-color' :
|
143 |
+
$t['textarea_border-color']= $d;
|
144 |
+
break;
|
145 |
+
case 'textarea-border-style' :
|
146 |
+
$t['textarea_border-style'] = $d;
|
147 |
+
break;
|
148 |
+
case 'textarea-border-radius' :
|
149 |
+
$t['textarea_border-top-left-radius'] = $d;
|
150 |
+
$t['textarea_border-top-left-radius_unit'] = $u;
|
151 |
+
$t['textarea_border-top-right-radius'] = $d;
|
152 |
+
$t['textarea_border-top-right-radius_unit'] = $u;
|
153 |
+
$t['textarea_border-bottom-left-radius'] = $d;
|
154 |
+
$t['textarea_border-bottom-left-radius_unit'] = $u;
|
155 |
+
$t['textarea_border-bottom-right-radius'] = $d;
|
156 |
+
$t['textarea_border-bottom-right-radius_unit'] = $u;
|
157 |
+
break;
|
158 |
+
case 'textarea-font-size' :
|
159 |
+
$t['textarea_font-size'] = $d;
|
160 |
+
$t['textarea_font-size_unit'] = $u;
|
161 |
+
break;
|
162 |
+
case 'textarea-line-height' :
|
163 |
+
$t['textarea_line-height'] = $d;
|
164 |
+
$t['textarea_line-height_unit'] = $u;
|
165 |
+
break;
|
166 |
+
case 'textarea-font-style' :
|
167 |
+
$t['textarea_font-style'] = $d;
|
168 |
+
break;
|
169 |
+
case 'label-font-style' :
|
170 |
+
$t['label_font-style']= $d;
|
171 |
+
$t['p_font-style']= $d;
|
172 |
+
break;
|
173 |
+
case 'label-font-weight' :
|
174 |
+
$t['label_font-weight'] = $d;
|
175 |
+
$t['p_font-weight'] = $d;
|
176 |
+
break;
|
177 |
+
case 'label-font-size' :
|
178 |
+
$t['label_font-size'] = $d;
|
179 |
+
$t['label_font-size_unit'] = $u;
|
180 |
+
$t['p_font-size'] = $d;
|
181 |
+
$t['p_font-size_unit'] = $u;
|
182 |
+
break;
|
183 |
+
case 'label-line-height' :
|
184 |
+
$t['label_line-height']= $d;
|
185 |
+
$t['label_line-height_unit']= $u;
|
186 |
+
$t['p_line-height']= $d;
|
187 |
+
$t['p_line-height_unit']= $u;
|
188 |
+
break;
|
189 |
+
case 'label-color' :
|
190 |
+
$t['label_color'] = $d;
|
191 |
+
$t['p_color'] = $d;
|
192 |
+
break;
|
193 |
+
case 'submit-button-width' :
|
194 |
+
$t['submit_width'] = $d;
|
195 |
+
$t['submit_width_unit'] = $u;
|
196 |
+
break;
|
197 |
+
case 'submit-button-box-sizing' :
|
198 |
+
$t['submit_box-sizing'] = $d;
|
199 |
+
break;
|
200 |
+
case 'submit-button-height' :
|
201 |
+
$t['submit_height'] = $d;
|
202 |
+
$t['submit_height_unit'] = $u;
|
203 |
+
break;
|
204 |
+
case 'submit-button-border-radius' :
|
205 |
+
$t['submit_border-top-left-radius'] = $d;
|
206 |
+
$t['submit_border-top-left-radius_unit'] = $u;
|
207 |
+
$t['submit_border-top-right-radius'] = $d;
|
208 |
+
$t['submit_border-top-right-radius_unit'] = $u;
|
209 |
+
$t['submit_border-bottom-left-radius'] = $d;
|
210 |
+
$t['submit_border-bottom-left-radius_unit'] = $u;
|
211 |
+
$t['submit_border-bottom-right-radius'] = $d;
|
212 |
+
$t['submit_border-bottom-right-radius_unit'] = $u;
|
213 |
+
break;
|
214 |
+
case 'submit-button-font-size' :
|
215 |
+
$t['submit_font-size'] = $d;
|
216 |
+
$t['submit_font-size_unit'] = $u;
|
217 |
+
break;
|
218 |
+
case 'submit-button-line-height' :
|
219 |
+
$t['submit_line-height'] = $d;
|
220 |
+
$t['submit_line-height_unit'] = $u;
|
221 |
+
break;
|
222 |
+
case 'submit-button-border-width' :
|
223 |
+
$t['submit_border-top-width'] = $d;
|
224 |
+
$t['submit_border-top-width_unit'] = $u;
|
225 |
+
$t['submit_border-right-width'] = $d;
|
226 |
+
$t['submit_border-right-width_unit'] = $u;
|
227 |
+
$t['submit_border-bottom-width'] = $d;
|
228 |
+
$t['submit_border-bottom-width_unit']= $u;
|
229 |
+
$t['submit_border-left-width']= $d;
|
230 |
+
$t['submit_border-left-width_unit']= $u;
|
231 |
+
break;
|
232 |
+
case 'submit-button-border-style':
|
233 |
+
$t['submit_border-style'] = $d;
|
234 |
+
break;
|
235 |
+
case 'submit-button-border-color' :
|
236 |
+
$t['submit_border-color'] = $d;
|
237 |
+
break;
|
238 |
+
case 'submit-button-color' :
|
239 |
+
$t['submit_color'] = $d;
|
240 |
+
break;
|
241 |
+
case 'submit-button-background' :
|
242 |
+
$t['submit_background-color'] = $d;
|
243 |
+
break;
|
244 |
+
}
|
245 |
+
if($k=="form-padding" || $k=="form-margin" ||$k=="input-margin" ||$k=="input-padding" ){
|
246 |
+
switch($nr){
|
247 |
+
case 1:
|
248 |
+
$t[$tfn.'-top'] = $d;
|
249 |
+
$t[$tfn.'-top_unit'] = $u;
|
250 |
+
$t[$tfn.'-right'] = $d;
|
251 |
+
$t[$tfn.'-right_unit'] = $u;
|
252 |
+
$t[$tfn.'-bottom'] = $d;
|
253 |
+
$t[$tfn.'-bottom_unit'] = $u;
|
254 |
+
$t[$tfn.'-left'] = $d;
|
255 |
+
$t[$tfn.'-left_unit'] = $u;
|
256 |
+
break;
|
257 |
+
case 2:
|
258 |
+
$t[$tfn.'-top'] = $da[0];
|
259 |
+
$t[$tfn.'-top_unit'] = $u;
|
260 |
+
$t[$tfn.'-right'] = $da[1];
|
261 |
+
$t[$tfn.'-right_unit'] = $u;
|
262 |
+
$t[$tfn.'-bottom'] = $da[0];
|
263 |
+
$t[$tfn.'-bottom_unit'] = $u;
|
264 |
+
$t[$tfn.'-left'] = $da[1];
|
265 |
+
$t[$tfn.'-left_unit'] = $u;
|
266 |
+
break;
|
267 |
+
case 3:
|
268 |
+
$t[$tfn.'-top'] = $da[0];
|
269 |
+
$t[$tfn.'-top_unit'] = $u;
|
270 |
+
$t[$tfn.'-right'] = $da[1];
|
271 |
+
$t[$tfn.'-right_unit'] = $u;
|
272 |
+
$t[$tfn.'-bottom'] = $da[2];
|
273 |
+
$t[$tfn.'-bottom_unit'] = $u;
|
274 |
+
$t[$tfn.'-left'] = $da[1];
|
275 |
+
$t[$tfn.'-left_unit'] = $u;
|
276 |
+
break;
|
277 |
+
case 4:
|
278 |
+
$t[$tfn.'-top'] = $da[0];
|
279 |
+
$t[$tfn.'-top_unit'] = $u;
|
280 |
+
$t[$tfn.'-right'] = $da[1];
|
281 |
+
$t[$tfn.'-right_unit'] = $u;
|
282 |
+
$t[$tfn.'-bottom'] = $da[2];
|
283 |
+
$t[$tfn.'-bottom_unit'] = $u;
|
284 |
+
$t[$tfn.'-left'] = $da[3];
|
285 |
+
$t[$tfn.'-left_unit'] = $u;
|
286 |
+
break;
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
+
return $t;
|
292 |
+
}
|
cf7-style-meta-box.php
CHANGED
@@ -1,281 +1,4 @@
|
|
1 |
<?php
|
2 |
-
function cf7_style_general_settings_array(){
|
3 |
-
return array(
|
4 |
-
|
5 |
-
"general_settings" => array(
|
6 |
-
/*!!! labels have to be unique*/
|
7 |
-
array(
|
8 |
-
"type" => "color-selector",
|
9 |
-
"label" => "Form background",
|
10 |
-
"description" => "Choose the background color of the form"
|
11 |
-
),array(
|
12 |
-
"type" => "number",
|
13 |
-
"label" => "Form width",
|
14 |
-
"description" => "Form width in pixels"
|
15 |
-
),array(
|
16 |
-
"type" => "selectbox",
|
17 |
-
"label" => "Form box sizing",
|
18 |
-
"value" => array( "inherit", "initial", "content-box", "border-box" ),
|
19 |
-
"description" => "Form box sizing in pixels"
|
20 |
-
),array(
|
21 |
-
"type" => "number",
|
22 |
-
"label" => "Form border width",
|
23 |
-
"description" => "Form border width in pixels"
|
24 |
-
),array(
|
25 |
-
"type" => "selectbox",
|
26 |
-
"label" => "Form border style",
|
27 |
-
"value" => array( "none", "solid", "dotted","double", "groove", "ridge", "inset", "outset" ),
|
28 |
-
"description" => "Style of the Border of the Form"
|
29 |
-
),array(
|
30 |
-
"type" => "text",
|
31 |
-
"label" => "Form padding",
|
32 |
-
"description" => "hover here for example",
|
33 |
-
"title" => "Ex 1: 25px 50px 75px 100px; top padding is 25px right padding is 50px bottom padding is 75px left padding is 100px Ex 2: 25px 50px 75px; top padding is 25px right and left paddings are 50px bottom padding is 75px Ex 3: 25px 50px; top and bottom paddings are 25px right and left paddings are 50px Ex 4: 25px; all four paddings are 25px "
|
34 |
-
),array(
|
35 |
-
"type" => "text",
|
36 |
-
"label" => "Form margin",
|
37 |
-
"description" => "hover here for example",
|
38 |
-
"title" => "Ex 1: 25px 50px 75px 100px; top margin is 25px right margin is 50px bottom margin is 75px left margin is 100px Ex 2: 25px 50px 75px; top margin is 25px right and left margin are 50px bottom margin is 75px Ex 3: 25px 50px; top and bottom margin are 25px right and left margin are 50px Ex 4: 25px; all four margin are 25px"
|
39 |
-
),array(
|
40 |
-
"type" => "color-selector",
|
41 |
-
"label" => "Form border color",
|
42 |
-
"description" => "Choose the form's border color"
|
43 |
-
),array(
|
44 |
-
"type" => "number",
|
45 |
-
"label" => "Form border radius",
|
46 |
-
"description" => "Choose the form's border radius in pixels"
|
47 |
-
),array(
|
48 |
-
"type" => "number",
|
49 |
-
"label" => "Form line height",
|
50 |
-
"description" => "Choose the form's line height in pixels"
|
51 |
-
)
|
52 |
-
),
|
53 |
-
"inputs_and_labels_settings" => array(
|
54 |
-
array(
|
55 |
-
"type" => "color-selector",
|
56 |
-
"label" => "Input Background",
|
57 |
-
"description" => "Choose the background color of the input"
|
58 |
-
),array(
|
59 |
-
"type" => "color-selector",
|
60 |
-
"label" => "Input Color",
|
61 |
-
"description" => "Choose the color for the input text"
|
62 |
-
),array(
|
63 |
-
"type" => "color-selector",
|
64 |
-
"label" => "Input Border Color",
|
65 |
-
"description" => "Choose a color for the input border"
|
66 |
-
),array(
|
67 |
-
"type" => "number",
|
68 |
-
"label" => "Input font size",
|
69 |
-
"description" => "Size of the input fonts in pixels"
|
70 |
-
),array(
|
71 |
-
"type" => "number",
|
72 |
-
"label" => "Input line height",
|
73 |
-
"description" => "Size of the input line height in pixels"
|
74 |
-
),array(
|
75 |
-
"type" => "number",
|
76 |
-
"label" => "Input border width",
|
77 |
-
"description" => "Size of the input border in pixels"
|
78 |
-
),array(
|
79 |
-
"type" => "selectbox",
|
80 |
-
"label" => "Input border style",
|
81 |
-
"value" => array( "none", "solid", "dotted","double", "groove", "ridge", "inset", "outset" ), // ???
|
82 |
-
"description" => "style of the input border"
|
83 |
-
),array(
|
84 |
-
"type" => "number",
|
85 |
-
"label" => "Input border radius",
|
86 |
-
"description" => "Border radius in px"
|
87 |
-
),array(
|
88 |
-
"type" => "selectbox",
|
89 |
-
"label" => "Input font style",
|
90 |
-
"value" => array( "normal", "italic", "oblique" ), // ???
|
91 |
-
"description" => "Choose from the following font styles"
|
92 |
-
),array(
|
93 |
-
"type" => "selectbox",
|
94 |
-
"label" => "Input font weight",
|
95 |
-
"value" => array( "normal", "bold", "bolder", "lighter", "initial", "inherit" ), // ???
|
96 |
-
"description" => "Choose from the following font weights"
|
97 |
-
),array(
|
98 |
-
"type" => "number",
|
99 |
-
"label" => "Input width",
|
100 |
-
"description" => "Input width in pixels"
|
101 |
-
),array(
|
102 |
-
"type" => "selectbox",
|
103 |
-
"label" => "Input box sizing",
|
104 |
-
"value" => array( "inherit", "initial", "content-box", "border-box" ),
|
105 |
-
"description" => "Input box sizing in pixels"
|
106 |
-
),array(
|
107 |
-
"type" => "number",
|
108 |
-
"label" => "Input height",
|
109 |
-
"description" => "Input height in pixels"
|
110 |
-
),array(
|
111 |
-
"type" => "text",
|
112 |
-
"label" => "Input padding",
|
113 |
-
"description" => "hover here for example",
|
114 |
-
"title" => "Ex 1: 25px 50px 75px 100px; top padding is 25px right padding is 50px bottom padding is 75px left padding is 100px Ex 2: 25px 50px 75px; top padding is 25px right and left paddings are 50px bottom padding is 75px Ex 3: 25px 50px; top and bottom paddings are 25px right and left paddings are 50px Ex 4: 25px; all four paddings are 25px "
|
115 |
-
),array(
|
116 |
-
"type" => "text",
|
117 |
-
"label" => "Input margin",
|
118 |
-
"description" => "hover here for example",
|
119 |
-
"title" => "Ex 1: 25px 50px 75px 100px; top margin is 25px right margin is 50px bottom margin is 75px left margin is 100px Ex 2: 25px 50px 75px; top margin is 25px right and left margin are 50px bottom margin is 75px Ex 3: 25px 50px; top and bottom margin are 25px right and left margin are 50px Ex 4: 25px; all four margin are 25px"
|
120 |
-
),array(
|
121 |
-
"type" => "color-selector",
|
122 |
-
"label" => "Textarea background color",
|
123 |
-
"description" => "Textarea background color"
|
124 |
-
),array(
|
125 |
-
"type" => "number",
|
126 |
-
"label" => "Textarea height",
|
127 |
-
"description" => "Textarea height in pixels"
|
128 |
-
),array(
|
129 |
-
"type" => "number",
|
130 |
-
"label" => "Textarea width",
|
131 |
-
"description" => "Textarea width in pixels"
|
132 |
-
),array(
|
133 |
-
"type" => "selectbox",
|
134 |
-
"label" => "Textarea box sizing",
|
135 |
-
"value" => array( "inherit", "initial", "content-box", "border-box" ),
|
136 |
-
"description" => "Textarea box sizing in pixels"
|
137 |
-
),array(
|
138 |
-
"type" => "number",
|
139 |
-
"label" => "Textarea border-size",
|
140 |
-
"description" => "Textarea border width pixels"
|
141 |
-
),array(
|
142 |
-
"type" => "color-selector",
|
143 |
-
"label" => "Textarea border color",
|
144 |
-
"description" => "Textarea border color"
|
145 |
-
),array(
|
146 |
-
"type" => "selectbox",
|
147 |
-
"label" => "Textarea border style",
|
148 |
-
"value" => array( "none", "solid", "dotted","double", "groove", "ridge", "inset", "outset" ),
|
149 |
-
"description" => "Textarea border style"
|
150 |
-
),array(
|
151 |
-
"type" => "number",
|
152 |
-
"label" => "Textarea border radius",
|
153 |
-
"description" => "Textarea border radius"
|
154 |
-
),array(
|
155 |
-
"type" => "number",
|
156 |
-
"label" => "Textarea font-size",
|
157 |
-
"description" => "Textarea font size"
|
158 |
-
),array(
|
159 |
-
"type" => "number",
|
160 |
-
"label" => "Textarea line height",
|
161 |
-
"description" => "Textarea line height in pixels"
|
162 |
-
),array(
|
163 |
-
"type" => "selectbox",
|
164 |
-
"label" => "Textarea font-style",
|
165 |
-
"value" => array( "normal", "bold", "bolder", "lighter", "initial", "inherit" ),
|
166 |
-
"description" => "Textarea font style"
|
167 |
-
),array(
|
168 |
-
"type" => "selectbox",
|
169 |
-
"label" => "Label font style",
|
170 |
-
"value" => array( "normal", "italic", "oblique" ),
|
171 |
-
"description" => "Choose from the following font styles"
|
172 |
-
),array(
|
173 |
-
"type" => "selectbox",
|
174 |
-
"label" => "Label font weight",
|
175 |
-
"value" => array( "normal", "bold", "bolder", "lighter", "initial", "inherit" ),
|
176 |
-
"description" => "Choose from the following label font weights"
|
177 |
-
),array(
|
178 |
-
"type" => "number",
|
179 |
-
"label" => "Label font size",
|
180 |
-
"description" => "Size of the label fonts in pixels"
|
181 |
-
),array(
|
182 |
-
"type" => "number",
|
183 |
-
"label" => "Label line height",
|
184 |
-
"description" => "Size of the label line height in pixels"
|
185 |
-
),array(
|
186 |
-
"type" => "color-selector",
|
187 |
-
"label" => "Label Color",
|
188 |
-
"description" => "Choose the color for the label text"
|
189 |
-
)
|
190 |
-
),
|
191 |
-
"submit_button_settings" => array(
|
192 |
-
array(
|
193 |
-
"type" => "number",
|
194 |
-
"label" => "Submit button width",
|
195 |
-
"description" => "Submit button width in px"
|
196 |
-
),array(
|
197 |
-
"type" => "selectbox",
|
198 |
-
"label" => "Submit button box sizing",
|
199 |
-
"value" => array( "inherit", "initial", "content-box", "border-box" ),
|
200 |
-
"description" => "Submit button box sizing in pixels"
|
201 |
-
),array(
|
202 |
-
"type" => "number",
|
203 |
-
"label" => "Submit button height",
|
204 |
-
"description" => "Submit button height in px"
|
205 |
-
),array(
|
206 |
-
"type" => "number",
|
207 |
-
"label" => "Submit button border radius",
|
208 |
-
"description" => "Border radius in px"
|
209 |
-
),array(
|
210 |
-
"type" => "number",
|
211 |
-
"label" => "Submit button font size",
|
212 |
-
"description" => "Font size in px"
|
213 |
-
),array(
|
214 |
-
"type" => "number",
|
215 |
-
"label" => "Submit button line height",
|
216 |
-
"description" => "Line height in px"
|
217 |
-
),array(
|
218 |
-
"type" => "number",
|
219 |
-
"label" => "Submit button border width",
|
220 |
-
"description" => "Size of the submit button border in pixels"
|
221 |
-
),array(
|
222 |
-
"type" => "selectbox",
|
223 |
-
"label" => "Submit button border style",
|
224 |
-
"value" => array( "none", "solid", "dotted","double", "groove", "ridge", "inset", "outset" ), // ???
|
225 |
-
"description" => "Type of the submit button border"
|
226 |
-
),array(
|
227 |
-
"type" => "color-selector",
|
228 |
-
"label" => "Submit button border color",
|
229 |
-
"description" => "Choose a color for the submit border"
|
230 |
-
),array(
|
231 |
-
"type" => "color-selector",
|
232 |
-
"label" => "Submit button color",
|
233 |
-
"description" => "Choose a color for the submit button text"
|
234 |
-
),array(
|
235 |
-
"type" => "color-selector",
|
236 |
-
"label" => "Submit button background",
|
237 |
-
"description" => "Choose a color for the submit background"
|
238 |
-
),
|
239 |
-
));
|
240 |
-
}
|
241 |
-
/**
|
242 |
-
* renders the custom meta box's inputs
|
243 |
-
*/
|
244 |
-
function cf7_style_render_settings( $type, $label, $options, $value, $description, $title ){
|
245 |
-
|
246 |
-
$cf7s_id = strtolower( str_replace( " ", "-", $label ) );
|
247 |
-
?>
|
248 |
-
<div class="element">
|
249 |
-
<label for="cf7s-<?php echo $cf7s_id; ?>">
|
250 |
-
<table>
|
251 |
-
<tr>
|
252 |
-
<td>
|
253 |
-
<strong>
|
254 |
-
<?php echo __( $label, "cf7style_text_domain"); ?>
|
255 |
-
</strong>
|
256 |
-
</td>
|
257 |
-
<td>
|
258 |
-
<?php $class = ( "color-selector" == $type ) ? "cf7-style-color-field" : "";
|
259 |
-
if( "selectbox" == $type ){ ?>
|
260 |
-
<select id="cf7s-<?php echo $cf7s_id; ?>" name="cf7stylecustom[<?php echo $cf7s_id; ?>]">
|
261 |
-
<option>Default</option>
|
262 |
-
<?php foreach( $options as $option ) {?>
|
263 |
-
<option value="<?php echo $option; ?>"<?php if($option == $value) echo " selected='selected'";?>><?php echo $option; ?></option>
|
264 |
-
<?php }//foreach end ?>
|
265 |
-
</select>
|
266 |
-
<?php } else { ?>
|
267 |
-
<input type="<?php echo ( $type == 'color-selector' ) ? 'text' : $type; ?>" id="cf7s-<?php echo $cf7s_id; ?>" name="cf7stylecustom[<?php echo $cf7s_id; ?>]" value="<?php echo $value; ?>" <?php if( $class != "" ) echo 'class="'.$class.'"';?>/>
|
268 |
-
<?php }//else end ?>
|
269 |
-
<small <?php echo ( isset( $title ) ? "title='".$title."'" : "" ); ?>><?php echo __( $description, "cf7style_text_domain"); ?></small>
|
270 |
-
</td>
|
271 |
-
</tr>
|
272 |
-
</table>
|
273 |
-
</label>
|
274 |
-
</div><!-- /.element -->
|
275 |
-
|
276 |
-
<?php
|
277 |
-
|
278 |
-
}
|
279 |
/**
|
280 |
* Calls the class the meta box. Used for selecting forms for each style.
|
281 |
*/
|
@@ -345,43 +68,17 @@ class cf7_style_meta_boxes {
|
|
345 |
);
|
346 |
}
|
347 |
}
|
|
|
348 |
public function render_meta_box_style_customizer( $post ) {
|
349 |
-
|
350 |
-
$setting_array = unserialize( get_post_meta( $post->ID, 'cf7_style_custom_styles', true ));
|
351 |
-
$result_manual = get_post_meta( $post->ID, 'cf7_style_manual_style', true ); ?>
|
352 |
-
|
353 |
-
<?php foreach( cf7_style_general_settings_array() as $key=>$settings) { ?>
|
354 |
-
<div class="general-settings">
|
355 |
-
<h3><?php echo __( str_replace( "_", " ", $key ).' for this custom style.', "cf7style_text_domain" ); ?></h3>
|
356 |
-
<?php
|
357 |
-
foreach( $settings as $setting ){
|
358 |
-
//this will be improved with: if ( isset( $setting_array[$setting["label"]] ) ) { - for later reference !!!
|
359 |
-
$current_val = ( !empty( $setting_array ) ) ? $setting_array[ strtolower( str_replace( " ", "-", $setting["label"] ) ) ] : "";
|
360 |
-
|
361 |
-
$current_option = ( $setting["type"] == "selectbox" ) ? $setting["value"] : "";
|
362 |
-
$current_title = ( isset( $setting["title"] ) ) ? $setting["title"] : "";
|
363 |
-
cf7_style_render_settings( $setting["type"], $setting["label"], $current_option, $current_val, $setting["description"], $current_title );
|
364 |
-
} ?>
|
365 |
-
</div><!-- /.general-settings -->
|
366 |
-
<?php } ?>
|
367 |
-
|
368 |
-
<div class="general-settings full-width">
|
369 |
-
<h3><?php _e( "CSS Editor", "cf7style" ); ?></h3>
|
370 |
-
<p>You can easily find CSS elements by using your browser inspector or Firebug, or view a quick guide <a href="http://sixrevisions.com/tools/firebug-guide-web-designers/" target="_blank" title="Firebug guide">here</a>.</p>
|
371 |
-
<label for="manual-style">
|
372 |
-
<textarea name="manual-style" id="manual-style" cols="30" rows="10"><?php echo $result_manual; ?></textarea>
|
373 |
-
</label>
|
374 |
-
</div>
|
375 |
-
|
376 |
-
<div class="clear"></div>
|
377 |
-
<?php
|
378 |
}
|
|
|
379 |
public function save_style_customizer( $post_id ) {
|
380 |
|
381 |
if ( ! isset( $_POST['cf_7_style_customizer_custom_box_nonce'] ) )
|
382 |
return $post_id;
|
383 |
|
384 |
-
$nonce = $_POST['cf_7_style_customizer_custom_box_nonce'];
|
385 |
|
386 |
|
387 |
// Verify that the nonce is valid.
|
@@ -405,15 +102,13 @@ class cf7_style_meta_boxes {
|
|
405 |
}
|
406 |
|
407 |
$posted_data = $_POST['cf7stylecustom'];
|
408 |
-
$
|
409 |
-
|
410 |
-
|
|
|
411 |
if ( is_array( $posted_data ) && isset( $posted_data ) ) {
|
412 |
$serialized_result = serialize( $posted_data );
|
413 |
-
update_post_meta( $post_id, '
|
414 |
-
}
|
415 |
-
if ( isset( $posted_manual_style_data ) ) {
|
416 |
-
update_post_meta( $post_id, 'cf7_style_manual_style', $posted_manual_style_data, "");
|
417 |
}
|
418 |
|
419 |
}
|
@@ -559,54 +254,46 @@ class cf7_style_meta_boxes {
|
|
559 |
*IMAGE META BOX ENDS HERE
|
560 |
***************************
|
561 |
*/
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
echo '</select>'; ?>
|
599 |
-
<div class="cf7-style preview-zone">
|
600 |
-
<h4>Preview Selected font:</h4>
|
601 |
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ultrices neque sit amet consequat. Aenean facilisis massa convallis nisl viverra eleifend. Nam fermentum mauris eu eleifend posuere. Duis at pharetra tellus. Suspendisse viverra tempor tellus, non efficitur nibh posuere nec. Sed vitae pellentesque augue, id efficitur enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eros turpis, hendrerit id condimentum vitae, fermentum ut dolor. Cras quis lobortis ante.</p>
|
602 |
-
</div>
|
603 |
-
<div class="clear"></div>
|
604 |
-
<?php
|
605 |
-
}
|
606 |
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
public function save_font_id( $post_id ) {
|
611 |
if ( ! isset( $_POST['cf_7_style_font_custom_box_nonce'] ) )
|
612 |
return $post_id;
|
@@ -632,14 +319,14 @@ class cf7_style_meta_boxes {
|
|
632 |
|
633 |
}
|
634 |
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
}
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
public function add_meta_box_style_paypal( $post_type ) {
|
644 |
$post_types = array('cf7_style'); //limit meta box to certain post types
|
645 |
if ( in_array( $post_type, $post_types )) {
|
@@ -653,89 +340,79 @@ class cf7_style_meta_boxes {
|
|
653 |
);
|
654 |
}
|
655 |
}
|
656 |
-
|
657 |
-
|
658 |
-
/**
|
659 |
* renders the image
|
660 |
*/
|
661 |
-
|
662 |
public function render_meta_paypal( $post ) { ?>
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
<?php }
|
668 |
}
|
669 |
|
670 |
//gets the slug of a post
|
671 |
function cf7_style_the_slug() {
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
}
|
677 |
//enques the font
|
678 |
function enque_selected_font() {
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
$active_styles = active_styles();
|
683 |
-
|
684 |
foreach( $active_styles as $cf7s_id ) {
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
if( ! empty( $googlefont ) && "none" !== $googlefont ) {
|
690 |
wp_register_style( 'googlefont-cf7style-' . $cf7s_id, 'http://fonts.googleapis.com/css?family=' . $googlefont . ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese', array(), false, 'all' );
|
691 |
wp_enqueue_style( 'googlefont-cf7style-' . $cf7s_id );
|
692 |
-
|
693 |
-
|
694 |
}
|
695 |
-
|
696 |
}
|
697 |
add_action( 'wp_enqueue_scripts', 'enque_selected_font' );
|
698 |
|
699 |
-
|
700 |
-
/**
|
701 |
* returns the name of the font on the current page/post
|
702 |
*/
|
703 |
-
|
704 |
function return_font_name( $cf7s_id ) {
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
return false;
|
711 |
}
|
712 |
|
713 |
-
|
714 |
-
/**
|
715 |
* hides change permalink and view buttons on editing screen
|
716 |
*/
|
717 |
|
718 |
add_action('admin_head', 'hide_edit_permalinks_on_style_customizer');
|
719 |
function hide_edit_permalinks_on_style_customizer() {
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
}
|
740 |
|
741 |
|
@@ -750,6 +427,8 @@ function manage_wp_posts_qe_bulk_quick_edit_custom_box( $column_name, $post_type
|
|
750 |
|
751 |
switch ( $post_type ) {
|
752 |
case 'cf7_style': ?>
|
|
|
|
|
753 |
<fieldset class="inline-edit-col-left cf7-quick-edit" style="clear:both">
|
754 |
<div class="hidden-fields"></div>
|
755 |
<h4><?php _e( "Activate this template on the following forms:", "cf7_style" ); ?></h4>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Calls the class the meta box. Used for selecting forms for each style.
|
4 |
*/
|
68 |
);
|
69 |
}
|
70 |
}
|
71 |
+
|
72 |
public function render_meta_box_style_customizer( $post ) {
|
73 |
+
require_once WPCF7S_PLUGIN_DIR . '/options.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
+
|
76 |
public function save_style_customizer( $post_id ) {
|
77 |
|
78 |
if ( ! isset( $_POST['cf_7_style_customizer_custom_box_nonce'] ) )
|
79 |
return $post_id;
|
80 |
|
81 |
+
$nonce = sanitize_text_field($_POST['cf_7_style_customizer_custom_box_nonce']);
|
82 |
|
83 |
|
84 |
// Verify that the nonce is valid.
|
102 |
}
|
103 |
|
104 |
$posted_data = $_POST['cf7stylecustom'];
|
105 |
+
$active_pane = sanitize_text_field($_POST['cf7styleactivepane']);
|
106 |
+
if( isset( $active_pane )){
|
107 |
+
update_post_meta( $post_id, 'cf7_style_active_panel', $active_pane, "");
|
108 |
+
}
|
109 |
if ( is_array( $posted_data ) && isset( $posted_data ) ) {
|
110 |
$serialized_result = serialize( $posted_data );
|
111 |
+
update_post_meta( $post_id, 'cf7_style_custom_styler', $serialized_result, "");
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
}
|
254 |
*IMAGE META BOX ENDS HERE
|
255 |
***************************
|
256 |
*/
|
257 |
+
/*
|
258 |
+
* Meta box for font selector
|
259 |
+
*/
|
260 |
+
public function add_meta_box_font_selector( $post_type ) {
|
261 |
+
$post_types = array('cf7_style'); //limit meta box to certain post types
|
262 |
+
if ( in_array( $post_type, $post_types )) {
|
263 |
+
add_meta_box(
|
264 |
+
'cf7_style_meta_box_font_selector'
|
265 |
+
,__( 'Select a Google Font', 'myplugin_textdomain' )
|
266 |
+
,array( $this, 'render_font_selector' )
|
267 |
+
,$post_type
|
268 |
+
,'advanced'
|
269 |
+
,'high'
|
270 |
+
);
|
271 |
+
}
|
272 |
+
}
|
273 |
+
public function render_font_selector( $post ) {
|
274 |
+
wp_nonce_field( 'cf_7_style_font_inner_custom_box', 'cf_7_style_font_custom_box_nonce' );
|
275 |
+
//getting all google fonts
|
276 |
+
$google_list = file_get_contents( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBAympIKDNKmfxhI3udY-U_9vDWSdfHrEo' );
|
277 |
+
$font_obj = json_decode( $google_list );
|
278 |
+
$cf7_style_font = get_post_meta( $post->ID, 'cf7_style_font', true );
|
279 |
+
$selected = '';
|
280 |
+
echo '<select name="cf7_style_font_selector">';
|
281 |
+
echo '<option value="none">None</option>';
|
282 |
+
foreach ($font_obj->items as $font) {
|
283 |
+
echo '<option value="' . $font->family . '"' . ( $cf7_style_font == $font->family ? 'selected="selected"' : '' ) . '>' . $font->family . '</option>';
|
284 |
+
}
|
285 |
+
echo '</select>'; ?>
|
286 |
+
<div class="cf7-style preview-zone">
|
287 |
+
<h4>Preview Selected font:</h4>
|
288 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ultrices neque sit amet consequat. Aenean facilisis massa convallis nisl viverra eleifend. Nam fermentum mauris eu eleifend posuere.</p>
|
289 |
+
</div>
|
290 |
+
<div class="clear"></div>
|
291 |
+
<?php
|
292 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
+
/**
|
295 |
+
* Save the font id
|
296 |
+
*/
|
297 |
public function save_font_id( $post_id ) {
|
298 |
if ( ! isset( $_POST['cf_7_style_font_custom_box_nonce'] ) )
|
299 |
return $post_id;
|
319 |
|
320 |
}
|
321 |
|
322 |
+
if ( isset ( $_POST['cf7_style_font_selector'] ) ) {
|
323 |
+
update_post_meta( $post_id, 'cf7_style_font', sanitize_text_field( $_POST['cf7_style_font_selector'] ));
|
324 |
+
}
|
325 |
}
|
326 |
+
/*************************************************
|
327 |
+
* Adds the meta box container for IMAGE PREVIEW
|
328 |
+
* IMAGE META BOX STARTS HERE
|
329 |
+
*/
|
330 |
public function add_meta_box_style_paypal( $post_type ) {
|
331 |
$post_types = array('cf7_style'); //limit meta box to certain post types
|
332 |
if ( in_array( $post_type, $post_types )) {
|
340 |
);
|
341 |
}
|
342 |
}
|
343 |
+
/*
|
|
|
|
|
344 |
* renders the image
|
345 |
*/
|
|
|
346 |
public function render_meta_paypal( $post ) { ?>
|
347 |
+
<p>Your donation will motivate us to work more and improve this plugin.</p>
|
348 |
+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ionut.iclanzan.reea@gmail.com&item_name=Donation+for+Contact+Form+Style" target="_blank">
|
349 |
+
<img src="https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg">
|
350 |
+
</a>
|
351 |
<?php }
|
352 |
}
|
353 |
|
354 |
//gets the slug of a post
|
355 |
function cf7_style_the_slug() {
|
356 |
+
global $post;
|
357 |
+
$post_data = get_post($post->ID, ARRAY_A);
|
358 |
+
$slug = $post_data['post_name'];
|
359 |
+
return $slug;
|
360 |
}
|
361 |
//enques the font
|
362 |
function enque_selected_font() {
|
363 |
+
if ( is_page() || is_single() || is_home() ) {
|
364 |
+
global $post;
|
|
|
365 |
$active_styles = active_styles();
|
|
|
366 |
foreach( $active_styles as $cf7s_id ) {
|
367 |
+
if ( $cf7s_id ) {
|
368 |
+
$fontid = get_post_meta( $cf7s_id, 'cf7_style_font', true );
|
369 |
+
$googlefont = preg_replace( "/ /", "+", $fontid );
|
370 |
+
if( ! empty( $googlefont ) && "none" !== $googlefont ) {
|
|
|
371 |
wp_register_style( 'googlefont-cf7style-' . $cf7s_id, 'http://fonts.googleapis.com/css?family=' . $googlefont . ':100,200,300,400,500,600,700,800,900&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese', array(), false, 'all' );
|
372 |
wp_enqueue_style( 'googlefont-cf7style-' . $cf7s_id );
|
373 |
+
}
|
374 |
+
}
|
375 |
}
|
376 |
+
}
|
377 |
}
|
378 |
add_action( 'wp_enqueue_scripts', 'enque_selected_font' );
|
379 |
|
380 |
+
/*
|
|
|
381 |
* returns the name of the font on the current page/post
|
382 |
*/
|
|
|
383 |
function return_font_name( $cf7s_id ) {
|
384 |
+
if ( $cf7s_id ) {
|
385 |
+
$fontname = get_post_meta( $cf7s_id, 'cf7_style_font', true );
|
386 |
+
return ( $fontname );
|
387 |
+
}
|
388 |
+
return false;
|
|
|
389 |
}
|
390 |
|
391 |
+
/*
|
|
|
392 |
* hides change permalink and view buttons on editing screen
|
393 |
*/
|
394 |
|
395 |
add_action('admin_head', 'hide_edit_permalinks_on_style_customizer');
|
396 |
function hide_edit_permalinks_on_style_customizer() {
|
397 |
+
$currentScreen = get_current_screen();
|
398 |
+
if ( $currentScreen->post_type == 'cf7_style' ) {
|
399 |
+
?>
|
400 |
+
<style type="text/css">
|
401 |
+
#titlediv {
|
402 |
+
margin-bottom: 10px;
|
403 |
+
}
|
404 |
+
#edit-slug-box, .inline-edit-col-left, .inline-edit-col-right, .view{
|
405 |
+
display: none;
|
406 |
+
}
|
407 |
+
.inline-edit-col-left.cf7-quick-edit {
|
408 |
+
display: block;
|
409 |
+
}
|
410 |
+
.inline-edit-cf7_style {
|
411 |
+
background: #eaeaea;
|
412 |
+
padding: 20px 0;
|
413 |
+
}
|
414 |
+
</style>
|
415 |
+
<?php }
|
416 |
}
|
417 |
|
418 |
|
427 |
|
428 |
switch ( $post_type ) {
|
429 |
case 'cf7_style': ?>
|
430 |
+
</td>
|
431 |
+
<td class="special-colspan">
|
432 |
<fieldset class="inline-edit-col-left cf7-quick-edit" style="clear:both">
|
433 |
<div class="hidden-fields"></div>
|
434 |
<h4><?php _e( "Activate this template on the following forms:", "cf7_style" ); ?></h4>
|
cf7-style.php
CHANGED
@@ -3,66 +3,28 @@
|
|
3 |
Plugin Name: Contact Form 7 Style
|
4 |
Plugin URI: http://wordpress.reea.net/contact-form-7-style/
|
5 |
Description: Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
|
6 |
-
Version:
|
7 |
-
Author:
|
8 |
-
Author URI: http://
|
9 |
License: GPL2
|
10 |
-
@Author:
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Include the plugin options
|
15 |
*/
|
|
|
|
|
|
|
16 |
function set_styleversion(){
|
17 |
-
return "
|
18 |
}
|
19 |
|
20 |
function get_predefined_cf7_style_template_data() {
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
'category' => 'simple pattern style',
|
25 |
-
'image' => '/admin/images/cf7_simple_twentyfifteen_pattern.jpg'
|
26 |
-
),
|
27 |
-
array (
|
28 |
-
'title' => 'Christmas Classic',
|
29 |
-
'category' => 'christmas style',
|
30 |
-
'image' => '/admin/images/cf7_xmas_classic.jpg'
|
31 |
-
),
|
32 |
-
array (
|
33 |
-
'title' => 'Christmas Red',
|
34 |
-
'category' => 'christmas style',
|
35 |
-
'image' => '/admin/images/cf7_xmas_red.jpg',
|
36 |
-
),
|
37 |
-
array (
|
38 |
-
'title' => 'Christmas Simple',
|
39 |
-
'category' => 'christmas style',
|
40 |
-
'image' => '/admin/images/cf7_xmas_simple.jpg'
|
41 |
-
),
|
42 |
-
array (
|
43 |
-
'title' => "Valentine's Day Classic",
|
44 |
-
'category' => "valentine's day style",
|
45 |
-
'image' => '/admin/images/cf7_vday_classic.jpg'
|
46 |
-
),
|
47 |
-
array (
|
48 |
-
'title' => "Valentine's Day Roses",
|
49 |
-
'category' => "valentine's day style",
|
50 |
-
'image' => '/admin/images/cf7_vday_roses.jpg'
|
51 |
-
),
|
52 |
-
array (
|
53 |
-
'title' => "Valentine's Day Birds",
|
54 |
-
'category' => "valentine's day style",
|
55 |
-
'image' => '/admin/images/cf7_vday_birds.jpg'
|
56 |
-
),
|
57 |
-
array (
|
58 |
-
'title' => "Valentine's Day Blue Birds",
|
59 |
-
'category' => "valentine's day style",
|
60 |
-
'image' => '/admin/images/cf7_vday_blue_birds.jpg'
|
61 |
-
)
|
62 |
-
);
|
63 |
}// end of get_predefined_cf7_style_template_data
|
64 |
-
|
65 |
-
|
66 |
/**
|
67 |
* Get contact form 7 id
|
68 |
*
|
@@ -77,12 +39,10 @@ function get_form_id( $cf7 ) {
|
|
77 |
if (!is_object($cf7)) {
|
78 |
return false;
|
79 |
}
|
80 |
-
|
81 |
return $cf7->id();
|
82 |
}
|
83 |
}
|
84 |
|
85 |
-
|
86 |
/**
|
87 |
* Add cf7skins classes to the CF7 HTML form class
|
88 |
*
|
@@ -101,33 +61,21 @@ function form_class_attr( $class, $id ) {
|
|
101 |
// Get the current CF7 form ID
|
102 |
$cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
|
103 |
$form_id = get_form_id( $cf7 );
|
104 |
-
|
105 |
$template_class = '';
|
106 |
$cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' );
|
107 |
if ( isset( $cf7_style_id[0] ) ) {
|
108 |
$cf7_style_data = get_post( $cf7_style_id[0], OBJECT );
|
109 |
-
|
110 |
-
|
111 |
-
if( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) {
|
112 |
-
$template_class = "cf7-style-" . $cf7_style_id[0];
|
113 |
-
} else {
|
114 |
-
$template_class = $cf7_style_data->post_name;
|
115 |
-
}
|
116 |
}
|
117 |
|
118 |
// Return the modified class
|
119 |
return $template_class;
|
120 |
}
|
121 |
-
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Get active styles
|
125 |
-
*/
|
126 |
-
|
127 |
function active_styles() {
|
128 |
|
129 |
$args = array(
|
130 |
-
'post_type'
|
131 |
'post_status' => 'publish',
|
132 |
'posts_per_page' => -1
|
133 |
);
|
@@ -139,198 +87,166 @@ function active_styles() {
|
|
139 |
$form_title = get_the_title();
|
140 |
$id = get_the_ID();
|
141 |
$style_id = get_post_meta( $id, 'cf7_style_id', true );
|
142 |
-
|
143 |
if ( ! empty( $style_id ) || $style_id != 0 ) {
|
144 |
$active_styles[] = $style_id;
|
145 |
}
|
146 |
-
|
147 |
endwhile;
|
148 |
wp_reset_postdata();
|
149 |
endif;
|
150 |
-
|
151 |
return $active_styles;
|
152 |
}
|
153 |
|
154 |
-
|
155 |
-
function count_element_settings( $elements, $checks ){
|
156 |
-
$inner = 0;
|
157 |
-
$arr = array();
|
158 |
-
foreach ( $checks as $index => $check ) {
|
159 |
-
$inner = 0;
|
160 |
-
foreach ( $elements as $key => $element ) {
|
161 |
-
if ( strpos( $key, $check ) === 0 ) {
|
162 |
-
$arr[ $index ] = $inner++;
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
return $arr;
|
167 |
-
}
|
168 |
function cf7_style_custom_css_generator(){
|
169 |
-
|
170 |
global $post;
|
171 |
if( empty( $post ) ) {
|
172 |
return false;
|
173 |
}
|
174 |
-
|
175 |
$args = array(
|
176 |
-
'post_type'
|
177 |
'post_status' => 'publish',
|
178 |
'posts_per_page' => -1
|
179 |
);
|
180 |
-
$
|
181 |
-
$
|
182 |
-
$style
|
183 |
-
$
|
184 |
-
$
|
185 |
-
|
186 |
if( $forms->have_posts() ) :
|
187 |
while( $forms->have_posts() ) : $forms->the_post();
|
188 |
-
$
|
189 |
-
$
|
190 |
-
$
|
191 |
-
|
192 |
if ( ( ! empty( $cf7s_id ) || $cf7s_id !== 0 ) && ! in_array( $cf7s_id, $active_styles ) ) {
|
193 |
if( empty( $active_styles ) ) {
|
194 |
-
$style
|
195 |
}
|
196 |
-
|
197 |
array_push( $active_styles, $cf7s_id );
|
198 |
$cf7_style_data = get_post( $cf7s_id, OBJECT );
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$
|
210 |
-
$
|
211 |
-
$
|
212 |
-
$
|
213 |
-
$
|
214 |
-
$
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
foreach( $cf7s_custom_settings as $setting_key => $setting )
|
219 |
-
$setting_key_part = explode( "
|
220 |
-
$second_part = ( $setting_key_part[0] != "submit" ) ? $setting_key_part[1] : "";
|
221 |
-
$third_part = ( !empty( $setting_key_part[2] ) ) ? ( ( $setting_key_part[0] != "submit" ) ? "-" : "" ) . $setting_key_part[2] : "";
|
222 |
-
$fourth_part = ( !empty( $setting_key_part[3] ) && $setting_key_part[0] == "submit" ) ? "-" . $setting_key_part[3] : "";
|
223 |
-
|
224 |
$classelem = "body .cf7-style." . ( ( is_numeric( $cf7s_slug ) ) ? "cf7-style-".$cf7s_slug : $cf7s_slug );
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
$allelem = $form_set_nr[ 1 ];
|
234 |
-
$classelem .= " input,\n".$classelem." textarea,\n".$classelem." input:focus,\n".$classelem." textarea:focus,\n".$classelem." textarea:focus,\n" . $classelem . " input[type=\"submit\"]:hover,\n".$classelem." .wpcf7-submit:not([disabled]),\n".$classelem." .wpcf7-submit:not([disabled]):hover";
|
235 |
-
$temp_1++;
|
236 |
-
break;
|
237 |
-
case 'label':
|
238 |
-
$startelem = $temp_2;
|
239 |
-
$allelem = $form_set_nr[ 2 ];
|
240 |
-
$classelem .= " label,\n".$classelem." > p";
|
241 |
-
$temp_2++;
|
242 |
-
break;
|
243 |
-
case 'submit':
|
244 |
-
$startelem = $temp_3;
|
245 |
-
$allelem = $form_set_nr[ 3 ];
|
246 |
-
$classelem .= " .wpcf7-submit,\n".$classelem." .wpcf7-submit:focus,\n".$classelem." input[type=\"submit\"],\n".$classelem." input[type=\"submit\"]:hover,\n".$classelem." .wpcf7-submit:not([disabled]),\n".$classelem." .wpcf7-submit:not([disabled]):hover";
|
247 |
-
$temp_3++;
|
248 |
-
break;
|
249 |
-
case 'textarea':
|
250 |
-
$startelem = $temp_4;
|
251 |
-
$allelem = $form_set_nr[ 4 ];
|
252 |
-
$classelem .= " textarea,\n".$classelem." textarea:focus";
|
253 |
-
$temp_4++;
|
254 |
-
break;
|
255 |
-
default:
|
256 |
-
# code...
|
257 |
-
break;
|
258 |
}
|
|
|
|
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
}
|
273 |
-
$style .= ";\n";
|
274 |
-
}
|
275 |
-
|
276 |
-
if( $second_part == 'line' && $setting == "" ) {
|
277 |
-
|
278 |
-
$style .= "\t" . $second_part . $third_part . ": normal;\n";
|
279 |
-
}
|
280 |
-
|
281 |
-
if ( $third_part == "line" && $setting == "" ) {
|
282 |
-
$style .= "\t" . $third_part . $fourth_part . ": normal;\n";
|
283 |
-
}
|
284 |
-
|
285 |
-
if( ( $second_part == 'box' || $third_part == 'box' ) && $setting != "Default" ) {
|
286 |
-
$style .= "\t -moz-" . $second_part . $third_part . ": ". $setting . ";\n";
|
287 |
-
$style .= "\t -webkit-" . $second_part . $third_part . ": ". $setting . ";\n";
|
288 |
-
$style .= "\t" . $second_part . $third_part . ": ". $setting . ";\n";
|
289 |
}
|
290 |
-
|
291 |
-
$style .= ( $startelem == $allelem || $allelem == 1 ) ? "}\n" : "";
|
292 |
-
|
293 |
}
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
$font_family = return_font_name( $cf7s_id );
|
296 |
|
297 |
if( ! empty( $font_family ) && "none" !== $font_family ) {
|
298 |
if (is_numeric($cf7s_slug)) {
|
299 |
$cf7s_slug = "cf7-style-".$cf7s_slug;
|
300 |
}
|
301 |
-
|
302 |
-
$style .= 'body .cf7-style.' . $cf7s_slug . ', body .cf7-style.' . $cf7s_slug . " input[type='submit'] {\n\t font-family: '" . $font_family . "',sans-serif;\n} ";
|
303 |
}
|
304 |
if( !empty( $cf7s_manual_style ) ){
|
305 |
$style.= "\n".$cf7s_manual_style."\n";
|
306 |
}
|
307 |
|
308 |
$style_number++;
|
309 |
-
}
|
310 |
-
|
311 |
|
312 |
endwhile;
|
313 |
-
|
314 |
if( ( $style_number !== 0 ) && $style_number == count( $active_styles ) ) {
|
315 |
$style .= "\n</style>\n";
|
316 |
}
|
317 |
-
|
318 |
echo $style;
|
319 |
-
|
320 |
wp_reset_postdata();
|
321 |
-
endif;
|
322 |
-
|
323 |
}// end of cf7_style_custom_css_generator
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
wp_enqueue_style(
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
function cf7_style_add_class( $class ){
|
336 |
global $post;
|
@@ -351,7 +267,7 @@ function contact_form_7_check() {
|
|
351 |
|
352 |
if ( ! in_array( $required_plugin, $active_plugins ) ) {
|
353 |
|
354 |
-
$html = '<div class="
|
355 |
$html .= '<p>';
|
356 |
$html .= 'Contact form 7 - Style is an addon. Please install <a href="http://wordpress.org/plugins/contact-form-7/" target="_blank">Contact form 7</a>.';
|
357 |
$html .= '</p>';
|
@@ -369,7 +285,22 @@ function contact_form_7_check() {
|
|
369 |
$html .= '</div><!-- /.updated -->';
|
370 |
echo $html;
|
371 |
update_option( 'cf7_style_cookie', true );
|
372 |
-
} // end if !$cf7_style_cookie
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
}
|
374 |
} // end if $active_plugins
|
375 |
}
|
@@ -378,7 +309,6 @@ add_action( 'admin_notices', 'contact_form_7_check' );
|
|
378 |
function cf7_style_create_post( $slug, $title, $image) {
|
379 |
// Initialize the page ID to -1. This indicates no action has been taken.
|
380 |
$post_id = -1;
|
381 |
-
// If the page doesn't already exist, then create it
|
382 |
if( null == get_page_by_title( $title, "OBJECT", "cf7_style" ) ) {
|
383 |
// Set the post ID so that we know the post was created successfully
|
384 |
$post_id = wp_insert_post(
|
@@ -443,10 +373,9 @@ function cf7_style_set_style_category_on_publish( $ID, $post ) {
|
|
443 |
}
|
444 |
} // end cf7_style_set_style_category_on_publish
|
445 |
function cf7_style_create_posts(){
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
}
|
450 |
}
|
451 |
// Hook into the 'cf7_style_create_posts' action
|
452 |
register_activation_hook( __FILE__, 'cf7_style_create_posts' );
|
@@ -454,7 +383,7 @@ register_activation_hook( __FILE__, 'cf7_style_create_posts' );
|
|
454 |
function cf7style_load_elements(){
|
455 |
|
456 |
$labels = array(
|
457 |
-
'name'
|
458 |
'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'cf7_style' ),
|
459 |
'menu_name' => __( 'Contact Style', 'cf7_style' ),
|
460 |
'parent_item_colon' => __( 'Parent Style:', 'cf7_style' ),
|
@@ -470,23 +399,23 @@ function cf7style_load_elements(){
|
|
470 |
);
|
471 |
$args = array(
|
472 |
'label' => __( 'cf7_style', 'cf7_style' ),
|
473 |
-
'description'
|
474 |
'labels' => $labels,
|
475 |
-
'supports'
|
476 |
-
'hierarchical'
|
477 |
-
'taxonomies'
|
478 |
'public' => true,
|
479 |
-
'show_ui'
|
480 |
-
'show_in_menu'
|
481 |
-
'show_in_nav_menus'
|
482 |
-
'show_in_admin_bar'
|
483 |
-
'menu_icon'
|
484 |
-
'menu_position'
|
485 |
-
'can_export'
|
486 |
-
'has_archive'
|
487 |
-
'exclude_from_search'
|
488 |
-
'publicly_queryable'
|
489 |
-
'capability_type'
|
490 |
);
|
491 |
/*register custom post type CF7_STYLE*/
|
492 |
register_post_type( 'cf7_style', $args );
|
@@ -497,66 +426,131 @@ function cf7style_load_elements(){
|
|
497 |
'menu_name' => __( 'Categories', 'cf7_style' ),
|
498 |
'all_items' => __( 'All Categories', 'cf7_style' ),
|
499 |
'parent_item' => __( 'Parent Categories', 'cf7_style' ),
|
500 |
-
'parent_item_colon'
|
501 |
-
'new_item_name'
|
502 |
-
'add_new_item'
|
503 |
'edit_item' => __( 'Edit Categories', 'cf7_style' ),
|
504 |
'update_item' => __( 'Update Categories', 'cf7_style' ),
|
505 |
-
'separate_items_with_commas'
|
506 |
'search_items' => __( 'Search Categories', 'cf7_style' ),
|
507 |
-
'add_or_remove_items'
|
508 |
-
'choose_from_most_used'
|
509 |
'not_found' => __( 'Not Found', 'cf7_style' ),
|
510 |
);
|
511 |
$args = array(
|
512 |
-
'labels'
|
513 |
-
'hierarchical'
|
514 |
-
'public'
|
515 |
-
'show_ui'
|
516 |
'show_admin_column' => true,
|
517 |
'show_in_nav_menus' => false,
|
518 |
-
'show_tagcloud'
|
519 |
);
|
520 |
//register tax
|
521 |
register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
|
522 |
-
|
523 |
-
if(
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
if (
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
}
|
538 |
}
|
|
|
539 |
}
|
540 |
-
update_option( 'cf7_style_add_categories', 1 );
|
541 |
}
|
542 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
require_once( 'cf7-style-meta-box.php' );
|
544 |
if ( ! is_admin() ) {
|
545 |
-
wp_enqueue_script('jquery');
|
546 |
-
wp_enqueue_style( "cf7-style-frontend-style", plugin_dir_url( __FILE__ ) . "css/frontend.css", false, set_styleversion(), "all");
|
547 |
-
wp_enqueue_style( "cf7-style-frontend-responsive-style", plugin_dir_url( __FILE__ ) . "css/responsive.css", false, set_styleversion(), "all");
|
548 |
-
wp_enqueue_script( "cf7-style-frontend-script", plugin_dir_url( __FILE__ ) . "js/frontend.js", false, set_styleversion());
|
549 |
add_action('wp_head', 'cf7_style_custom_css_generator');
|
550 |
}
|
551 |
}
|
552 |
|
553 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
add_action( 'init', 'cf7style_load_elements' );
|
555 |
add_action( 'restrict_manage_posts', 'cf7_style_add_taxonomy_filters' );
|
556 |
add_action( 'publish_cf7_style', 'cf7_style_set_style_category_on_publish', 10, 2 );
|
557 |
add_filter( 'wpcf7_form_class_attr', 'cf7_style_add_class' );
|
558 |
add_filter('manage_cf7_style_posts_columns', 'cf7_style_event_table_head');
|
559 |
add_action( 'manage_cf7_style_posts_custom_column', 'cf7_style_event_table_content', 10, 2 );
|
|
|
560 |
function cf7_style_event_table_head( $defaults ) {
|
561 |
$new = array();
|
562 |
foreach( $defaults as $key=>$value) {
|
@@ -585,24 +579,18 @@ function cf7_style_deactivate() {
|
|
585 |
register_deactivation_hook( __FILE__, 'cf7_style_deactivate' );
|
586 |
|
587 |
/*
|
588 |
-
* Function created for deactivated Contact Form 7 Designer
|
589 |
* This is because styles of that plugin is in conflict with ours.
|
590 |
* No one should add an id in the html tag.
|
591 |
*/
|
592 |
function deactivate_contact_form_7_designer_plugin() {
|
593 |
-
//designer
|
594 |
if ( is_plugin_active('contact-form-7-designer/cf7-styles.php') ) {
|
595 |
deactivate_plugins('contact-form-7-designer/cf7-styles.php');
|
596 |
add_action( 'admin_notices', 'cf7_designer_deactivation_notice' );
|
597 |
}
|
598 |
-
//skins
|
599 |
-
if ( is_plugin_active('cf7-skins-beta/index.php') ) {
|
600 |
-
deactivate_plugins('cf7-skins-beta/index.php');
|
601 |
-
add_action( 'admin_notices', 'cf7_skins_deactivation_notice' );
|
602 |
-
}
|
603 |
-
|
604 |
}
|
605 |
add_action('admin_init', 'deactivate_contact_form_7_designer_plugin');
|
|
|
606 |
/*
|
607 |
* notice for the user
|
608 |
*/
|
@@ -613,25 +601,83 @@ function cf7_designer_deactivation_notice() { ?>
|
|
613 |
<?php }
|
614 |
|
615 |
/*
|
616 |
-
*
|
617 |
*/
|
618 |
-
|
619 |
-
<div class="error">
|
620 |
-
<p>You cannot activate CF7 Skins while CF7 Style is activated!</p>
|
621 |
-
</div>
|
622 |
-
<?php }
|
623 |
-
|
624 |
/*
|
625 |
-
*
|
626 |
*/
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: Contact Form 7 Style
|
4 |
Plugin URI: http://wordpress.reea.net/contact-form-7-style/
|
5 |
Description: Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
|
6 |
+
Version: 3.0
|
7 |
+
Author: Johnny, dorumarginean, mlehelsz, MirceaR
|
8 |
+
Author URI: http://cf7style.com
|
9 |
License: GPL2
|
10 |
+
@Author: Johnny, dorumarginean, mlehelsz, MirceaR
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Include the plugin options
|
15 |
*/
|
16 |
+
define( 'WPCF7S_PLUGIN', __FILE__ );
|
17 |
+
define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
|
18 |
+
|
19 |
function set_styleversion(){
|
20 |
+
return "3.0";
|
21 |
}
|
22 |
|
23 |
function get_predefined_cf7_style_template_data() {
|
24 |
+
$templates_string = file_get_contents( plugins_url() . '/contact-form-7-style/predefined-templates.json');
|
25 |
+
$templates = json_decode($templates_string, true);
|
26 |
+
return $templates;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}// end of get_predefined_cf7_style_template_data
|
|
|
|
|
28 |
/**
|
29 |
* Get contact form 7 id
|
30 |
*
|
39 |
if (!is_object($cf7)) {
|
40 |
return false;
|
41 |
}
|
|
|
42 |
return $cf7->id();
|
43 |
}
|
44 |
}
|
45 |
|
|
|
46 |
/**
|
47 |
* Add cf7skins classes to the CF7 HTML form class
|
48 |
*
|
61 |
// Get the current CF7 form ID
|
62 |
$cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
|
63 |
$form_id = get_form_id( $cf7 );
|
|
|
64 |
$template_class = '';
|
65 |
$cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' );
|
66 |
if ( isset( $cf7_style_id[0] ) ) {
|
67 |
$cf7_style_data = get_post( $cf7_style_id[0], OBJECT );
|
68 |
+
$template_class = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ?
|
69 |
+
"cf7-style-" . $cf7_style_id[0] : $cf7_style_data->post_name;
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
// Return the modified class
|
73 |
return $template_class;
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
function active_styles() {
|
76 |
|
77 |
$args = array(
|
78 |
+
'post_type' => 'wpcf7_contact_form',
|
79 |
'post_status' => 'publish',
|
80 |
'posts_per_page' => -1
|
81 |
);
|
87 |
$form_title = get_the_title();
|
88 |
$id = get_the_ID();
|
89 |
$style_id = get_post_meta( $id, 'cf7_style_id', true );
|
|
|
90 |
if ( ! empty( $style_id ) || $style_id != 0 ) {
|
91 |
$active_styles[] = $style_id;
|
92 |
}
|
|
|
93 |
endwhile;
|
94 |
wp_reset_postdata();
|
95 |
endif;
|
|
|
96 |
return $active_styles;
|
97 |
}
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
function cf7_style_custom_css_generator(){
|
|
|
100 |
global $post;
|
101 |
if( empty( $post ) ) {
|
102 |
return false;
|
103 |
}
|
|
|
104 |
$args = array(
|
105 |
+
'post_type' => 'wpcf7_contact_form',
|
106 |
'post_status' => 'publish',
|
107 |
'posts_per_page' => -1
|
108 |
);
|
109 |
+
$forms = new WP_Query( $args );
|
110 |
+
$total_num_posts = $forms->found_posts;
|
111 |
+
$style = "";
|
112 |
+
$cf7s_manual_style = get_option( 'cf7_style_manual_style', true );
|
113 |
+
$active_styles = array();
|
114 |
+
$style_number = 0;
|
115 |
if( $forms->have_posts() ) :
|
116 |
while( $forms->have_posts() ) : $forms->the_post();
|
117 |
+
$id = get_the_ID();
|
118 |
+
$cf7s_id = get_post_meta( $id, 'cf7_style_id', true );
|
119 |
+
$form_title = get_the_title($cf7s_id);
|
|
|
120 |
if ( ( ! empty( $cf7s_id ) || $cf7s_id !== 0 ) && ! in_array( $cf7s_id, $active_styles ) ) {
|
121 |
if( empty( $active_styles ) ) {
|
122 |
+
$style .= "\n<style class='cf7-style' media='screen' type='text/css'>\n";
|
123 |
}
|
|
|
124 |
array_push( $active_styles, $cf7s_id );
|
125 |
$cf7_style_data = get_post( $cf7s_id, OBJECT );
|
126 |
+
$check_custom_style = has_term( 'custom-style', 'style_category', $cf7_style_data );
|
127 |
+
/*Check if custom style or template*/
|
128 |
+
$cf7s_slug = ( $check_custom_style ) ? $cf7s_id : sanitize_title( $form_title);
|
129 |
+
/*check if custom again*/
|
130 |
+
if( $check_custom_style ){
|
131 |
+
$cf7s_custom_settings = unserialize( get_post_meta( $cf7s_id, 'cf7_style_custom_styler', true ) );
|
132 |
+
$cf7s_custom_settings = ( empty($cf7s_custom_settings) ) ? array() : $cf7s_custom_settings;
|
133 |
+
$groundzero = "";
|
134 |
+
$groundzero_hover = "";
|
135 |
+
$groundone = "";
|
136 |
+
$groundone_hover = "";
|
137 |
+
$tempSave = "0";
|
138 |
+
$bleah = array();
|
139 |
+
$bleah_hover = array();
|
140 |
+
$i = 0;
|
141 |
+
$i_hover = 0;
|
142 |
+
$curr_tag_gen = "";
|
143 |
+
$cur_property_gen = "";
|
144 |
+
$the_hover = "no";
|
145 |
+
foreach( $cf7s_custom_settings as $setting_key => $setting ){
|
146 |
+
$setting_key_part = explode( "_", $setting_key );
|
|
|
|
|
|
|
|
|
147 |
$classelem = "body .cf7-style." . ( ( is_numeric( $cf7s_slug ) ) ? "cf7-style-".$cf7s_slug : $cf7s_slug );
|
148 |
+
$html_element = ( $setting_key_part[0] == "submit" || $setting_key_part[0] == "radio" || $setting_key_part[0] == "checkbox" ) ?
|
149 |
+
" input[type='". $setting_key_part[0]."']" : ( ( $setting_key_part[0] == "form" ) ? "" : ' '.$setting_key_part[0] );
|
150 |
+
$endtag = ( $i == 0 ) ? "" : "}\n";
|
151 |
+
$endtag_hover = ( $i_hover == 0 ) ? "" : "}\n";
|
152 |
+
$curr_tag_gen = $classelem.$html_element;
|
153 |
+
if(!empty( $setting )){
|
154 |
+
$setting = ($setting_key_part[1] == "background-image") ? 'url("'.$setting.'")' : $setting;
|
155 |
+
$cur_property_gen = "\t\t".$setting_key_part[1].": ".$setting. ";\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
+
$the_hover = ( array_key_exists (3,$setting_key_part) && $setting_key_part[3] == "hover" ) ? "yes" :
|
158 |
+
( array_key_exists (2,$setting_key_part) && $setting_key_part[2] == "hover" ) ? "yes" : "no";
|
159 |
|
160 |
+
if($the_hover == "yes"){
|
161 |
+
if( $groundzero_hover != $setting_key_part[0]){
|
162 |
+
$bleah_hover[$i_hover] = $endtag_hover.$curr_tag_gen.":hover {\n";
|
163 |
+
$groundzero_hover = $setting_key_part[0];
|
164 |
+
}
|
165 |
+
$i_hover++;
|
166 |
+
if(!empty( $setting )){
|
167 |
+
if ( $groundone_hover != $setting_key_part[1]) {
|
168 |
+
$groundone_hover = $setting_key_part[1];
|
169 |
+
$tempSave = $setting;
|
170 |
+
if( $setting != "px" && $setting != "%" && $setting != "em" ){
|
171 |
+
$bleah_hover[$i_hover] = $cur_property_gen;
|
172 |
+
}
|
173 |
+
} else {
|
174 |
+
$bleah_hover[--$i_hover] = ( $tempSave != "0" ) ? ( "\t\t".$setting_key_part[1].": ".$tempSave.$setting. ";\n") : "";
|
175 |
+
$tempSave = "0";
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}else {
|
179 |
+
if( $groundzero != $setting_key_part[0]){
|
180 |
+
$bleah[$i] = $endtag.$curr_tag_gen." {\n";
|
181 |
+
$groundzero = $setting_key_part[0];
|
182 |
+
}
|
183 |
+
$i++;
|
184 |
+
if(!empty( $setting )){
|
185 |
+
if ( $groundone != $setting_key_part[1]) {
|
186 |
+
$groundone = $setting_key_part[1];
|
187 |
+
$tempSave = $setting;
|
188 |
+
if( $setting != "px" && $setting != "%" && $setting != "em" ){
|
189 |
+
$bleah[$i] = $cur_property_gen;
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
$bleah[--$i] = ( $tempSave != "0" ) ? ( "\t\t".$setting_key_part[1].": ".$tempSave.$setting. ";\n") : "";
|
193 |
+
$tempSave = "0";
|
194 |
+
}
|
195 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
|
|
|
|
|
|
197 |
}
|
198 |
+
foreach ($bleah as $style_line) {
|
199 |
+
$style .= $style_line;
|
200 |
+
}
|
201 |
+
$style .= "}\n";
|
202 |
+
foreach ($bleah_hover as $style_line) {
|
203 |
+
$style .= $style_line;
|
204 |
+
}
|
205 |
+
$style .= "}";
|
206 |
+
}/*custom end*/
|
207 |
$font_family = return_font_name( $cf7s_id );
|
208 |
|
209 |
if( ! empty( $font_family ) && "none" !== $font_family ) {
|
210 |
if (is_numeric($cf7s_slug)) {
|
211 |
$cf7s_slug = "cf7-style-".$cf7s_slug;
|
212 |
}
|
213 |
+
$style .= "\n".'body .cf7-style.' . $cf7s_slug . ",\nbody .cf7-style." . $cf7s_slug . " input[type='submit'] {\n\t font-family: '" . $font_family . "',sans-serif;\n} ";
|
|
|
214 |
}
|
215 |
if( !empty( $cf7s_manual_style ) ){
|
216 |
$style.= "\n".$cf7s_manual_style."\n";
|
217 |
}
|
218 |
|
219 |
$style_number++;
|
220 |
+
}/*Main if ends here*/
|
|
|
221 |
|
222 |
endwhile;
|
|
|
223 |
if( ( $style_number !== 0 ) && $style_number == count( $active_styles ) ) {
|
224 |
$style .= "\n</style>\n";
|
225 |
}
|
|
|
226 |
echo $style;
|
|
|
227 |
wp_reset_postdata();
|
228 |
+
endif;
|
|
|
229 |
}// end of cf7_style_custom_css_generator
|
230 |
+
function cf7_style_admin_scripts($hook){
|
231 |
+
global $post_type;
|
232 |
+
$cur_plug_url = plugin_dir_url( __FILE__ );
|
233 |
+
wp_enqueue_style( "cf7-style-bar-style", $cur_plug_url . "css/admin-bar.css", array(), set_styleversion(), "all");
|
234 |
+
if( 'cf7_style_page_cf7style-css-editor' == $hook ){
|
235 |
+
wp_enqueue_script( "cf7_style_codemirror_js", $cur_plug_url . "admin/js/codemirror.js", array( 'jquery' ), false, true );
|
236 |
+
wp_enqueue_style( "cf7-style-codemirror-style", $cur_plug_url . "admin/css/codemirror.css", array(), set_styleversion(), "all" );
|
237 |
+
wp_enqueue_script( "cf7-style-codemirror-mode", $cur_plug_url . "admin/js/mode/css/css.js", array( 'jquery' ), false, true );
|
238 |
+
}
|
239 |
+
if( 'cf7_style' == $post_type){
|
240 |
+
wp_enqueue_style( 'wp-color-picker' );
|
241 |
+
wp_enqueue_script( 'thickbox' );
|
242 |
+
wp_enqueue_style( 'thickbox' );
|
243 |
+
wp_enqueue_script( 'media-upload' );
|
244 |
+
}
|
245 |
+
if( 'plugins.php'== $hook || 'cf7_style' == $post_type || 'toplevel_page_wpcf7' == $hook || 'cf7_style_page_cf7style-css-editor' == $hook){
|
246 |
+
wp_enqueue_style('cf7-style-font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css');
|
247 |
+
wp_enqueue_style( "cf7-style-admin-style", $cur_plug_url . "admin/css/admin.css", false, "1.0", "all");
|
248 |
+
wp_enqueue_script( "cf7_style_admin_js", $cur_plug_url . "admin/js/admin.js", array( 'wp-color-picker' ), false, true );
|
249 |
+
}
|
250 |
}
|
251 |
function cf7_style_add_class( $class ){
|
252 |
global $post;
|
267 |
|
268 |
if ( ! in_array( $required_plugin, $active_plugins ) ) {
|
269 |
|
270 |
+
$html = '<div class="error">';
|
271 |
$html .= '<p>';
|
272 |
$html .= 'Contact form 7 - Style is an addon. Please install <a href="http://wordpress.org/plugins/contact-form-7/" target="_blank">Contact form 7</a>.';
|
273 |
$html .= '</p>';
|
285 |
$html .= '</div><!-- /.updated -->';
|
286 |
echo $html;
|
287 |
update_option( 'cf7_style_cookie', true );
|
288 |
+
} // end if !$cf7_style_cookie
|
289 |
+
$cf7_style_templates = get_option( 'cf7_style_no_temps' );
|
290 |
+
if($cf7_style_templates != "hide_box"){
|
291 |
+
$box = '<div class="updated template-message-box">';
|
292 |
+
$box .= '<p><label><input type="checkbox" name="custom_template_check" checked="checked" />Keep predefined Contact Form 7 Style templates ?</label></p>';
|
293 |
+
$box .= '<div class="double-check hidden">';
|
294 |
+
$box .= '<label>Are you sure you want to remove the predefined templates? ';
|
295 |
+
$box .= '<span>Yes</span><input type="radio" name="double_check_template" value="yes" />';
|
296 |
+
$box .= '</label><label>';
|
297 |
+
$box .= '<span>No</span><input type="radio" name="double_check_template" value="no" checked="checked" /></label>';
|
298 |
+
$box .= '<a href="#" class="confirm-remove-template button">Confirm</a>';
|
299 |
+
$box .= '</div><a href="#" class="remove_template_notice">Dismiss</a>';
|
300 |
+
$box .= '<div style="clear:both;"></div>';
|
301 |
+
$box .= '</div>';
|
302 |
+
echo $box;
|
303 |
+
}
|
304 |
}
|
305 |
} // end if $active_plugins
|
306 |
}
|
309 |
function cf7_style_create_post( $slug, $title, $image) {
|
310 |
// Initialize the page ID to -1. This indicates no action has been taken.
|
311 |
$post_id = -1;
|
|
|
312 |
if( null == get_page_by_title( $title, "OBJECT", "cf7_style" ) ) {
|
313 |
// Set the post ID so that we know the post was created successfully
|
314 |
$post_id = wp_insert_post(
|
373 |
}
|
374 |
} // end cf7_style_set_style_category_on_publish
|
375 |
function cf7_style_create_posts(){
|
376 |
+
update_option( 'cf7_style_no_temps', 'show_box' );
|
377 |
+
update_option( 'cf7_style_welcome', 'show_box' );
|
378 |
+
update_option( 'cf7_style_update_saved', 'yes' );
|
|
|
379 |
}
|
380 |
// Hook into the 'cf7_style_create_posts' action
|
381 |
register_activation_hook( __FILE__, 'cf7_style_create_posts' );
|
383 |
function cf7style_load_elements(){
|
384 |
|
385 |
$labels = array(
|
386 |
+
'name' => _x( 'Contact Styles', 'Post Type General Name', 'cf7_style' ),
|
387 |
'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'cf7_style' ),
|
388 |
'menu_name' => __( 'Contact Style', 'cf7_style' ),
|
389 |
'parent_item_colon' => __( 'Parent Style:', 'cf7_style' ),
|
399 |
);
|
400 |
$args = array(
|
401 |
'label' => __( 'cf7_style', 'cf7_style' ),
|
402 |
+
'description' => __( 'Add/remove contact style', 'cf7_style' ),
|
403 |
'labels' => $labels,
|
404 |
+
'supports' => array( 'title' ),
|
405 |
+
'hierarchical' => false,
|
406 |
+
'taxonomies' => array('style_category'),
|
407 |
'public' => true,
|
408 |
+
'show_ui' => true,
|
409 |
+
'show_in_menu' => true,
|
410 |
+
'show_in_nav_menus' => false,
|
411 |
+
'show_in_admin_bar' => false,
|
412 |
+
'menu_icon' => "dashicons-twitter",
|
413 |
+
'menu_position' => 28.555555,
|
414 |
+
'can_export' => true,
|
415 |
+
'has_archive' => false,
|
416 |
+
'exclude_from_search' => true,
|
417 |
+
'publicly_queryable' => false,
|
418 |
+
'capability_type' => 'page'
|
419 |
);
|
420 |
/*register custom post type CF7_STYLE*/
|
421 |
register_post_type( 'cf7_style', $args );
|
426 |
'menu_name' => __( 'Categories', 'cf7_style' ),
|
427 |
'all_items' => __( 'All Categories', 'cf7_style' ),
|
428 |
'parent_item' => __( 'Parent Categories', 'cf7_style' ),
|
429 |
+
'parent_item_colon' => __( 'Parent Categories:', 'cf7_style' ),
|
430 |
+
'new_item_name' => __( 'New Categories Name', 'cf7_style' ),
|
431 |
+
'add_new_item' => __( 'Add New Categories', 'cf7_style' ),
|
432 |
'edit_item' => __( 'Edit Categories', 'cf7_style' ),
|
433 |
'update_item' => __( 'Update Categories', 'cf7_style' ),
|
434 |
+
'separate_items_with_commas' => __( 'Separate Categories with commas', 'cf7_style' ),
|
435 |
'search_items' => __( 'Search Categories', 'cf7_style' ),
|
436 |
+
'add_or_remove_items' => __( 'Add or remove Categories', 'cf7_style' ),
|
437 |
+
'choose_from_most_used' => __( 'Choose from the most used Categories', 'cf7_style' ),
|
438 |
'not_found' => __( 'Not Found', 'cf7_style' ),
|
439 |
);
|
440 |
$args = array(
|
441 |
+
'labels' => $labels,
|
442 |
+
'hierarchical' => true,
|
443 |
+
'public' => true,
|
444 |
+
'show_ui' => false,
|
445 |
'show_admin_column' => true,
|
446 |
'show_in_nav_menus' => false,
|
447 |
+
'show_tagcloud' => true,
|
448 |
);
|
449 |
//register tax
|
450 |
register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
|
451 |
+
$cf7_style_templates = get_option( 'cf7_style_no_temps' );
|
452 |
+
if( $cf7_style_templates == 'show_box'){
|
453 |
+
//die();
|
454 |
+
foreach ( get_predefined_cf7_style_template_data() as $style ) {
|
455 |
+
cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
|
456 |
+
}
|
457 |
+
if( get_option( 'cf7_style_add_categories', 0 ) == 0 ){
|
458 |
+
$cf7_style_args = array(
|
459 |
+
'post_type' => 'cf7_style'
|
460 |
+
);
|
461 |
+
|
462 |
+
$cf7_style_query = new WP_Query( $cf7_style_args );
|
463 |
+
if ( $cf7_style_query->have_posts() ) {
|
464 |
+
while ( $cf7_style_query->have_posts() ) {
|
465 |
+
$cf7_style_query->the_post();
|
466 |
+
$temp_title = get_the_title();
|
467 |
+
$temp_ID = get_the_ID();
|
468 |
+
|
469 |
+
foreach ( get_predefined_cf7_style_template_data() as $style ) {
|
470 |
+
if( $temp_title == wptexturize( $style[ 'title' ] ) ) {
|
471 |
+
wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' );
|
472 |
+
}
|
473 |
}
|
474 |
}
|
475 |
+
update_option( 'cf7_style_add_categories', 1 );
|
476 |
}
|
|
|
477 |
}
|
478 |
}
|
479 |
+
$cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
|
480 |
+
if( $cf7_style_update_saved == "yes" ) {
|
481 |
+
$cf7_style_args = array(
|
482 |
+
'post_type' => 'cf7_style',
|
483 |
+
'style_category' => 'custom-style',
|
484 |
+
'posts_per_page' => '-1'
|
485 |
+
);
|
486 |
+
$cf7s_manual_old_style = "";
|
487 |
+
$new_settings = array();
|
488 |
+
$cf7_style_query = new WP_Query( $cf7_style_args );
|
489 |
+
if ( $cf7_style_query->have_posts() ) {
|
490 |
+
while ( $cf7_style_query->have_posts() ) {
|
491 |
+
$cf7_style_query->the_post();
|
492 |
+
$cur_style_id = get_the_ID();
|
493 |
+
$cur_manual_style = get_post_meta( $cur_style_id, 'cf7_style_manual_style', true );
|
494 |
+
$cur_custom_styles = get_post_meta( $cur_style_id, 'cf7_style_custom_styles', true );
|
495 |
+
if($cur_manual_style){
|
496 |
+
$cf7s_manual_old_style .= $cur_manual_style;
|
497 |
+
update_post_meta( $cur_style_id, 'cf7_style_manual_style', '' );
|
498 |
+
}
|
499 |
+
if($cur_custom_styles){
|
500 |
+
$cf7s_custom_old_settings = unserialize($cur_custom_styles);
|
501 |
+
require_once( 'cf7-style-match-old.php' );
|
502 |
+
$new_settings = get_new_styler_data( $cf7s_custom_old_settings );
|
503 |
+
update_post_meta( $cur_style_id, 'cf7_style_manual_styles', '');
|
504 |
+
update_post_meta( $cur_style_id, 'cf7_style_custom_styler', serialize( $new_settings ), "");
|
505 |
+
}
|
506 |
+
}
|
507 |
+
if($cf7s_manual_old_style){
|
508 |
+
update_option( 'cf7_style_manual_style', $cf7s_manual_old_style );
|
509 |
+
}
|
510 |
+
}
|
511 |
+
update_option( 'cf7_style_update_saved', 'no' );
|
512 |
+
}
|
513 |
require_once( 'cf7-style-meta-box.php' );
|
514 |
if ( ! is_admin() ) {
|
|
|
|
|
|
|
|
|
515 |
add_action('wp_head', 'cf7_style_custom_css_generator');
|
516 |
}
|
517 |
}
|
518 |
|
519 |
+
function cf7_style_frontend_scripts(){
|
520 |
+
$plug_dir_url = plugin_dir_url( __FILE__ );
|
521 |
+
$cf7_style_templates = get_option( 'cf7_style_no_temps' );
|
522 |
+
if (!wp_script_is( 'jquery', 'enqueued' )) {
|
523 |
+
wp_enqueue_script('jquery');
|
524 |
+
}
|
525 |
+
wp_enqueue_style( "cf7-style-bar-style", $plug_dir_url . "css/admin-bar.css", array(), set_styleversion(), "all");
|
526 |
+
wp_enqueue_style( "cf7-style-frontend-style", $plug_dir_url . "css/frontend.css", array(), set_styleversion(), "all");
|
527 |
+
wp_enqueue_style( "cf7-style-responsive-style", $plug_dir_url . "css/responsive.css", array(), set_styleversion(), "all");
|
528 |
+
wp_enqueue_script( "cf7-style-frontend-script", $plug_dir_url . "js/frontend.js", array( 'jquery' ), set_styleversion(), true);
|
529 |
+
}
|
530 |
+
function cf7style_toolbar_link($wp_admin_bar) {
|
531 |
+
$args = array(
|
532 |
+
'id' => 'cf7-style',
|
533 |
+
'title' => 'Contact Form Style',
|
534 |
+
'href' => admin_url("edit.php?post_type=cf7_style"),
|
535 |
+
'meta' => array(
|
536 |
+
'class' => 'contact-style',
|
537 |
+
'title' => 'Contact Form Style',
|
538 |
+
'html' => '<span class="admin-style-icon"><i class="dashicons-before dashicons-twitter" aria-hidden="true"></i></span>'
|
539 |
+
)
|
540 |
+
);
|
541 |
+
$wp_admin_bar->add_node($args);
|
542 |
+
}
|
543 |
+
add_action('admin_bar_menu', 'cf7style_toolbar_link', 999);
|
544 |
+
|
545 |
+
add_action( 'admin_enqueue_scripts', 'cf7_style_admin_scripts' );
|
546 |
+
add_action( 'wp_enqueue_scripts', 'cf7_style_frontend_scripts' );
|
547 |
add_action( 'init', 'cf7style_load_elements' );
|
548 |
add_action( 'restrict_manage_posts', 'cf7_style_add_taxonomy_filters' );
|
549 |
add_action( 'publish_cf7_style', 'cf7_style_set_style_category_on_publish', 10, 2 );
|
550 |
add_filter( 'wpcf7_form_class_attr', 'cf7_style_add_class' );
|
551 |
add_filter('manage_cf7_style_posts_columns', 'cf7_style_event_table_head');
|
552 |
add_action( 'manage_cf7_style_posts_custom_column', 'cf7_style_event_table_content', 10, 2 );
|
553 |
+
|
554 |
function cf7_style_event_table_head( $defaults ) {
|
555 |
$new = array();
|
556 |
foreach( $defaults as $key=>$value) {
|
579 |
register_deactivation_hook( __FILE__, 'cf7_style_deactivate' );
|
580 |
|
581 |
/*
|
582 |
+
* Function created for deactivated Contact Form 7 Designer plugin.
|
583 |
* This is because styles of that plugin is in conflict with ours.
|
584 |
* No one should add an id in the html tag.
|
585 |
*/
|
586 |
function deactivate_contact_form_7_designer_plugin() {
|
|
|
587 |
if ( is_plugin_active('contact-form-7-designer/cf7-styles.php') ) {
|
588 |
deactivate_plugins('contact-form-7-designer/cf7-styles.php');
|
589 |
add_action( 'admin_notices', 'cf7_designer_deactivation_notice' );
|
590 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
}
|
592 |
add_action('admin_init', 'deactivate_contact_form_7_designer_plugin');
|
593 |
+
|
594 |
/*
|
595 |
* notice for the user
|
596 |
*/
|
601 |
<?php }
|
602 |
|
603 |
/*
|
604 |
+
* Tracking feature
|
605 |
*/
|
606 |
+
require_once( 'misc/tracking.php' );
|
|
|
|
|
|
|
|
|
|
|
607 |
/*
|
608 |
+
* Welcome panel
|
609 |
*/
|
610 |
+
require_once( 'misc/welcome.php' );
|
611 |
+
/*
|
612 |
+
* Slider meta box in CF7
|
613 |
+
*/
|
614 |
+
require_once( 'inc/slider_meta_box.php' );
|
615 |
+
/*
|
616 |
+
* global css page
|
617 |
+
*/
|
618 |
+
require_once( 'inc/editor_page.php' );
|
619 |
+
/*
|
620 |
+
* Remove Predefined templates
|
621 |
+
*/
|
622 |
+
function cf7_style_remove_templates() {
|
623 |
+
global $wpdb;
|
624 |
+
$del_args = array(
|
625 |
+
'posts_per_page' => -1,
|
626 |
+
'post_type' => 'cf7_style',
|
627 |
+
'tax_query' => array(
|
628 |
+
array(
|
629 |
+
'taxonomy' => 'style_category',
|
630 |
+
'field' => 'slug',
|
631 |
+
'terms' => 'custom-style',
|
632 |
+
'operator' => 'NOT IN',
|
633 |
+
),
|
634 |
+
),
|
635 |
+
);
|
636 |
+
$del_query = new WP_Query( $del_args );
|
637 |
+
if ( $del_query->have_posts() ) {
|
638 |
+
while ( $del_query->have_posts() ) {
|
639 |
+
$del_query->the_post();
|
640 |
+
wp_delete_post(get_the_ID(),false);
|
641 |
+
}
|
642 |
+
print_r('success');
|
643 |
+
}
|
644 |
+
wp_die();
|
645 |
+
}
|
646 |
+
add_action( 'wp_ajax_cf7_style_remove_templates', 'cf7_style_remove_templates' );
|
647 |
+
function cf7_style_remove_box() {
|
648 |
+
global $wpdb;
|
649 |
+
update_option( 'cf7_style_no_temps', 'hide_box' );
|
650 |
+
wp_die();
|
651 |
+
}
|
652 |
+
add_action( 'wp_ajax_cf7_style_remove_box', 'cf7_style_remove_box' );
|
653 |
+
function cf7_style_remove_welcome_box() {
|
654 |
+
global $wpdb;
|
655 |
+
update_option( 'cf7_style_welcome', 'hide_box' );
|
656 |
+
wp_die();
|
657 |
+
}
|
658 |
+
add_action( 'wp_ajax_cf7_style_remove_welcome_box', 'cf7_style_remove_welcome_box' );
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Frontend edit link
|
662 |
+
*/
|
663 |
+
|
664 |
+
function cf7_style_frontend_edit_link( $form ) {
|
665 |
+
|
666 |
+
if( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
|
667 |
+
|
668 |
+
$cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
|
669 |
+
$form_id = get_form_id( $cf7 );
|
670 |
+
$cf7_style_id = get_post_meta( $form_id, 'cf7_style_id', true );
|
671 |
+
|
672 |
+
if( empty( $cf7_style_id ) ) {
|
673 |
+
$form .= "<a href='" . admin_url( 'edit.php?post_type=cf7_style' ) . "' class='frontend-edit-style-link'>" . __( 'Add Style', 'cf7_style' ) . "</a>";
|
674 |
+
} else {
|
675 |
+
$cf7_style_data = get_post( $cf7_style_id, OBJECT );
|
676 |
+
$template_type = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ? __( 'Edit custom style', 'cf7_style' ) : __( 'Edit predifined template', 'cf7_style' );
|
677 |
+
$form .= "<a href='" . admin_url( 'post.php?post=' . $cf7_style_id . '&action=edit' ) . "' class='frontend-edit-style-link'>" . $template_type . "</a>";
|
678 |
+
}
|
679 |
+
}
|
680 |
+
|
681 |
+
return $form;
|
682 |
+
}
|
683 |
+
add_filter( 'wpcf7_form_elements', 'cf7_style_frontend_edit_link' );
|
css/admin-bar.css
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#wp-admin-bar-cf7-style a {
|
2 |
+
display: block;
|
3 |
+
float: right;
|
4 |
+
}
|
5 |
+
|
6 |
+
#wpadminbar .admin-style-icon {
|
7 |
+
float: right;
|
8 |
+
padding-top: 7px;
|
9 |
+
display: block;
|
10 |
+
margin-right: -4px;
|
11 |
+
margin-left: 10px;
|
12 |
+
}
|
13 |
+
|
14 |
+
#wpadminbar .admin-style-icon:after {
|
15 |
+
color: #000;
|
16 |
+
content: ".";
|
17 |
+
font-size: 10px;
|
18 |
+
left: 22px;
|
19 |
+
position: absolute;
|
20 |
+
top: -6px;
|
21 |
+
}
|
css/frontend.css
CHANGED
@@ -14,6 +14,8 @@
|
|
14 |
* 3.0 - Simple Style
|
15 |
* -----------------------------------------------------------------------------
|
16 |
*/
|
|
|
|
|
17 |
/**
|
18 |
* Reset
|
19 |
*
|
@@ -66,6 +68,8 @@ body .cf7-style div.wpcf7-response-output.wpcf7-mail-sent-ok {
|
|
66 |
color: green;
|
67 |
border: 2px solid green;
|
68 |
}
|
|
|
|
|
69 |
/**
|
70 |
* Valentine's Day
|
71 |
*
|
@@ -78,9 +82,15 @@ body .valentines-day-classic input.wpcf7-form-control.wpcf7-number,
|
|
78 |
body .valentines-day-classic input.wpcf7-form-control.wpcf7-date,
|
79 |
body .valentines-day-classic textarea.wpcf7-form-control.wpcf7-textarea,
|
80 |
body .valentines-day-classic select.wpcf7-form-control.wpcf7-select,
|
81 |
-
body .valentines-day-classic input.wpcf7-form-control.wpcf7-quiz
|
|
|
|
|
|
|
|
|
82 |
margin: 5px 0 0;
|
83 |
padding: 15px 10px;
|
|
|
|
|
84 |
border-left: 1px solid #AAA;
|
85 |
border-bottom: 1px solid #AAA;
|
86 |
outline: 0;
|
@@ -96,27 +106,16 @@ body .valentines-day-classic input.wpcf7-form-control.wpcf7-quiz {
|
|
96 |
box-sizing: border-box;
|
97 |
}
|
98 |
|
99 |
-
body .valentines-day-classic textarea.wpcf7-form-control.wpcf7-textarea,
|
100 |
body .valentines-day-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
101 |
border: none;
|
102 |
}
|
103 |
|
104 |
body .wpcf7 form.valentines-day-classic p {
|
105 |
-
margin-bottom:
|
106 |
font-size: 16px;
|
107 |
color: #222;
|
108 |
}
|
109 |
|
110 |
-
body .valentines-day-classic input.wpcf7-form-control.wpcf7-submit {
|
111 |
-
position: absolute;
|
112 |
-
right: 0;
|
113 |
-
-webkit-transition: none;
|
114 |
-
-moz-transition: none;
|
115 |
-
-ms-transition: none;
|
116 |
-
-o-transition: none;
|
117 |
-
transition: none;
|
118 |
-
}
|
119 |
-
|
120 |
body .valentines-day-classic {
|
121 |
background: url('../images/vday-classic/hearted-bg.png') -45px 0 repeat;
|
122 |
position: relative;
|
@@ -139,8 +138,13 @@ body .valentines-day-classic p {
|
|
139 |
text-shadow: 1px 1px #FFF;
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
142 |
body .valentines-day-classic input,
|
143 |
-
body .valentines-day-classic textarea
|
|
|
144 |
background: rgba(255, 255, 255, 0.7);
|
145 |
border: none;
|
146 |
border-left: 1px solid #AAA;
|
@@ -161,8 +165,9 @@ body .valentines-day-classic textarea:focus {
|
|
161 |
border-bottom: 1px solid #AAA;
|
162 |
}
|
163 |
|
164 |
-
body .valentines-day-classic input.wpcf7-form-control.wpcf7-submit
|
165 |
-
body .valentines-day-classic .wpcf7-submit
|
|
|
166 |
-webkit-box-shadow: none;
|
167 |
-moz-box-shadow: none;
|
168 |
box-shadow: none;
|
@@ -170,40 +175,32 @@ body .valentines-day-classic .wpcf7-submit {
|
|
170 |
-moz-border-radius: 10px;
|
171 |
border-radius: 10px;
|
172 |
border: none;
|
173 |
-
height: 20px;
|
174 |
-
line-height: normal;
|
175 |
text-align: center;
|
176 |
-
padding: 20px;
|
177 |
min-width: 90px;
|
178 |
background: rgb(125, 185, 232);
|
179 |
/* Old browsers */
|
180 |
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
|
181 |
-
|
182 |
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzdkYjllOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZDU0ZTRlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMzklIiBzdG9wLWNvbG9yPSIjZDQwMDAwIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iODUlIiBzdG9wLWNvbG9yPSIjOTQwYTBhIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==);
|
183 |
background: -moz-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
184 |
/* FF3.6+ */
|
185 |
-
|
186 |
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(125, 185, 232, 1)), color-stop(0%, rgba(213, 78, 78, 1)), color-stop(39%, rgba(212, 0, 0, 1)), color-stop(85%, rgba(148, 10, 10, 1)));
|
187 |
/* Chrome,Safari4+ */
|
188 |
-
|
189 |
background: -webkit-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
190 |
/* Chrome10+,Safari5.1+ */
|
191 |
-
|
192 |
background: -o-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
193 |
/* Opera 11.10+ */
|
194 |
-
|
195 |
background: -ms-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
196 |
/* IE10+ */
|
197 |
-
|
198 |
background: linear-gradient(to right, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
199 |
/* W3C */
|
200 |
-
|
201 |
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#7db9e8', endColorstr='#940a0a', GradientType=1);
|
202 |
/* IE6-8 */
|
203 |
-
|
204 |
color: #FFF;
|
205 |
float: right;
|
206 |
text-shadow: 1px 1px #555;
|
|
|
207 |
}
|
208 |
|
209 |
body .valentines-day-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]):focus,
|
@@ -227,6 +224,118 @@ body .valentines-day-classic div.wpcf7-response-output.wpcf7-mail-sent-ok {
|
|
227 |
color: green;
|
228 |
border: solid 1px green;
|
229 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
/**
|
231 |
* Valentine's Day
|
232 |
*
|
@@ -239,7 +348,8 @@ body .valentines-day-roses input.wpcf7-form-control.wpcf7-number,
|
|
239 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-date,
|
240 |
body .valentines-day-roses textarea.wpcf7-form-control.wpcf7-textarea,
|
241 |
body .valentines-day-roses select.wpcf7-form-control.wpcf7-select,
|
242 |
-
body .valentines-day-roses input.wpcf7-form-control.wpcf7-quiz
|
|
|
243 |
margin: 5px 0 0;
|
244 |
padding: 15px 10px;
|
245 |
border-bottom: 1px solid #490706;
|
@@ -248,12 +358,19 @@ body .valentines-day-roses input.wpcf7-form-control.wpcf7-quiz {
|
|
248 |
font-size: 13px;
|
249 |
line-height: 17px;
|
250 |
background: none;
|
251 |
-
color: #
|
252 |
font-family: 'Raleway';
|
253 |
font-weight: normal;
|
254 |
-
-webkit-box-sizing:
|
255 |
-
-moz-box-sizing:
|
256 |
-
box-sizing:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
body .valentines-day-roses textarea.wpcf7-form-control.wpcf7-textarea,
|
@@ -262,9 +379,13 @@ body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit:not([disabled])
|
|
262 |
}
|
263 |
|
264 |
body .wpcf7 form.valentines-day-roses p {
|
265 |
-
margin-bottom:
|
266 |
font-size: 16px;
|
267 |
-
color: #
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit {
|
@@ -279,9 +400,8 @@ body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit {
|
|
279 |
|
280 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit:not([disabled]):focus,
|
281 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit:not([disabled]):hover {
|
282 |
-
background:
|
283 |
border: none;
|
284 |
-
color: #7F2A3A;
|
285 |
}
|
286 |
|
287 |
body .valentines-day-roses {
|
@@ -299,11 +419,6 @@ body .valentines-day-roses {
|
|
299 |
clear: both;
|
300 |
}
|
301 |
|
302 |
-
body .valentines-day-roses input[type="text"],
|
303 |
-
body .valentines-day-roses input[type="email"],
|
304 |
-
body .valentines-day-roses input[type="url"],
|
305 |
-
body .valentines-day-roses input[type="password"],
|
306 |
-
body .valentines-day-roses input[type="search"],
|
307 |
body .valentines-day-roses textarea {
|
308 |
width: 92%;
|
309 |
}
|
@@ -334,12 +449,16 @@ body .valentines-day-roses .letter-box {
|
|
334 |
background: #826e50 url(../images/vday-rose/contact-bg.png) 0 0 no-repeat;
|
335 |
width: 285px;
|
336 |
margin: 32px 0 0 -50px;
|
337 |
-
padding: 35px 15px
|
|
|
|
|
|
|
|
|
338 |
}
|
339 |
|
340 |
-
body .valentines-day-roses .wpcf7-submit {
|
341 |
position: absolute;
|
342 |
-
bottom:
|
343 |
right: 20px;
|
344 |
border: none;
|
345 |
padding: 7px 15px;
|
@@ -375,6 +494,8 @@ body .valentines-day-roses div.wpcf7-response-output.wpcf7-mail-sent-ok {
|
|
375 |
background: none repeat scroll 0 0 rgba( 255, 255, 255, 0.6);
|
376 |
border: none;
|
377 |
}
|
|
|
|
|
378 |
/**
|
379 |
* Valentine's Day
|
380 |
*
|
@@ -387,7 +508,9 @@ body .valentines-day-birds input.wpcf7-form-control.wpcf7-number,
|
|
387 |
body .valentines-day-birds input.wpcf7-form-control.wpcf7-date,
|
388 |
body .valentines-day-birds textarea.wpcf7-form-control.wpcf7-textarea,
|
389 |
body .valentines-day-birds select.wpcf7-form-control.wpcf7-select,
|
390 |
-
body .valentines-day-birds input.wpcf7-form-control.wpcf7-quiz
|
|
|
|
|
391 |
margin: 0 0 5px 0;
|
392 |
padding: 8px 10px;
|
393 |
border: 2px dashed #000;
|
@@ -414,7 +537,8 @@ body .valentines-day-birds input.wpcf7-form-control.wpcf7-text,
|
|
414 |
body .valentines-day-birds input.wpcf7-form-control.wpcf7-number,
|
415 |
body .valentines-day-birds input.wpcf7-form-control.wpcf7-date,
|
416 |
body .valentines-day-birds textarea.wpcf7-form-control.wpcf7-textarea,
|
417 |
-
body .valentines-day-birds select.wpcf7-form-control.wpcf7-select
|
|
|
418 |
width: 100%;
|
419 |
}
|
420 |
|
@@ -451,6 +575,10 @@ body .valentines-day-birds div.wpcf7-response-output.wpcf7-validation-errors:bef
|
|
451 |
display: none;
|
452 |
}
|
453 |
|
|
|
|
|
|
|
|
|
454 |
body .valentines-day-birds {
|
455 |
position: relative;
|
456 |
width: 280px;
|
@@ -485,8 +613,9 @@ body .valentines-day-birds .bg-bottom {
|
|
485 |
}
|
486 |
|
487 |
body .wpcf7 form.valentines-day-birds p {
|
488 |
-
margin:
|
489 |
color: #222;
|
|
|
490 |
}
|
491 |
|
492 |
body .valentines-day-birds input,
|
@@ -541,6 +670,8 @@ body .valentines-day-birds .wpcf7-validation-errors {
|
|
541 |
body .valentines-day-birds .wpcf7-mail-sent-ok {
|
542 |
color: green;
|
543 |
}
|
|
|
|
|
544 |
/**
|
545 |
* Valentine's Day
|
546 |
*
|
@@ -553,7 +684,8 @@ body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-number,
|
|
553 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-date,
|
554 |
body .valentines-day-blue-birds textarea.wpcf7-form-control.wpcf7-textarea,
|
555 |
body .valentines-day-blue-birds select.wpcf7-form-control.wpcf7-select,
|
556 |
-
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-quiz
|
|
|
557 |
margin: 5px 0 0;
|
558 |
padding: 15px;
|
559 |
border: 0;
|
@@ -570,12 +702,24 @@ body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-quiz {
|
|
570 |
box-sizing: border-box;
|
571 |
}
|
572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
574 |
border: none;
|
575 |
}
|
576 |
|
577 |
body .wpcf7 form.valentines-day-blue-birds p {
|
578 |
-
margin-bottom:
|
579 |
font-size: 16px;
|
580 |
}
|
581 |
|
@@ -589,6 +733,8 @@ body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit {
|
|
589 |
transition: none;
|
590 |
}
|
591 |
|
|
|
|
|
592 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:not([disabled]):focus,
|
593 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:not([disabled]):hover {
|
594 |
background: url("../images/vday-blue-birds/submit.png") no-repeat top right;
|
@@ -608,9 +754,8 @@ body .valentines-day-blue-birds .header {
|
|
608 |
width: 100%;
|
609 |
}
|
610 |
|
611 |
-
body .valentines-day-blue-birds input,
|
612 |
body .valentines-day-blue-birds textarea {
|
613 |
-
width:
|
614 |
display: inline-block;
|
615 |
background: #dad3c2;
|
616 |
border: none;
|
@@ -621,7 +766,7 @@ body .valentines-day-blue-birds textarea:focus {
|
|
621 |
background: #dad3c2;
|
622 |
}
|
623 |
|
624 |
-
body .valentines-day-blue-birds .wpcf7-submit {
|
625 |
background: url("../images/vday-blue-birds/submit.png") no-repeat top right;
|
626 |
line-height: 50px;
|
627 |
font-size: 30px;
|
@@ -671,6 +816,8 @@ body .valentines-day-blue-birds div.wpcf7-validation-errors {
|
|
671 |
body .valentines-day-blue-birds div.wpcf7-mail-sent-ok {
|
672 |
background: rgba( 9, 94, 0, .9);
|
673 |
}
|
|
|
|
|
674 |
/**
|
675 |
* Xmas
|
676 |
*
|
@@ -683,7 +830,8 @@ body .christmas-classic input.wpcf7-form-control.wpcf7-number,
|
|
683 |
body .christmas-classic input.wpcf7-form-control.wpcf7-date,
|
684 |
body .christmas-classic textarea.wpcf7-form-control.wpcf7-textarea,
|
685 |
body .christmas-classic select.wpcf7-form-control.wpcf7-select,
|
686 |
-
body .christmas-classic input.wpcf7-form-control.wpcf7-quiz
|
|
|
687 |
margin: 5px 0 0;
|
688 |
padding: 3px 10px;
|
689 |
border: 1px dotted #b2a28e;
|
@@ -703,11 +851,24 @@ body .christmas-classic input.wpcf7-form-control.wpcf7-quiz {
|
|
703 |
width: 100%;
|
704 |
}
|
705 |
|
|
|
|
|
|
|
|
|
706 |
body .christmas-classic textarea.wpcf7-form-control.wpcf7-textarea {
|
707 |
padding: 5px 10px;
|
708 |
height: 140px;
|
709 |
}
|
710 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
body .christmas-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
712 |
border: none;
|
713 |
}
|
@@ -755,7 +916,6 @@ body .christmas-classic .footer {
|
|
755 |
bottom: -255px;
|
756 |
margin: 0 0 0 -70px;
|
757 |
padding: 0;
|
758 |
-
|
759 |
}
|
760 |
|
761 |
body .christmas-classic input,
|
@@ -797,19 +957,30 @@ body .christmas-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]),
|
|
797 |
body .christmas-classic .wpcf7-submit {
|
798 |
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
|
799 |
border: medium none;
|
800 |
-
bottom: -
|
801 |
-
height:
|
802 |
-
left:
|
803 |
position: absolute;
|
804 |
text-indent: -9999px;
|
805 |
-
width:
|
806 |
z-index: 10;
|
807 |
}
|
808 |
|
|
|
|
|
|
|
|
|
|
|
809 |
body .christmas-classic div.wpcf7-response-output {
|
810 |
width: 84%;
|
811 |
margin: 0 auto;
|
812 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
813 |
/**
|
814 |
* Xmas
|
815 |
*
|
@@ -817,6 +988,10 @@ body .christmas-classic div.wpcf7-response-output {
|
|
817 |
* -----------------------------------------------------------------------------
|
818 |
*/
|
819 |
|
|
|
|
|
|
|
|
|
820 |
body .christmas-red input.wpcf7-form-control.wpcf7-text,
|
821 |
body .christmas-red input.wpcf7-form-control.wpcf7-number,
|
822 |
body .christmas-red input.wpcf7-form-control.wpcf7-date,
|
@@ -840,13 +1015,23 @@ body .christmas-red input.wpcf7-form-control.wpcf7-quiz {
|
|
840 |
box-sizing: border-box;
|
841 |
}
|
842 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
843 |
body .christmas-red textarea.wpcf7-form-control.wpcf7-textarea,
|
844 |
body .christmas-red input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
845 |
border: none;
|
846 |
}
|
847 |
|
848 |
body .wpcf7 form.christmas-red p {
|
849 |
-
margin-bottom:
|
850 |
font-size: 16px;
|
851 |
color: #fff;
|
852 |
}
|
@@ -883,7 +1068,7 @@ body .christmas-red .footer {
|
|
883 |
}
|
884 |
|
885 |
body .christmas-red p {
|
886 |
-
width: 370px;
|
887 |
margin: 0 auto;
|
888 |
}
|
889 |
|
@@ -892,6 +1077,7 @@ body .christmas-red textarea {
|
|
892 |
color: #222;
|
893 |
width: 100%;
|
894 |
font-size: 16px;
|
|
|
895 |
}
|
896 |
|
897 |
body .christmas-red input[type="text"],
|
@@ -899,10 +1085,16 @@ body .christmas-red input[type="email"],
|
|
899 |
body .christmas-red input[type="url"],
|
900 |
body .christmas-red input[type="password"],
|
901 |
body .christmas-red input[type="search"],
|
902 |
-
body .christmas-red textarea
|
|
|
903 |
width: 100%;
|
904 |
}
|
905 |
|
|
|
|
|
|
|
|
|
|
|
906 |
body .christmas-red input:focus,
|
907 |
body .christmas-red textarea:focus {
|
908 |
background: #fff;
|
@@ -935,7 +1127,7 @@ body .christmas-red .wpcf7-mail-sent-ok,
|
|
935 |
body .christmas-classic-validation-errors,
|
936 |
body .christmas-classic-mail-sent-ok {
|
937 |
border: none;
|
938 |
-
width: 350px;
|
939 |
font-size: 22px;
|
940 |
color: #FC8181;
|
941 |
margin-left: 25px;
|
@@ -962,17 +1154,39 @@ body .christmas-classic span.wpcf7-not-valid-tip {
|
|
962 |
border-radius: 5px;
|
963 |
}
|
964 |
|
965 |
-
body .christmas-red span.wpcf7-list-item
|
|
|
966 |
display: inline-block;
|
967 |
height: 32px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
968 |
}
|
969 |
|
970 |
-
body .christmas-red .wpcf7-radio .wpcf7-list-item {
|
971 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
972 |
}
|
973 |
|
974 |
-
body .christmas-red .wpcf7-radio .wpcf7-list-item.active
|
975 |
-
|
|
|
976 |
}
|
977 |
|
978 |
body .christmas-red .wpcf7-radio .wpcf7-list-item-label {
|
@@ -981,23 +1195,20 @@ body .christmas-red .wpcf7-radio .wpcf7-list-item-label {
|
|
981 |
}
|
982 |
|
983 |
body .christmas-red span.wpcf7-list-item input[type="radio"] {
|
|
|
|
|
984 |
width: 30px;
|
985 |
height: 30px;
|
986 |
cursor: pointer;
|
987 |
/* IE 8 */
|
988 |
-
|
989 |
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
990 |
/* IE 5-7 */
|
991 |
-
|
992 |
filter: alpha(opacity=0);
|
993 |
/* Netscape */
|
994 |
-
|
995 |
-moz-opacity: 0;
|
996 |
/* Safari 1.x */
|
997 |
-
|
998 |
-khtml-opacity: 0;
|
999 |
/* Good browsers */
|
1000 |
-
|
1001 |
opacity: 0;
|
1002 |
}
|
1003 |
|
@@ -1030,6 +1241,8 @@ body .christmas-red div.wpcf7-response-output.wpcf7-mail-sent-ok {
|
|
1030 |
body .christmas-red span.wpcf7-not-valid-tip {
|
1031 |
padding: 5px 10px 5px 0;
|
1032 |
}
|
|
|
|
|
1033 |
/**
|
1034 |
* Xmas
|
1035 |
*
|
@@ -1062,6 +1275,12 @@ body .christmas-simple p {
|
|
1062 |
body .christmas-simple p input[type="text"],
|
1063 |
body .christmas-simple p input[type="email"],
|
1064 |
body .christmas-simple p input[type="tel"],
|
|
|
|
|
|
|
|
|
|
|
|
|
1065 |
body .christmas-simple p textarea,
|
1066 |
body .christmas-simple p input[type="text"]:hover,
|
1067 |
body .christmas-simple p input[type="email"]:hover,
|
@@ -1074,6 +1293,17 @@ body .christmas-simple p textarea:focus {
|
|
1074 |
width: 94%;
|
1075 |
background: transparent;
|
1076 |
border: dashed 2px #7d5f48;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1077 |
}
|
1078 |
|
1079 |
body .christmas-simple textarea {
|
@@ -1106,9 +1336,9 @@ body .christmas-simple .footer {
|
|
1106 |
border-bottom: 2px dashed #542c0e;
|
1107 |
border-radius: 0 0 20px 20px;
|
1108 |
border-top: medium none;
|
1109 |
-
bottom: -
|
1110 |
padding-bottom: 3px;
|
1111 |
-
width:
|
1112 |
}
|
1113 |
|
1114 |
body .christmas-simple .ribbon {
|
@@ -1147,8 +1377,10 @@ body .christmas-simple input[type='submit']:hover {
|
|
1147 |
background: #e7e3d0;
|
1148 |
color: #000;
|
1149 |
}
|
|
|
|
|
1150 |
/**
|
1151 |
-
*
|
1152 |
*/
|
1153 |
|
1154 |
body .christmas-simple span.wpcf7-not-valid-tip {
|
@@ -1162,12 +1394,16 @@ body .christmas-simple span.wpcf7-not-valid-tip {
|
|
1162 |
background: #fff;
|
1163 |
border: none;
|
1164 |
}
|
|
|
|
|
1165 |
/*Christmas clasic - unique*/
|
1166 |
|
1167 |
body .christmas-classic .wpcf7-not-valid-tip {
|
1168 |
width: 100%;
|
1169 |
background: transparent;
|
1170 |
}
|
|
|
|
|
1171 |
/***
|
1172 |
* SIMPLE
|
1173 |
*
|
@@ -1243,3 +1479,30 @@ body .twenty-fifteen-pattern input[type="submit"]:hover {
|
|
1243 |
background: rgba(51, 51, 51, 0.7);
|
1244 |
outline: 0 none;
|
1245 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
* 3.0 - Simple Style
|
15 |
* -----------------------------------------------------------------------------
|
16 |
*/
|
17 |
+
|
18 |
+
|
19 |
/**
|
20 |
* Reset
|
21 |
*
|
68 |
color: green;
|
69 |
border: 2px solid green;
|
70 |
}
|
71 |
+
|
72 |
+
|
73 |
/**
|
74 |
* Valentine's Day
|
75 |
*
|
82 |
body .valentines-day-classic input.wpcf7-form-control.wpcf7-date,
|
83 |
body .valentines-day-classic textarea.wpcf7-form-control.wpcf7-textarea,
|
84 |
body .valentines-day-classic select.wpcf7-form-control.wpcf7-select,
|
85 |
+
body .valentines-day-classic input.wpcf7-form-control.wpcf7-quiz,
|
86 |
+
body .valentines-day-classic input.wpcf7-form-control.wpcf7-range,
|
87 |
+
body .valentines-day-classic input.wpcf7-form-control.wpcf7-date,
|
88 |
+
body .valentines-day-classic input.wpcf7-form-control.wpcf7-select,
|
89 |
+
body .valentines-day-classic input.wpcf7-form-control.wpcf7-file {
|
90 |
margin: 5px 0 0;
|
91 |
padding: 15px 10px;
|
92 |
+
border-top: 0;
|
93 |
+
border-right: 0;
|
94 |
border-left: 1px solid #AAA;
|
95 |
border-bottom: 1px solid #AAA;
|
96 |
outline: 0;
|
106 |
box-sizing: border-box;
|
107 |
}
|
108 |
|
|
|
109 |
body .valentines-day-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
110 |
border: none;
|
111 |
}
|
112 |
|
113 |
body .wpcf7 form.valentines-day-classic p {
|
114 |
+
margin-bottom: 15px;
|
115 |
font-size: 16px;
|
116 |
color: #222;
|
117 |
}
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
body .valentines-day-classic {
|
120 |
background: url('../images/vday-classic/hearted-bg.png') -45px 0 repeat;
|
121 |
position: relative;
|
138 |
text-shadow: 1px 1px #FFF;
|
139 |
}
|
140 |
|
141 |
+
body .valentines-day-classic span.wpcf7-list-item {
|
142 |
+
display: inline-block;
|
143 |
+
}
|
144 |
+
|
145 |
body .valentines-day-classic input,
|
146 |
+
body .valentines-day-classic textarea,
|
147 |
+
body .valentines-day-classic select {
|
148 |
background: rgba(255, 255, 255, 0.7);
|
149 |
border: none;
|
150 |
border-left: 1px solid #AAA;
|
165 |
border-bottom: 1px solid #AAA;
|
166 |
}
|
167 |
|
168 |
+
body .cf7-style.valentines-day-classic input.wpcf7-form-control.wpcf7-submit[disabled],
|
169 |
+
body .cf7-style.valentines-day-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]),
|
170 |
+
body .cf7-style.valentines-day-classic .wpcf7-submit {
|
171 |
-webkit-box-shadow: none;
|
172 |
-moz-box-shadow: none;
|
173 |
box-shadow: none;
|
175 |
-moz-border-radius: 10px;
|
176 |
border-radius: 10px;
|
177 |
border: none;
|
178 |
+
line-height: 20px;
|
|
|
179 |
text-align: center;
|
180 |
+
padding: 10px 20px;
|
181 |
min-width: 90px;
|
182 |
background: rgb(125, 185, 232);
|
183 |
/* Old browsers */
|
184 |
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
|
|
|
185 |
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzdkYjllOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZDU0ZTRlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMzklIiBzdG9wLWNvbG9yPSIjZDQwMDAwIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iODUlIiBzdG9wLWNvbG9yPSIjOTQwYTBhIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==);
|
186 |
background: -moz-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
187 |
/* FF3.6+ */
|
|
|
188 |
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(125, 185, 232, 1)), color-stop(0%, rgba(213, 78, 78, 1)), color-stop(39%, rgba(212, 0, 0, 1)), color-stop(85%, rgba(148, 10, 10, 1)));
|
189 |
/* Chrome,Safari4+ */
|
|
|
190 |
background: -webkit-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
191 |
/* Chrome10+,Safari5.1+ */
|
|
|
192 |
background: -o-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
193 |
/* Opera 11.10+ */
|
|
|
194 |
background: -ms-linear-gradient(left, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
195 |
/* IE10+ */
|
|
|
196 |
background: linear-gradient(to right, rgba(125, 185, 232, 1) 0%, rgba(213, 78, 78, 1) 0%, rgba(212, 0, 0, 1) 39%, rgba(148, 10, 10, 1) 85%);
|
197 |
/* W3C */
|
|
|
198 |
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#7db9e8', endColorstr='#940a0a', GradientType=1);
|
199 |
/* IE6-8 */
|
|
|
200 |
color: #FFF;
|
201 |
float: right;
|
202 |
text-shadow: 1px 1px #555;
|
203 |
+
cursor: pointer;
|
204 |
}
|
205 |
|
206 |
body .valentines-day-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]):focus,
|
224 |
color: green;
|
225 |
border: solid 1px green;
|
226 |
}
|
227 |
+
|
228 |
+
body .valentines-day-classic input[type="file"],
|
229 |
+
body .valentines-day-classic input[type="range"],
|
230 |
+
body .valentines-day-classic input[type="date"],
|
231 |
+
body .valentines-day-classic select {
|
232 |
+
width: 100%;
|
233 |
+
}
|
234 |
+
|
235 |
+
body .valentines-day-classic input[type=range] {
|
236 |
+
-webkit-appearance: none;
|
237 |
+
}
|
238 |
+
|
239 |
+
body .valentines-day-classic input[type=range]::-webkit-slider-runnable-track {
|
240 |
+
height: 5px;
|
241 |
+
background: #ddd;
|
242 |
+
border: none;
|
243 |
+
border-radius: 3px;
|
244 |
+
}
|
245 |
+
|
246 |
+
body .valentines-day-classic input[type=range]::-webkit-slider-thumb {
|
247 |
+
-webkit-appearance: none;
|
248 |
+
border: none;
|
249 |
+
height: 16px;
|
250 |
+
width: 16px;
|
251 |
+
border-radius: 50%;
|
252 |
+
background: #777;
|
253 |
+
margin-top: -4px;
|
254 |
+
cursor: pointer;
|
255 |
+
}
|
256 |
+
|
257 |
+
body .valentines-day-classic input[type=range]:focus {
|
258 |
+
outline: none;
|
259 |
+
}
|
260 |
+
|
261 |
+
body .valentines-day-classic input[type=range]:focus::-webkit-slider-runnable-track {
|
262 |
+
background: #ccc;
|
263 |
+
}
|
264 |
+
|
265 |
+
body .valentines-day-classic input[type=range] {
|
266 |
+
/* fix for FF unable to apply focus style bug */
|
267 |
+
border: 1px solid white;
|
268 |
+
/*required for proper track sizing in FF*/
|
269 |
+
width: 100%;
|
270 |
+
}
|
271 |
+
|
272 |
+
body .valentines-day-classic input[type=range]::-moz-range-track {
|
273 |
+
height: 5px;
|
274 |
+
background: #ddd;
|
275 |
+
border: none;
|
276 |
+
border-radius: 3px;
|
277 |
+
}
|
278 |
+
|
279 |
+
body .valentines-day-classic input[type=range]::-moz-range-thumb {
|
280 |
+
border: none;
|
281 |
+
height: 16px;
|
282 |
+
width: 16px;
|
283 |
+
border-radius: 50%;
|
284 |
+
background: #777;
|
285 |
+
cursor: pointer;
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
/*hide the outline behind the border*/
|
290 |
+
|
291 |
+
body .valentines-day-classic input[type=range]:-moz-focusring {
|
292 |
+
outline: 1px solid white;
|
293 |
+
outline-offset: -1px;
|
294 |
+
}
|
295 |
+
|
296 |
+
body .valentines-day-classic input[type=range]:focus::-moz-range-track {
|
297 |
+
background: #ccc;
|
298 |
+
}
|
299 |
+
|
300 |
+
body .valentines-day-classic input[type=range]::-ms-track {
|
301 |
+
height: 5px;
|
302 |
+
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
|
303 |
+
background: transparent;
|
304 |
+
/*leave room for the larger thumb to overflow with a transparent border */
|
305 |
+
border-color: transparent;
|
306 |
+
border-width: 6px 0;
|
307 |
+
/*remove default tick marks*/
|
308 |
+
color: transparent;
|
309 |
+
}
|
310 |
+
|
311 |
+
body .valentines-day-classic input[type=range]::-ms-fill-lower {
|
312 |
+
background: #ddd;
|
313 |
+
border-radius: 10px;
|
314 |
+
}
|
315 |
+
|
316 |
+
body .valentines-day-classic input[type=range]::-ms-fill-upper {
|
317 |
+
background: #ddd;
|
318 |
+
border-radius: 10px;
|
319 |
+
}
|
320 |
+
|
321 |
+
body .valentines-day-classic input[type=range]::-ms-thumb {
|
322 |
+
border: none;
|
323 |
+
height: 16px;
|
324 |
+
width: 16px;
|
325 |
+
border-radius: 50%;
|
326 |
+
background: #777;
|
327 |
+
cursor: pointer;
|
328 |
+
}
|
329 |
+
|
330 |
+
body .valentines-day-classic input[type=range]:focus::-ms-fill-lower {
|
331 |
+
background: #ccc;
|
332 |
+
}
|
333 |
+
|
334 |
+
body .valentines-day-classic input[type=range]:focus::-ms-fill-upper {
|
335 |
+
background: #ccc;
|
336 |
+
}
|
337 |
+
|
338 |
+
|
339 |
/**
|
340 |
* Valentine's Day
|
341 |
*
|
348 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-date,
|
349 |
body .valentines-day-roses textarea.wpcf7-form-control.wpcf7-textarea,
|
350 |
body .valentines-day-roses select.wpcf7-form-control.wpcf7-select,
|
351 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-quiz,
|
352 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-file {
|
353 |
margin: 5px 0 0;
|
354 |
padding: 15px 10px;
|
355 |
border-bottom: 1px solid #490706;
|
358 |
font-size: 13px;
|
359 |
line-height: 17px;
|
360 |
background: none;
|
361 |
+
color: #000;
|
362 |
font-family: 'Raleway';
|
363 |
font-weight: normal;
|
364 |
+
-webkit-box-sizing: border-box;
|
365 |
+
-moz-box-sizing: border-box;
|
366 |
+
box-sizing: border-box;
|
367 |
+
}
|
368 |
+
|
369 |
+
body .valentines-day-roses select.wpcf7-form-control.wpcf7-select,
|
370 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-file,
|
371 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-range,
|
372 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-date {
|
373 |
+
width: 100%;
|
374 |
}
|
375 |
|
376 |
body .valentines-day-roses textarea.wpcf7-form-control.wpcf7-textarea,
|
379 |
}
|
380 |
|
381 |
body .wpcf7 form.valentines-day-roses p {
|
382 |
+
margin-bottom: 15px;
|
383 |
font-size: 16px;
|
384 |
+
color: #000;
|
385 |
+
}
|
386 |
+
|
387 |
+
body .wpcf7 form.valentines-day-roses span.wpcf7-list-item {
|
388 |
+
display: inline-block;
|
389 |
}
|
390 |
|
391 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit {
|
400 |
|
401 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit:not([disabled]):focus,
|
402 |
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit:not([disabled]):hover {
|
403 |
+
background: #7F2A3A;
|
404 |
border: none;
|
|
|
405 |
}
|
406 |
|
407 |
body .valentines-day-roses {
|
419 |
clear: both;
|
420 |
}
|
421 |
|
|
|
|
|
|
|
|
|
|
|
422 |
body .valentines-day-roses textarea {
|
423 |
width: 92%;
|
424 |
}
|
449 |
background: #826e50 url(../images/vday-rose/contact-bg.png) 0 0 no-repeat;
|
450 |
width: 285px;
|
451 |
margin: 32px 0 0 -50px;
|
452 |
+
padding: 35px 15px 50px;
|
453 |
+
}
|
454 |
+
|
455 |
+
body .wpcf7 form.valentines-day-roses .letter-box p {
|
456 |
+
color: #000;
|
457 |
}
|
458 |
|
459 |
+
body .wpcf7 form.valentines-day-roses .wpcf7-submit {
|
460 |
position: absolute;
|
461 |
+
bottom: 10px;
|
462 |
right: 20px;
|
463 |
border: none;
|
464 |
padding: 7px 15px;
|
494 |
background: none repeat scroll 0 0 rgba( 255, 255, 255, 0.6);
|
495 |
border: none;
|
496 |
}
|
497 |
+
|
498 |
+
|
499 |
/**
|
500 |
* Valentine's Day
|
501 |
*
|
508 |
body .valentines-day-birds input.wpcf7-form-control.wpcf7-date,
|
509 |
body .valentines-day-birds textarea.wpcf7-form-control.wpcf7-textarea,
|
510 |
body .valentines-day-birds select.wpcf7-form-control.wpcf7-select,
|
511 |
+
body .valentines-day-birds input.wpcf7-form-control.wpcf7-quiz,
|
512 |
+
body .valentines-day-birds input.wpcf7-form-control.wpcf7-range,
|
513 |
+
body .valentines-day-birds input.wpcf7-form-control.wpcf7-file {
|
514 |
margin: 0 0 5px 0;
|
515 |
padding: 8px 10px;
|
516 |
border: 2px dashed #000;
|
537 |
body .valentines-day-birds input.wpcf7-form-control.wpcf7-number,
|
538 |
body .valentines-day-birds input.wpcf7-form-control.wpcf7-date,
|
539 |
body .valentines-day-birds textarea.wpcf7-form-control.wpcf7-textarea,
|
540 |
+
body .valentines-day-birds select.wpcf7-form-control.wpcf7-select,
|
541 |
+
body .valentines-day-birds input.wpcf7-form-control.wpcf7-range {
|
542 |
width: 100%;
|
543 |
}
|
544 |
|
575 |
display: none;
|
576 |
}
|
577 |
|
578 |
+
body .valentines-day-birds span.wpcf7-list-item {
|
579 |
+
display: inline-block;
|
580 |
+
}
|
581 |
+
|
582 |
body .valentines-day-birds {
|
583 |
position: relative;
|
584 |
width: 280px;
|
613 |
}
|
614 |
|
615 |
body .wpcf7 form.valentines-day-birds p {
|
616 |
+
margin-bottom: 20px;
|
617 |
color: #222;
|
618 |
+
line-height: 1.5em;
|
619 |
}
|
620 |
|
621 |
body .valentines-day-birds input,
|
670 |
body .valentines-day-birds .wpcf7-mail-sent-ok {
|
671 |
color: green;
|
672 |
}
|
673 |
+
|
674 |
+
|
675 |
/**
|
676 |
* Valentine's Day
|
677 |
*
|
684 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-date,
|
685 |
body .valentines-day-blue-birds textarea.wpcf7-form-control.wpcf7-textarea,
|
686 |
body .valentines-day-blue-birds select.wpcf7-form-control.wpcf7-select,
|
687 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-quiz,
|
688 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-file {
|
689 |
margin: 5px 0 0;
|
690 |
padding: 15px;
|
691 |
border: 0;
|
702 |
box-sizing: border-box;
|
703 |
}
|
704 |
|
705 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-date,
|
706 |
+
body .valentines-day-blue-birds select.wpcf7-form-control.wpcf7-select,
|
707 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-file,
|
708 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-range {
|
709 |
+
width: 100%;
|
710 |
+
}
|
711 |
+
|
712 |
+
body .valentines-day-blue-birds .wpcf7-list-item,
|
713 |
+
body .valentines-day-blue-birds .wpcf7-list-item-label {
|
714 |
+
display: inline-block;
|
715 |
+
}
|
716 |
+
|
717 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
718 |
border: none;
|
719 |
}
|
720 |
|
721 |
body .wpcf7 form.valentines-day-blue-birds p {
|
722 |
+
margin-bottom: 15px;
|
723 |
font-size: 16px;
|
724 |
}
|
725 |
|
733 |
transition: none;
|
734 |
}
|
735 |
|
736 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:hover,
|
737 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:focus,
|
738 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:not([disabled]):focus,
|
739 |
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit:not([disabled]):hover {
|
740 |
background: url("../images/vday-blue-birds/submit.png") no-repeat top right;
|
754 |
width: 100%;
|
755 |
}
|
756 |
|
|
|
757 |
body .valentines-day-blue-birds textarea {
|
758 |
+
width: 100%;
|
759 |
display: inline-block;
|
760 |
background: #dad3c2;
|
761 |
border: none;
|
766 |
background: #dad3c2;
|
767 |
}
|
768 |
|
769 |
+
body .valentines-day-blue-birds input.wpcf7-form-control.wpcf7-submit {
|
770 |
background: url("../images/vday-blue-birds/submit.png") no-repeat top right;
|
771 |
line-height: 50px;
|
772 |
font-size: 30px;
|
816 |
body .valentines-day-blue-birds div.wpcf7-mail-sent-ok {
|
817 |
background: rgba( 9, 94, 0, .9);
|
818 |
}
|
819 |
+
|
820 |
+
|
821 |
/**
|
822 |
* Xmas
|
823 |
*
|
830 |
body .christmas-classic input.wpcf7-form-control.wpcf7-date,
|
831 |
body .christmas-classic textarea.wpcf7-form-control.wpcf7-textarea,
|
832 |
body .christmas-classic select.wpcf7-form-control.wpcf7-select,
|
833 |
+
body .christmas-classic input.wpcf7-form-control.wpcf7-quiz,
|
834 |
+
body .christmas-classic input.wpcf7-form-control.wpcf7-file {
|
835 |
margin: 5px 0 0;
|
836 |
padding: 3px 10px;
|
837 |
border: 1px dotted #b2a28e;
|
851 |
width: 100%;
|
852 |
}
|
853 |
|
854 |
+
body .christmas-classic select.wpcf7-form-control.wpcf7-select[multiple] {
|
855 |
+
height: auto;
|
856 |
+
}
|
857 |
+
|
858 |
body .christmas-classic textarea.wpcf7-form-control.wpcf7-textarea {
|
859 |
padding: 5px 10px;
|
860 |
height: 140px;
|
861 |
}
|
862 |
|
863 |
+
body .christmas-classic input.wpcf7-form-control.wpcf7-file {
|
864 |
+
padding: 8px 10px;
|
865 |
+
}
|
866 |
+
|
867 |
+
body .christmas-classic span.wpcf7-list-item {
|
868 |
+
margin: 0.5em;
|
869 |
+
display: inline-block;
|
870 |
+
}
|
871 |
+
|
872 |
body .christmas-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
873 |
border: none;
|
874 |
}
|
916 |
bottom: -255px;
|
917 |
margin: 0 0 0 -70px;
|
918 |
padding: 0;
|
|
|
919 |
}
|
920 |
|
921 |
body .christmas-classic input,
|
957 |
body .christmas-classic .wpcf7-submit {
|
958 |
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
|
959 |
border: medium none;
|
960 |
+
bottom: -246px;
|
961 |
+
height: 86px;
|
962 |
+
left: 21px;
|
963 |
position: absolute;
|
964 |
text-indent: -9999px;
|
965 |
+
width: 95px;
|
966 |
z-index: 10;
|
967 |
}
|
968 |
|
969 |
+
body .christmas-classic input.wpcf7-form-control.wpcf7-submit:not([disabled]):hover,
|
970 |
+
body .christmas-classic .wpcf7-submit:hover {
|
971 |
+
background-color: rgba(255, 255, 255, .3);
|
972 |
+
}
|
973 |
+
|
974 |
body .christmas-classic div.wpcf7-response-output {
|
975 |
width: 84%;
|
976 |
margin: 0 auto;
|
977 |
}
|
978 |
+
|
979 |
+
body .christmas-classic span.wpcf7-list-item-label {
|
980 |
+
display: inline-block;
|
981 |
+
}
|
982 |
+
|
983 |
+
|
984 |
/**
|
985 |
* Xmas
|
986 |
*
|
988 |
* -----------------------------------------------------------------------------
|
989 |
*/
|
990 |
|
991 |
+
body .christmas-red .wpcf7-form-control-wrap {
|
992 |
+
display: inherit;
|
993 |
+
}
|
994 |
+
|
995 |
body .christmas-red input.wpcf7-form-control.wpcf7-text,
|
996 |
body .christmas-red input.wpcf7-form-control.wpcf7-number,
|
997 |
body .christmas-red input.wpcf7-form-control.wpcf7-date,
|
1015 |
box-sizing: border-box;
|
1016 |
}
|
1017 |
|
1018 |
+
body .christmas-red select.wpcf7-form-control.wpcf7-select[multiple] {
|
1019 |
+
height: auto;
|
1020 |
+
padding: 5px 10px;
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
body .christmas-red input.wpcf7-form-control.wpcf7-acceptance {
|
1024 |
+
display: inline-block;
|
1025 |
+
width: auto;
|
1026 |
+
}
|
1027 |
+
|
1028 |
body .christmas-red textarea.wpcf7-form-control.wpcf7-textarea,
|
1029 |
body .christmas-red input.wpcf7-form-control.wpcf7-submit:not([disabled]) {
|
1030 |
border: none;
|
1031 |
}
|
1032 |
|
1033 |
body .wpcf7 form.christmas-red p {
|
1034 |
+
margin-bottom: 15px;
|
1035 |
font-size: 16px;
|
1036 |
color: #fff;
|
1037 |
}
|
1068 |
}
|
1069 |
|
1070 |
body .christmas-red p {
|
1071 |
+
max-width: 370px;
|
1072 |
margin: 0 auto;
|
1073 |
}
|
1074 |
|
1077 |
color: #222;
|
1078 |
width: 100%;
|
1079 |
font-size: 16px;
|
1080 |
+
margin: 0;
|
1081 |
}
|
1082 |
|
1083 |
body .christmas-red input[type="text"],
|
1085 |
body .christmas-red input[type="url"],
|
1086 |
body .christmas-red input[type="password"],
|
1087 |
body .christmas-red input[type="search"],
|
1088 |
+
body .christmas-red textarea,
|
1089 |
+
body .christmas-red select {
|
1090 |
width: 100%;
|
1091 |
}
|
1092 |
|
1093 |
+
body .christmas-red input[type="radio"],
|
1094 |
+
body .christmas-red input[type="checkbox"] {
|
1095 |
+
width: auto;
|
1096 |
+
}
|
1097 |
+
|
1098 |
body .christmas-red input:focus,
|
1099 |
body .christmas-red textarea:focus {
|
1100 |
background: #fff;
|
1127 |
body .christmas-classic-validation-errors,
|
1128 |
body .christmas-classic-mail-sent-ok {
|
1129 |
border: none;
|
1130 |
+
max-width: 350px;
|
1131 |
font-size: 22px;
|
1132 |
color: #FC8181;
|
1133 |
margin-left: 25px;
|
1154 |
border-radius: 5px;
|
1155 |
}
|
1156 |
|
1157 |
+
body .christmas-red span.wpcf7-list-item,
|
1158 |
+
.wpcf7-form-control .wpcf7-radio {
|
1159 |
display: inline-block;
|
1160 |
height: 32px;
|
1161 |
+
margin-left: 1em;
|
1162 |
+
position: relative;
|
1163 |
+
}
|
1164 |
+
|
1165 |
+
body .christmas-red .wpcf7-radio .wpcf7-list-item-label:before {
|
1166 |
+
content: '';
|
1167 |
+
position: absolute;
|
1168 |
+
right: 0;
|
1169 |
+
top: 0;
|
1170 |
+
width: 32px;
|
1171 |
+
height: 32px;
|
1172 |
+
background: url(../images/xmas-red/radio.png) no-repeat 0 2px;
|
1173 |
+
z-index: 1;
|
1174 |
}
|
1175 |
|
1176 |
+
body .christmas-red .wpcf7-radio input + .wpcf7-list-item-label:before {
|
1177 |
+
content: '';
|
1178 |
+
position: absolute;
|
1179 |
+
left: 0;
|
1180 |
+
top: 0;
|
1181 |
+
width: 32px;
|
1182 |
+
height: 32px;
|
1183 |
+
background: url(../images/xmas-red/radio.png) no-repeat 0 2px;
|
1184 |
+
z-index: 1;
|
1185 |
}
|
1186 |
|
1187 |
+
body .christmas-red .wpcf7-radio .wpcf7-list-item.active .wpcf7-list-item-label:before,
|
1188 |
+
body .christmas-red .wpcf7-radio .wpcf7-list-item .active .wpcf7-list-item-label:before {
|
1189 |
+
background-position: 0 -31px;
|
1190 |
}
|
1191 |
|
1192 |
body .christmas-red .wpcf7-radio .wpcf7-list-item-label {
|
1195 |
}
|
1196 |
|
1197 |
body .christmas-red span.wpcf7-list-item input[type="radio"] {
|
1198 |
+
position: relative;
|
1199 |
+
z-index: 2;
|
1200 |
width: 30px;
|
1201 |
height: 30px;
|
1202 |
cursor: pointer;
|
1203 |
/* IE 8 */
|
|
|
1204 |
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
1205 |
/* IE 5-7 */
|
|
|
1206 |
filter: alpha(opacity=0);
|
1207 |
/* Netscape */
|
|
|
1208 |
-moz-opacity: 0;
|
1209 |
/* Safari 1.x */
|
|
|
1210 |
-khtml-opacity: 0;
|
1211 |
/* Good browsers */
|
|
|
1212 |
opacity: 0;
|
1213 |
}
|
1214 |
|
1241 |
body .christmas-red span.wpcf7-not-valid-tip {
|
1242 |
padding: 5px 10px 5px 0;
|
1243 |
}
|
1244 |
+
|
1245 |
+
|
1246 |
/**
|
1247 |
* Xmas
|
1248 |
*
|
1275 |
body .christmas-simple p input[type="text"],
|
1276 |
body .christmas-simple p input[type="email"],
|
1277 |
body .christmas-simple p input[type="tel"],
|
1278 |
+
body .christmas-simple p input[type="range"],
|
1279 |
+
body .christmas-simple p input[type="url"],
|
1280 |
+
body .christmas-simple p input[type="number"],
|
1281 |
+
body .christmas-simple p input[type="date"],
|
1282 |
+
body .christmas-simple p input[type="file"],
|
1283 |
+
body .christmas-simple p select,
|
1284 |
body .christmas-simple p textarea,
|
1285 |
body .christmas-simple p input[type="text"]:hover,
|
1286 |
body .christmas-simple p input[type="email"]:hover,
|
1293 |
width: 94%;
|
1294 |
background: transparent;
|
1295 |
border: dashed 2px #7d5f48;
|
1296 |
+
padding: 0.625em 0.4375em;
|
1297 |
+
}
|
1298 |
+
|
1299 |
+
body .christmas-simple span.wpcf7-list-item {
|
1300 |
+
display: inline-block;
|
1301 |
+
margin-left: 1em;
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
body .christmas-simple input[type="checkbox"],
|
1305 |
+
body .christmas-simple input[type="radio"] {
|
1306 |
+
margin-right: 0;
|
1307 |
}
|
1308 |
|
1309 |
body .christmas-simple textarea {
|
1336 |
border-bottom: 2px dashed #542c0e;
|
1337 |
border-radius: 0 0 20px 20px;
|
1338 |
border-top: medium none;
|
1339 |
+
bottom: -35px;
|
1340 |
padding-bottom: 3px;
|
1341 |
+
width: 425px;
|
1342 |
}
|
1343 |
|
1344 |
body .christmas-simple .ribbon {
|
1377 |
background: #e7e3d0;
|
1378 |
color: #000;
|
1379 |
}
|
1380 |
+
|
1381 |
+
|
1382 |
/**
|
1383 |
+
* Fix Error tooltips position
|
1384 |
*/
|
1385 |
|
1386 |
body .christmas-simple span.wpcf7-not-valid-tip {
|
1394 |
background: #fff;
|
1395 |
border: none;
|
1396 |
}
|
1397 |
+
|
1398 |
+
|
1399 |
/*Christmas clasic - unique*/
|
1400 |
|
1401 |
body .christmas-classic .wpcf7-not-valid-tip {
|
1402 |
width: 100%;
|
1403 |
background: transparent;
|
1404 |
}
|
1405 |
+
|
1406 |
+
|
1407 |
/***
|
1408 |
* SIMPLE
|
1409 |
*
|
1479 |
background: rgba(51, 51, 51, 0.7);
|
1480 |
outline: 0 none;
|
1481 |
}
|
1482 |
+
|
1483 |
+
.logged-in div.wpcf7 {
|
1484 |
+
position: relative;
|
1485 |
+
margin-top: 70px;
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
.logged-in .frontend-edit-style-link {
|
1489 |
+
position: absolute;
|
1490 |
+
left: 0;
|
1491 |
+
top: -50px;
|
1492 |
+
z-index: 9;
|
1493 |
+
display: block;
|
1494 |
+
padding: 5px 10px;
|
1495 |
+
border: none;
|
1496 |
+
-webkit-box-shadow: none;
|
1497 |
+
box-shadow: none;
|
1498 |
+
text-decoration: none;
|
1499 |
+
background: #fff;
|
1500 |
+
color: #555;
|
1501 |
+
opacity: 0.8;
|
1502 |
+
-webkit-border-radius: 5px;
|
1503 |
+
border-radius: 5px;
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
.logged-in .frontend-edit-style-link:hover {
|
1507 |
+
opacity: 1;
|
1508 |
+
}
|
css/responsive.css
CHANGED
@@ -56,6 +56,7 @@
|
|
56 |
|
57 |
body .christmas-classic-container {
|
58 |
width: 100%;
|
|
|
59 |
margin-bottom: 310px;
|
60 |
}
|
61 |
body .christmas-classic p {
|
@@ -67,7 +68,7 @@
|
|
67 |
bottom: -15px;
|
68 |
}
|
69 |
body .christmas-classic .footer {
|
70 |
-
width:
|
71 |
margin-left: -79px;
|
72 |
height: 300px;
|
73 |
bottom: -300px;
|
@@ -98,7 +99,9 @@
|
|
98 |
* -----------------------------------------------------------------------------
|
99 |
*/
|
100 |
|
101 |
-
body .christmas-simple-container
|
|
|
|
|
102 |
body .christmas-simple {
|
103 |
width: 100%;
|
104 |
}
|
@@ -157,8 +160,9 @@
|
|
157 |
|
158 |
body .christmas-red-container {
|
159 |
width: 480px;
|
160 |
-
margin
|
161 |
padding-bottom: 4px;
|
|
|
162 |
}
|
163 |
body .christmas-red .header {
|
164 |
width: 489px;
|
@@ -183,9 +187,7 @@
|
|
183 |
body .valentines-day-roses .letter-box {
|
184 |
margin-top: 64px;
|
185 |
}
|
186 |
-
|
187 |
-
right: 45px;
|
188 |
-
}
|
189 |
}
|
190 |
|
191 |
@media only screen and (min-device-width: 768px) and (max-device-width: 1023px) {
|
@@ -220,6 +222,51 @@
|
|
220 |
}
|
221 |
}
|
222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
@media only screen and (min-device-width: 321px) and (max-device-width: 480px) {
|
224 |
/**
|
225 |
* Xmas
|
@@ -280,19 +327,47 @@
|
|
280 |
}
|
281 |
}
|
282 |
|
283 |
-
@media only screen and (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
/**
|
285 |
* Xmas
|
286 |
*
|
287 |
* 1.3 - Simple
|
288 |
* -----------------------------------------------------------------------------
|
289 |
*/
|
290 |
-
|
291 |
body .christmas-simple .ribbon {
|
292 |
width: 90px;
|
293 |
top: -40px;
|
294 |
right: -20px;
|
295 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
/**
|
297 |
* Valentine's Day
|
298 |
*
|
@@ -305,6 +380,7 @@
|
|
305 |
padding-bottom: 0;
|
306 |
margin-bottom: 10px;
|
307 |
}
|
|
|
308 |
/**
|
309 |
* Valentine's Day
|
310 |
*
|
@@ -312,16 +388,11 @@
|
|
312 |
* -----------------------------------------------------------------------------
|
313 |
*/
|
314 |
|
315 |
-
body .valentines-day-roses {
|
316 |
-
padding-left: 150px;
|
317 |
-
padding-right: 0;
|
318 |
-
}
|
319 |
body .valentines-day-roses .letter-box {
|
320 |
margin-top: 17px;
|
321 |
}
|
322 |
-
|
323 |
-
|
324 |
-
}
|
325 |
/**
|
326 |
* Valentine's Day
|
327 |
*
|
@@ -348,10 +419,17 @@
|
|
348 |
padding: 0 90px 0 0;
|
349 |
margin-bottom: 0;
|
350 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
body .valentines-day-birds-container {
|
352 |
width: 100%;
|
353 |
background-position: 2px 0;
|
354 |
-
border-bottom: 1px solid #000;
|
355 |
}
|
356 |
body .valentines-day-birds .bg-header {
|
357 |
width: 490px;
|
@@ -363,6 +441,9 @@
|
|
363 |
body .valentines-day-birds .bg-bottom {
|
364 |
display: none;
|
365 |
}
|
|
|
|
|
|
|
366 |
/**
|
367 |
* Simple pattern
|
368 |
*
|
@@ -376,7 +457,57 @@
|
|
376 |
}
|
377 |
}
|
378 |
|
379 |
-
@media only screen and (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
|
381 |
@media only screen and (max-width: 320px) {
|
382 |
/**
|
@@ -398,13 +529,15 @@
|
|
398 |
body .christmas-red .footer {
|
399 |
width: 270px;
|
400 |
}
|
|
|
|
|
|
|
401 |
/**
|
402 |
* Xmas
|
403 |
*
|
404 |
* 1.2 - Classic
|
405 |
* -----------------------------------------------------------------------------
|
406 |
-
*/
|
407 |
-
|
408 |
body .christmas-classic-container {
|
409 |
margin-bottom: 170px;
|
410 |
}
|
@@ -449,19 +582,13 @@
|
|
449 |
* -----------------------------------------------------------------------------
|
450 |
*/
|
451 |
|
452 |
-
body .valentines-day-roses {
|
453 |
-
padding-left: 10px;
|
454 |
-
padding-top: 30px;
|
455 |
-
background-position: 0 55px;
|
456 |
-
}
|
457 |
body .valentines-day-roses textarea.wpcf7-form-control.wpcf7-textarea {
|
458 |
width: 140px;
|
459 |
-
|
460 |
-
|
461 |
}
|
462 |
body .valentines-day-roses .letter-box {
|
463 |
-
|
464 |
-
margin-left: -20px;
|
465 |
}
|
466 |
body .valentines-day-roses div.wpcf7-validation-errors,
|
467 |
body .valentines-day-roses div.wpcf7-mail-sent-ok {
|
@@ -496,3 +623,21 @@
|
|
496 |
height: 120px;
|
497 |
}
|
498 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
body .christmas-classic-container {
|
58 |
width: 100%;
|
59 |
+
max-width: 480px;
|
60 |
margin-bottom: 310px;
|
61 |
}
|
62 |
body .christmas-classic p {
|
68 |
bottom: -15px;
|
69 |
}
|
70 |
body .christmas-classic .footer {
|
71 |
+
width: 559px;
|
72 |
margin-left: -79px;
|
73 |
height: 300px;
|
74 |
bottom: -300px;
|
99 |
* -----------------------------------------------------------------------------
|
100 |
*/
|
101 |
|
102 |
+
body .christmas-simple-container{
|
103 |
+
width: 85%;
|
104 |
+
}
|
105 |
body .christmas-simple {
|
106 |
width: 100%;
|
107 |
}
|
160 |
|
161 |
body .christmas-red-container {
|
162 |
width: 480px;
|
163 |
+
margin: 0 auto 140px;
|
164 |
padding-bottom: 4px;
|
165 |
+
display: block;
|
166 |
}
|
167 |
body .christmas-red .header {
|
168 |
width: 489px;
|
187 |
body .valentines-day-roses .letter-box {
|
188 |
margin-top: 64px;
|
189 |
}
|
190 |
+
|
|
|
|
|
191 |
}
|
192 |
|
193 |
@media only screen and (min-device-width: 768px) and (max-device-width: 1023px) {
|
222 |
}
|
223 |
}
|
224 |
|
225 |
+
@media only screen and (min-width: 480px) and (max-device-width: 767px){
|
226 |
+
/**
|
227 |
+
* Xmas
|
228 |
+
*
|
229 |
+
* 1.1 - Red
|
230 |
+
* -----------------------------------------------------------------------------
|
231 |
+
*/
|
232 |
+
body .christmas-red-container{
|
233 |
+
width: 468px;
|
234 |
+
}
|
235 |
+
body .christmas-red .header,
|
236 |
+
body .christmas-red .footer{
|
237 |
+
width: 476px;
|
238 |
+
}
|
239 |
+
body .christmas-red .header{
|
240 |
+
top: -83px;
|
241 |
+
left: -4px;
|
242 |
+
background: url(../images/xmas-red/header.png ) no-repeat 0px top;
|
243 |
+
background-size: contain;
|
244 |
+
}
|
245 |
+
body .christmas-red .footer{
|
246 |
+
left: -4px;
|
247 |
+
}
|
248 |
+
body .christmas-red p{
|
249 |
+
padding: 0 20px;
|
250 |
+
}
|
251 |
+
body .christmas-red select.wpcf7-form-control.wpcf7-select option{
|
252 |
+
width: 100%;
|
253 |
+
background-color: #fff;
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Xmas
|
259 |
+
*
|
260 |
+
* 1.2 - Classic
|
261 |
+
* -----------------------------------------------------------------------------
|
262 |
+
*/
|
263 |
+
body .christmas-simple .header{
|
264 |
+
top: -33px;
|
265 |
+
}
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
@media only screen and (min-device-width: 321px) and (max-device-width: 480px) {
|
271 |
/**
|
272 |
* Xmas
|
327 |
}
|
328 |
}
|
329 |
|
330 |
+
@media only screen and (max-device-width: 480px) {
|
331 |
+
/**
|
332 |
+
* Xmas
|
333 |
+
*
|
334 |
+
* 1.1 - Classic
|
335 |
+
* -----------------------------------------------------------------------------
|
336 |
+
*/
|
337 |
+
body .christmas-classic p {
|
338 |
+
padding: 0 25px;
|
339 |
+
}
|
340 |
+
|
341 |
+
|
342 |
+
|
343 |
+
|
344 |
/**
|
345 |
* Xmas
|
346 |
*
|
347 |
* 1.3 - Simple
|
348 |
* -----------------------------------------------------------------------------
|
349 |
*/
|
350 |
+
|
351 |
body .christmas-simple .ribbon {
|
352 |
width: 90px;
|
353 |
top: -40px;
|
354 |
right: -20px;
|
355 |
}
|
356 |
+
|
357 |
+
body .christmas-simple p{
|
358 |
+
padding: 0 20px;
|
359 |
+
}
|
360 |
+
|
361 |
+
body .christmas-simple span.wpcf7-list-item {
|
362 |
+
display: block;
|
363 |
+
}
|
364 |
+
|
365 |
+
body .christmas-simple .header {
|
366 |
+
top: -28px;
|
367 |
+
}
|
368 |
+
|
369 |
+
|
370 |
+
|
371 |
/**
|
372 |
* Valentine's Day
|
373 |
*
|
380 |
padding-bottom: 0;
|
381 |
margin-bottom: 10px;
|
382 |
}
|
383 |
+
|
384 |
/**
|
385 |
* Valentine's Day
|
386 |
*
|
388 |
* -----------------------------------------------------------------------------
|
389 |
*/
|
390 |
|
|
|
|
|
|
|
|
|
391 |
body .valentines-day-roses .letter-box {
|
392 |
margin-top: 17px;
|
393 |
}
|
394 |
+
|
395 |
+
|
|
|
396 |
/**
|
397 |
* Valentine's Day
|
398 |
*
|
419 |
padding: 0 90px 0 0;
|
420 |
margin-bottom: 0;
|
421 |
}
|
422 |
+
body .valentines-day-birds:after{
|
423 |
+
content: '';
|
424 |
+
width: 94%;
|
425 |
+
position: absolute;
|
426 |
+
top: 100%;
|
427 |
+
right: 50px;
|
428 |
+
border-bottom: 1px solid #000;
|
429 |
+
}
|
430 |
body .valentines-day-birds-container {
|
431 |
width: 100%;
|
432 |
background-position: 2px 0;
|
|
|
433 |
}
|
434 |
body .valentines-day-birds .bg-header {
|
435 |
width: 490px;
|
441 |
body .valentines-day-birds .bg-bottom {
|
442 |
display: none;
|
443 |
}
|
444 |
+
|
445 |
+
|
446 |
+
|
447 |
/**
|
448 |
* Simple pattern
|
449 |
*
|
457 |
}
|
458 |
}
|
459 |
|
460 |
+
@media only screen and (max-width: 479px){
|
461 |
+
/**
|
462 |
+
* Xmas
|
463 |
+
*
|
464 |
+
* 1.2 - Classic
|
465 |
+
* -----------------------------------------------------------------------------
|
466 |
+
*/
|
467 |
+
body .christmas-classic .footer {
|
468 |
+
margin-left: -56px;
|
469 |
+
width: 373px;
|
470 |
+
}
|
471 |
+
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Valentine's Day
|
475 |
+
*
|
476 |
+
* 2.3 Birds
|
477 |
+
* -----------------------------------------------------------------------------
|
478 |
+
*/
|
479 |
+
body .valentines-day-birds{
|
480 |
+
margin-top: 221px;
|
481 |
+
}
|
482 |
+
body .valentines-day-birds .bg-header {
|
483 |
+
width: 383px;
|
484 |
+
height: 213px;
|
485 |
+
left: -83px;
|
486 |
+
top: -211px;
|
487 |
+
}
|
488 |
+
body .wpcf7 form.valentines-day-birds p{
|
489 |
+
font-size: 0.8rem;
|
490 |
+
}
|
491 |
+
|
492 |
+
|
493 |
+
body .wpcf7 form.valentines-day-blue-birds p{
|
494 |
+
font-size: 0.8rem;
|
495 |
+
padding: 0 20px;
|
496 |
+
}
|
497 |
+
|
498 |
+
body .valentines-day-roses {
|
499 |
+
padding: 0 20px;
|
500 |
+
}
|
501 |
+
body .valentines-day-roses>p{
|
502 |
+
text-align: right;
|
503 |
+
padding-top: 8px;
|
504 |
+
text-align: center;
|
505 |
+
padding-left: 100px;
|
506 |
+
}
|
507 |
+
|
508 |
+
}
|
509 |
+
|
510 |
+
|
511 |
|
512 |
@media only screen and (max-width: 320px) {
|
513 |
/**
|
529 |
body .christmas-red .footer {
|
530 |
width: 270px;
|
531 |
}
|
532 |
+
|
533 |
+
|
534 |
+
|
535 |
/**
|
536 |
* Xmas
|
537 |
*
|
538 |
* 1.2 - Classic
|
539 |
* -----------------------------------------------------------------------------
|
540 |
+
*/
|
|
|
541 |
body .christmas-classic-container {
|
542 |
margin-bottom: 170px;
|
543 |
}
|
582 |
* -----------------------------------------------------------------------------
|
583 |
*/
|
584 |
|
|
|
|
|
|
|
|
|
|
|
585 |
body .valentines-day-roses textarea.wpcf7-form-control.wpcf7-textarea {
|
586 |
width: 140px;
|
587 |
+
height: 90px;
|
588 |
+
padding: 5px;
|
589 |
}
|
590 |
body .valentines-day-roses .letter-box {
|
591 |
+
width: 100%;
|
|
|
592 |
}
|
593 |
body .valentines-day-roses div.wpcf7-validation-errors,
|
594 |
body .valentines-day-roses div.wpcf7-mail-sent-ok {
|
623 |
height: 120px;
|
624 |
}
|
625 |
}
|
626 |
+
|
627 |
+
|
628 |
+
@media only screen and (min-device-width: 991px) and (max-device-width: 1199px){
|
629 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit {
|
630 |
+
right: 50%;
|
631 |
+
margin-right: -40px;
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
@media only screen and (max-device-width: 767px){
|
636 |
+
body .valentines-day-roses .letter-box{
|
637 |
+
margin: 20px auto;
|
638 |
+
}
|
639 |
+
body .valentines-day-roses input.wpcf7-form-control.wpcf7-submit {
|
640 |
+
right: 50%;
|
641 |
+
margin-right: -40px;
|
642 |
+
}
|
643 |
+
}
|
inc/editor_page.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* page to save global css
|
4 |
+
*/
|
5 |
+
if ( !function_exists( 'cf7style_editor_page_init' ) ) {
|
6 |
+
add_action('admin_menu', 'cf7style_editor_page_init');
|
7 |
+
function cf7style_editor_page_init() {
|
8 |
+
add_submenu_page(
|
9 |
+
'edit.php?post_type=cf7_style',
|
10 |
+
'CSS Editor',
|
11 |
+
'CSS Editor',
|
12 |
+
'manage_options',
|
13 |
+
'cf7style-css-editor',
|
14 |
+
'cf7style_editor_page_view'
|
15 |
+
);
|
16 |
+
|
17 |
+
}
|
18 |
+
}
|
19 |
+
if ( !function_exists( 'cf7style_editor_page_view' ) ) {
|
20 |
+
function cf7style_editor_page_view() {
|
21 |
+
do_settings_sections( 'cf7style-css-editor' );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
$initiatenewoptions = new init_sections_register_fields();
|
25 |
+
class init_sections_register_fields {
|
26 |
+
function init_sections_register_fields( ) {
|
27 |
+
add_filter( 'admin_init' , array( $this , 'register_new_fields' ) );
|
28 |
+
}
|
29 |
+
function register_new_fields() {
|
30 |
+
add_settings_section(
|
31 |
+
'cf7styleeditor',
|
32 |
+
'Global CSS',
|
33 |
+
array( $this, 'description' ),
|
34 |
+
'cf7style-css-editor'
|
35 |
+
);
|
36 |
+
$fields = array (
|
37 |
+
'cf7_style_manual_style' => 'CSS',
|
38 |
+
);
|
39 |
+
foreach ( $fields as $field => $value ) {
|
40 |
+
add_settings_field(
|
41 |
+
$field,
|
42 |
+
$value,
|
43 |
+
array($this, 'text_inputs'),
|
44 |
+
'cf7style-css-editor',
|
45 |
+
'cf7styleeditor',
|
46 |
+
array( $field )
|
47 |
+
);
|
48 |
+
register_setting( 'general', $field, 'esc_attr' );
|
49 |
+
}
|
50 |
+
}
|
51 |
+
function text_inputs( $args ) {
|
52 |
+
if ( isset( $_POST[ $args[0] ] ) ) {
|
53 |
+
update_option( $args[0], $_POST[$args[0]] );
|
54 |
+
}
|
55 |
+
echo '<form method="POST" action="">';
|
56 |
+
$option = get_option( $args[0] );
|
57 |
+
echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option . '</textarea>';
|
58 |
+
submit_button( 'Save CSS', 'primary' );
|
59 |
+
echo '</form>';
|
60 |
+
|
61 |
+
}
|
62 |
+
function description() {
|
63 |
+
echo '<p>On this page You can add a custom CSS mark-up, especially rules which could not be loaded via the style customizer above.</p>';
|
64 |
+
}
|
65 |
+
}
|
inc/slider_meta_box.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* function for displaying the meta box
|
4 |
+
*/
|
5 |
+
function cf7_style_display_slider( $post ) {
|
6 |
+
$stylearray = array(
|
7 |
+
'post_type' => 'cf7_style',
|
8 |
+
'posts_per_page' => -1,
|
9 |
+
'order' => 'DESC',
|
10 |
+
'orderby' => 'ID'
|
11 |
+
);
|
12 |
+
$styles = get_posts( $stylearray );
|
13 |
+
$activetemplate = get_post_meta( $post->id(), 'cf7_style_id', true );
|
14 |
+
|
15 |
+
?>
|
16 |
+
<div class="cf7-style-slider">
|
17 |
+
<div class="cf7-style-slider-wrap">
|
18 |
+
<ul class="cf7slider">
|
19 |
+
<?php
|
20 |
+
$i = 1;
|
21 |
+
foreach ($styles as $style) {
|
22 |
+
$previewimage = get_post_meta( $style->ID, 'cf7_style_image_preview', true ); ?>
|
23 |
+
<li class="slide <?php echo ( ( $activetemplate == $style->ID ) ? 'active current-saved' : '' );?>">
|
24 |
+
<span>
|
25 |
+
<div class="overlay">
|
26 |
+
<em><?php echo ( ( $activetemplate == $style->ID ) ? 'Active' : 'Not Active' );?></em>
|
27 |
+
</div>
|
28 |
+
<img src="<?php echo plugins_url(); ?>/contact-form-7-style/<?php echo ( !empty( $previewimage ) ? $previewimage : '/images/default_form.jpg' ); ?>" alt="" />
|
29 |
+
<input type="radio" id="cf7style_template_<?php echo $i; ?>" name="cf7style_template" class="cf7style_template" value="<?php echo $style->ID; ?>" <?php echo ( ( $activetemplate == $style->ID ) ? 'checked' : '' );?> />
|
30 |
+
|
31 |
+
<?php echo $style->post_title; ?>
|
32 |
+
</span>
|
33 |
+
</li>
|
34 |
+
<?php $i++; } ?>
|
35 |
+
</ul>
|
36 |
+
<div class="cf7arrows">
|
37 |
+
<div><a href="#" class="narrow left" data-direction="left"></a></div>
|
38 |
+
<div><a href="#" class="narrow right" data-direction="right"></a></div>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
|
43 |
+
<?php }
|
44 |
+
/*
|
45 |
+
* saving stuff
|
46 |
+
*/
|
47 |
+
function cf7_style_save_meta_box_data( $post_id ) {
|
48 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
if ( isset( $_POST['wpcf7-new'] ) ) {
|
52 |
+
if ( ! current_user_can( 'edit_page', $post_id ) ) {
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
} else {
|
56 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
if ( ! isset( $_POST['cf7style_template'] ) ) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
if ( !is_numeric( $_POST['cf7style_template'] ) ) {
|
65 |
+
die('No tricks please');
|
66 |
+
}
|
67 |
+
$styleid = sanitize_text_field( $_POST['cf7style_template'] );
|
68 |
+
update_post_meta( $post_id, 'cf7_style_id', $styleid );
|
69 |
+
}
|
70 |
+
add_action( 'save_post', 'cf7_style_save_meta_box_data' );
|
71 |
+
|
72 |
+
|
73 |
+
/*
|
74 |
+
* new panel
|
75 |
+
*/
|
76 |
+
function cf7style_add_template_panel ( $panels ) {
|
77 |
+
$panels['Cf7StyleTemplate'] = array(
|
78 |
+
'title' => __( 'Template', 'contact-form-7' ),
|
79 |
+
'callback' => 'cf7_style_display_slider'
|
80 |
+
);
|
81 |
+
return $panels;
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
/*
|
87 |
+
* old meta box
|
88 |
+
*/
|
89 |
+
function cf7style_meta_box ( $post_id ) {
|
90 |
+
add_meta_box('cf7_style_slider', 'Choose a template', 'cf7_style_display_slider', null, 'mail', 'core');
|
91 |
+
}
|
92 |
+
|
93 |
+
/*
|
94 |
+
* depending on what CF7 version is active,
|
95 |
+
* we use the appropiate hook!
|
96 |
+
*/
|
97 |
+
function init_meta_box_by_version() {
|
98 |
+
$plugin_folder = get_plugins( '/' . 'contact-form-7' );
|
99 |
+
$plugin_file = 'wp-contact-form-7.php';
|
100 |
+
$CF7Version = $plugin_folder[$plugin_file]['Version'];
|
101 |
+
if ( $CF7Version < 4.2 ) {
|
102 |
+
add_action( 'wpcf7_add_meta_boxes', 'cf7style_meta_box' );
|
103 |
+
} else {
|
104 |
+
add_filter( 'wpcf7_editor_panels', 'cf7style_add_template_panel' );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
add_action( 'admin_init', 'init_meta_box_by_version' );
|
js/frontend.js
CHANGED
@@ -2,13 +2,12 @@
|
|
2 |
jQuery functions for the Front end area
|
3 |
*/
|
4 |
jQuery(document).ready( function( $ ) {
|
5 |
-
var vdayRoses = 0;
|
6 |
// Valentine's Day Classic
|
7 |
$(".valentines-day-classic").prepend("<div class='heart'></div>");
|
8 |
|
9 |
//valentine's Day Rose
|
10 |
if( $(".valentines-day-roses").length > 0 ){
|
11 |
-
$(".valentines-day-roses").append("<div class='letter-box'></div>").find("input
|
12 |
}
|
13 |
|
14 |
|
@@ -29,7 +28,7 @@ jQuery(document).ready( function( $ ) {
|
|
29 |
$('.christmas-red').prepend('<div class="header"></div><div class="left"></div>').append('<div class="footer"></div>');
|
30 |
$('.christmas-red .wpcf7-radio .wpcf7-list-item').first().addClass('active');
|
31 |
$('.christmas-red .wpcf7-radio .wpcf7-list-item input').on( 'click', function() {
|
32 |
-
$('.christmas-red .wpcf7-radio .wpcf7-list-item').removeClass('active');
|
33 |
$(this).parent().addClass('active');
|
34 |
});
|
35 |
|
2 |
jQuery functions for the Front end area
|
3 |
*/
|
4 |
jQuery(document).ready( function( $ ) {
|
|
|
5 |
// Valentine's Day Classic
|
6 |
$(".valentines-day-classic").prepend("<div class='heart'></div>");
|
7 |
|
8 |
//valentine's Day Rose
|
9 |
if( $(".valentines-day-roses").length > 0 ){
|
10 |
+
$(".valentines-day-roses").append("<div class='letter-box'></div>").find("input, select").parents('p').appendTo($(".letter-box"));
|
11 |
}
|
12 |
|
13 |
|
28 |
$('.christmas-red').prepend('<div class="header"></div><div class="left"></div>').append('<div class="footer"></div>');
|
29 |
$('.christmas-red .wpcf7-radio .wpcf7-list-item').first().addClass('active');
|
30 |
$('.christmas-red .wpcf7-radio .wpcf7-list-item input').on( 'click', function() {
|
31 |
+
$('.christmas-red .wpcf7-radio .wpcf7-list-item, .christmas-red .wpcf7-radio .wpcf7-list-item label').removeClass('active');
|
32 |
$(this).parent().addClass('active');
|
33 |
});
|
34 |
|
misc/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php //silence
|
misc/tracking.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* on deactivation, if tracking is on, it will send info to plugin authors that the plugin is no longer active
|
4 |
+
*/
|
5 |
+
define( 'CF7_STYLE_PLUGIN_PATH', WP_PLUGIN_DIR . '/contact-form-7-style/' );
|
6 |
+
if ( !function_exists( 'cf7_style_announce_authors_about_deactivation' ) ) {
|
7 |
+
function cf7_style_announce_authors_about_deactivation () {
|
8 |
+
$allowedornot = get_option( 'cf7_style_allow_tracking' );
|
9 |
+
cf7style_send_tracking_info( $allowedornot, '0' );
|
10 |
+
}
|
11 |
+
register_deactivation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_deactivation' );
|
12 |
+
}
|
13 |
+
/*
|
14 |
+
* on activation, if tracking is on, it will send info to plugin authors that the plugin is active.
|
15 |
+
*/
|
16 |
+
if ( !function_exists( 'cf7_style_announce_authors_about_activation' ) ) {
|
17 |
+
function cf7_style_announce_authors_about_activation () {
|
18 |
+
$allowedornot = get_option( 'cf7_style_allow_tracking' );
|
19 |
+
cf7style_send_tracking_info( $allowedornot, '1' );
|
20 |
+
}
|
21 |
+
register_activation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_activation' );
|
22 |
+
}
|
23 |
+
/*
|
24 |
+
* enque pointer
|
25 |
+
*/
|
26 |
+
if ( !function_exists( 'cf7_style_tracking_enque_script' ) ) {
|
27 |
+
add_action( 'admin_enqueue_scripts', 'cf7_style_tracking_enque_script' );
|
28 |
+
function cf7_style_tracking_enque_script() {
|
29 |
+
$activeordismiss = get_option( 'cf7_style_allow_tracking' );
|
30 |
+
if ( $activeordismiss !== '0' && $activeordismiss !== '1' ) {
|
31 |
+
wp_enqueue_style( 'wp-pointer' );
|
32 |
+
wp_enqueue_script( 'wp-pointer' );
|
33 |
+
add_action( 'admin_print_footer_scripts', 'cf7_style_print_tooltip' );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/*
|
39 |
+
* prints the tooltip
|
40 |
+
*/
|
41 |
+
if ( !function_exists( 'cf7_style_print_tooltip' ) ) {
|
42 |
+
function cf7_style_print_tooltip() {
|
43 |
+
$pointer_content = '<h3>Contact Form 7 Style Tracking!</h3>';
|
44 |
+
$pointer_content .= '<p>You can allow us to track your website URL. We will know just that our plugin is actived and version of your WordPress. It will help us improve our plugin by knowing who is using it.</p>';
|
45 |
+
$pointer_content .= '<p><label for="cf7_style_allow_tracking">Allow tracking:</label> <input id="cf7_style_allow_tracking" type="checkbox" value="1" name="cf7_style_allow_tracking" /></p>'; ?>
|
46 |
+
<script type="text/javascript">
|
47 |
+
//<![CDATA[
|
48 |
+
jQuery(document).ready( function($) {
|
49 |
+
$('.menu-icon-cf7_style').pointer({
|
50 |
+
pointerClass: 'cf7style-pointer',
|
51 |
+
content: '<?php echo $pointer_content; ?>',
|
52 |
+
position: 'left',
|
53 |
+
close: function() {
|
54 |
+
$.post( ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=0", function(res){});
|
55 |
+
$('.cf7style-pointer').hide();
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
}).pointer('open');
|
59 |
+
});
|
60 |
+
//]]>
|
61 |
+
</script>
|
62 |
+
<style type="text/css">
|
63 |
+
.cf7style-pointer .wp-pointer-arrow {
|
64 |
+
top: 20px;
|
65 |
+
left: -1px;
|
66 |
+
}
|
67 |
+
</style>
|
68 |
+
<?php
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/*
|
73 |
+
* allow tracking set option
|
74 |
+
*/
|
75 |
+
if ( !function_exists( 'cf7_style_allow_tracking' ) ) {
|
76 |
+
function cf7_style_allow_tracking() {
|
77 |
+
if ( $_POST['action'] == 'cf7_style_allow_tracking' ) {
|
78 |
+
if ( !is_numeric( $_POST['cf7_style_allow_tracking'] ) ) {
|
79 |
+
die();
|
80 |
+
}
|
81 |
+
$allowedornot = $_POST['cf7_style_allow_tracking'];
|
82 |
+
if ( $allowedornot == '1' ) {
|
83 |
+
update_option( 'cf7_style_allow_tracking', '1' );
|
84 |
+
cf7style_send_tracking_info( $allowedornot, '1' );
|
85 |
+
} else {
|
86 |
+
update_option( 'cf7_style_allow_tracking', '0' );
|
87 |
+
cf7style_send_tracking_info( $allowedornot, '1' );
|
88 |
+
}
|
89 |
+
die();
|
90 |
+
}
|
91 |
+
}
|
92 |
+
add_action( 'wp_ajax_cf7_style_allow_tracking', 'cf7_style_allow_tracking' );
|
93 |
+
}
|
94 |
+
|
95 |
+
/*
|
96 |
+
* send traciking info function
|
97 |
+
*/
|
98 |
+
if ( !function_exists( 'cf7style_send_tracking_info' ) ) {
|
99 |
+
function cf7style_send_tracking_info( $allowedornot, $activated ) {
|
100 |
+
$url = 'http://cf7style.com/tracking/index.php';
|
101 |
+
$plugin_folder = get_plugins( '/' . 'contact-form-7-style' );
|
102 |
+
$plugin_file = 'cf7-style.php';
|
103 |
+
$plugindata = $plugin_folder[$plugin_file]['Version'];
|
104 |
+
$multi = ( is_multisite() ? '1' : '0' );
|
105 |
+
$data = array (
|
106 |
+
'allowed' => $allowedornot,
|
107 |
+
'wpversion' => get_bloginfo('version'),
|
108 |
+
'styleversion' => $plugindata,
|
109 |
+
'siteurl' => site_url(),
|
110 |
+
'multisite' => $multi,
|
111 |
+
'activated' => $activated
|
112 |
+
);
|
113 |
+
$cf7curl = curl_init();
|
114 |
+
$Curl = $url.'?method=withstyle&data='.base64_encode(json_encode($data)).'&format=json';
|
115 |
+
$curlconfig = array (
|
116 |
+
CURLOPT_URL => $Curl,
|
117 |
+
CURLOPT_RETURNTRANSFER => true
|
118 |
+
);
|
119 |
+
curl_setopt_array( $cf7curl, $curlconfig );
|
120 |
+
$output = curl_exec($cf7curl);
|
121 |
+
curl_close($cf7curl);
|
122 |
+
}
|
123 |
+
}
|
misc/welcome.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Welcome panel html
|
4 |
+
*/
|
5 |
+
if ( !function_exists( 'cf7_style_show_welcome_panel' ) ) {
|
6 |
+
function cf7_style_show_welcome_panel() {
|
7 |
+
$welm = get_option( 'cf7_style_welcome' );
|
8 |
+
if( $welm == "show_box") {
|
9 |
+
?>
|
10 |
+
<div class="wrap welcome-container">
|
11 |
+
<table class="wp-list-table widefat fixed cf7style-welcome-panel ">
|
12 |
+
<tbody>
|
13 |
+
<tr>
|
14 |
+
<td>
|
15 |
+
<h3>Need support?</h3>
|
16 |
+
<p>Support can be found <a href="https://wordpress.org/support/plugin/contact-form-7-style" target="_blank">here</a> or you can <a href="http://cf7style.com/contact/" target="_blank">contact us</a> for any related question!</p>
|
17 |
+
<p>Thank you for using Contact Form 7 Style!</p>
|
18 |
+
</td>
|
19 |
+
<td>
|
20 |
+
<ul>
|
21 |
+
<li><h3>Get Started</h3></li>
|
22 |
+
<li><a href="<?php echo admin_url('post-new.php?post_type=cf7_style'); ?>">Creating you first custom template</a></li>
|
23 |
+
<li><a href="<?php echo admin_url('edit.php?post_type=cf7_style'); ?>">Using predefined templates</a></li>
|
24 |
+
<li><a href="<?php echo admin_url('edit.php?post_type=cf7_style&page=cf7style-css-editor'); ?>">Adding Extra CSS</a></li>
|
25 |
+
</ul>
|
26 |
+
</td>
|
27 |
+
<td>
|
28 |
+
<ul>
|
29 |
+
<li>
|
30 |
+
<h3>Information</h3>
|
31 |
+
</li>
|
32 |
+
<li><a href="http://cf7style.com/#team" target="_blank">Who we are?</a></li>
|
33 |
+
<li><a href="http://cf7style.com/#why-cf7style" target="_blank">Why use our plugin?</a></li>
|
34 |
+
<li><a href="http://cf7style.com/faq/" target="_blank">FAQ</a></li>
|
35 |
+
</ul>
|
36 |
+
</td>
|
37 |
+
<td>
|
38 |
+
<h3>Buy as a coffee</h3>
|
39 |
+
<p>Supporting and developing this plugin takes us a lot of effort and energy.</p>
|
40 |
+
<p>You would help us a lot if you make a donation. We thank you in advance. </p>
|
41 |
+
</td>
|
42 |
+
<td>
|
43 |
+
<h3> </h3>
|
44 |
+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ionut.iclanzan.reea@gmail.com&item_name=Donation+for+Contact+Form+Style" target="_blank">
|
45 |
+
<?php echo '<img src="' . plugins_url( 'contact-form-7-style/admin/images/donate1.jpg' ) . '" > ';?>
|
46 |
+
</a>
|
47 |
+
</td>
|
48 |
+
</tr>
|
49 |
+
<tr>
|
50 |
+
<td colspan="5">
|
51 |
+
<a class="close-cf7-panel" href="#">Dismiss</a>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
</tbody>
|
55 |
+
|
56 |
+
|
57 |
+
</table>
|
58 |
+
</div>
|
59 |
+
<?php }
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
/*
|
64 |
+
* Welcome panel initialization on Cf7Style screen
|
65 |
+
*/
|
66 |
+
if ( !function_exists( 'cf7style_screen_page' ) ) {
|
67 |
+
function cf7style_screen_page() {
|
68 |
+
$screen = get_current_screen();
|
69 |
+
if ( $screen->id == 'edit-cf7_style' ) {
|
70 |
+
add_action( 'admin_notices' , 'cf7_style_show_welcome_panel' );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
add_action( 'current_screen', 'cf7style_screen_page' );
|
74 |
+
}
|
75 |
+
|
options.json
ADDED
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"width": {
|
3 |
+
"name": "Width",
|
4 |
+
"slug": "width",
|
5 |
+
"type": {
|
6 |
+
"numeric": {
|
7 |
+
"title": "Width",
|
8 |
+
"style": "width",
|
9 |
+
"property": "0",
|
10 |
+
"unit": [
|
11 |
+
"px",
|
12 |
+
"%",
|
13 |
+
"em"
|
14 |
+
]
|
15 |
+
}
|
16 |
+
},
|
17 |
+
"desc": "Change the default width of the current element."
|
18 |
+
},
|
19 |
+
"height": {
|
20 |
+
"name": "Height",
|
21 |
+
"slug": "height",
|
22 |
+
"type": {
|
23 |
+
"numeric": {
|
24 |
+
"title": "Height",
|
25 |
+
"style": "height",
|
26 |
+
"property": "0",
|
27 |
+
"unit": [
|
28 |
+
"px",
|
29 |
+
"%",
|
30 |
+
"em"
|
31 |
+
]
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"desc": "Change the default height of the current element."
|
35 |
+
},
|
36 |
+
"background": {
|
37 |
+
"name": "Background",
|
38 |
+
"slug": "background",
|
39 |
+
"type": {
|
40 |
+
"color-picker": {
|
41 |
+
"title": "Background Color",
|
42 |
+
"style": "background-color",
|
43 |
+
"property": "#fff"
|
44 |
+
},
|
45 |
+
"input": {
|
46 |
+
"title": "Background Image",
|
47 |
+
"style": "background-image",
|
48 |
+
"property": "none"
|
49 |
+
},
|
50 |
+
"select1": {
|
51 |
+
"title": "Background Position",
|
52 |
+
"style": "background-position",
|
53 |
+
"property": [
|
54 |
+
"left top",
|
55 |
+
"left center",
|
56 |
+
"left bottom",
|
57 |
+
"center top",
|
58 |
+
"center center",
|
59 |
+
"center bottom",
|
60 |
+
"right top",
|
61 |
+
"right center",
|
62 |
+
"right bottom"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
"select2": {
|
66 |
+
"title": "Background Size",
|
67 |
+
"style": "background-size",
|
68 |
+
"property": [
|
69 |
+
"inherit",
|
70 |
+
"cover",
|
71 |
+
"contain"
|
72 |
+
]
|
73 |
+
},
|
74 |
+
"select3": {
|
75 |
+
"title": "Background Repeat",
|
76 |
+
"style": "background-repeat",
|
77 |
+
"property": [
|
78 |
+
"no-repeat",
|
79 |
+
"repeat-x",
|
80 |
+
"repeat-y",
|
81 |
+
"repeat",
|
82 |
+
"space",
|
83 |
+
"round"
|
84 |
+
]
|
85 |
+
},
|
86 |
+
"select4": {
|
87 |
+
"title": "Background Attachment",
|
88 |
+
"style": "background-attachment",
|
89 |
+
"property": [
|
90 |
+
"inherit",
|
91 |
+
"fixed",
|
92 |
+
"scroll",
|
93 |
+
"local"
|
94 |
+
]
|
95 |
+
}
|
96 |
+
},
|
97 |
+
"desc": "Change the default background properties of the current element."
|
98 |
+
},
|
99 |
+
"border": {
|
100 |
+
"name": "Border",
|
101 |
+
"slug": "border",
|
102 |
+
"type": {
|
103 |
+
"numeric1": {
|
104 |
+
"title": "Border Width",
|
105 |
+
"style": "border-width",
|
106 |
+
"property": "0 0 0 0",
|
107 |
+
"unit": [
|
108 |
+
"px",
|
109 |
+
"%",
|
110 |
+
"em"
|
111 |
+
]
|
112 |
+
},
|
113 |
+
"select": {
|
114 |
+
"title": "Border Style",
|
115 |
+
"style": "border-style",
|
116 |
+
"property": [
|
117 |
+
"none",
|
118 |
+
"solid",
|
119 |
+
"dotted",
|
120 |
+
"double",
|
121 |
+
"groove",
|
122 |
+
"ridge",
|
123 |
+
"inset",
|
124 |
+
"outset"
|
125 |
+
]
|
126 |
+
},
|
127 |
+
"color-picker": {
|
128 |
+
"title": "Border color",
|
129 |
+
"style": "border-color",
|
130 |
+
"property": "#fff"
|
131 |
+
},
|
132 |
+
"numeric2": {
|
133 |
+
"title": "Border radius",
|
134 |
+
"style": "border-radius",
|
135 |
+
"property": "0 0 0 0",
|
136 |
+
"unit": [
|
137 |
+
"px",
|
138 |
+
"%",
|
139 |
+
"em"
|
140 |
+
]
|
141 |
+
}
|
142 |
+
},
|
143 |
+
"desc": "Add custom border."
|
144 |
+
},
|
145 |
+
"font": {
|
146 |
+
"name": "Font",
|
147 |
+
"slug": "font",
|
148 |
+
"type": {
|
149 |
+
"numeric1": {
|
150 |
+
"title": "Font size",
|
151 |
+
"style": "font-size",
|
152 |
+
"property": "0",
|
153 |
+
"unit": [
|
154 |
+
"px",
|
155 |
+
"%",
|
156 |
+
"em"
|
157 |
+
]
|
158 |
+
},
|
159 |
+
"select2": {
|
160 |
+
"title": "Font weight",
|
161 |
+
"style": "font-weight",
|
162 |
+
"property": [
|
163 |
+
"inherit",
|
164 |
+
"normal",
|
165 |
+
"bold",
|
166 |
+
"lighter",
|
167 |
+
"bolder",
|
168 |
+
"300",
|
169 |
+
"400",
|
170 |
+
"600",
|
171 |
+
"700"
|
172 |
+
]
|
173 |
+
},
|
174 |
+
"select1": {
|
175 |
+
"title": "Font style",
|
176 |
+
"style": "font-style",
|
177 |
+
"property": [
|
178 |
+
"normal",
|
179 |
+
"italic",
|
180 |
+
"oblique"
|
181 |
+
]
|
182 |
+
},
|
183 |
+
"select4": {
|
184 |
+
"title": "Text Align",
|
185 |
+
"style": "text-align",
|
186 |
+
"property": [
|
187 |
+
"left",
|
188 |
+
"right",
|
189 |
+
"center",
|
190 |
+
"justify",
|
191 |
+
"start",
|
192 |
+
"end"
|
193 |
+
]
|
194 |
+
},
|
195 |
+
"select3": {
|
196 |
+
"title": "Text transform",
|
197 |
+
"style": "text-transform",
|
198 |
+
"property": [
|
199 |
+
"inherit",
|
200 |
+
"capitalize",
|
201 |
+
"uppercase",
|
202 |
+
"lowercase",
|
203 |
+
"none"
|
204 |
+
]
|
205 |
+
},
|
206 |
+
"select5": {
|
207 |
+
"title": "Text decoration",
|
208 |
+
"style": "text-decoration",
|
209 |
+
"property": [
|
210 |
+
"none",
|
211 |
+
"underline",
|
212 |
+
"inherit",
|
213 |
+
"initial",
|
214 |
+
"unset"
|
215 |
+
]
|
216 |
+
},
|
217 |
+
"numeric2": {
|
218 |
+
"title": "Line Height",
|
219 |
+
"style": "line-height",
|
220 |
+
"property": "0",
|
221 |
+
"unit": [
|
222 |
+
"px",
|
223 |
+
"%",
|
224 |
+
"em"
|
225 |
+
]
|
226 |
+
},
|
227 |
+
|
228 |
+
"numeric3": {
|
229 |
+
"title": "Text indent",
|
230 |
+
"style": "text-indent",
|
231 |
+
"property": "0",
|
232 |
+
"unit": [
|
233 |
+
"px",
|
234 |
+
"%",
|
235 |
+
"em"
|
236 |
+
]
|
237 |
+
},
|
238 |
+
|
239 |
+
"color-picker": {
|
240 |
+
"title": "Color",
|
241 |
+
"style": "color",
|
242 |
+
"property": "#fff"
|
243 |
+
}
|
244 |
+
},
|
245 |
+
"desc": "Add custom font."
|
246 |
+
},
|
247 |
+
"margin": {
|
248 |
+
"name": "Margin",
|
249 |
+
"slug": "margin",
|
250 |
+
"type": {
|
251 |
+
"numeric": {
|
252 |
+
"title": "Margin",
|
253 |
+
"style": "margin",
|
254 |
+
"property": "0 0 0 0",
|
255 |
+
"unit": [
|
256 |
+
"px",
|
257 |
+
"%",
|
258 |
+
"em"
|
259 |
+
]
|
260 |
+
}
|
261 |
+
},
|
262 |
+
"desc": "Add custom margin."
|
263 |
+
},
|
264 |
+
"padding": {
|
265 |
+
"name": "Padding",
|
266 |
+
"slug": "padding",
|
267 |
+
"type": {
|
268 |
+
"numeric": {
|
269 |
+
"title": "Padding",
|
270 |
+
"style": "padding",
|
271 |
+
"property": "0 0 0 0",
|
272 |
+
"unit": [
|
273 |
+
"px",
|
274 |
+
"%",
|
275 |
+
"em"
|
276 |
+
]
|
277 |
+
}
|
278 |
+
},
|
279 |
+
"desc": "Add custom padding."
|
280 |
+
},
|
281 |
+
"float": {
|
282 |
+
"name": "Position",
|
283 |
+
"slug": "float",
|
284 |
+
"type": {
|
285 |
+
"select": {
|
286 |
+
"title": "Position",
|
287 |
+
"style": "float",
|
288 |
+
"property": [
|
289 |
+
"inherit",
|
290 |
+
"none",
|
291 |
+
"left",
|
292 |
+
"right"
|
293 |
+
]
|
294 |
+
}
|
295 |
+
},
|
296 |
+
"desc": "Add custom float."
|
297 |
+
},
|
298 |
+
"display": {
|
299 |
+
"name": "Display",
|
300 |
+
"slug": "display",
|
301 |
+
"type": {
|
302 |
+
"select": {
|
303 |
+
"title": "Display",
|
304 |
+
"style": "display",
|
305 |
+
"property": [
|
306 |
+
"inherit",
|
307 |
+
"none",
|
308 |
+
"inline",
|
309 |
+
"inline-block",
|
310 |
+
"block"
|
311 |
+
]
|
312 |
+
}
|
313 |
+
},
|
314 |
+
"desc": "Add custom display."
|
315 |
+
},
|
316 |
+
"box-sizing": {
|
317 |
+
"name": "Box sizing",
|
318 |
+
"slug": "box-sizing",
|
319 |
+
"type": {
|
320 |
+
"select": {
|
321 |
+
"title": "Box sizing",
|
322 |
+
"style": "box-sizing",
|
323 |
+
"property": [
|
324 |
+
"inherit",
|
325 |
+
"initial",
|
326 |
+
"unset",
|
327 |
+
"content-box",
|
328 |
+
"border-box"
|
329 |
+
]
|
330 |
+
}
|
331 |
+
},
|
332 |
+
"desc": "Add custom box sizing."
|
333 |
+
},
|
334 |
+
"comming-soon": {
|
335 |
+
"name": "Comming Soon",
|
336 |
+
"slug": "box-sizing",
|
337 |
+
"type": {
|
338 |
+
"comming-soon": {}
|
339 |
+
}
|
340 |
+
}
|
341 |
+
}
|
options.php
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contact Form 7 Style Options
|
4 |
+
*/
|
5 |
+
|
6 |
+
$domain = 'cf7_style';
|
7 |
+
$shortname = 'cf7s_custom';
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Options
|
11 |
+
*/
|
12 |
+
|
13 |
+
$options_string = file_get_contents( plugins_url() . '/contact-form-7-style/options.json');
|
14 |
+
$options = json_decode($options_string, true);
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Generate property fields
|
18 |
+
*/
|
19 |
+
|
20 |
+
function generate_property_fields( $key, $std, $name, $type, $saved_values, $selector_type, $domain ) {
|
21 |
+
$temp = '';
|
22 |
+
/*Had to remove numbers which adds the UNIQUE keys!*/
|
23 |
+
$title_addon = ($selector_type != "") ? str_replace('_', ' ', $selector_type): "";
|
24 |
+
$hidden_element = ($selector_type != "") ? "class='hidden".$title_addon."-element'": "";
|
25 |
+
$current_key = preg_replace('/[0-9]+/', '', strtolower( $key ) );
|
26 |
+
switch ( $current_key ) {
|
27 |
+
case 'color-picker':
|
28 |
+
case 'input':
|
29 |
+
$field_class = ($current_key == "input") ? "cf7-style-upload-field" : "cf7-style-color-field";
|
30 |
+
$saved_one = (array_key_exists( $name . "_". $std["style"].$selector_type, $saved_values)) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
|
31 |
+
return "<li ".$hidden_element."><label for='". $name . "_". $std["style"] .$selector_type."'><strong>".$std["title"].$title_addon.":</strong></label>".(($current_key == "color-picker") ? "<span class='icon smaller'><i class='fa fa-eyedropper' aria-hidden='true'></i></span>" : "")."<input type='text' id='". $name . "_". $std["style"] .$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"] .$selector_type."]' value='". $saved_one ."' class='".$field_class."' /></li>";
|
32 |
+
break;
|
33 |
+
case 'comming-soon':
|
34 |
+
return "<li></li>";
|
35 |
+
break;
|
36 |
+
case 'numeric':
|
37 |
+
$val = explode( " ", $std["property"] );
|
38 |
+
$temp .= "<li ".$hidden_element.">";
|
39 |
+
if( $std["property"] == "0 0 0 0"){
|
40 |
+
if( $std["style"] == "border-radius"){
|
41 |
+
$element= array( "top-left", "top-right-radius", "bottom-left-radius", "bottom-right-radius" );
|
42 |
+
$temp .= "<label for='".$name . "_border-top-left-radius".$selector_type."'><strong>".$std["title"].":</strong>";
|
43 |
+
} else {
|
44 |
+
$element= array( "top", "right", "bottom", "left" );
|
45 |
+
$labelos = explode( "-",$std["style"]);
|
46 |
+
if( $std["style"] == "border-radius"){
|
47 |
+
$ending = "-top-".$labelos[1].$selector_type;
|
48 |
+
} else {
|
49 |
+
$ending = "-top".$selector_type;
|
50 |
+
}
|
51 |
+
$temp .= "<label for='".$name . "_". $labelos[0].$ending."'><strong>".$std["title"].$title_addon.":</strong>";
|
52 |
+
}
|
53 |
+
}else {
|
54 |
+
$temp .= "<label for='".$name . "_". $std["style"].$selector_type."'><strong>".$std["title"].$title_addon.":</strong>";
|
55 |
+
}
|
56 |
+
$incrementor = 0;
|
57 |
+
$indexer = 0;
|
58 |
+
$arrows = array('up', 'right', 'down' , 'left');
|
59 |
+
$fonts = array( 'font-size' => 'text-height', 'line-height' => 'font', 'text-indent' => 'indent');
|
60 |
+
foreach( $val as $elem_key => $elem_value ) {
|
61 |
+
if( $std["property"] == "0 0 0 0"){
|
62 |
+
/*Add new style properties if 4 value property inserted*/
|
63 |
+
$newproperty = explode("-", $std["style"]);
|
64 |
+
$endstyling = $element[ $incrementor];
|
65 |
+
if( $std["style"] == "border-radius"){
|
66 |
+
$endstyling = $element[ $incrementor ]."-".end($newproperty);
|
67 |
+
}
|
68 |
+
$std["style"] = $newproperty[0] ."-".$endstyling;
|
69 |
+
$incrementor++;
|
70 |
+
}
|
71 |
+
$test = ( $std["style"] == "border-top" || $std["style"] == "border-right" || $std["style"] == "border-bottom" || $std["style"] == "border-left") ? '-width' : '' ;
|
72 |
+
$saved_one = ( array_key_exists( $name . "_". $std["style"].$test.$selector_type, $saved_values)) ? $saved_values [ $name . "_". $std["style"].$test.$selector_type ] : "";
|
73 |
+
switch ($type){
|
74 |
+
case "width" : $temp .= '<span class="icon"><i class="fa fa-arrows-h" aria-hidden="true"></i></span>'; break;
|
75 |
+
case "height" : $temp .= '<span class="icon"><i class="fa fa-arrows-v" aria-hidden="true"></i></span>'; break;
|
76 |
+
case "border" :
|
77 |
+
case "margin" :
|
78 |
+
case "padding": $temp .= '<span class="icon"><i class="fa fa-long-arrow-'.$arrows[$indexer++].'" aria-hidden="true"></i></span>'; break;
|
79 |
+
case "font" : $temp .= '<span class="icon"><i class="fa fa-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
|
80 |
+
}
|
81 |
+
$temp .= "<input type='number' min='0' max='1000' id='". $name . "_". $std["style"].$test.$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"].$test.$selector_type."]' value='". $saved_one ."' />";
|
82 |
+
|
83 |
+
$temp .= "<select id='". $name . "_". $std["style"] .$test . "_unit".$selector_type."' name='cf7stylecustom[". $name . "_". $std["style"] .$test ."_unit".$selector_type."]'>";
|
84 |
+
foreach( $std["unit"] as $unit_val ) {
|
85 |
+
$saved_one_unit = ( array_key_exists( $name . "_". $std["style"]. "_unit".$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"]. "_unit".$selector_type ] : "";
|
86 |
+
$temp .= "<option ". selected( $saved_one_unit , $unit_val, false ) . ">". $unit_val ."</option>";
|
87 |
+
}
|
88 |
+
$temp .= "</select>";
|
89 |
+
|
90 |
+
}
|
91 |
+
$temp .= "</label></li>";
|
92 |
+
return $temp;
|
93 |
+
break;
|
94 |
+
|
95 |
+
case 'select':
|
96 |
+
$fonts = array( 'font-style' => 'italic', 'font-weight' => 'bold', 'text-align' => 'align-center', 'text-decoration' => 'underline', 'text-transform' => 'header' );
|
97 |
+
$temp .= "<li ".$hidden_element."><label for='".$name . "_" . $std["style"].$selector_type."'><strong>".$std["title"].$title_addon.":</strong>";
|
98 |
+
switch ($type){
|
99 |
+
case "font" : $temp .= '<span class="icon"><i class="fa fa-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
|
100 |
+
}
|
101 |
+
$temp .= "<select id='". $name . "_" . $std["style"].$selector_type. "' name='cf7stylecustom[". $name . "_" . $std["style"] .$selector_type."]'>";
|
102 |
+
$temp .= '<option value="">'.__( "Choose value", $domain ).'</option>';
|
103 |
+
foreach( $std["property"] as $key => $value ) {
|
104 |
+
$saved_one = ( array_key_exists($name . "_". $std["style"].$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
|
105 |
+
$temp .= "<option ". selected( $saved_one , $value, false ) . ">". $value ."</option>";
|
106 |
+
}
|
107 |
+
$temp .= "</select></label></li>";
|
108 |
+
return $temp;
|
109 |
+
|
110 |
+
break;
|
111 |
+
|
112 |
+
default:
|
113 |
+
|
114 |
+
break;
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Elements
|
122 |
+
*/
|
123 |
+
$sameElements = array( "width", "height", "background", "margin", "padding", "font", "border", "float", "display", "box-sizing" );
|
124 |
+
$containerElements = array( "width", "height", "margin", "padding", "font", "border", "float", "box-sizing" );
|
125 |
+
$elements = array(
|
126 |
+
'form' => array(
|
127 |
+
'name' => 'form',
|
128 |
+
'description' => 'The Contact Form 7 form element\'s design can be modified below:',
|
129 |
+
'settings' => array("width", "height", "background", "margin", "padding", "border", "float", "box-sizing" )
|
130 |
+
),
|
131 |
+
'input' => array(
|
132 |
+
'name' => 'input',
|
133 |
+
'description' => 'This section allows styling of text, email, URL and contact numbers fields.',
|
134 |
+
'settings' => $sameElements
|
135 |
+
),
|
136 |
+
'textarea' => array(
|
137 |
+
'name' => 'text area',
|
138 |
+
'description' => 'This section allows styling the textarea fields.',
|
139 |
+
'settings' => $sameElements
|
140 |
+
),
|
141 |
+
"p" => array(
|
142 |
+
'name' => 'text',
|
143 |
+
'description' => '',
|
144 |
+
'settings' => $containerElements
|
145 |
+
),
|
146 |
+
'label' => array(
|
147 |
+
'name' => 'input label',
|
148 |
+
'description' => 'This section allows styling the input label.',
|
149 |
+
'settings' => $containerElements
|
150 |
+
),
|
151 |
+
'fieldset' => array(
|
152 |
+
'name' => 'fieldset',
|
153 |
+
'description' => '',
|
154 |
+
'settings' => $containerElements
|
155 |
+
),
|
156 |
+
'submit' => array(
|
157 |
+
'name' => 'submit button',
|
158 |
+
'description' => 'This section allows styling the submit button.',
|
159 |
+
'settings' => $sameElements
|
160 |
+
),
|
161 |
+
'select' => array(
|
162 |
+
'name' => 'dropdown menu',
|
163 |
+
'description' => 'This section allows styling the dropdown menus.',
|
164 |
+
'settings' => $sameElements
|
165 |
+
),
|
166 |
+
'acceptance' => array(
|
167 |
+
'name' => 'acceptance',
|
168 |
+
'description' => '',
|
169 |
+
'settings' => array("comming-soon")
|
170 |
+
),
|
171 |
+
'checkbox' => array(
|
172 |
+
'name' => 'checkboxes',
|
173 |
+
'description' => '',
|
174 |
+
'settings' => array("comming-soon")
|
175 |
+
),
|
176 |
+
'radio-buttons' => array(
|
177 |
+
'name' => 'radio buttons',
|
178 |
+
'description' => '',
|
179 |
+
'settings' => array("comming-soon")
|
180 |
+
),
|
181 |
+
'file' => array(
|
182 |
+
'name' => 'file',
|
183 |
+
'description' => '',
|
184 |
+
'settings' => array("comming-soon")
|
185 |
+
),
|
186 |
+
'quiz' => array(
|
187 |
+
'name' => 'quiz',
|
188 |
+
'description' => '',
|
189 |
+
'settings' => array("comming-soon")
|
190 |
+
),
|
191 |
+
);
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Get saved values
|
196 |
+
*/
|
197 |
+
|
198 |
+
wp_nonce_field( 'cf_7_style_style_customizer_inner_custom_box', 'cf_7_style_customizer_custom_box_nonce' );
|
199 |
+
$saved_values = unserialize( get_post_meta( $post->ID, 'cf7_style_custom_styler', 'a:0:{}' ) );
|
200 |
+
$saved_values = (empty($saved_values)) ? array() : $saved_values;
|
201 |
+
$active_panel = get_post_meta( $post->ID, 'cf7_style_active_panel', 'form' );
|
202 |
+
$active_panel = ( $active_panel=="" ) ? "form" : $active_panel;
|
203 |
+
|
204 |
+
$form_tags = '<div id="form-tag">';
|
205 |
+
$form_tags .= '<h4>'. __( "Choose element", $domain ).'</h4>';
|
206 |
+
$form_panel = '';
|
207 |
+
$form_index = 0;
|
208 |
+
foreach( $elements as $property => $property_value ) {
|
209 |
+
$selected_class = ( $active_panel == $property) ? ' button-primary' : '';
|
210 |
+
$hidden_class = ( $active_panel != $property || ( $active_panel =="" && $form_index++ > 0)) ? ' hidden' : '';
|
211 |
+
$form_tags .= "<a href='#' class='button".$selected_class."' data-property='".$property."'>" . $property_value['name'] . "</a>";
|
212 |
+
$form_panel .= "<div class='". $property ."-panel panel".$hidden_class." clearfix'>";
|
213 |
+
if( $property_value['description'] != ""){
|
214 |
+
$form_panel .= '<h4 class="description-title">'.$property_value['description'].'</h4>';
|
215 |
+
}
|
216 |
+
foreach( $property_value['settings'] as $sub_property_key => $sub_property_value ) {
|
217 |
+
$property = strtolower( $property );
|
218 |
+
$sub_property_slug = strtolower( $options[$sub_property_value]['slug'] );
|
219 |
+
$style_element_name = strtolower($options[$sub_property_value]['name']);
|
220 |
+
$half_width_class = ( $style_element_name == "box sizing" || $style_element_name == "display" || $style_element_name == "position" || $style_element_name == "width" || $style_element_name == "height") ? "half-size" : "";
|
221 |
+
$form_panel .= '<div class="element-styling '.$half_width_class.' '.$style_element_name.'"><h3><span><'.$property.'></span> '.$style_element_name . '</h3>';
|
222 |
+
if( $options[$sub_property_value]['type'] ) {
|
223 |
+
$form_panel .= "<ul>";
|
224 |
+
foreach( $options[$sub_property_value]['type'] as $key => $value ) {
|
225 |
+
if( $key != "comming-soon" ){
|
226 |
+
$form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '', $domain);
|
227 |
+
$form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover', $domain );
|
228 |
+
} else {
|
229 |
+
$form_panel .= "<li></li>";
|
230 |
+
}
|
231 |
+
}
|
232 |
+
$form_panel .= "</ul>";
|
233 |
+
$form_panel .= "</div>";
|
234 |
+
}
|
235 |
+
}
|
236 |
+
$form_panel .= "</div>";
|
237 |
+
}
|
238 |
+
?>
|
239 |
+
|
240 |
+
<div class="generate-preview">
|
241 |
+
<?php
|
242 |
+
$form_args = array(
|
243 |
+
'post_type' => 'wpcf7_contact_form',
|
244 |
+
'posts_per_page' => -1,
|
245 |
+
'meta_key' => 'cf7_style_id',
|
246 |
+
'meta_value' => $post->ID
|
247 |
+
);
|
248 |
+
$indexter = 0;
|
249 |
+
$form_el = array();
|
250 |
+
$form_query = new WP_Query( $form_args );
|
251 |
+
while ( $form_query->have_posts() ) : $form_query->the_post();
|
252 |
+
$cur_title = get_the_title();
|
253 |
+
$form_el[$indexter]['form'] = do_shortcode( '[contact-form-7 id="'.get_the_ID().'" title="'.$cur_title.'"]' );
|
254 |
+
$form_el[$indexter++]['form_title'] = $cur_title;
|
255 |
+
endwhile;
|
256 |
+
wp_reset_postdata();
|
257 |
+
$form_choose ="";
|
258 |
+
if($indexter > 1){
|
259 |
+
$form_choose = '<div class="choose-preview"><h4>'.__( "Choose form to preview:", $domain ).'</h4>';
|
260 |
+
$form_choose .= '<select name="form-preview" id="form-preview">';
|
261 |
+
foreach ($form_el as $key => $cur_form) {
|
262 |
+
$form_choose .= '<option value="'.$key.'" '.selected($key,0,false).'>'.$cur_form['form_title'].'</option>';
|
263 |
+
}
|
264 |
+
$form_choose .= "</select></div>";
|
265 |
+
}
|
266 |
+
$form_tags .= '</div>';?>
|
267 |
+
<div class="panel-options">
|
268 |
+
<h3><?php echo __( "Customize form", $domain );?></h3>
|
269 |
+
<?php echo $form_tags; ?>
|
270 |
+
<div class="element-selector clearfix">
|
271 |
+
<h4><?php echo __( "Choose element state", $domain ); ?></h4>
|
272 |
+
<label><input type="radio" name="element-type" checked = "checked" value="normal" /> <?php echo __( "normal state", $domain ); ?></label>
|
273 |
+
<label><input type="radio" name="element-type" value="hover" /> <?php echo __( ":hover state", $domain ); ?></label>
|
274 |
+
<div class="hidden"><input type="text" name="cf7styleactivepane" value="<?php echo $active_panel; ?>"></div>
|
275 |
+
</div>
|
276 |
+
<?php echo $form_panel; ?>
|
277 |
+
</div>
|
278 |
+
<div class='panel-header'>
|
279 |
+
|
280 |
+
<h3><?php echo __( "Preview Area", $domain ); ?></h3>
|
281 |
+
<?php echo $form_choose; ?>
|
282 |
+
<div class='preview-form-tag' id="preview">
|
283 |
+
<?php
|
284 |
+
$indexter = 0;
|
285 |
+
foreach ($form_el as $key => $cur_form) {
|
286 |
+
$extra_class= ($indexter++ != 0) ? 'hidden' : ''; ?>
|
287 |
+
<div class="preview-form-container <?php echo $extra_class; ?>">
|
288 |
+
<h4><?php echo $cur_form['form_title']; ?></h4>
|
289 |
+
<?php echo $cur_form['form']; ?>
|
290 |
+
</div>
|
291 |
+
<?php } ?>
|
292 |
+
</div>
|
293 |
+
</div>
|
294 |
+
</div>
|
295 |
+
<div class="fixed-save-style">
|
296 |
+
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="Save Style">
|
297 |
+
</div>
|
predefined-templates.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"title":"Twenty Fifteen Pattern",
|
4 |
+
"category":"simple pattern style",
|
5 |
+
"image":"\/admin\/images\/cf7_simple_twentyfifteen_pattern.jpg"
|
6 |
+
},
|
7 |
+
{
|
8 |
+
"title":"Christmas Classic",
|
9 |
+
"category":"christmas style",
|
10 |
+
"image":"\/admin\/images\/cf7_xmas_classic.jpg"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"title":"Christmas Red",
|
14 |
+
"category":"christmas style",
|
15 |
+
"image":"\/admin\/images\/cf7_xmas_red.jpg"
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"title":"Christmas Simple",
|
19 |
+
"category":"christmas style",
|
20 |
+
"image":"\/admin\/images\/cf7_xmas_simple.jpg"
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"title":"Valentine's Day Classic",
|
24 |
+
"category":"valentine's day style",
|
25 |
+
"image":"\/admin\/images\/cf7_vday_classic.jpg"
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"title":"Valentine's Day Roses",
|
29 |
+
"category":"valentine's day style",
|
30 |
+
"image":"\/admin\/images\/cf7_vday_roses.jpg"
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"title":"Valentine's Day Birds",
|
34 |
+
"category":"valentine's day style",
|
35 |
+
"image":"\/admin\/images\/cf7_vday_birds.jpg"
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"title":"Valentine's Day Blue Birds",
|
39 |
+
"category":"valentine's day style",
|
40 |
+
"image":"\/admin\/images\/cf7_vday_blue_birds.jpg"
|
41 |
+
}
|
42 |
+
]
|
readme.txt
CHANGED
@@ -1,137 +1,156 @@
|
|
1 |
-
=== Contact Form 7 Style ===
|
2 |
-
Contributors:
|
3 |
-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ionut.iclanzan.reea@gmail.com&item_name=Donation+for+Contact+Form+Style
|
4 |
-
Tags: contact form 7, contact form 7 style, contact form 7 css, contact form 7 styling, CF7, CF7 style, styling contact form, styling contact form 7, multiple form styling, custom form styling, CF7 addon, customize, templates, valentine's day templates, Christmas templates
|
5 |
-
Requires at least: 3.0.1
|
6 |
-
Tested up to: 4.2
|
7 |
-
Stable tag: 4.
|
8 |
-
License: GPLv2 or later
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
-
Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
|
16 |
-
Supports custom styling, which can be easily managed via admin dashboard. Also has predefined templates like Simple Pattern, Valentine's Day, Christmas that can be activated on your Contact Form 7. <BR>
|
17 |
-
|
18 |
-
> This plugin requires the <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7 plugin</a><BR>
|
19 |
-
|
20 |
-
**Custom style options: <BR>**
|
21 |
-
- color styling, <BR>
|
22 |
-
- custom fonts ( google fonts included ), <BR>
|
23 |
-
- styling for input fields, text, textarea, labels, submit button <BR>
|
24 |
-
- border-color, <BR>
|
25 |
-
- form background-color, <BR>
|
26 |
-
- form
|
27 |
-
-
|
28 |
-
-
|
29 |
-
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
==
|
43 |
-
|
44 |
-
1.
|
45 |
-
2.
|
46 |
-
3.
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
*
|
65 |
-
|
66 |
-
|
67 |
-
*
|
68 |
-
*
|
69 |
-
*
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
*
|
74 |
-
*
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
*
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
*
|
92 |
-
*
|
93 |
-
*
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
*
|
98 |
-
|
99 |
-
= 2.
|
100 |
-
*
|
101 |
-
*
|
102 |
-
|
103 |
-
|
104 |
-
*
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
*
|
109 |
-
|
110 |
-
|
111 |
-
*
|
112 |
-
*
|
113 |
-
|
114 |
-
|
115 |
-
*
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
*
|
121 |
-
|
122 |
-
|
123 |
-
*
|
124 |
-
*
|
125 |
-
*
|
126 |
-
|
127 |
-
|
128 |
-
*
|
129 |
-
|
130 |
-
= 1.
|
131 |
-
*
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
*
|
136 |
-
* Added
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Contact Form 7 Style ===
|
2 |
+
Contributors: ionut.iclanzan, dorumarginean, mlehelsz, mircear
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ionut.iclanzan.reea@gmail.com&item_name=Donation+for+Contact+Form+Style
|
4 |
+
Tags: contact form 7, contact form 7 style, contact form 7 css, contact form 7 styling, CF7, CF7 style, styling contact form, styling contact form 7, multiple form styling, custom form styling, CF7 addon, customize, templates, valentine's day templates, Christmas templates, manual styling, live preview, hover state styling
|
5 |
+
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.5.2
|
7 |
+
Stable tag: 4.5.2
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
[Contact Form 7 Style](http://cf7style.com/) plugin is an addon for [Contact Form 7](http://wordpress.org/plugins/contact-form-7/) which needs to be installed on your wordpress blog.
|
16 |
+
Supports custom styling, which can be easily managed via admin dashboard. Also has predefined templates like Simple Pattern, Valentine's Day, Christmas that can be activated on your Contact Form 7. <BR>
|
17 |
+
|
18 |
+
> This plugin requires the <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7 plugin</a><BR>
|
19 |
+
|
20 |
+
**Custom style options: <BR>**
|
21 |
+
- color styling, <BR>
|
22 |
+
- custom fonts ( google fonts included ), <BR>
|
23 |
+
- styling for input fields, text, textarea, labels, submit button <BR>
|
24 |
+
- border-color, <BR>
|
25 |
+
- form background-color, <BR>
|
26 |
+
- form background-image, <BR>
|
27 |
+
- form container styling, <BR>
|
28 |
+
- form container background-image styling, <BR>
|
29 |
+
- customized style can be imported / exported <BR>
|
30 |
+
- quick edit option <BR>
|
31 |
+
- support multiple forms with different design<BR>
|
32 |
+
- Style Template Slider on the Contact Form 7 form Settings page<BR>
|
33 |
+
- px,em, % unit selector for all the specified style settings<BR>
|
34 |
+
- possibility to change the syling for the HOVER state of each element<BR>
|
35 |
+
- Live preview on changing/adding the new style properties of each element<BR>
|
36 |
+
|
37 |
+
<strong>Support can be found [here](https://wordpress.org/support/plugin/contact-form-7-style).</strong>
|
38 |
+
|
39 |
+
or you can check the [FAQ](http://cf7style.com/faq/) section.
|
40 |
+
|
41 |
+
|
42 |
+
== Installation ==
|
43 |
+
|
44 |
+
1. Upload the entire `contact-form-7-style` folder to the `/wp-content/plugins/` directory
|
45 |
+
2. Make sure that Contact Form 7 is installed and activated ( an admin notice will check for this )
|
46 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
47 |
+
|
48 |
+
You will find 'Contact Style' menu in your WordPress admin panel.
|
49 |
+
|
50 |
+
== Screenshots ==
|
51 |
+
|
52 |
+
1. The Contact Style main settings page with predefined, responsive Style Templates
|
53 |
+
2. Custom new style Settings page with Google Font Selector, live preview and multiple element styling with the possibility to change the settings unit.
|
54 |
+
3. Template slider for quick setup of the form styling on the Contact Form 7 Settings Page.
|
55 |
+
4. Possibility to remove predefined templates only with 2 clicks.
|
56 |
+
5. Quick Edit on the Contact Style Settings Page, which allows Style Apply on various forms in a few seconds away.
|
57 |
+
6. Manual CSS Editor on the pages/posts which contains one or more Contact Form 7 forms.
|
58 |
+
7. Form Selector on the new Custom Style Setup Page.
|
59 |
+
8. Google Font Selector with all the Google Fonts included in one Dropdown with preview on the right side of the Dropdown.
|
60 |
+
|
61 |
+
== Changelog ==
|
62 |
+
|
63 |
+
= 3.0.0 =
|
64 |
+
* UI rework, update, redesign
|
65 |
+
* New feature - Live Preview on all element changes with the actual Contact Form 7 form where the styling is applied
|
66 |
+
* New feature - Hover state design for all elements
|
67 |
+
* New feature - Style Selector Slider on Contact Form 7 Settings page, for quick style selection
|
68 |
+
* New feature - Introduced new unit selector
|
69 |
+
* New feature - Introduced new background-image add-on
|
70 |
+
* New feature - Introduced new styling properties
|
71 |
+
* New feature - Introduced fieldset, dropdowns, radio, checkbox
|
72 |
+
* Improvements - Bugfixing, running process, code updates
|
73 |
+
* Improvements - Modified Custom Styling logic and add it to new settings page
|
74 |
+
* Improvements - Message boxes behaviour
|
75 |
+
* Improvements - autocomplete styling where possible
|
76 |
+
|
77 |
+
= 2.2.5 =
|
78 |
+
* [Fixed](https://wordpress.org/support/topic/avada-theme-5) Avada Theme Fusion Page Builder incompatibility issue
|
79 |
+
* [Fixed](https://wordpress.org/support/topic/good-morning-1) Contact form 7 shortcode detection for Flatco - Multipurpose & Responsive WordPress Theme
|
80 |
+
* Improve plugin installer process
|
81 |
+
|
82 |
+
|
83 |
+
= 2.2.4 =
|
84 |
+
* New feature - ability to add your own custom css rules
|
85 |
+
* [Fixed](https://wordpress.org/support/topic/textarea-height-and-submit-width) textarea and submit button on focus issue
|
86 |
+
|
87 |
+
= 2.2.3 =
|
88 |
+
* [Fixed](https://wordpress.org/support/topic/style-doesnt-apply-to-an-existing-form) simple template style issue
|
89 |
+
|
90 |
+
= 2.2.2 =
|
91 |
+
* Minor JQuery fixes for newer wordpress version
|
92 |
+
* Fixed custom style for textarea selector
|
93 |
+
* Admin panel minor adjustments
|
94 |
+
|
95 |
+
= 2.2.1 =
|
96 |
+
* New feature - textarea field additional options
|
97 |
+
* [Fixed](https://wordpress.org/support/topic/field-style-issue?replies=6) textarea field style issue
|
98 |
+
|
99 |
+
= 2.2 =
|
100 |
+
* Fixed Chrome preview problem
|
101 |
+
* Removed unnecessary elements from nav menus
|
102 |
+
* Fixed custom style no title problem
|
103 |
+
* [Fixed](https://wordpress.org/support/topic/custom-style-is-not-working?replies=6) css class generator
|
104 |
+
* New feature - Added quick edit
|
105 |
+
* New feature - Added new simple pattern style category with Twenty Fifteen Pattern
|
106 |
+
|
107 |
+
= 2.1.1 =
|
108 |
+
* Minor JQuery fixes for older wordpress version
|
109 |
+
|
110 |
+
= 2.1 =
|
111 |
+
* New feature - Google fonts preview when edit the style
|
112 |
+
* New feature - List all styles thumbnail preview for predefined templates
|
113 |
+
|
114 |
+
= 2.0.1 =
|
115 |
+
* Admin panel minor adjustments
|
116 |
+
|
117 |
+
= 2.0 =
|
118 |
+
* New UI Admin settings options
|
119 |
+
* Use custom post type for individual style set up
|
120 |
+
* Multiple cf7 forms can have their own style
|
121 |
+
* Style can be activated only for certain cf7 forms
|
122 |
+
* All google fonts available for use
|
123 |
+
* Styling improvement for theme twentyfifteen, twentyfourteen
|
124 |
+
* New settings available
|
125 |
+
* Possibility to change certain settings for the "custom style" styles
|
126 |
+
* Style filtering by categories for easier use
|
127 |
+
* Possibility to save your settings and import / export the generated "custom style"
|
128 |
+
* Donate option for support the plugin's continued development and better user support
|
129 |
+
|
130 |
+
= 1.1.1 =
|
131 |
+
* Added plugin update notification in plugin template selection panel
|
132 |
+
|
133 |
+
= 1.1.0 =
|
134 |
+
* Added Valentine's Day templates for 2014.
|
135 |
+
* Fixed Xmas Red header and footer position
|
136 |
+
* Added Custom Style submenu for styling the templates
|
137 |
+
|
138 |
+
= 1.0.1 =
|
139 |
+
* Fixed x-mas classic display on 2014 wordpress theme.
|
140 |
+
|
141 |
+
= 1.0 =
|
142 |
+
* First plugin version.
|
143 |
+
|
144 |
+
== Upgrade Notice ==
|
145 |
+
= Contact Form 7 Style Version 3.0.0 =
|
146 |
+
* UI rework, update, redesign
|
147 |
+
* New feature - Live Preview on all element changes with the actual Contact Form 7 form where the styling is applied
|
148 |
+
* New feature - Hover state design for all elements
|
149 |
+
* New feature - Style Selector Slider on Contact Form 7 Settings page, for quick style selection
|
150 |
+
* New feature - Introduced new unit selector
|
151 |
+
* New feature - Introduced new background-image add-on
|
152 |
+
* New feature - Introduced new styling properties
|
153 |
+
* New feature - Introduced fieldset, dropdowns, radio, checkbox
|
154 |
+
* Improvements - Bugfixing, running process, code updates
|
155 |
+
* Improvements - Modified Custom Styling logic and add it to new settings page
|
156 |
+
* Improvements - Message boxes behaviour
|
screenshot-1.jpg
CHANGED
Binary file
|
screenshot-2.jpg
CHANGED
Binary file
|
screenshot-3.jpg
CHANGED
Binary file
|
screenshot-4.jpg
ADDED
Binary file
|
screenshot-5.jpg
ADDED
Binary file
|
screenshot-6.jpg
ADDED
Binary file
|
screenshot-7.jpg
ADDED
Binary file
|
screenshot-8.jpg
ADDED
Binary file
|