Master Slider – Responsive Touch Slider - Version 1.0.10

Version Description

Download this release

Release Info

Developer averta
Plugin Icon 128x128 Master Slider – Responsive Touch Slider
Version 1.0.10
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.10

README.txt CHANGED
@@ -3,10 +3,10 @@ Contributors: averta
3
  Donate link: http://averta.net/
4
  License: GPLv3
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
- Tags: banner rotator, carousel, content slider, gallery, image slider, responsive slider, showcase, slideshow, swipe, touch slider, video gallery, SEO, vertical slide, HTML5 slider, hardware accelerate, css3, animation, mobile slider, iOS, android, video slider, youtube slider, horizontal slider, vertical slider, fullwidth slider, fullscreen slider, post slider, photo slider, online album, mobile slider, WordPress slider,wpml, ,ultisite, wistia
7
  Requires at least: 3.8
8
- Tested up to: 3.9.1
9
- Stable tag: 1.0.5
10
 
11
  The Most advanced responsive HTML5 WordPress slider plugin with touch swipe navigation that works smoothly on devices too.
12
 
@@ -14,8 +14,9 @@ The Most advanced responsive HTML5 WordPress slider plugin with touch swipe navi
14
 
15
  Master Slider is a free responsive image and content slider with super smooth hardware accelerated transitions. It supports touch navigation with pure swipe gesture that you have never experienced before. It's a truly responsive and device friendly slider which works perfectly in all major devices.
16
 
 
17
 
18
- Master Slider is built using WordPress best practices both on the front and the back end. This results in an efficient, robust and intuitive plugin. It's works with any theme, including the default WordPress themes.
19
 
20
 
21
  = Features =
@@ -123,7 +124,7 @@ You can use automatic update to update the plugin safely.
123
 
124
  If you have any question about working with "Master Slider", you can take a look at [online documentations](http://masterslider.com/doc/wp/free/)
125
 
126
- If you get stuck you can ask for help on the [Support Forums](http://wordpress.org/tags/master-slider).
127
 
128
  = Will Master Slider work with my theme? =
129
  Master Slider works with any theme, including the default WordPress themes.
@@ -157,11 +158,26 @@ Bugs can be reported in our [support forums](http://wordpress.org/tags/master-sl
157
 
158
  == Changelog ==
159
 
160
- = Version 1.0.5 / (15.07.2014) =
161
- * An issue with uninstalling the plugin fixed
 
 
 
 
 
 
 
162
 
163
- = Version 1.0.4 / (13.07.2014) =
164
- * Documentations added to readme file
 
 
 
 
 
 
 
 
165
 
166
  = Version 1.0.1 / (12.07.2014) =
167
  * initial release
@@ -170,5 +186,6 @@ Bugs can be reported in our [support forums](http://wordpress.org/tags/master-sl
170
 
171
  == Upgrade Notice ==
172
 
173
- = 1.0.5 =
174
- * An issue with uninstalling the plugin fixed
 
3
  Donate link: http://averta.net/
4
  License: GPLv3
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
+ Tags: banner rotator, carousel, content slider, gallery, image slider, responsive slider, showcase, slideshow, swipe, touch slider, video gallery, SEO, vertical slide, HTML5 slider, hardware accelerate, css3, animation, mobile slider, iOS, android, video slider, youtube slider, horizontal slider, vertical slider, fullwidth slider, fullscreen slider, post slider, photo slider, online album, mobile slider, WordPress slider,wpml, ,ultisite, wistia, woocommerce, product slider, woocommerce slider
7
  Requires at least: 3.8
8
+ Tested up to: 3.9.2
9
+ Stable tag: 1.0.10
10
 
11
  The Most advanced responsive HTML5 WordPress slider plugin with touch swipe navigation that works smoothly on devices too.
12
 
14
 
15
  Master Slider is a free responsive image and content slider with super smooth hardware accelerated transitions. It supports touch navigation with pure swipe gesture that you have never experienced before. It's a truly responsive and device friendly slider which works perfectly in all major devices.
16
 
17
+ [youtube http://www.youtube.com/watch?v=t0N5BTH8kfE]
18
 
19
+ Master Slider is built using WordPress best practices both on the front and the back end. This results in an efficient, robust and intuitive plugin. It's works with any theme, including the default WordPress themes.
20
 
21
 
22
  = Features =
124
 
125
  If you have any question about working with "Master Slider", you can take a look at [online documentations](http://masterslider.com/doc/wp/free/)
126
 
127
+ If you get stuck you can follow these [steps to get support](http://masterslider.com/doc/wp/free/#support).
128
 
129
  = Will Master Slider work with my theme? =
130
  Master Slider works with any theme, including the default WordPress themes.
158
 
159
  == Changelog ==
160
 
161
+ = Version 1.0.10 / (07.08.2014) =
162
+ * Slide info is now shortcode enabled
163
+ * compatibility with WordPress 3.9.2 added
164
+
165
+ = Version 1.0.9 / (22.07.2014) =
166
+ * A minor bug in plugins page fixed
167
+
168
+ = Version 1.0.8 / (21.07.2014) =
169
+ * A link added to plugins page for rating this plugin
170
 
171
+ = Version 1.0.7 / (19.07.2014) =
172
+ * [New Feature]: New option added to global setting that let you load plugins's scripts on all pages.
173
+ ( Useful when loading slider via Ajax )
174
+ * An issue with text editor fixed
175
+
176
+ = Version 1.0.6 / (17.07.2014) =
177
+ * [New]: Introduction video added
178
+
179
+ = Version 1.0.5 / (15.07.2014) =
180
+ * [Fix]: An issue with uninstalling the plugin fixed
181
 
182
  = Version 1.0.1 / (12.07.2014) =
183
  * initial release
186
 
187
  == Upgrade Notice ==
188
 
189
+ = 1.0.10 =
190
+ * Slide info is now shortcode enabled
191
+ * compatibility with WordPress 3.9.2 added
admin/includes/classes/class-msp-parser.php CHANGED
@@ -316,7 +316,7 @@ class MSP_Parser {
316
  'target' => isset( $slide['linkTarget'] ) ? (string) $slide['linkTarget'] : '',
317
  'video' => isset( $slide['video'] ) ? esc_attr( $slide['video'] ) : '', // youtube or vimeo video link
318
 
319
- 'info' => wp_slash( $info ), // image alternative text
320
 
321
  'mp4' => isset( $slide['bgv_mp4'] ) ? esc_attr( $slide['bgv_mp4'] ) : '', // self host video bg
322
  'webm' => isset( $slide['bgv_webm'] ) ? esc_attr( $slide['bgv_webm'] ) : '', // self host video bg
316
  'target' => isset( $slide['linkTarget'] ) ? (string) $slide['linkTarget'] : '',
317
  'video' => isset( $slide['video'] ) ? esc_attr( $slide['video'] ) : '', // youtube or vimeo video link
318
 
319
+ 'info' => wp_slash( do_shortcode( $info ) ), // image alternative text
320
 
321
  'mp4' => isset( $slide['bgv_mp4'] ) ? esc_attr( $slide['bgv_mp4'] ) : '', // self host video bg
322
  'webm' => isset( $slide['bgv_webm'] ) ? esc_attr( $slide['bgv_webm'] ) : '', // self host video bg
admin/includes/msp-hooks.php CHANGED
@@ -1 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
+ function after_master_slider_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ){
4
+ if( MSWP_AVERTA_BASE_NAME == $plugin_file ) {
5
+ $plugin_meta[] = '<a href="http://wordpress.org/support/view/plugin-reviews/' . MSWP_SLUG . '?rating=5#postform" target="_blank" title="' . esc_attr__( 'Rate this plugin', MSWP_TEXT_DOMAIN ) . '">' . __( 'Rate this plugin', MSWP_TEXT_DOMAIN ) . '</a>';
6
+ $plugin_meta[] = '<a href="http://masterslider.com/doc/wp/free/#donate" target="_blank" title="' . esc_attr__( 'Donate', MSWP_TEXT_DOMAIN ) . '">' . __( 'Donate', MSWP_TEXT_DOMAIN ) . '</a>';
7
+ }
8
+ return $plugin_meta;
9
+ }
10
+
11
+ add_filter( "plugin_row_meta", 'after_master_slider_row_meta', 10, 4 );
admin/views/setting/class-msp-settings.php CHANGED
@@ -70,6 +70,11 @@ class MSP_Settings {
70
  )
71
  );
72
 
 
 
 
 
 
73
  return $sections;
74
  }
75
 
@@ -105,6 +110,15 @@ class MSP_Settings {
105
  )
106
  );
107
 
 
 
 
 
 
 
 
 
 
108
  return $settings_fields;
109
  }
110
 
70
  )
71
  );
72
 
73
+ $sections[] = array(
74
+ 'id' => 'msp_advanced',
75
+ 'title' => __( 'Advanced Setting', MSWP_TEXT_DOMAIN )
76
+ );
77
+
78
  return $sections;
79
  }
80
 
110
  )
111
  );
112
 
113
+ $settings_fields['msp_advanced'] = array(
114
+ array(
115
+ 'name' => 'allways_load_ms_assets',
116
+ 'label' => __( 'Load assets on all pages?', MSWP_TEXT_DOMAIN ),
117
+ 'desc' => __( 'By default, Master Slider will load corresponding JavaScript files on demand. but if you need to load assets on all pages, check this option. ( For example, if you plan to load Master Slider via Ajax, you need to check this option ) ', MSWP_TEXT_DOMAIN ),
118
+ 'type' => 'checkbox'
119
+ )
120
+ );
121
+
122
  return $settings_fields;
123
  }
124
 
admin/views/slider-panel/js/masterslider.wp.js CHANGED
@@ -1,3108 +1,7 @@
1
- //js\mspanel\MSpanel.js
2
-
3
- /*!
4
- * @overview Master Slider Lite Wordpress Panel
5
- * @copyright Copyright 2014 Averta Ltd.
6
- * @version 1.0
7
- * http://www.averta.net
8
- */
9
-
10
- window.MSPanel = Ember.Application.create({ rootElement : "#msp-root" });
11
- MSPanel.version = '1.0';
12
- MSPanel.SliderID = parseQueryString(window.location.search).slider_id || __MSP_SLIDER_ID || '100';
13
-
14
- /**
15
- * Adds new function to String object 'jfmt' it's like Ember.fmt but first replaces '%s' or '%d' to '%@'
16
- * @example 'Hi, %s'.jfmt('John');
17
- */
18
- String.prototype.jfmt = function(){ return ''.fmt.apply(this.replace(/%s|%d/, '%@') ,arguments); };
19
-
20
- $ = jQuery.noConflict();
21
- jQuery.ui.dialog.prototype._focusTabbable = function(){};
22
-
23
- // Setup Application Router
24
- MSPanel.Router.map(function() {
25
- this.resource('settings' );
26
- this.resource('slides', {path: '/'});
27
- this.resource('controls');
28
- this.resource('callbacks');
29
- this.resource('error');
30
- });
31
- MSPanel.Router.reopen({ location: 'none' });
32
-
33
- // Application route
34
- MSPanel.ApplicationRoute = Ember.Route.extend({
35
- model: function() {
36
- var setting = MSPanel.Settings.find();
37
- if( setting.get('length') === 0){
38
- MSPanel.Settings.create().save();
39
- }
40
- }
41
- });
42
-
43
- MSPanel.SettingsRoute = Ember.Route.extend({
44
- model: function() {
45
- return MSPanel.Settings.find(1);
46
- },
47
- setupController: function(controller, model) {
48
- controller.set('model', model);
49
- controller.setup();
50
- }
51
- });
52
-
53
- MSPanel.SlidesRoute = Ember.Route.extend({
54
- model: function(){
55
- return MSPanel.Slide.find();
56
- },
57
-
58
- setupController: function(controller, model) {
59
- controller.set('model', model);
60
- controller.set('sliderSettings' , MSPanel.Settings.find(1)/*this.store.find('settings' , 1)*/);
61
- controller.setup();
62
- }
63
-
64
- });
65
-
66
- MSPanel.ControlsRoute = Ember.Route.extend({
67
- model: function() {
68
- return MSPanel.Control.find();
69
- },
70
-
71
- setupController: function(controller, model) {
72
- controller.set('model', model);
73
- controller.setup();
74
- this.activate();
75
- },
76
-
77
- activate: function() {
78
- var controller = this.get('controller');
79
- if(controller){
80
- controller.set('controlOptions', 'empty-template')
81
- }
82
- }
83
-
84
- });
85
-
86
- MSPanel.CallbacksRoute = Ember.Route.extend({
87
- model: function() {
88
- return MSPanel.Callback.find();
89
- },
90
-
91
- setupController: function(controller, model) {
92
- controller.set('model', model);
93
- controller.setup();
94
- }
95
- });//js\mspanel\models\SliderModel.js
96
-
97
- /**
98
- * Master Slider Panel Model
99
- * @package MSPanel
100
- * @author averta
101
- */
102
-
103
- ;(function(){
104
-
105
- var attr = Ember.attr,
106
- hasMany = Ember.hasMany,
107
- belongsTo = Ember.belongsTo;
108
-
109
- // custom data type, converts absolute paths to relative
110
- var regp = /https\:|http\:/;
111
- var WPPath = {
112
-
113
- // convert to relative
114
- serialize: function(path){
115
- if ( path == undefined ){
116
- return path;
117
- }
118
-
119
- if( regp.test(path) ) { // is it absolute?
120
- return path.replace(__MS.upload_dir, '');
121
- } else {
122
- return path;
123
- }
124
- },
125
-
126
- // covert to absolute
127
- deserialize: function(path){
128
- if ( path == undefined ) {
129
- return path;
130
- }
131
-
132
- if( regp.test(path) ) { // is it absolute?
133
- return path;
134
- } else {
135
- return __MS.upload_dir + path;
136
- }
137
- }
138
-
139
- };
140
-
141
- /**
142
- * Slider Settings Model
143
- */
144
- MSPanel.Settings = Ember.Model.extend({
145
-
146
- /* Internal Options */
147
- // -------------------------------------------------------------------
148
- id : attr('number'), // settings record id (not slider id)
149
- snapping : attr('boolean', {defaultValue : true}),
150
- bgImageThumb : attr(WPPath),
151
- disableControls : attr('boolean', {defaultValue: false}),
152
- // -------------------------------------------------------------------
153
-
154
- // General
155
- name : attr('string' , {defaultValue: __MSP_LAN.sm_001}),
156
- width : attr('number' , {defaultValue: 1000}),
157
- height : attr('number' , {defaultValue: 500}),
158
- wrapperWidth : attr('number'),
159
- wrapperWidthUnit : attr('string' , {defaultValue: 'px'}),
160
- autoCrop : attr('boolean', {defaultValue: false}),
161
- type : attr('string'),
162
- sliderId : attr('string'),
163
-
164
- /**
165
- * Slider sizing methods
166
- * Values:
167
- * boxed,
168
- * fullwidth,
169
- * fullscreen,
170
- * fillwidth,
171
- * autofill,
172
- * partialview
173
- */
174
- layout : attr('string' , {defaultValue: 'boxed'}),
175
- autoHeight : attr('boolean', {defaultValue: false}),
176
-
177
- // navigation and appearance
178
- trView : attr('string' , {defaultValue: 'basic'}),
179
- speed : attr('number' , {defaultValue: 20}),
180
- space : attr('number' , {defaultValue: 0}),
181
- start : attr('number' , {defaultValue: 1}),
182
- grabCursor : attr('boolean', {defaultValue: true}),
183
- swipe : attr('boolean', {defaultValue: true}),
184
- mouse : attr('boolean', {defaultValue: true}),
185
- wheel : attr('boolean', {defaultValue: false}),
186
- autoplay : attr('boolean', {defaultValue: false}),
187
- loop : attr('boolean', {defaultValue: false}),
188
- shuffle : attr('boolean', {defaultValue: false}),
189
- preload : attr('string' , {defaultValue: '-1'}),
190
- overPause : attr('boolean', {defaultValue: true}),
191
- endPause : attr('boolean', {defaultValue: false}),
192
- hideLayers : attr('boolean', {defaultValue: false}),
193
- dir : attr('string' , {defaultValue: 'h'}),
194
- parallaxMode: attr('srting' , {defaultValue: 'swipe'}),
195
- centerControls : attr('boolean', {defaultValue: true}),
196
- instantShowLayers : attr('boolean', {defaultValue: false}),
197
- fullscreenMargin : attr('number'),
198
-
199
- // misc
200
- inlineStyle : attr('string'),
201
- className : attr('string'),
202
- bgColor : attr('string'),
203
- bgImage : attr(WPPath),
204
-
205
- skin : attr('string' , {defaultValue: 'ms-skin-default'}),
206
- msTemplate : attr('string' , {defaultValue: 'custom'}),
207
- msTemplateClass : attr('string' , {defaultValue: ''}),
208
- usedFonts : attr('string'),
209
-
210
- // Flickr/Facebook Settings
211
- apiKey : attr('string'),
212
- setId : attr('string'),
213
- setType : attr('string'),
214
- imgCount : attr('number'),
215
- thumbSize : attr('srting'),
216
- imgSize : attr('string'),
217
-
218
- // Posts Settings
219
- postType : attr('string'),
220
- postCats : attr(Array),
221
- postTags : attr(Array),
222
- postCount : attr('number'),
223
- postImageType : attr('string'),
224
- postOrder : attr('string'),
225
- postOrderDir : attr('string'),
226
- postExcerptLen : attr('number'),
227
- postExcludeIds : attr('string'),
228
- postOffset : attr('number'),
229
- postLinkSlide : attr('boolean'),
230
- postLinkTarget : attr('string'),
231
- postSlideBg : attr('string'),
232
- postSlideBgthumb: attr('string'), // internal
233
-
234
- // woocommmerce settings
235
- wcOnlyInstock : attr('boolean'),
236
- wcOnlyFeatured : attr('boolean'),
237
- wcOnlyOnsale : attr('boolean')
238
- })
239
-
240
- /**
241
- * Slider Slide Model
242
- */
243
- MSPanel.Slide = Ember.Model.extend({
244
-
245
- /* Internal Options */
246
- // -------------------------------------------------------------------
247
- id : attr('number'),
248
- timeline_h : attr('number' , {defaultValue: 200}),
249
- bgThumb : attr(WPPath),
250
- thumbOrginal : attr(WPPath),
251
- // -------------------------------------------------------------------
252
-
253
- // General
254
- order : attr('number'),
255
- ishide : attr('boolean'),
256
- bg : attr(WPPath),
257
- duration : attr('number', {defaultValue : 3}),
258
-
259
- fillMode : attr('string', {defaultValue : 'fill'}),
260
- thumb : attr(WPPath),
261
- info : attr('string'),
262
- link : attr('string'),
263
- linkTarget : attr('string'),
264
- video : attr('string'),
265
- bgColor : attr('string'),
266
-
267
- bgv_mp4 : attr('string'),
268
- bgv_ogg : attr('string'),
269
- bgv_webm : attr('string'),
270
- bgv_fillmode : attr('string' , {defaultValue: 'fill'}),
271
-
272
- bgv_loop : attr('boolean', {defaultValue: true}),
273
- bgv_mute : attr('boolean', {defaultValue: true}),
274
- bgv_autopause : attr('boolean', {defaultValue: false}),
275
-
276
- cssId : attr('string'),
277
- cssClass : attr('string'),
278
- bgAlt : attr('string'),
279
-
280
- /**
281
- * Slide Layers
282
- * Object format: layer_ids:[1,2,3,...]
283
- */
284
- layers : hasMany('MSPanel.Layer', {key: 'layer_ids'})
285
-
286
- });
287
-
288
- /**
289
- * Slide Layer Model
290
- */
291
- MSPanel.Layer = Ember.Model.extend({
292
-
293
- /* Internal Options */
294
- // -------------------------------------------------------------------
295
- id : attr('number'),
296
- name : attr('string'),
297
- isLocked : attr('boolean' , {defaultValue: false}),
298
- isHided : attr('boolean' , {defaultValue: false}),
299
- isSoloed : attr('boolean' , {defaultValue: false}),
300
- slide : belongsTo('MSPanel.Slide', {key: 'slide'}),
301
- styleModel : belongsTo('MSPanel.Style', {key: 'styleModel', embedded:false}),
302
-
303
- showEffect : belongsTo('MSPanel.Effect', {key: 'showEffect', embedded:false} ),
304
- showTransform : attr('string' , {defaultValue: ''}), // tranform style
305
- showOrigin : attr('string' , {defaultValue: ''}), // transform origin
306
- showFade : attr('boolean', {defaultValue: true}),
307
-
308
- hideEffect : belongsTo('MSPanel.Effect', {key: 'hideEffect', embedded:false}),
309
- hideTransform : attr('string' , {defaultValue: ''}), // transform style
310
- hideOrigin : attr('string' , {defaultValue: ''}),
311
- hideFade : attr('boolean', {defaultValue: true}),
312
- imgThumb : attr(WPPath),
313
-
314
- stageOffsetX : attr('number', {defaultValue: 0}),
315
- stageOffsetY : attr('number', {defaultValue: 0}),
316
-
317
-
318
- // -------------------------------------------------------------------
319
-
320
- // General
321
- order : attr('number'),
322
- type : attr('string'), // values: text, video, image, hotspot
323
-
324
- // misc
325
- cssClass : attr('string'), // custom css class name
326
- cssId : attr('string'), // custom css id
327
- title : attr('string'), // title attribute
328
- rel : attr('string'), // rel attribute
329
-
330
- // layer content
331
- content : attr('string' , {defaultValue : 'Lorem Ipsum'}), // for text, hotspot
332
- img : attr(WPPath), // for image and video
333
- imgAlt : attr('string'),
334
- video : attr('string', {defaultValue: 'http://player.vimeo.com/video/11721242'}), // video iframe path
335
-
336
- align : attr('string', {defaultValue: 'top'}),
337
-
338
- useAction : attr('boolean', {defaultValue: false}),
339
- action : attr('string'),
340
- toSlide : attr('number'), // gotoSlide action parameter
341
- link : attr('string'),
342
- linkTarget : attr('string'),
343
-
344
- // Position
345
- offsetX : attr('number' , {defaultValue : 0}),
346
- offsetY : attr('number' , {defaultValue : 0}),
347
- width : attr('number'),
348
- height : attr('number'),
349
- resize : attr('boolean', {defaultValue : true}),
350
- fixed : attr('boolean', {defaultValue : false}),
351
- widthlimit : attr('number' , {defaultValue : '0'}),
352
- origin : attr('string' , {defaultValue : 'tl'}),
353
-
354
- stayHover : attr('boolean', {defaultValue: true}), // hotspot only
355
-
356
- // layer style class name
357
- className : attr('string'),
358
-
359
- // layer parallax effect
360
- parallax : attr('string'),
361
-
362
- // Show Effect
363
- showDuration : attr('number' , {defaultValue : 1}),
364
- showDelay : attr('number' , {defaultValue : 0}),
365
- showEase : attr('string' , {defaultValue : 'easeOutQuint'}),
366
- showEffFunc : attr('string'), // used by master slider
367
-
368
- // Hide Effect
369
- useHide : attr('boolean', {defaultValue : false}),
370
- hideDuration : attr('number' , {defaultValue : 1}),
371
- hideDelay : attr('number' , {defaultValue : 1}),
372
- hideEase : attr('string' , {defaultValue : 'easeOutQuint'}),
373
- hideEffFunc : attr('string'), // used by master slider
374
-
375
- // btn layer only
376
- btnClass : attr('string', {defaultValue : 'ms-default-btn'})
377
-
378
- //style : attr('string' , {defaultValue: ''}),
379
- });
380
-
381
- /**
382
- * Layer Styles Model
383
- */
384
- MSPanel.Style = Ember.Model.extend({
385
-
386
- /* Internal Options */
387
- // -------------------------------------------------------------------
388
- id : attr('number'),
389
- name : attr('string'),
390
- // -------------------------------------------------------------------
391
-
392
- /**
393
- * style type
394
- * values:
395
- * preset, preset style
396
- * copy, on copy of preset style used in mspanel
397
- * custom, layer custom style
398
- */
399
- type : attr('string'),
400
-
401
- /**
402
- * style class name
403
- * format:
404
- * preset-> msp-preset-{{presetID}}
405
- * custom-> msp-cn-{{sliderID}}-{{layer-ID}}
406
- */
407
- className : attr('string'),
408
- //css : attr('string'),
409
-
410
- backgroundColor : attr('string'),
411
-
412
- // padding
413
- paddingTop : attr('number'),
414
- paddingRight : attr('number'),
415
- paddingBottom : attr('number'),
416
- paddingLeft : attr('number'),
417
-
418
- // border
419
- borderTop : attr('number'),
420
- borderRight : attr('number'),
421
- borderBottom : attr('number'),
422
- borderLeft : attr('number'),
423
-
424
- borderColor : attr('string'),
425
- borderRadius : attr('number'),
426
- borderStyle : attr('string'),
427
-
428
- //Typography
429
- fontFamily : attr('string'),
430
- fontWeight : attr('string' , {defaultValue: 'normal'}),
431
- fontSize : attr('number'),
432
-
433
- textAlign : attr('string'),
434
- letterSpacing : attr('number'),
435
- lineHeight : attr('string' , {defaultValue: 'normal'}),
436
- whiteSpace : attr('string'),
437
- color : attr('string'),
438
-
439
- // custom style
440
- custom : attr('string')
441
- });
442
-
443
- MSPanel.PresetStyle = MSPanel.Style.extend({});
444
-
445
- /**
446
- * Layer Effect Model
447
- */
448
- MSPanel.Effect = Ember.Model.extend({
449
-
450
- /* Internal Options */
451
- // -------------------------------------------------------------------
452
- id : attr('number'),
453
- name : attr('string'),
454
- // -------------------------------------------------------------------
455
-
456
- type : attr('string'), // preset or null
457
-
458
- fade : attr('boolean', {defaultValue: true}),
459
-
460
- translateX : attr('number'),
461
- translateY : attr('number'),
462
- translateZ : attr('number'),
463
-
464
- scaleX : attr('number'),
465
- scaleY : attr('number'),
466
-
467
- rotate : attr('number'),
468
- rotateX : attr('number'),
469
- rotateY : attr('number'),
470
- rotateZ : attr('number'),
471
-
472
- skewX : attr('number'),
473
- skewY : attr('number'),
474
-
475
- originX : attr('number'),
476
- originY : attr('number'),
477
- originZ : attr('number')
478
-
479
- // effect function for master slider
480
- //msEffect : attr('string'),
481
-
482
- });
483
-
484
- MSPanel.PresetEffect = MSPanel.Effect.extend({});
485
-
486
- /**
487
- * Slider control model
488
- */
489
- MSPanel.Control = Ember.Model.extend({
490
-
491
- /* Internal Options */
492
- // -------------------------------------------------------------------
493
- id : attr('number'),
494
- label : attr('string'),
495
- // -------------------------------------------------------------------
496
-
497
- // general
498
- name : attr('string'),
499
-
500
- autoHide : attr('boolean', {defaultValue: true}), // in JS autohide
501
- overVideo : attr('boolean', {defaultValue: true}),
502
-
503
- // misc
504
- cssClass : attr('string'),
505
- cssId : attr('string'),
506
-
507
- // align and margin
508
- //align : attr('string'), // values : t, r, b, l \ tl,tr,bl,br (for circle timer)
509
- //inset : attr('boolean'), // in slider or out of slider
510
- margin : attr('number'), // element margin from top ,...
511
-
512
- // used for bullets, scrollbar and thumbs/tabs
513
- dir : attr('string'), // h or v
514
-
515
- // circle timer options
516
- color : attr('string'), // also scrollbar | timebar
517
- radius : attr('number'),
518
- stroke : attr('number'),
519
-
520
- // thumbs/tabs
521
- speed : attr('number'),
522
- space : attr('number'),
523
- type : attr('string'), // tab or thumb
524
-
525
- width : attr('number'), /// thumblist | scrollbar | timebar
526
- height : attr('number'), // thumbelist
527
-
528
- align : attr('string'), // thumblist | scrollbar | bullets | timebar | slideinfo
529
- inset : attr('boolean'), // thumblist | scrollbar | timebar | slideinfo
530
-
531
- size : attr('number'), // slide info
532
-
533
- hideUnder : attr('number'),
534
-
535
- fillMode : attr('string')
536
-
537
- });
538
-
539
- /**
540
- * Slider Callback functions
541
- */
542
- MSPanel.Callback = Ember.Model.extend({
543
-
544
- /* Internal Options */
545
- // -------------------------------------------------------------------
546
- id : attr('number'),
547
- label : attr('string'),
548
- // -------------------------------------------------------------------
549
-
550
- name : attr('string'),
551
- content : attr('string', {defaultValue: 'function(event){\n var api = event.target;\n}'})
552
-
553
- });
554
-
555
- /**
556
- * Button Class Names
557
- * @since 1.9.0
558
- */
559
-
560
- MSPanel.ButtonStyle = Ember.Model.extend({
561
-
562
- /* Internal Options */
563
- // -------------------------------------------------------------
564
- id : attr('number'),
565
- // -------------------------------------------------------------
566
-
567
- className : attr('string'),
568
- normal : attr('string'),
569
- hover : attr('string'),
570
- active : attr('string')
571
-
572
- });
573
-
574
-
575
- var decodeFix = function(str){
576
- var decoded = B64.decode(str);
577
- return decoded.slice(0, decoded.lastIndexOf('}')+1);
578
- }
579
-
580
- window.__MSP_PRESET_BUTTON = null;
581
-
582
- MSPanel.data = __MSP_DATA ? JSON.parse(decodeFix(__MSP_DATA)) : {meta:{}};
583
- MSPanel.PSData = __MSP_PRESET_STYLE ? JSON.parse(decodeFix(__MSP_PRESET_STYLE)) : {meta:{}};
584
- MSPanel.PEData = __MSP_PRESET_EFFECT ? JSON.parse(decodeFix(__MSP_PRESET_EFFECT)) : {meta:{}};
585
- MSPanel.PBData = __MSP_PRESET_BUTTON ? JSON.parse(decodeFix(__MSP_PRESET_BUTTON)) : {meta:{}};
586
-
587
- MSPanel.Settings.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
588
- MSPanel.Slide.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
589
- MSPanel.Layer.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
590
- MSPanel.Style.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
591
- MSPanel.Effect.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
592
- MSPanel.Control.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
593
- MSPanel.Callback.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.data});
594
- MSPanel.PresetStyle.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.PSData});
595
- MSPanel.PresetEffect.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.PEData});
596
- MSPanel.ButtonStyle.adapter = Ember.OfflineAdapter.create({applicationData:MSPanel.PBData});
597
-
598
- })();//js\mspanel\models\SliderTemplates.js
599
-
600
- MSPanel.SliderTemplates = [
601
-
602
- {
603
- name:'Custom Template',
604
- value:'custom',
605
- className: '',
606
- img: __MSP_PATH + 'images/templates/custom.gif',
607
- controls: null
608
- },
609
-
610
- {
611
- name:'3D Flow Carousel',
612
- value:'3d-flow-carousel',
613
- className:'ms-caro3d-template',
614
- img: __MSP_PATH + 'images/templates/3d-flow-carousel.png',
615
- settings: {
616
- space:0,
617
- loop:true,
618
- trView:'flow',
619
- layout:'partialview',
620
- dir:'h',
621
- wheel:false
622
- },
623
- controls: null
624
- },
625
-
626
- {
627
- name:'3D Wave Carousel',
628
- value:'3d-wave-carousel',
629
- className:'ms-caro3d-template',
630
- img: __MSP_PATH + 'images/templates/3d-wave-carousel.png',
631
- settings: {
632
- space:0,
633
- loop:true,
634
- trView:'flow',
635
- layout:'partialview',
636
- dir:'h',
637
- wheel:false
638
- },
639
- controls: null
640
- },
641
-
642
- {
643
- name:'Image Gallery with Thumbs',
644
- value:'image-gallery',
645
- className:'ms-gallery-template',
646
- img: __MSP_PATH + 'images/templates/image-gallery.png',
647
- settings: {
648
- space:0,
649
- trView:'basic',
650
- skin:'ms-skin-black-2 round-skin'
651
- },
652
- controls: null,
653
- disableControls: true
654
- },
655
-
656
- {
657
- name:'Slider with Bottom Aligned Thumbs',
658
- value:'slider-horizontal-thumbs',
659
- className:'ms-thumbs-template',
660
- img: __MSP_PATH + 'images/templates/slider-bottom-thumbs.png',
661
- settings: {
662
- trView:'scale',
663
- space:0
664
- },
665
- controls: {
666
- arrows: {},
667
- scrollbar: {dir:'h'},
668
- thumblist: {autohide:false ,dir:'h',arrows:false, align:'bottom', width:127, height:137, margin:5, space:5}
669
- }
670
- },
671
-
672
- {
673
- name:'Slider with Top Aligned Thumbs',
674
- value:'slider-top-thumbs',
675
- className:'ms-thumbs-template',
676
- img: __MSP_PATH + 'images/templates/slider-top-thumbs.png',
677
- settings: {
678
- trView:'scale',
679
- space:0
680
- },
681
- controls: {
682
- arrows: {},
683
- scrollbar: {dir:'h'},
684
- thumblist: {autohide:false ,dir:'h',arrows:false, align:'top', width:127, height:137, margin:5, space:5}
685
- }
686
- },
687
-
688
- {
689
- name:'Slider with Right Aligned Thumbs',
690
- value:'slider-vertical-thumbs',
691
- className:'ms-thumbs-template',
692
- img: __MSP_PATH + 'images/templates/slider-right-thumbs.png',
693
- settings: null,
694
- controls: {
695
- arrows: {},
696
- scrollbar: {dir:'v'},
697
- thumblist: {autohide:false ,dir:'v',arrows:false, align:'right', width:127, height:137, margin:5, space:5}
698
- }
699
- },
700
-
701
- {
702
- name:'Slider with Left Aligned Thumbs',
703
- value:'slider-left-thumbs',
704
- className:'ms-thumbs-template',
705
- img: __MSP_PATH + 'images/templates/slider-left-thumbs.png',
706
- settings: null,
707
- controls: {
708
- arrows: {},
709
- scrollbar: {dir:'v'},
710
- thumblist: {autohide:false ,dir:'v',arrows:false, align:'left', width:127, height:137, margin:5, space:5}
711
- }
712
- },
713
-
714
- {
715
- name:'Slider with Horizontal Tabs',
716
- value:'slider-horizontal-tabs',
717
- className:'ms-tabs-template',
718
- img: __MSP_PATH + 'images/templates/slider-horizontal-tabs.png',
719
- settings: null,
720
- controls: {
721
- arrows: {},
722
- circletimer: {color:"#FFFFFF" , stroke:9},
723
- thumblist: {autohide:false ,dir:'h', type:'tabs',width:240,height:120, align:'bottom', space:0 , margin:-12, hideUnder:400}
724
- }
725
- },
726
-
727
- {
728
- name:'Slider with Vertical Tabs',
729
- value:'slider-vertical-tabs',
730
- className:'ms-tabs-template',
731
- img: __MSP_PATH + 'images/templates/slider-vertical-tabs.png',
732
- settings: null,
733
- controls: {
734
- arrows: {},
735
- circletimer: {color:"#FFFFFF" , stroke:9},
736
- thumblist: {autohide:false ,dir:'v', type:'tabs', align:'right', margin:-12, space:0, width:229, height:100, hideUnder:550}
737
- }
738
- },
739
-
740
- {
741
- name:'Partial View Slider V1',
742
- value:'partial-1',
743
- className:'ms-partialview-template',
744
- img: __MSP_PATH + 'images/templates/partial-1.png',
745
- settings: {
746
- space:10,
747
- loop:true,
748
- trView:'partialWave',
749
- layout:'partialview',
750
- dir:'h'
751
- },
752
- controls: {
753
- arrows: {},
754
- circletimer: {color:"#FFFFFF" , stroke:9},
755
- slideinfo: {autohide:false, align:'bottom', size:160}
756
- }
757
- },
758
-
759
- {
760
- name:'Partial View Slider V2',
761
- value:'partial-2',
762
- className:'ms-partialview-template',
763
- img: __MSP_PATH + 'images/templates/partial-2.png',
764
- settings: {
765
- space:10,
766
- loop:true,
767
- trView:'fadeWave',
768
- layout:'partialview',
769
- dir:'h'
770
- },
771
- controls: {
772
- arrows: {},
773
- circletimer: {color:"#FFFFFF" , stroke:9},
774
- slideinfo: {autohide:false, align:'bottom', size:160}
775
- }
776
- },
777
-
778
- {
779
- name:'Partial View Slider V3',
780
- value:'partial-3',
781
- className:'ms-partialview-template',
782
- img: __MSP_PATH + 'images/templates/partial-3.png',
783
- settings: {
784
- space:10,
785
- loop:true,
786
- trView:'fadeFlow',
787
- layout:'partialview',
788
- dir:'h'
789
- },
790
- controls: {
791
- arrows: {},
792
- circletimer: {color:"#FFFFFF" , stroke:9},
793
- slideinfo: {autohide:false, align:'bottom', size:160}
794
- }
795
- },
796
-
797
- {
798
- name:'Slider in Display',
799
- value:'display',
800
- className:'ms-display-template',
801
- img: __MSP_PATH + 'images/templates/display.png',
802
- settings: {
803
- width:507,
804
- height:286,
805
- speed:20,
806
- space:2,
807
- trView:'flow',
808
- dir:'h',
809
- layout:'boxed'
810
- },
811
- controls: {
812
- arrows: {},
813
- circletimer: {color:"#FFFFFF" , stroke:9},
814
- bullets: {autohide:false}
815
- },
816
- disableControls: true
817
- },
818
-
819
- {
820
- name:'Slider in Flat Display',
821
- value:'flat-display',
822
- className:'ms-display-template',
823
- img: __MSP_PATH + 'images/templates/flat-display.png',
824
- settings: {
825
- width:507,
826
- height:286,
827
- speed:20,
828
- space:2,
829
- trView:'flow',
830
- dir:'h',
831
- layout:'boxed'
832
- },
833
- controls: {
834
- arrows: {},
835
- circletimer: {color:"#FFFFFF" , stroke:9},
836
- bullets: {autohide:false}
837
- },
838
- disableControls: true
839
- },
840
-
841
- {
842
- name:'Slider in Laptop',
843
- value:'laptop',
844
- className:'ms-laptop-template',
845
- img: __MSP_PATH + 'images/templates/laptop.png',
846
- settings: {
847
- width:492,
848
- height:309,
849
- speed:20,
850
- space:2,
851
- trView:'mask',
852
- dir:'h',
853
- layout:'boxed'
854
- },
855
- controls: {
856
- arrows: {},
857
- circletimer: {color:"#FFFFFF" , stroke:9},
858
- bullets: {autohide:false}
859
- },
860
- disableControls: true
861
- },
862
-
863
- {
864
- name:'Slider in Flat Laptop',
865
- value:'flat-laptop',
866
- className:'ms-laptop-template',
867
- img: __MSP_PATH + 'images/templates/flat-laptop.png',
868
- settings: {
869
- width:492,
870
- height:309,
871
- speed:20,
872
- space:2,
873
- trView:'mask',
874
- dir:'h',
875
- layout:'boxed'
876
- },
877
- controls: {
878
- arrows: {},
879
- circletimer: {color:"#FFFFFF" , stroke:9},
880
- bullets: {autohide:false}
881
- },
882
- disableControls: true
883
- },
884
-
885
- {
886
- name:'Slider in Tablet',
887
- value:'tablet',
888
- className:'ms-tablet-template',
889
- img: __MSP_PATH + 'images/templates/tablet.png',
890
- settings: {
891
- width:400,
892
- height:534,
893
- speed:20,
894
- space:2,
895
- trView:'wave',
896
- dir:'h',
897
- layout:'boxed'
898
- },
899
- controls: {
900
- arrows: {},
901
- circletimer: {color:"#FFFFFF" , stroke:9},
902
- bullets: {autohide:false}
903
- },
904
- disableControls: true
905
- },
906
-
907
- {
908
- name:'Slider in Flat Tablet',
909
- value:'flat-tablet',
910
- className:'ms-tablet-template',
911
- img: __MSP_PATH + 'images/templates/flat-tablet.png',
912
- settings: {
913
- width:400,
914
- height:534,
915
- speed:20,
916
- space:2,
917
- trView:'basic',
918
- dir:'h',
919
- layout:'boxed'
920
- },
921
- controls: {
922
- arrows: {},
923
- circletimer: {color:"#FFFFFF" , stroke:9},
924
- bullets: {autohide:false}
925
- },
926
- disableControls: true
927
- },
928
-
929
- {
930
- name:'Slider in Landscape Tablet',
931
- value:'tablet-land',
932
- className:'ms-tablet-template ms-tablet-land',
933
- img: __MSP_PATH + 'images/templates/tablet-land.png',
934
- settings: {
935
- width:632,
936
- height:476,
937
- speed:20,
938
- space:2,
939
- trView:'mask',
940
- dir:'h',
941
- layout:'boxed'
942
- },
943
- controls: {
944
- arrows: {},
945
- circletimer: {color:"#FFFFFF" , stroke:9},
946
- bullets: {autohide:false}
947
- },
948
- disableControls: true
949
- },
950
-
951
- {
952
- name:'Slider in Flat Landscape Tablet',
953
- value:'flat-tablet-land',
954
- className:'ms-tablet-template ms-tablet-land',
955
- img: __MSP_PATH + 'images/templates/flat-tablet-land.png',
956
- settings: {
957
- width:632,
958
- height:476,
959
- speed:20,
960
- space:2,
961
- trView:'mask',
962
- dir:'h',
963
- layout:'boxed'
964
- },
965
- controls: {
966
- arrows: {},
967
- circletimer: {color:"#FFFFFF" , stroke:9},
968
- bullets: {autohide:false}
969
- },
970
- disableControls: true
971
- },
972
-
973
- {
974
- name:'Slider in Smart Phone',
975
- value:'phone',
976
- className:'ms-phone-template',
977
- img: __MSP_PATH + 'images/templates/phone.png',
978
- settings: {
979
- width:258,
980
- height:456,
981
- speed:20,
982
- space:2,
983
- trView:'wave',
984
- dir:'h',
985
- layout:'boxed'
986
- },
987
- controls: {
988
- arrows: {},
989
- circletimer: {color:"#FFFFFF" , stroke:9},
990
- bullets: {autohide:false}
991
- },
992
- disableControls: true
993
- },
994
-
995
- {
996
- name:'Slider in Flat Smart Phone',
997
- value:'flat-phone',
998
- className:'ms-phone-template',
999
- img: __MSP_PATH + 'images/templates/flat-phone.png',
1000
- settings: {
1001
- width:258,
1002
- height:456,
1003
- speed:20,
1004
- space:2,
1005
- trView:'basic',
1006
- dir:'h',
1007
- layout:'boxed'
1008
- },
1009
- controls: {
1010
- arrows: {},
1011
- circletimer: {color:"#FFFFFF" , stroke:9},
1012
- bullets: {autohide:false}
1013
- },
1014
- disableControls: true
1015
- },
1016
-
1017
- {
1018
- name:'Slider in Landscape Smart Phone',
1019
- value:'phone-land',
1020
- className:'ms-phone-template ms-phone-land',
1021
- img: __MSP_PATH + 'images/templates/phone-land.png',
1022
- settings: {
1023
- width:456,
1024
- height:258,
1025
- speed:20,
1026
- space:2,
1027
- trView:'mask',
1028
- dir:'h',
1029
- layout:'boxed'
1030
- },
1031
- controls: {
1032
- arrows: {},
1033
- circletimer: {color:"#FFFFFF" , stroke:9},
1034
- bullets: {autohide:false}
1035
- },
1036
- disableControls: true
1037
- },
1038
-
1039
- {
1040
- name:'Slider in Flat Landscape Smart Phone',
1041
- value:'flat-phone-land',
1042
- className:'ms-phone-template ms-phone-land',
1043
- img: __MSP_PATH + 'images/templates/flat-phone-land.png',
1044
- settings: {
1045
- width:456,
1046
- height:258,
1047
- speed:20,
1048
- space:2,
1049
- trView:'mask',
1050
- dir:'h',
1051
- layout:'boxed'
1052
- },
1053
- controls: {
1054
- arrows: {},
1055
- bullets: {autohide:false}
1056
- },
1057
- disableControls: true
1058
- },
1059
-
1060
- {
1061
- name:'Vertical Slider',
1062
- value:'vertical-slider',
1063
- className:'ms-vertical-template',
1064
- img: __MSP_PATH + 'images/templates/vertical-slider.png',
1065
- settings: {
1066
- space:5,
1067
- dir:'v'
1068
- },
1069
- controls: {
1070
- arrows: {},
1071
- scrollbar: {dir:'v'},
1072
- circletimer: {color:"#FFFFFF" , stroke:9},
1073
- thumblist : {autohide:false ,dir:'v',space:5,margin:5,align:'right'}
1074
- }
1075
- },
1076
-
1077
- {
1078
- name:'Staff Carousel V1',
1079
- value:'staff-1',
1080
- className:'ms-staff-carousel',
1081
- img: __MSP_PATH + 'images/templates/staff-1.png',
1082
- settings: {
1083
- loop:true,
1084
- width:240,
1085
- height:240,
1086
- speed:20,
1087
- trView:'focus',
1088
- layout:'partialview',
1089
- space:0,
1090
- wheel:true,
1091
- dir:'h'
1092
- },
1093
- controls: {
1094
- arrows: {},
1095
- slideinfo: {autohide:false, align:'bottom', size:160}
1096
- }
1097
- },
1098
-
1099
- {
1100
- name:'Staff Carousel V2',
1101
- value:'staff-2',
1102
- className:'ms-staff-carousel',
1103
- img: __MSP_PATH + 'images/templates/staff-2.png',
1104
- settings: {
1105
- loop:true,
1106
- width:240,
1107
- height:240,
1108
- speed:20,
1109
- trView:'fadeBasic',
1110
- layout:'partialview',
1111
- space:0,
1112
- dir:'h'
1113
- },
1114
- controls: {
1115
- arrows: {},
1116
- slideinfo: {autohide:false, align:'bottom', size:160}
1117
- }
1118
- },
1119
-
1120
- {
1121
- name:'Staff Carousel V3',
1122
- value:'staff-3',
1123
- className:'ms-staff-carousel ms-round',
1124
- img: __MSP_PATH + 'images/templates/staff-3.png',
1125
- settings: {
1126
- loop:true,
1127
- width:240,
1128
- height:240,
1129
- speed:20,
1130
- trView:'focus',
1131
- layout:'partialview',
1132
- space:0,
1133
- space:35,
1134
- dir:'h'
1135
- },
1136
- controls: {
1137
- arrows: {},
1138
- slideinfo: {autohide:false, align:'bottom', size:160}
1139
- }
1140
- },
1141
-
1142
- {
1143
- name:'Staff Carousel V4',
1144
- value:'staff-4',
1145
- className:'ms-staff-carousel ms-round',
1146
- img: __MSP_PATH + 'images/templates/staff-4.png',
1147
- settings: {
1148
- loop:true,
1149
- width:240,
1150
- height:240,
1151
- speed:20,
1152
- trView:'fadeBasic',
1153
- layout:'partialview',
1154
- space:0,
1155
- space:45,
1156
- dir:'h'
1157
- },
1158
- controls: {
1159
- arrows: {},
1160
- slideinfo: {autohide:false, align:'bottom', size:160}
1161
- }
1162
- },
1163
-
1164
- {
1165
- name:'Staff Carousel V5',
1166
- value:'staff-5',
1167
- className:'ms-staff-carousel',
1168
- img: __MSP_PATH + 'images/templates/staff-5.png',
1169
- settings: {
1170
- loop:true,
1171
- width:240,
1172
- height:240,
1173
- speed:20,
1174
- trView:'wave',
1175
- layout:'partialview',
1176
- space:0,
1177
- wheel:true,
1178
- dir:'h'
1179
- },
1180
- controls: {
1181
- arrows: {},
1182
- slideinfo: {autohide:false, align:'bottom', size:160}
1183
- }
1184
- },
1185
-
1186
- {
1187
- name:'Staff Carousel V6',
1188
- value:'staff-6',
1189
- className:'ms-staff-carousel',
1190
- img: __MSP_PATH + 'images/templates/staff-6.png',
1191
- settings: {
1192
- loop:true,
1193
- width:240,
1194
- height:240,
1195
- speed:20,
1196
- trView:'flow',
1197
- layout:'partialview',
1198
- space:0,
1199
- wheel:true,
1200
- dir:'h'
1201
- },
1202
- controls: {
1203
- arrows: {},
1204
- slideinfo: {autohide:false, align:'bottom', size:160}
1205
- }
1206
- },
1207
- ];
1208
- //js\mspanel\views\UIViews.js
1209
-
1210
- /* ---------------------------------------------------------
1211
- Slideframe
1212
- ------------------------------------------------------------*/
1213
- MSPanel.SlideFrame = Ember.View.extend({
1214
- classNames : ['msp-slideframe'],
1215
- classNameBindings: ['selected:active'],
1216
- selected : false,
1217
- thumb_src : '',
1218
- showbtnclass : 'msp-ico msp-ico-whitehide',
1219
-
1220
- template : Ember.Handlebars.compile('<div class="msp-img-cont">'+
1221
- '{{#if view.hasImg}}'+
1222
- '<div class="msp-imgselect-preview" {{bind-attr style=view.preview}})"></div>'+
1223
- '{{/if}}'+
1224
- '</div>'+
1225
- '<span class="msp-frame-slideorder">#{{view.order}}</span>'+
1226
- '<div class="msp-framehandle">'+
1227
- '<ul>'+
1228
- '<li><a title="'+__MSP_LAN.ui_001+'" href="#" {{action "hideswitch" target=view}}><span {{bind-attr class=view.showbtnclass}}></span></a></li>'+
1229
- '<li><a title="'+__MSP_LAN.ui_002+'" href="#" {{action "duplicate" target=view}}><span class="msp-ico msp-ico-whiteduplicate"></span></a></li>'+
1230
- '<li><a title="'+__MSP_LAN.ui_003+'" href="#" {{action "remove" target=view}}><span class="msp-ico msp-ico-whiteremove"></span></a></li>'+
1231
- '</ul>'+
1232
- '</div>'),
1233
-
1234
- click : function(event){
1235
- this.get('controller').send('select' , this.get('slide'));
1236
- },
1237
-
1238
- onValueChanged: function(){
1239
- var hasImg = !Ember.isEmpty(this.get('slide.bg'));
1240
- this.beginPropertyChanges();
1241
- this.set('hasImg' ,hasImg);
1242
- if(hasImg){
1243
- this.set('preview', 'background-image:url(' + this.get('slide.bgThumb') + ');');
1244
- }
1245
- this.endPropertyChanges();
1246
- }.observes('slide.bg').on('didInsertElement'),
1247
-
1248
- onSelect : function(){
1249
- var slide = this.get('slide');
1250
-
1251
- this.set('selected' , slide === this.get('controller.currentSlide'));
1252
-
1253
- }.observes('controller.currentSlide').on('init'),
1254
-
1255
- hideChange : function(){
1256
- if(this.get('slide.ishide'))
1257
- this.set('showbtnclass' , 'msp-ico msp-ico-whitehide msp-ico-whiteshow');
1258
- else
1259
- this.set('showbtnclass' , 'msp-ico msp-ico-whitehide');
1260
-
1261
- }.observes('slide.ishide').on('init'),
1262
-
1263
- order: function(){
1264
- return this.get('slide.order') + 1;
1265
- }.property('slide.order'),
1266
-
1267
- actions : {
1268
- duplicate : function(){
1269
- this.get('controller').duplicateSlide(this.get('slide'));
1270
- },
1271
-
1272
- hideswitch : function(){
1273
- this.set('slide.ishide' , !this.get('slide.ishide'));
1274
- },
1275
-
1276
- remove : function(){
1277
- if(confirm(__MSP_LAN.ui_004))
1278
- this.get('controller').removeSlide(this.get('slide'));
1279
- }
1280
- }
1281
- });
1282
-
1283
- /* ---------------------------------------------------------
1284
- SlideList
1285
- ------------------------------------------------------------*/
1286
- MSPanel.SlideList = Ember.View.extend({
1287
- tagName : 'ul',
1288
- classNames : ['msp-slides'],
1289
-
1290
- template : Ember.Handlebars.compile(
1291
- '{{#each item in controller}}'+
1292
- '<li class="msp-slideframe-item" {{bind-attr data-id=item.id}}>{{view MSPanel.SlideFrame slide=item}}</li>'+
1293
- '{{/each}}'+
1294
- '<li class="msp-addslide-cont">'+
1295
- '<div class="msp-addslide" {{action "newSlide"}}>'+
1296
- '<span class="msp-ico msp-ico-grayaddlarge"></span>'+
1297
- '<span class="msp-addslide-label">Add Slide</span>'+
1298
- '</div>'+
1299
- '</li>'),
1300
-
1301
- didInsertElement : function(){
1302
-
1303
- var that = this;
1304
-
1305
- this.$().sortable({
1306
- placeholder: "msp-frames-srtplaceholder",
1307
- items: ">li:not(.msp-addslide-cont)",
1308
- delay: 100,
1309
- update : function(event , ui){that.updateSort();},
1310
- create: function(event, ui){that.updateSort();}
1311
- });
1312
-
1313
- },
1314
-
1315
- updateSort: function(){
1316
- var indexes = {};
1317
- $('.msp-slideframe-item').each(function(index) {
1318
- indexes[$(this).data('id')] = index;
1319
- });
1320
- this.$().sortable('cancel');
1321
- this.get('controller').updateSlidesSort(indexes);
1322
- }
1323
- });
1324
-
1325
-
1326
- /* ---------------------------------------------------------
1327
- ImgSelect
1328
- ------------------------------------------------------------*/
1329
-
1330
-
1331
- /*
1332
- var frame; // to store already used upload frame
1333
-
1334
- $upload_btn.on( 'click', function() {
1335
- var $this = $(this);
1336
- // get input field (the image src field)
1337
- var $input = $this.siblings('input[type="text"]');
1338
-
1339
- // If the frame already exists, re-open it.
1340
- if ( frame ) {
1341
- frame.open();
1342
- return;
1343
- }
1344
-
1345
- var frame = wp.media.frames.frame = wp.media({
1346
- title: "Select Image", // the select button label in media uploader
1347
- multiple: false, // use single image upload or multiple?
1348
- frame: 'select',
1349
- library: { type: 'image' },
1350
- button : { text : 'Add Image' }
1351
- });
1352
-
1353
- // on "Add Image" button clicked in media uploader
1354
- frame.on( 'select', function() {
1355
- var attachment = frame.state().get('selection').first().toJSON();
1356
- $input.val(attachment.url).trigger('change'); // insert attachment url in our input field
1357
- });
1358
-
1359
- // open media uploader
1360
- frame.open();
1361
- });
1362
- */
1363
-
1364
-
1365
- MSPanel.ImgSelect = Ember.View.extend({
1366
- classNames : ['msp-imgselect'],
1367
- value : '',
1368
- hasImg : false,
1369
- frame: null,
1370
- template : Ember.Handlebars.compile('<div class="msp-img-cont">'+
1371
- '{{#if view.hasImg}}'+
1372
- '<div class="msp-imgselect-preview" {{bind-attr style=view.preview}})"></div>'+
1373
- '{{/if}}'+
1374
- '</div>'+
1375
- '{{#if view.hasImg}}'+
1376
- '<button {{action removeImg target="view"}} class="msp-img-btn"><span class="msp-ico msp-ico-grayremove"></span></button>'+
1377
- '{{else}}'+
1378
- '<button {{action addImg target="view"}} class="msp-img-btn"><span class="msp-ico msp-ico-grayadd"></span></button>'+
1379
- '{{/if}}'),
1380
-
1381
- willDestroyElement: function(){
1382
- var frame = this.get('frame');
1383
-
1384
- if(frame){
1385
- frame.detach();
1386
- frame.remove();
1387
- frame = null;
1388
- this.set('frame', null);
1389
- }
1390
- },
1391
-
1392
- onValueChanged: function(){
1393
- this.beginPropertyChanges();
1394
- this.set('hasImg' , !Ember.isEmpty(this.get('value')));
1395
- this.set('preview', 'background-image:url(' + this.get('thumb') + ');') ;
1396
- this.endPropertyChanges();
1397
- }.observes('value').on('didInsertElement'),
1398
-
1399
- actions : {
1400
- removeImg : function(){
1401
- this.beginPropertyChanges();
1402
- this.set('value' , undefined);
1403
- this.set('thumb' , undefined);
1404
- this.endPropertyChanges();
1405
- },
1406
-
1407
- addImg : function(){
1408
- if( typeof wp === 'undefined'){
1409
- return;
1410
- }
1411
-
1412
- var that = this,
1413
- frame = this.get('frame');
1414
-
1415
- if ( frame ) {
1416
- frame.open();
1417
-
1418
- return;
1419
- }
1420
-
1421
- var frame = wp.media.frames.frame = wp.media({
1422
- title: "Select Image", // the select button label in media uploader
1423
- multiple: false, // use single image upload or multiple?
1424
- frame: 'select',
1425
- library: { type: 'image' },
1426
- button : { text : 'Add Image' }
1427
- });
1428
-
1429
- // on "Add Image" button clicked in media uploader
1430
- frame.on( 'select', function() {
1431
- var attachment = frame.state().get('selection').first().toJSON();
1432
- //console.log(attachment)
1433
- that.set('thumb', (attachment.sizes.thumbnail || attachment.sizes.full).url);
1434
- that.set('value', attachment.url);
1435
- });
1436
-
1437
- // open media uploader
1438
- frame.open();
1439
- this.set('frame', frame);
1440
- }
1441
- }
1442
- });
1443
-
1444
- /* ---------------------------------------------------------
1445
- Selectbox
1446
- ------------------------------------------------------------*/
1447
-
1448
- MSPanel.Select = Ember.Select.extend({
1449
- tagName: 'div',
1450
- classNames: ['msp-ddlist'],
1451
- layout: Ember.Handlebars.compile('<select>{{yield}}</select>'),
1452
- value: null,
1453
- width: 100,
1454
-
1455
- didInsertElement: function(){
1456
- var that = this;
1457
- this.$('select').on('change', function(){
1458
- var option = that.$('select option:selected');
1459
- that.set('value', option.attr('value'));
1460
- }).width(this.get('width'));
1461
-
1462
- this.onValueChanged();
1463
- },
1464
-
1465
- onValueChanged: function(){
1466
- if( !Ember.isEmpty(this.get('value')) ){
1467
- this.$('select').val(this.get('value'));
1468
- }
1469
- }.observes('value')
1470
-
1471
- /*classNames:['msp-selectbox'],
1472
- tagName:'div',
1473
- layout: Ember.Handlebars.compile('<select>{{yield}}</select>'),
1474
- width:100,
1475
- didInsertElement: function() {
1476
- var that = this,
1477
- isFirst = true;
1478
- var ddslick = this.$('select').ddslick({width:this.get('width') , onSelected: function(selectedData){
1479
- !isFirst && that.set('value' , selectedData.selectedData.value);
1480
- isFirst = false;
1481
- } });
1482
- this.onValueChanged();
1483
- },
1484
-
1485
- onValueChanged: function(){
1486
- var that = this,
1487
- cindex = 0;
1488
- this.$('.dd-option-value').each(function(){
1489
- var $this = $(this);
1490
-
1491
- if( $this.attr('value') === that.get('value') ){
1492
- that.$('.dd-container').ddslick('select' , {index:cindex});
1493
- return false;
1494
- }
1495
- cindex ++;
1496
- });
1497
-
1498
- }.observes('value')*/
1499
- });
1500
-
1501
-
1502
- /* ---------------------------------------------------------
1503
- URLTarget
1504
- ------------------------------------------------------------*/
1505
- MSPanel.URLTarget = MSPanel.Select.extend({
1506
-
1507
- onInit : function(){
1508
- var contents = [{lable:__MSP_LAN.ui_005 , value:"_self"},
1509
- {lable:__MSP_LAN.ui_006 , value:"_blank"},
1510
- {lable:__MSP_LAN.ui_007 , value:"_parent"},
1511
- {lable:__MSP_LAN.ui_008 , value:"_top"}];
1512
-
1513
- this.set('content' , contents);
1514
- this.set('optionValuePath' , "content.value");
1515
- this.set('optionLabelPath' , "content.lable");
1516
-
1517
- this.set('width' , 200);
1518
-
1519
- }.on('init')
1520
- /*
1521
- didInsertElement: function(){
1522
- //this.$().css('vertical-align', 'top');
1523
- this._super();
1524
- }*/
1525
- });
1526
-
1527
-
1528
- /* ---------------------------------------------------------
1529
- Fillmode
1530
- ------------------------------------------------------------*/
1531
- MSPanel.Fillmode = Ember.View.extend({
1532
- classNames : ['msp-fill-dd'],
1533
- type : 'slide', // video
1534
- value: 'fill',
1535
- index: 1,
1536
- template : Ember.Handlebars.compile('<select>{{#each item in view.contents}}'+
1537
- '<option {{bind-attr value=item.value data-imagesrc=item.img}}>{{item.text}}</option>'+
1538
- '{{/each}}</select>'),
1539
- didInsertElement : function(){
1540
- var that = this,
1541
- isFirst = true;
1542
- this.$('select').ddslick({width:154 , onSelected: function(selected){
1543
- !isFirst && that.set('value' , selected.selectedData.value);
1544
- isFirst = false;
1545
- } });
1546
-
1547
- this.onValueChanged();
1548
- },
1549
-
1550
- onValueChanged : function(){
1551
- if( Ember.isEmpty(this.get('value')) ){
1552
- return;
1553
- }
1554
- this.$('.dd-container').ddslick('select', {index:this.get('valuedic')[this.get('value')]});
1555
- }.observes('value'),
1556
-
1557
- onInit : function(){
1558
- var contents , valuedic;
1559
- if(this.get('type') === 'slide'){
1560
-
1561
- contents = [{value:'fill' , text:__MSP_LAN.ui_009 , img: __MSP_PATH + 'images/fill.png' },
1562
- {value:'fit' , text:__MSP_LAN.ui_010 , img: __MSP_PATH + 'images/fit.png' },
1563
- {value:'center' , text:__MSP_LAN.ui_011 , img: __MSP_PATH + 'images/center.png' },
1564
- {value:'stretch' , text:__MSP_LAN.ui_012 , img: __MSP_PATH + 'images/stretch.png' },
1565
- {value:'tile' , text:__MSP_LAN.ui_013 , img: __MSP_PATH + 'images/tile.png' }];
1566
-
1567
- valuedic = {fill:0 , fit:1 , center:2 , stretch:3 , tile:4};
1568
-
1569
- }else if(this.get('type') === 'video'){
1570
-
1571
- contents = [{value:'fill' , text:__MSP_LAN.ui_009 , img: __MSP_PATH + 'images/fill.png' },
1572
- {value:'fit' , text:__MSP_LAN.ui_010 , img: __MSP_PATH + 'images/fit.png' }
1573
- //{value:'none' , text:__MSP_LAN.ui_013 , img:'images/none.png' }
1574
- ];
1575
-
1576
- valuedic = {fill:0 , fit:1 , none:2};
1577
- }
1578
-
1579
- this.set('contents' , contents);
1580
- this.set('valuedic' , valuedic);
1581
- }.on('init')
1582
-
1583
- });
1584
-
1585
- /* ------------------------------------------------------- *\
1586
- SimpleCodeBlock
1587
- \* --------------------------------------------------------*/
1588
- MSPanel.SimpleCodeBlock = Ember.View.extend({
1589
- classNames: ['msp-shortcode-box'],
1590
- template: Ember.Handlebars.compile('<input type="text" readonly {{bind-attr value=view.value}}>' ),
1591
- width:150,
1592
- didInsertElement: function(){
1593
- this.$('input').on('click',function(){
1594
- $(this).select();
1595
- }).width(this.get('width'));
1596
- }
1597
- });//js\mspanel\views\SettingsView.js
1598
-
1599
- /**
1600
- * Settings Page View
1601
- * @package MSPanel
1602
- * @extends {Ember.View}
1603
- */
1604
-
1605
- MSPanel.SettingsView = Ember.View.extend({
1606
- didInsertElement: function(){
1607
- this.set('controller.mainView' , this);
1608
- }
1609
- });//js\mspanel\views\SlidesView.js
1610
-
1611
- /**
1612
- * Slides Page View
1613
- * @package MSPanel
1614
- * @extends {Ember.View}
1615
- */
1616
-
1617
- MSPanel.SlidesView = Ember.View.extend({
1618
- didInsertElement: function(){
1619
- this.set('controller.mainView' , this);
1620
- }
1621
- });//js\mspanel\views\StageView.js
1622
-
1623
- /* ---------------------------------------------------------
1624
- Stage View
1625
- ------------------------------------------------------------*/
1626
- MSPanel.StageArea = Ember.View.extend({
1627
- classNames : ['msp-stage-area'],
1628
- template : Ember.Handlebars.compile('{{view MSPanel.Stage}}'+
1629
- '{{#if noticeMsg}}<div class="msp-stage-msg"><span class="msp-ico msp-ico-notice"></span>{{{noticeMsg}}}</div>{{/if}}'),
1630
- });
1631
-
1632
-
1633
- MSPanel.Stage = Ember.View.extend({
1634
-
1635
- classNames : ['msp-slide-stage'],
1636
- attributeBindings : ['style'],
1637
- template : Ember.Handlebars.compile('<div id="stage-bg" class="msp-stage-bg"></div>'),
1638
-
1639
- resize : function(){
1640
-
1641
- var w = this.get('controller.sliderSettings.width'),
1642
- h = this.get('controller.sliderSettings.height');
1643
-
1644
- this.set('width' , w);
1645
- this.set('height' , h);
1646
-
1647
- this.$().css({
1648
- width : w,
1649
- height : h
1650
- });
1651
-
1652
- }.observes('controller.sliderSettings.width' , 'controller.sliderSettings.height').on('didInsertElement'),
1653
-
1654
- didInsertElement : function(){
1655
- var BG = this.$('#stage-bg'),
1656
- BGImage = $('<img/>');
1657
-
1658
- BGImage.css('visibelity' , 'hidden').each($.jqLoadFix);
1659
-
1660
- var aligner = new MSAligner(this.get('controller.currentSlide.fillMode') , BG , BGImage);
1661
-
1662
- this.set('bgAligner' , aligner);
1663
- this.set('bgImg', BGImage);
1664
- this.onBGChange();
1665
- },
1666
-
1667
- onBGColorChange: function(){
1668
-
1669
- var color = this.get('controller.currentSlide.bgColor');
1670
-
1671
- if( !Ember.isEmpty(color) ){
1672
- this.$('#stage-bg').css('background-color', color);
1673
- } else {
1674
- this.$('#stage-bg').css('background-color', '');
1675
- }
1676
-
1677
- }.observes('controller.currentSlide.bgColor'),
1678
-
1679
- onBGChange: function(){
1680
- var alinger = this.get('bgAligner');
1681
- if(alinger){
1682
- alinger.reset();
1683
- }
1684
-
1685
- var bg = this.get('controller.currentSlide.bg'),
1686
- bgImg = this.get('bgImg');
1687
-
1688
- if( !Ember.isEmpty(bg) ){
1689
- var that = this;
1690
- bgImg.appendTo(this.$('#stage-bg'));
1691
- bgImg.preloadImg(bg , function(event) {that._onBGLoad(event);});
1692
- bgImg.attr('src', bg);
1693
- //alinger.align();
1694
- } else {
1695
- bgImg.detach();
1696
- }
1697
- }.observes('controller.currentSlide.bg'),
1698
-
1699
- _onBGLoad: function(event){
1700
- var aligner = this.get('bgAligner');
1701
-
1702
- if( !aligner ) {
1703
- return;
1704
- }
1705
-
1706
- aligner.init(event.width , event.height);
1707
- aligner.align();
1708
- this.get('bgImg').css('visibelity' , '');
1709
- },
1710
-
1711
- onFillModeChanged : function(){
1712
- var aligner = this.get('bgAligner');
1713
- aligner.changeType(this.get('controller.currentSlide.fillMode'));
1714
- }.observes('controller.currentSlide.fillMode'),
1715
-
1716
- willDestroyElement: function(){
1717
- this.set('bgAligner' , null);
1718
- }
1719
- });//js\mspanel\views\ControlsView.js
1720
-
1721
- /*MSPanel.ControlsView = Ember.View.extend({
1722
- didInsertElement: function(){
1723
- this.get('controller').send('showControlOptions');
1724
- }
1725
- });
1726
- */
1727
- MSPanel.ControlBtn = Ember.View.extend({
1728
- control: null,
1729
- tagName: 'div',
1730
- active:false,
1731
- classNames: ['msp-control-btn'],
1732
- classNameBindings: ['active:msp-blue-btn'],
1733
-
1734
- template : Ember.Handlebars.compile('<span class="msp-control-label">{{view.control.label}}</span>'+
1735
- '<a href="#" {{action "removeControl" target=view bubbles=false}}><span class="msp-control-removes msp-ico msp-ico-whiteremove"></span></a>'),
1736
-
1737
-
1738
- didInsertElement: function() {
1739
-
1740
- },
1741
-
1742
- onActiveChange: function(){
1743
- this.set('active', this.get('controller.currentControl') === this.get('control'));
1744
-
1745
- if( this.get('active') ){
1746
- this.get('controller').send('showControlOptions');
1747
- }
1748
-
1749
- }.observes('controller.currentControl').on('init'),
1750
-
1751
- click: function(){
1752
- if( this.get('active') ) {
1753
- return;
1754
- }
1755
- this.set('controller.currentControl', this.get('control'));
1756
- //this.get('controller').send('showControlOptions');
1757
- },
1758
-
1759
- actions: {
1760
- removeControl: function(){
1761
- if( confirm('Are you sure want to remvoe "' + this.get('control.label') + '" control?')){
1762
- this.get('controller').send('removeControl', this.get('control'));
1763
- }
1764
- }
1765
- }
1766
-
1767
- });
1768
- //js\mspanel\components\UIComponents.js
1769
-
1770
- /**
1771
- MSPanel UI Components
1772
- Version 1.0b
1773
- */
1774
-
1775
- /* ---------------------------------------------------------
1776
- Metabox
1777
- ------------------------------------------------------------*/
1778
-
1779
- MSPanel.MetaBoxComponent = Ember.Component.extend({
1780
- tagName: 'div',
1781
- classNames: ['msp-metabox'],
1782
- layout: Ember.Handlebars.compile('<div class="msp-metabox-handle">'+
1783
- '<h3 class="msp-metabox-title">{{title}}</h3>'+
1784
- '<div class="msp-metabox-toggle"></div>'+
1785
- '</div>'+
1786
- '{{yield}}'+
1787
- '<div class="clear"> </div>')
1788
- });
1789
-
1790
-
1791
- /* ---------------------------------------------------------
1792
- Tabs
1793
- ------------------------------------------------------------*/
1794
-
1795
- Ember.TEMPLATES['components/tabs-panel'] = Ember.Handlebars.compile('{{yield}}');
1796
- MSPanel.TabsPanelComponent = Ember.Component.extend({
1797
- tagName: 'div',
1798
- attributeBindings: ['id'],
1799
- classNames: ['msp-metabox msp-metabox-tabs'],
1800
- didInsertElement: function() {
1801
- this.$().avertaLiveTabs();
1802
- }
1803
- });
1804
-
1805
-
1806
- /* ---------------------------------------------------------
1807
- Switchbox
1808
- ------------------------------------------------------------*/
1809
-
1810
- MSPanel.SwitchBoxComponent = Ember.Component.extend({
1811
- classNames : ['msp-switchbox'],
1812
- offlable : 'OFF',
1813
- onlable : 'ON',
1814
- value : false,
1815
-
1816
- layout : Ember.Handlebars.compile('<div class="msp-switch-cont">'+
1817
- '<span class="msp-switch-off">{{view.offlable}}</span>'+
1818
- '<div class="msp-switch-handle"></div>'+
1819
- '<span class="msp-switch-on">{{view.onlable}}</span>'+
1820
- '</div>'),
1821
-
1822
- click:function(){
1823
- var that = this;
1824
- that.set('value' , !that.get('value'));
1825
- },
1826
-
1827
- update: function(){
1828
-
1829
- if(this.get('value')) this.$().addClass('switched');
1830
- else this.$().removeClass('switched');
1831
-
1832
- }.observes('value').on('didInsertElement')
1833
-
1834
- });
1835
-
1836
-
1837
- /* ---------------------------------------------------------
1838
- WP TinyMCE Editor
1839
- ------------------------------------------------------------*/
1840
- var hiddenEditor = jQuery('#mspHiddenEditor')[0].outerHTML;
1841
- function WPEditorTemplate(id){
1842
- var newEditor = $(hiddenEditor);
1843
- newEditor.find('link').remove(); // remove all css files init
1844
- return newEditor.html().replace(/msp-hidden/g, id);
1845
- }
1846
- var __tmc_msp_id = 0;
1847
-
1848
- MSPanel.WPEditor = Ember.View.extend({
1849
- classNames : ['msp-wp-editor'],
1850
- _id : null,
1851
- template : null,
1852
- tab: null,
1853
- tabs: null,
1854
-
1855
- onInit: function(){
1856
- var id = 'msp-wpeditor-' + __tmc_msp_id;
1857
- this.set('_id', id );
1858
- this.set('template', Ember.Handlebars.compile( WPEditorTemplate(id)));
1859
-
1860
- __tmc_msp_id++;
1861
-
1862
- }.on('init'),
1863
-
1864
- didInsertElement: function(){
1865
- var tabs = this.get('tabs');
1866
- if( Ember.isEmpty(tabs) ) {
1867
- this.createEditor();
1868
- return;
1869
- }
1870
-
1871
- // is in tabs
1872
- $('#'+tabs).bind('avtTabChange', {that:this}, this.refreshEditor);
1873
- },
1874
-
1875
- refreshEditor: function(event , tab){
1876
- var that = event.data.that;
1877
-
1878
- if( that.get('tab') === tab ){
1879
- that.createEditor();
1880
- }
1881
- },
1882
-
1883
- createEditor: function(){
1884
- if( this.get('inited') === true ){
1885
- return;
1886
- }
1887
-
1888
- this.set('inited', true);
1889
- var id = this.get('_id'),
1890
- that = this;
1891
-
1892
- // tinymce
1893
- if( window.tinymce ){
1894
- var settings = $.extend({}, window.tinyMCEPreInit.mceInit['msp-hidden'] || {});
1895
- settings.forced_root_block = "";
1896
- settings.force_br_newlines = true;
1897
- settings.force_p_newlines = false;
1898
- settings.wpautop = false;
1899
-
1900
- if( tinyMCE.majorVersion == '3' ){
1901
- settings.body_class = settings.elements = id;
1902
- tinymce.init(settings);
1903
- setTimeout(function(){
1904
- that.initEditor(tinyMCE.getInstanceById(id));
1905
- }, 50);
1906
- } else if ( tinyMCE.majorVersion == '4' ){
1907
- settings.body_class = "content post-type-post post-status-auto-draft post-format-standard";
1908
- settings.selector = '#'+id;
1909
- tinymce.init(settings);
1910
- setTimeout(function(){
1911
- that.initEditor(tinyMCE.get(id));
1912
- }, 50);
1913
- }
1914
- settings.setup = function(ed) {
1915
- //that.initEditor(ed);
1916
- }
1917
-
1918
- }
1919
-
1920
- var qtagSettings = $.extend({}, window.tinyMCEPreInit.qtInit['msp-hidden'] || {}),
1921
- qtags;
1922
-
1923
- qtagSettings.id = id;
1924
-
1925
- if ( typeof(QTags) === 'function' ) {
1926
- qtags = quicktags(qtagSettings);
1927
- QTags.buttonsInitDone = false;
1928
- QTags._buttonsInit();
1929
- that.set('qtags', qtags );
1930
- switchEditors.go(id, 'html');
1931
-
1932
- this.$('textarea#'+this.get('_id')).on('change keyup paste', function(e){
1933
- that.set('internalChange', true);
1934
- that.set('value', $(this).val());
1935
- });
1936
- }
1937
- },
1938
-
1939
- initEditor: function(mce){
1940
- var id = this.get('_id'),
1941
- value = this.get('value'),
1942
- that = this;
1943
-
1944
- this.$('.wp-editor-wrap').on('mousedown', function(){
1945
- wpActiveEditor = id;
1946
- });
1947
-
1948
- function updateValue(ed,e){
1949
- that.set('value', mce.getContent());
1950
- }
1951
-
1952
- function internalUpdate(ed,e){
1953
- that.set('internalChange', true);
1954
- that.set('value', mce.getContent());
1955
- that.set('internalChange', false);
1956
- }
1957
-
1958
- // register events
1959
- if( tinyMCE.majorVersion == '3' ){
1960
- mce.onChange.add(internalUpdate);
1961
- mce.onKeyUp.add(internalUpdate);
1962
- } else if ( tinyMCE.majorVersion == '4' ){
1963
- mce.on('change', internalUpdate);
1964
- mce.on('keyup', internalUpdate);
1965
- }
1966
-
1967
- this.$().click(internalUpdate);
1968
-
1969
- setTimeout(function(){
1970
- switchEditors.go(id, 'html');
1971
- switchEditors.go(id, 'tmce');
1972
- }, 100);
1973
-
1974
- this.set('mce', mce);
1975
-
1976
- this.onValueChanged();
1977
- },
1978
-
1979
- onValueChanged: function(){
1980
-
1981
- if( !this.get('inited') ){
1982
- return;
1983
- }
1984
-
1985
- var value = this.get('value');
1986
-
1987
- this.$('textarea#'+this.get('_id')).val(value);
1988
-
1989
- if( this.get('internalChange') ){
1990
- this.set('internalChange', false);
1991
- return;
1992
- }
1993
-
1994
- var mce = this.get('mce');
1995
- if( !Ember.isEmpty(mce) && value != null){
1996
- mce.setContent(value);
1997
- } else if( value == null ){
1998
- mce.setContent(' ');
1999
- }
2000
-
2001
- }.observes('value'),
2002
-
2003
- willDestroyElement: function(){
2004
- if( !this.get('inited') ){
2005
- return;
2006
- }
2007
-
2008
- if( window.tinymce ){
2009
- tinymce.remove(this.get('_id'));
2010
- }
2011
-
2012
- var qtags = this.get('qtags');
2013
- if( qtags ){
2014
- $(qtags.toolbar).remove();
2015
- qtags.toolbar = null;
2016
- qtags = null;
2017
-
2018
- if( QTags.instances[this.get('_id')] ) {
2019
- delete QTags.instances[this.get('_id')];
2020
- }
2021
-
2022
- this.$('textarea#'+this.get('_id')).remove();
2023
- }
2024
-
2025
- var tabs = this.get('tabs');
2026
- if( !Ember.isEmpty(tabs) ){
2027
- $('#' + tabs).unbind('avtTabChange', this.refreshEditor);
2028
- }
2029
- }
2030
- });
2031
-
2032
-
2033
- /* ---------------------------------------------------------
2034
- CKEditor
2035
- ------------------------------------------------------------*/
2036
- /*MSPanel.HTMLTextArea = Ember.TextArea.extend({
2037
- didInsertElement: function() {
2038
- this._super();
2039
- var that = this;
2040
-
2041
- var cke = CKEDITOR.replace( that.get('elementId'), {
2042
- uiColor: '#f1f1f1',
2043
- removeButtons: 'Underline,Subscript,Superscript',
2044
- entities : false,
2045
- htmlEncodeOutput: true,
2046
- forcePasteAsPlainText: true,
2047
- enterMode : CKEDITOR.ENTER_BR,
2048
- shiftEnterMode: CKEDITOR.ENTER_P ,
2049
- toolbarGroups : [
2050
- { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
2051
- { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
2052
- { name: 'links' },
2053
- { name: 'insert' },
2054
- { name: 'tools' },
2055
-
2056
- { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
2057
- '/',
2058
- { name: 'styles' },
2059
- { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
2060
- { name: 'paragraph', groups: [ 'blocks', 'align','list', 'indent' ] },
2061
- { name: 'others' }
2062
-
2063
- ]
2064
-
2065
- });
2066
-
2067
- var update = function(e){
2068
- //if (e.editor.checkDirty()) {
2069
- that.set('internalChange' , true);
2070
- that.set('value', cke.getData());
2071
- //console.log('changes', that.get('value'));
2072
-
2073
- //}
2074
- }
2075
-
2076
- //cke.on( 'contentDom', function() {
2077
- // var editable = cke.editable();
2078
-
2079
- // editable.attachListener( editable, 'keyup', function() {
2080
- // console.log( 'Editable has been clicked' );
2081
- // update();
2082
- // });
2083
- //});
2084
-
2085
- cke.on('key', update);
2086
- cke.on('blur', update);
2087
- cke.on('paste', update);
2088
-
2089
- this.set('cke' , cke);
2090
- },
2091
-
2092
- willDestroyElement: function(){
2093
- this.get('cke').destroy();
2094
- //CKEDITOR.remove(this.get('cke'));
2095
- this.set('cke', null);
2096
- },
2097
-
2098
- onValueChanged : function(){
2099
- if(this.get('internalChange')){
2100
- this.set('internalChange' , false);
2101
- return;
2102
- }
2103
-
2104
- var cke = this.get('cke');
2105
- cke.setData(this.get('value'));
2106
- }.observes('value')
2107
- });*/
2108
-
2109
- /* ---------------------------------------------------------
2110
- Number Input
2111
- ------------------------------------------------------------*/
2112
-
2113
- /* Fixed jQuery UI Spinner changing value without focus bug. */
2114
- if( jQuery.ui && jQuery.ui.spinner ){
2115
- jQuery.ui.spinner.prototype._events.mousewheel = function ( event, delta ) {
2116
-
2117
- if ( !delta || !this.element.is(':focus') ) {
2118
- return;
2119
- }
2120
- if ( !this.spinning && !this._start( event ) ) {
2121
- return false;
2122
- }
2123
-
2124
- this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
2125
- clearTimeout( this.mousewheelTimer );
2126
- this.mousewheelTimer = this._delay(function() {
2127
- if ( this.spinning ) {
2128
- this._stop( event );
2129
- }
2130
- }, 100 );
2131
- event.preventDefault();
2132
- }
2133
- }
2134
-
2135
- MSPanel.NumberInputView = Ember.View.extend({
2136
- step : 1,
2137
- min: 0,
2138
- tagName: 'input',
2139
- attributeBindings:['type'],
2140
- lastValue: null,
2141
- type: 'text',
2142
-
2143
- didInsertElement : function(){
2144
-
2145
- var that = this,
2146
- input = this.$();
2147
- var updateValue = function(event, ui){
2148
- var value = input.spinner('value');
2149
- that.set('internalChange', true);
2150
-
2151
- if( isNaN(value) || value == null ){
2152
- that.set('value', undefined);
2153
- }else{
2154
- that.set('value', parseFloat(value));
2155
- }
2156
- }
2157
-
2158
- input.on('change',updateValue).spinner({
2159
- step: this.get('step'),
2160
- numberFormat: "n",
2161
- min:this.get('min'),
2162
- max:this.get('max'),
2163
- spin: updateValue,
2164
- stop: updateValue
2165
- }).spinner('value', this.get('value'));
2166
-
2167
- },
2168
-
2169
- onValueChanged : function(){
2170
-
2171
- if(this.get('internalChange')){
2172
- this.set('internalChange', false);
2173
- return;
2174
- }
2175
-
2176
- //this.$().val(this.get('value'));
2177
-
2178
- this.$().spinner('value', this.get('value'));
2179
-
2180
-
2181
- /*if(this.get('internalChange')){
2182
- this.set('internalChange', false);
2183
- return;
2184
- }*/
2185
- //var value = Number(this.get('value'));
2186
-
2187
- //this.$().val(value);
2188
-
2189
- /*
2190
- if(value == this.get('lastValue')){
2191
- return;
2192
- }
2193
- // convert to number always
2194
- if(value === '' || isNaN(value)){
2195
- this.set('value', undefined);
2196
- return;
2197
- }
2198
-
2199
- if( typeof value !== 'number') {
2200
- this.set('value', Number(this.get('value')));
2201
- }
2202
-
2203
- if(!Ember.isEmpty(value) && value < this.get('min')){
2204
- value = this.get('min');
2205
- this.set('value' , value);
2206
- }
2207
-
2208
-
2209
-
2210
- */
2211
- }.observes('value')
2212
-
2213
- });
2214
-
2215
- Ember.Handlebars.helper('number-input' , MSPanel.NumberInputView);
2216
-
2217
- /**
2218
- * Color Picker
2219
- * @package MSPanel
2220
- * @requires spectrum color picker
2221
- */
2222
- MSPanel.ColorPickerComponent = Ember.Component.extend({
2223
- tagName: 'input',
2224
- classNames: 'msp-color-picker',
2225
- value: null,
2226
-
2227
- didInsertElement: function(){
2228
- var that = this;
2229
- this.$().spectrum({
2230
- color: this.get('value'),
2231
- allowEmpty:true,
2232
- showInput: true,
2233
- showAlpha: true,
2234
- clickoutFiresChange:true,
2235
- preferredFormat: "hex6",
2236
- change: function(color) {
2237
- if( color === null) {
2238
- that.set('value' , null);
2239
- } else {
2240
- that.set('value', color.toString());
2241
- }
2242
- }
2243
- })
2244
- },
2245
-
2246
- willDestroyElement: function(){
2247
- this.$().spectrum("destroy");
2248
- },
2249
- onValueChanged: function(){
2250
- this.$().spectrum("set", this.get('value'));
2251
- }.observes('value')
2252
-
2253
- });
2254
-
2255
- /**
2256
- * Dropdwon list
2257
- * @package MSPanel
2258
- */
2259
- MSPanel.DropdwonListComponent = Ember.Component.extend({
2260
- tagName: 'div',
2261
- classNames: ['msp-ddlist'],
2262
- layout: Ember.Handlebars.compile('<select>{{yield}}</select>'),
2263
- value: null,
2264
- width: 100,
2265
-
2266
- didInsertElement: function(){
2267
- var that = this;
2268
- this.$('select').on('change', function(){
2269
- var option = that.$('select option:selected');
2270
- that.set('value', option.attr('value'));
2271
- }).width(this.get('width'));
2272
-
2273
- this.onValueChanged();
2274
- },
2275
-
2276
- onValueChanged: function(){
2277
- if( !Ember.isEmpty(this.get('value')) ){
2278
- this.$('select').val(this.get('value'));
2279
- }
2280
- }.observes('value')
2281
- });
2282
-
2283
-
2284
- /**
2285
- * CodeMirror Component
2286
- * @package MSPanel
2287
- * @requires Codemirror
2288
- */
2289
- MSPanel.CodeMirrorComponent = Ember.Component.extend({
2290
- classNames: ['msp-codemirror'],
2291
- width: 250,
2292
- height: 200,
2293
- mode: 'css',
2294
- tab: null,
2295
- tabs: null,
2296
- layout: Ember.Handlebars.compile('<textarea>{{yield}}</textarea>'),
2297
-
2298
- didInsertElement: function(){
2299
-
2300
- this.$().width(this.get('width'))
2301
- .height(this.get('height'));
2302
-
2303
- var that = this,
2304
- editor = CodeMirror.fromTextArea(this.$('>textarea')[0], {
2305
- lineNumbers:true,
2306
- mode:this.get('mode')
2307
- });
2308
-
2309
- editor.on('change', function(){
2310
- that.set('internalChange', true);
2311
- that.set('value', editor.getValue());
2312
- })
2313
-
2314
- this.set('editor', editor);
2315
-
2316
- var value = this.get('value');
2317
- if( !Ember.isEmpty(value) ) {
2318
- editor.setValue(value);
2319
- }
2320
-
2321
- // is in tabs
2322
- var tabs = this.get('tabs');
2323
- if( !Ember.isEmpty(tabs) ){
2324
- $('#'+tabs).bind('avtTabChange', {that:this}, this.refreshEditor);
2325
- }
2326
- },
2327
-
2328
- onValueChanged: function(){
2329
- if( this.get('internalChange') === true) {
2330
- this.set('internalChange', false);
2331
- return;
2332
- }
2333
-
2334
- this.get('editor').setValue(this.get('value'));
2335
- this.set('internalChange', false);
2336
-
2337
- }.observes('value'),
2338
-
2339
- refreshEditor: function(event , tab){
2340
- var that = event.data.that;
2341
-
2342
- if( that.get('tab') === tab ) {
2343
- that.get('editor').refresh();
2344
- }
2345
- },
2346
-
2347
- willDestroyElement: function(){
2348
- var tabs = this.get('tabs');
2349
- if( !Ember.isEmpty(tabs) ){
2350
- $('#' + tabs).unbind('avtTabChange', this.refreshEditor);
2351
- }
2352
-
2353
- var editor = this.get('editor');
2354
- editor.toTextArea();
2355
- editor = null;
2356
- this.set('editor', null);
2357
- }
2358
-
2359
- });//js\mspanel\controllers\ApplicationController.js
2360
-
2361
- /*
2362
- * Application controller
2363
- * @package MSPanel
2364
- */
2365
-
2366
- MSPanel.pushData = null;
2367
- MSPanel.ApplicationController = Ember.Controller.extend({
2368
-
2369
- sliderId : MSPanel.SliderID,
2370
-
2371
- // if true save button will be disabled
2372
- isSending: false,
2373
-
2374
- // the status message that appears after save button
2375
- statusMsg: '',
2376
-
2377
- hasError: false,
2378
-
2379
-
2380
- onInit: function(){
2381
- // fetch all data
2382
-
2383
- //setting
2384
- MSPanel.Settings.find();
2385
- // slides
2386
- MSPanel.Slide.find();
2387
- // layer
2388
- //MSPanel.Layer.find();
2389
- // style
2390
- //MSPanel.Style.find();
2391
- // effect
2392
- //MSPanel.Effect.find();
2393
- // style
2394
- //MSPanel.PresetStyle.find();
2395
- // effect
2396
- //MSPanel.PresetEffect.find();
2397
- //control
2398
- MSPanel.Control.find();
2399
- //callback
2400
- MSPanel.Callback.find();
2401
- //buttonClass
2402
- //MSPanel.ButtonStyle.find();
2403
-
2404
- //this.set('useCustomTemplate', MSPanel.Settings.find(0).get('msTemplate') === 'custom');
2405
- this.set('disableControls', MSPanel.Settings.find(0).get('disableControls'));
2406
-
2407
- var that = this;
2408
- MSPanel.pushData = function(){
2409
- that.prepareData();
2410
- };
2411
-
2412
- // redirect if woocommerce not installed
2413
- if ( __MSP_TYPE === 'wc-product' && __MSP_POST == null && __WC_INSTALL_URL != null ){
2414
- this.set('hasError', true);
2415
- this.set('errorTemplate', 'wooc-error');
2416
- this.set('wooLink', __WC_INSTALL_URL);
2417
- }
2418
-
2419
- // generate buttons style element
2420
- this.generateButtonStyles();
2421
-
2422
- this.set('shortCode', '[masterslider id='+this.get('sliderId')+']');
2423
- this.set('phpFunction', '<?php masterslider('+this.get('sliderId')+'); ?>');
2424
-
2425
- jQuery('#panelLoading').remove();
2426
-
2427
- }.on('init'),
2428
-
2429
- prepareData: function(){
2430
- // Generate used fonts
2431
- var fonts = {},
2432
- font_str = '';
2433
- MSPanel.Style.find().forEach(function(record){
2434
- var font = record.get('fontFamily'),
2435
- weight = record.get('fontWeight');
2436
-
2437
- if( !Ember.isEmpty(font) ){
2438
-
2439
- if( !fonts[font] ){
2440
- fonts[font] = [];
2441
- }
2442
-
2443
- if( weight === 'normal' ){
2444
- weight = 'regular';
2445
- }
2446
-
2447
- if( !Ember.isEmpty(weight) && fonts[font].indexOf(weight) === -1 ) {
2448
- fonts[font].push(weight);
2449
- }
2450
- }
2451
- });
2452
-
2453
- for(var font in fonts){
2454
- font_str += font.replace(/\s/, '+') + ':' + fonts[font].join(',') + '|';
2455
- }
2456
-
2457
- MSPanel.Settings.find(1).set('usedFonts', font_str.slice(0,-1));
2458
-
2459
- // save all models
2460
-
2461
- // settings
2462
- this.saveRecords(MSPanel.Settings.find());
2463
- // slides
2464
- this.saveRecords(MSPanel.Slide.find());
2465
- /*// layer
2466
- this.saveRecords(MSPanel.Layer.find());
2467
- // style
2468
- this.saveRecords(MSPanel.Style.find());
2469
- // effect
2470
- this.saveRecords(MSPanel.Effect.find());
2471
- // preset style
2472
- this.saveRecords(MSPanel.PresetStyle.find());
2473
- // preset effect
2474
- this.saveRecords(MSPanel.PresetEffect.find());*/
2475
- // control
2476
- this.saveRecords(MSPanel.Control.find());
2477
- // callback functions
2478
- this.saveRecords(MSPanel.Callback.find());
2479
- // button classes
2480
- //this.saveRecords(MSPanel.ButtonStyle.find());
2481
-
2482
- //console.log('saving data');
2483
- },
2484
-
2485
- generateButtonStyles: function(){
2486
- var styles = MSPanel.ButtonStyle.find(),
2487
- css = '',
2488
- $styleElement = $('#msp-buttons');
2489
-
2490
- styles.forEach(function(style){
2491
- css += '.' + style.get('className') + ' {'+
2492
- style.get('normal')+
2493
- '}\n'+
2494
-
2495
- '.' + style.get('className') + ':hover {'+
2496
- style.get('hover')+
2497
- '}\n'+
2498
- '.' + style.get('className') + ':active {'+
2499
- style.get('active')+
2500
- '}\n';
2501
- });
2502
-
2503
- if( $styleElement.length === 0 ) {
2504
- $styleElement = $('<style id="msp-buttons"></style>').text(css).appendTo($('head'));
2505
- } else {
2506
- $styleElement.text(css);
2507
- }
2508
- },
2509
-
2510
- actions: {
2511
- saveAll: function(){
2512
- this.prepareData();
2513
- this.sendData();
2514
- },
2515
-
2516
- showPreview: function(event){
2517
- if(window.lunchMastersliderPreview){
2518
- lunchMastersliderPreview(event);
2519
- }
2520
- }
2521
- },
2522
-
2523
- saveRecords: function(records){
2524
- records.forEach(function(record){ record.save(); });
2525
- },
2526
-
2527
- /**
2528
- * Send Data to WP Admin
2529
- * @since 1.0.0
2530
- * @return {null}
2531
- */
2532
- sendData: function(){
2533
-
2534
- this.set('statusMsg', __MSP_LAN.ap_001);
2535
- this.set('isSending', true);
2536
- var that = this;
2537
-
2538
-
2539
- jQuery.post(
2540
- __MS.ajax_url,
2541
- {
2542
- action : 'msp_panel_handler', // the handler
2543
- nonce : jQuery('#msp-main-wrapper').data('nonce'), // the generated nonce value
2544
- msp_data : B64.encode(JSON.stringify(MSPanel.data)),
2545
- preset_style : B64.encode(JSON.stringify(MSPanel.PSData)),
2546
- preset_effect : B64.encode(JSON.stringify(MSPanel.PEData)),
2547
- buttons : B64.encode(JSON.stringify(MSPanel.PBData)),
2548
- slider_id : MSPanel.SliderID,
2549
- },
2550
- function(res){
2551
- that.set('statusMsg', res.message);
2552
- that.set('isSending', false);
2553
- /*if( res.success === true ){
2554
- that.set('statusMsg', __MSP_LAN.ap_003);
2555
- that.set('isSending', false);
2556
- }else{
2557
- that.set('isSending', false);
2558
- that.set('statusMsg', __MSP_LAN.ap_002);
2559
- }*/
2560
- }
2561
- );
2562
- }
2563
-
2564
- });
2565
-
2566
-
2567
- //js\mspanel\controllers\SettingsController.js
2568
-
2569
-
2570
- /**
2571
- * Master Slider Settings Controller
2572
- * @package MSPanel
2573
- * @extends {Ember.Controller}
2574
- */
2575
- MSPanel.SettingsController = Ember.ObjectController.extend({
2576
-
2577
- customSlider : window.__MSP_TYPE && window.__MSP_TYPE === 'custom',
2578
- templateSlider : window.__MSP_TYPE && ( window.__MSP_TYPE === 'flickr' || window.__MSP_TYPE === 'post' || window.__MSP_TYPE === 'wc-product' || window.__MSP_TYPE === 'facebook'),
2579
-
2580
- sliderSkins : __MSP_SKINS,
2581
-
2582
-
2583
- needs: ['application', 'controls'],
2584
- msTemplateName: null,
2585
- msTemplateImg: null,
2586
- draftMSTemplate:null,
2587
- templates: MSPanel.SliderTemplates,
2588
-
2589
- showAutoHeight: false,
2590
- showNearbyNum: false,
2591
- showWrapperWidth: false,
2592
- preloadMethod: null,
2593
-
2594
- /**
2595
- * Setup controller init values
2596
- * It called from ember router in MSPanel.js
2597
- */
2598
- setup: function(){
2599
- // read preload valu from model and setup preload select list
2600
- var preload = this.get('preload');
2601
- if( preload === 'all' || preload === '-1' ){
2602
- this.set('preloadMethod' , preload);
2603
- } else {
2604
- this.set('preloadMethod' , 'nearby');
2605
- }
2606
-
2607
- this.set('draftMSTemplate', this.get('msTemplate'));
2608
- this.updateTemplate(true);
2609
- },
2610
-
2611
- /**
2612
- * Remove autoheight option if layout style is fullscreen or autofill
2613
- */
2614
- sliderLayoutChanged: function(){
2615
- var layout = this.get('layout');
2616
- if( layout === 'fullscreen' || layout === 'autofill' ) {
2617
- this.set('showAutoHeight' , false);
2618
- this.set('autoHeight' , false);
2619
- } else {
2620
- this.set('showAutoHeight' , true);
2621
- }
2622
-
2623
- this.set('showWrapperWidth', layout === 'boxed' || layout === 'partialview');
2624
-
2625
- /* if( layout === 'boxed' && Ember.isEmpty(this.get('wrapperWidth')) ){
2626
- this.set('wrapperWidth', this.get('width'));
2627
- this.set('wrapperWidthUnit', 'px');
2628
- }
2629
-
2630
- if( layout === 'partialview' && Ember.isEmpty(this.get('wrapperWidth')) ){
2631
- this.set('wrapperWidth', '100');
2632
- this.set('wrapperWidthUnit', '%');
2633
- }*/
2634
-
2635
- this.set('showFSMargin', layout === 'fullscreen');
2636
-
2637
- }.observes('layout').on('setup'),
2638
-
2639
- /**
2640
- * controll preloading method
2641
- */
2642
- preloadSetup: function(){
2643
- var preloadMethod = this.get('preloadMethod');
2644
-
2645
- if( preloadMethod === 'nearby' ) {
2646
- this.set('showNearbyNum' , true);
2647
- var preload = this.get('preload');
2648
- if(preload === 'all' || preload === '-1'){
2649
- this.set('preload' , '0');
2650
- }
2651
- } else {
2652
- this.set('showNearbyNum' , false);
2653
- this.set('preload' , preloadMethod);
2654
- }
2655
-
2656
- }.observes('preloadMethod').on('setup'),
2657
-
2658
- updateTemplate: function(init){
2659
- var templateObject,
2660
- msTemplate = this.get('msTemplate');
2661
-
2662
- this.get('templates').forEach(function(template){
2663
- if( template.value === msTemplate ) {
2664
- templateObject = template;
2665
- return;
2666
- }
2667
- });
2668
-
2669
- if( templateObject ){
2670
- this.set('msTemplateName', templateObject.name);
2671
- this.set('msTemplateImg', templateObject.img);
2672
- this.set('msTemplateClass', templateObject.className);
2673
- this.set('controllers.application.disableControls', templateObject.disableControls );
2674
- this.set('disableControls', templateObject.disableControls );
2675
-
2676
- if(!init){
2677
- var controllController = this.get('controllers.controls'),
2678
- controlObj,
2679
- control;
2680
- // remove added controls
2681
- var controls = MSPanel.Control.find();
2682
-
2683
- while(controls.get('firstObject')){
2684
- var control = controls.get('firstObject');
2685
-
2686
- controllController.findControlObj(control.get('name')).used = false;
2687
- control.deleteRecord();
2688
- }
2689
-
2690
- // create template controls
2691
- for (var controlName in templateObject.controls){
2692
- controlObj = controllController.findControlObj(controlName);
2693
- control = MSPanel.Control.create($.extend(true, controllController.getDefaultValues(controlName), templateObject.controls[controlName]));
2694
- control.set('label', controlObj.label);
2695
- controlObj.used = true;
2696
- control.save();
2697
- }
2698
-
2699
- // update slider settings
2700
- for(var option in templateObject.settings){
2701
- this.set(option, templateObject.settings[option]);
2702
- }
2703
- }
2704
-
2705
- } else { // template not found! so lets select custom template
2706
- this.set('draftMSTemplate', 'custom');
2707
- this.updateTemplate();
2708
- }
2709
-
2710
-
2711
- },
2712
-
2713
- actions: {
2714
-
2715
- openTemplates: function(){
2716
- var templatesView = MSPanel.TemplatesView.create({
2717
- controller: this
2718
- });
2719
-
2720
- this.get('mainView').createChildView(templatesView);
2721
- this.set('templatesView', templatesView);
2722
-
2723
- templatesView.appendTo(MSPanel.rootElement);
2724
- },
2725
-
2726
- closeTemplates: function(){
2727
- this.get('templatesView').destroy();
2728
-
2729
- // rollback to current template
2730
- this.set('draftMSTemplate', this.get('msTemplate'));
2731
- },
2732
-
2733
- saveTemplate: function(){
2734
- if( this.get('draftMSTemplate') === this.get('msTemplate') ){
2735
- this.send('closeTemplates');
2736
- return;
2737
- }
2738
-
2739
- if( confirm(__MSP_LAN.tv_002) ){
2740
- // update msTemplate
2741
- this.set('msTemplate', this.get('draftMSTemplate'));
2742
- this.send('closeTemplates');
2743
- this.updateTemplate();
2744
- }
2745
- }
2746
- }
2747
- });
2748
- //js\mspanel\controllers\SlidesController.js
2749
-
2750
- MSPanel.SlidesController = Ember.ArrayController.extend({
2751
-
2752
- customSlider : window.__MSP_TYPE && window.__MSP_TYPE === 'custom',
2753
-
2754
- _order : -1,
2755
-
2756
- sortProperties: ['order'],
2757
- mainView: null, // main view object which will be setted by MSPanel.SlidesView
2758
-
2759
- currentSlide: null,
2760
-
2761
- setup: function(){
2762
- if( this.get('length') === 0 ){
2763
- this.send('newSlide');
2764
- } else {
2765
- var slide = this.get('firstObject');
2766
- this.set('currentSlide' , slide);
2767
- }
2768
-
2769
- // slider type
2770
- if( Ember.isEmpty(this.get('sliderSettings.type')) ){
2771
- this.set('sliderSettings.type', __MSP_TYPE);
2772
- }
2773
-
2774
- this.set('sliderSettings.sliderId', MSPanel.SliderID);
2775
-
2776
- this.updateOrder();
2777
- //this.set('_order', this.get('lastObject.order'));
2778
- },
2779
-
2780
- duplicateSlide : function(slide){
2781
- var slideProp = slide.toJSON();
2782
- delete slideProp.id;
2783
- delete slideProp.layers;
2784
-
2785
- var newSlide = MSPanel.Slide.create(slideProp);
2786
-
2787
- // insert after
2788
- newSlide.set('order' , slide.get('order') + 1);
2789
-
2790
- // update order
2791
- this.forEach(function(_slide){
2792
- var slide_order = _slide.get('order'),
2793
- nslide_order = newSlide.get('order');
2794
-
2795
- if(slide_order >= nslide_order && _slide !== newSlide)
2796
- _slide.set('order' , slide_order + 1);
2797
- });
2798
-
2799
- newSlide.save();
2800
- this.updateOrder();
2801
- },
2802
-
2803
- updateSlidesSort : function(indexes) {
2804
- this.beginPropertyChanges();
2805
-
2806
- this.forEach(function(slide) {
2807
- slide.set('order', indexes[slide.get('id')]);
2808
- }, this);
2809
- this.endPropertyChanges();
2810
- this.set('_order', this.get('lastObject.order'));
2811
- },
2812
-
2813
- updateOrder: function(){
2814
- var i = 0;
2815
- this.forEach(function(slide){
2816
- slide.set('order', i++);
2817
- });
2818
-
2819
- this.set('_order', i - 1);
2820
- },
2821
-
2822
- removeSlide : function(slide){
2823
-
2824
- slide.deleteRecord();
2825
-
2826
- if(this.get('length') === 0){
2827
- this.send('newSlide');
2828
- }else{
2829
- this.send('select' , this.get('firstObject'));
2830
- }
2831
-
2832
- this.updateOrder();
2833
- },
2834
-
2835
- actions: {
2836
-
2837
- newSlide : function(){
2838
- var slide = MSPanel.Slide.create({order: this.get('_order') + 1});
2839
- this.set('currentSlide' , slide);
2840
- this.set('_order' , this.get('_order') + 1);
2841
- slide.save();
2842
- },
2843
-
2844
- select : function(slide){
2845
- if(slide === this.get('currentSlide')) return;
2846
- this.set('currentSlide' , slide);
2847
- }
2848
- }
2849
- });
2850
- //js\mspanel\controllers\ControlsController.js
2851
-
2852
- /**
2853
- * Master Slider Panel, Slider Controls controller
2854
- * @package MSPanel
2855
- * @author Averta
2856
- * @version 1.0b
2857
- */
2858
- MSPanel.ControlsController = Ember.ArrayController.extend({
2859
-
2860
- needs: 'application',
2861
-
2862
- controls: [
2863
- {used:false, label:__MSP_LAN.cc_001, value:'arrows'},
2864
- {used:false, label:__MSP_LAN.cc_002, value:'timebar'},
2865
- {used:false, label:__MSP_LAN.cc_003, value:'bullets'},
2866
- {used:false, label:__MSP_LAN.cc_004, value:'circletimer'},
2867
- {used:false, label:__MSP_LAN.cc_005, value:'scrollbar'},
2868
- {used:false, label:__MSP_LAN.cc_006, value:'slideinfo'},
2869
- {used:false, label:__MSP_LAN.cc_007, value:'thumblist'}
2870
- ],
2871
-
2872
- selectedControl: null, // selected control in combo box
2873
-
2874
- availableControls: [], // already added to slider
2875
-
2876
- noMore: false,
2877
-
2878
- currentControl: null, // current active control
2879
-
2880
- setup: function(){
2881
- var that = this;
2882
- this.forEach(function(control){
2883
- that.findControlObj(control.get('name')).used = true;
2884
- });
2885
- this.set('availableControls', this.findAvailableControls());
2886
- },
2887
-
2888
- actions: {
2889
-
2890
- addControl: function(){
2891
-
2892
- var controlName = this.get('selectedControl'),
2893
- controlObj = this.findControlObj(controlName),
2894
- control;
2895
-
2896
- // create control object
2897
- control = MSPanel.Control.create(this.getDefaultValues(controlName));
2898
- control.set('label', controlObj.label);
2899
-
2900
- controlObj.used = true;
2901
- this.set('availableControls', this.findAvailableControls());
2902
- control.save();
2903
-
2904
- this.set('currentControl', control);
2905
- },
2906
-
2907
- removeControl: function(control){
2908
- this.findControlObj(control.get('name')).used = false;
2909
- this.set('availableControls', this.findAvailableControls());
2910
- control.deleteRecord();
2911
-
2912
- this.set('currentControl', this.get('firstObject'));
2913
- this.send('showControlOptions');
2914
- },
2915
-
2916
- showControlOptions: function(){
2917
- var currentControl = this.get('currentControl');
2918
-
2919
- if( Ember.isEmpty(currentControl) ){
2920
- this.set('controlOptions', 'empty-template');
2921
- } else {
2922
- this.set('controlOptions', currentControl.get('name') + '-options');
2923
- }
2924
- }
2925
-
2926
- },
2927
-
2928
- /**
2929
- * Find selected control from controls
2930
- * @param {string} control
2931
- * @return {object}
2932
- */
2933
- findControlObj: function(control){
2934
- var controls = this.get('controls');
2935
- for(var i=0,l=controls.length; i!==l; i++){
2936
- if( controls[i].value === control ){
2937
- return controls[i];
2938
- }
2939
- }
2940
-
2941
- return null;
2942
- },
2943
-
2944
- findAvailableControls: function(){
2945
- var avc = [],
2946
- controls = this.get('controls');
2947
- for(var i=0,l=controls.length; i!==l; i++){
2948
- if( !controls[i].used ){
2949
- avc.push(controls[i]);
2950
- }
2951
- }
2952
-
2953
- this.set('noMore', avc.length === 0);
2954
- this.set('selectedControl', avc[0]?avc[0].value:null);
2955
-
2956
- return avc;
2957
- },
2958
-
2959
- /**
2960
- * creates an object of default values for new control
2961
- * @param {Control} control
2962
- * @return {Object}
2963
- */
2964
- getDefaultValues: function(control){
2965
- var values = {name:control};
2966
-
2967
- values.inset = !(control === 'slideinfo' || control === 'thumblist');
2968
-
2969
- switch(control){
2970
- case 'timebar':
2971
- values.align = 'bottom';
2972
- values.color = '#FFFFFF';
2973
- values.autoHide = false;
2974
- values.width = 4;
2975
- break;
2976
- case 'bullets':
2977
- values.align = 'bottom';
2978
- values.dir = 'h';
2979
- values.margin = 10;
2980
- break;
2981
- case 'circletimer':
2982
- //values.align = 'tl';
2983
- values.color = '#A2A2A2';
2984
- values.stroke = 10;
2985
- values.radius = 4;
2986
- values.autoHide = false;
2987
- break;
2988
- case 'scrollbar':
2989
- values.align = 'top';
2990
- values.dir = 'h';
2991
- values.color = '#3D3D3D';
2992
- values.margin = 10;
2993
- values.autoHide = false;
2994
- values.width = 4;
2995
- break;
2996
- case 'slideinfo':
2997
- values.align = 'bottom';
2998
- values.margin = 10;
2999
- values.autoHide = false;
3000
- break;
3001
- case 'thumblist':
3002
- values.align = 'bottom';
3003
- values.space = 5;
3004
- values.width = 100;
3005
- values.height = 80;
3006
- values.margin = 10;
3007
- values.fillMode = 'fill';
3008
- values.autoHide = false;
3009
- break;
3010
- }
3011
-
3012
- return values;
3013
- }
3014
-
3015
- });
3016
- //js\mspanel\controllers\CallbacksController.js
3017
-
3018
- /**
3019
- * Master Slider Panel Callbacks controller
3020
- * @package MSPanel
3021
- * @version 1.0
3022
- * @author Averta
3023
- */
3024
-
3025
- MSPanel.CallbacksController = Ember.ArrayController.extend({
3026
-
3027
- callbacks: [
3028
- {used: false, label:__MSP_LAN.cb_011, value:'INIT'},
3029
- {used: false, label:__MSP_LAN.cb_001, value:'CHANGE_START'},
3030
- {used: false, label:__MSP_LAN.cb_002, value:'CHANGE_END'},
3031
- {used: false, label:__MSP_LAN.cb_003, value:'WAITING'},
3032
- {used: false, label:__MSP_LAN.cb_004, value:'RESIZE'},
3033
- {used: false, label:__MSP_LAN.cb_005, value:'VIDEO_PLAY'},
3034
- {used: false, label:__MSP_LAN.cb_006, value:'VIDEO_CLOSE'},
3035
- {used: false, label:__MSP_LAN.cb_007, value:'SWIPE_START'},
3036
- {used: false, label:__MSP_LAN.cb_008, value:'SWIPE_MOVE'},
3037
- {used: false, label:__MSP_LAN.cb_009, value:'SWIPE_END'}
3038
- ],
3039
-
3040
- availableCallbacks: [],
3041
- noMore: false,
3042
- selectedCallback: null, // selected callback in combo box
3043
-
3044
- setup: function(){
3045
- var that = this;
3046
- this.forEach(function(callback){
3047
- that.findCallbackObj(callback.get('name')).used = true;
3048
- });
3049
- this.set('availableCallbacks', this.findAvailableCallbacks());
3050
- },
3051
-
3052
- actions: {
3053
- addCallback: function(){
3054
- var callbackName = this.get('selectedCallback'),
3055
- callbackObj = this.findCallbackObj(callbackName),
3056
- callback;
3057
-
3058
- // create callback object
3059
- callback = MSPanel.Callback.create({
3060
- name:callbackObj.value,
3061
- label:callbackObj.label
3062
- });
3063
-
3064
- callbackObj.used = true;
3065
- this.set('availableCallbacks', this.findAvailableCallbacks());
3066
- callback.save();
3067
- },
3068
-
3069
- removeCallback: function(callback){
3070
- if( confirm(__MSP_LAN.cb_010.jfmt(callback.get('label'))) ){
3071
- this.findCallbackObj(callback.get('name')).used = false;
3072
- this.set('availableCallbacks', this.findAvailableCallbacks());
3073
- callback.deleteRecord();
3074
- }
3075
- }
3076
-
3077
- },
3078
-
3079
- /**
3080
- * Find selected callback from callbacks
3081
- * @param {string} callback
3082
- * @return {object}
3083
- */
3084
- findCallbackObj: function(callback){
3085
- var callbacks = this.get('callbacks');
3086
- for(var i=0,l=callbacks.length; i!==l; i++){
3087
- if( callbacks[i].value === callback ){
3088
- return callbacks[i];
3089
- }
3090
- }
3091
- return null;
3092
- },
3093
-
3094
- findAvailableCallbacks: function(){
3095
- var avc = [],
3096
- callbacks = this.get('callbacks');
3097
- for(var i=0,l=callbacks.length; i!==l; i++){
3098
- if( !callbacks[i].used ){
3099
- avc.push(callbacks[i]);
3100
- }
3101
- }
3102
-
3103
- this.set('noMore', avc.length === 0);
3104
- this.set('selectedCallback', avc[0]?avc[0].value:null);
3105
- return avc;
3106
- },
3107
-
3108
- });
1
+ /*!
2
+ * @overview Master Slider Lite Wordpress Panel
3
+ * @copyright Copyright 2014 Averta Ltd.
4
+ * @version 1.0
5
+ * http://www.averta.net
6
+ */
7
+ function WPEditorTemplate(n){var t=$(hiddenEditor);return t.find("link").remove(),t.html().replace(/msp-hidden/g,n)}var hiddenEditor,__tmc_msp_id;window.MSPanel=Ember.Application.create({rootElement:"#msp-root"}),MSPanel.version="1.0",MSPanel.SliderID=parseQueryString(window.location.search).slider_id||__MSP_SLIDER_ID||"100",String.prototype.jfmt=function(){return"".fmt.apply(this.replace(/%s|%d/,"%@"),arguments)},$=jQuery.noConflict(),jQuery.ui.dialog.prototype._focusTabbable=function(){},MSPanel.Router.map(function(){this.resource("settings"),this.resource("slides",{path:"/"}),this.resource("controls"),this.resource("callbacks"),this.resource("error")}),MSPanel.Router.reopen({location:"none"}),MSPanel.ApplicationRoute=Ember.Route.extend({model:function(){var n=MSPanel.Settings.find();n.get("length")===0&&MSPanel.Settings.create().save()}}),MSPanel.SettingsRoute=Ember.Route.extend({model:function(){return MSPanel.Settings.find(1)},setupController:function(n,t){n.set("model",t),n.setup()}}),MSPanel.SlidesRoute=Ember.Route.extend({model:function(){return MSPanel.Slide.find()},setupController:function(n,t){n.set("model",t),n.set("sliderSettings",MSPanel.Settings.find(1)),n.setup()}}),MSPanel.ControlsRoute=Ember.Route.extend({model:function(){return MSPanel.Control.find()},setupController:function(n,t){n.set("model",t),n.setup(),this.activate()},activate:function(){var n=this.get("controller");n&&n.set("controlOptions","empty-template")}}),MSPanel.CallbacksRoute=Ember.Route.extend({model:function(){return MSPanel.Callback.find()},setupController:function(n,t){n.set("model",t),n.setup()}}),function(){var n=Ember.attr,f=Ember.hasMany,r=Ember.belongsTo,u=/https\:|http\:/,t={serialize:function(n){return n==undefined?n:u.test(n)?n.replace(__MS.upload_dir,""):n},deserialize:function(n){return n==undefined?n:u.test(n)?n:__MS.upload_dir+n}},i;MSPanel.Settings=Ember.Model.extend({id:n("number"),snapping:n("boolean",{defaultValue:!0}),bgImageThumb:n(t),disableControls:n("boolean",{defaultValue:!1}),name:n("string",{defaultValue:__MSP_LAN.sm_001}),width:n("number",{defaultValue:1e3}),height:n("number",{defaultValue:500}),wrapperWidth:n("number"),wrapperWidthUnit:n("string",{defaultValue:"px"}),autoCrop:n("boolean",{defaultValue:!1}),type:n("string"),sliderId:n("string"),layout:n("string",{defaultValue:"boxed"}),autoHeight:n("boolean",{defaultValue:!1}),trView:n("string",{defaultValue:"basic"}),speed:n("number",{defaultValue:20}),space:n("number",{defaultValue:0}),start:n("number",{defaultValue:1}),grabCursor:n("boolean",{defaultValue:!0}),swipe:n("boolean",{defaultValue:!0}),mouse:n("boolean",{defaultValue:!0}),wheel:n("boolean",{defaultValue:!1}),autoplay:n("boolean",{defaultValue:!1}),loop:n("boolean",{defaultValue:!1}),shuffle:n("boolean",{defaultValue:!1}),preload:n("string",{defaultValue:"-1"}),overPause:n("boolean",{defaultValue:!0}),endPause:n("boolean",{defaultValue:!1}),hideLayers:n("boolean",{defaultValue:!1}),dir:n("string",{defaultValue:"h"}),parallaxMode:n("srting",{defaultValue:"swipe"}),centerControls:n("boolean",{defaultValue:!0}),instantShowLayers:n("boolean",{defaultValue:!1}),fullscreenMargin:n("number"),inlineStyle:n("string"),className:n("string"),bgColor:n("string"),bgImage:n(t),skin:n("string",{defaultValue:"ms-skin-default"}),msTemplate:n("string",{defaultValue:"custom"}),msTemplateClass:n("string",{defaultValue:""}),usedFonts:n("string"),apiKey:n("string"),setId:n("string"),setType:n("string"),imgCount:n("number"),thumbSize:n("srting"),imgSize:n("string"),postType:n("string"),postCats:n(Array),postTags:n(Array),postCount:n("number"),postImageType:n("string"),postOrder:n("string"),postOrderDir:n("string"),postExcerptLen:n("number"),postExcludeIds:n("string"),postOffset:n("number"),postLinkSlide:n("boolean"),postLinkTarget:n("string"),postSlideBg:n("string"),postSlideBgthumb:n("string"),wcOnlyInstock:n("boolean"),wcOnlyFeatured:n("boolean"),wcOnlyOnsale:n("boolean")}),MSPanel.Slide=Ember.Model.extend({id:n("number"),timeline_h:n("number",{defaultValue:200}),bgThumb:n(t),thumbOrginal:n(t),order:n("number"),ishide:n("boolean"),bg:n(t),duration:n("number",{defaultValue:3}),fillMode:n("string",{defaultValue:"fill"}),thumb:n(t),info:n("string"),link:n("string"),linkTarget:n("string"),video:n("string"),bgColor:n("string"),bgv_mp4:n("string"),bgv_ogg:n("string"),bgv_webm:n("string"),bgv_fillmode:n("string",{defaultValue:"fill"}),bgv_loop:n("boolean",{defaultValue:!0}),bgv_mute:n("boolean",{defaultValue:!0}),bgv_autopause:n("boolean",{defaultValue:!1}),cssId:n("string"),cssClass:n("string"),bgAlt:n("string"),layers:f("MSPanel.Layer",{key:"layer_ids"})}),MSPanel.Layer=Ember.Model.extend({id:n("number"),name:n("string"),isLocked:n("boolean",{defaultValue:!1}),isHided:n("boolean",{defaultValue:!1}),isSoloed:n("boolean",{defaultValue:!1}),slide:r("MSPanel.Slide",{key:"slide"}),styleModel:r("MSPanel.Style",{key:"styleModel",embedded:!1}),showEffect:r("MSPanel.Effect",{key:"showEffect",embedded:!1}),showTransform:n("string",{defaultValue:""}),showOrigin:n("string",{defaultValue:""}),showFade:n("boolean",{defaultValue:!0}),hideEffect:r("MSPanel.Effect",{key:"hideEffect",embedded:!1}),hideTransform:n("string",{defaultValue:""}),hideOrigin:n("string",{defaultValue:""}),hideFade:n("boolean",{defaultValue:!0}),imgThumb:n(t),stageOffsetX:n("number",{defaultValue:0}),stageOffsetY:n("number",{defaultValue:0}),order:n("number"),type:n("string"),cssClass:n("string"),cssId:n("string"),title:n("string"),rel:n("string"),content:n("string",{defaultValue:"Lorem Ipsum"}),img:n(t),imgAlt:n("string"),video:n("string",{defaultValue:"http://player.vimeo.com/video/11721242"}),align:n("string",{defaultValue:"top"}),useAction:n("boolean",{defaultValue:!1}),action:n("string"),toSlide:n("number"),link:n("string"),linkTarget:n("string"),offsetX:n("number",{defaultValue:0}),offsetY:n("number",{defaultValue:0}),width:n("number"),height:n("number"),resize:n("boolean",{defaultValue:!0}),fixed:n("boolean",{defaultValue:!1}),widthlimit:n("number",{defaultValue:"0"}),origin:n("string",{defaultValue:"tl"}),stayHover:n("boolean",{defaultValue:!0}),className:n("string"),parallax:n("string"),showDuration:n("number",{defaultValue:1}),showDelay:n("number",{defaultValue:0}),showEase:n("string",{defaultValue:"easeOutQuint"}),showEffFunc:n("string"),useHide:n("boolean",{defaultValue:!1}),hideDuration:n("number",{defaultValue:1}),hideDelay:n("number",{defaultValue:1}),hideEase:n("string",{defaultValue:"easeOutQuint"}),hideEffFunc:n("string"),btnClass:n("string",{defaultValue:"ms-default-btn"})}),MSPanel.Style=Ember.Model.extend({id:n("number"),name:n("string"),type:n("string"),className:n("string"),backgroundColor:n("string"),paddingTop:n("number"),paddingRight:n("number"),paddingBottom:n("number"),paddingLeft:n("number"),borderTop:n("number"),borderRight:n("number"),borderBottom:n("number"),borderLeft:n("number"),borderColor:n("string"),borderRadius:n("number"),borderStyle:n("string"),fontFamily:n("string"),fontWeight:n("string",{defaultValue:"normal"}),fontSize:n("number"),textAlign:n("string"),letterSpacing:n("number"),lineHeight:n("string",{defaultValue:"normal"}),whiteSpace:n("string"),color:n("string"),custom:n("string")}),MSPanel.PresetStyle=MSPanel.Style.extend({}),MSPanel.Effect=Ember.Model.extend({id:n("number"),name:n("string"),type:n("string"),fade:n("boolean",{defaultValue:!0}),translateX:n("number"),translateY:n("number"),translateZ:n("number"),scaleX:n("number"),scaleY:n("number"),rotate:n("number"),rotateX:n("number"),rotateY:n("number"),rotateZ:n("number"),skewX:n("number"),skewY:n("number"),originX:n("number"),originY:n("number"),originZ:n("number")}),MSPanel.PresetEffect=MSPanel.Effect.extend({}),MSPanel.Control=Ember.Model.extend({id:n("number"),label:n("string"),name:n("string"),autoHide:n("boolean",{defaultValue:!0}),overVideo:n("boolean",{defaultValue:!0}),cssClass:n("string"),cssId:n("string"),margin:n("number"),dir:n("string"),color:n("string"),radius:n("number"),stroke:n("number"),speed:n("number"),space:n("number"),type:n("string"),width:n("number"),height:n("number"),align:n("string"),inset:n("boolean"),size:n("number"),hideUnder:n("number"),fillMode:n("string")}),MSPanel.Callback=Ember.Model.extend({id:n("number"),label:n("string"),name:n("string"),content:n("string",{defaultValue:"function(event){\n var api = event.target;\n}"})}),MSPanel.ButtonStyle=Ember.Model.extend({id:n("number"),className:n("string"),normal:n("string"),hover:n("string"),active:n("string")}),i=function(n){var t=B64.decode(n);return t.slice(0,t.lastIndexOf("}")+1)},window.__MSP_PRESET_BUTTON=null,MSPanel.data=__MSP_DATA?JSON.parse(i(__MSP_DATA)):{meta:{}},MSPanel.PSData=__MSP_PRESET_STYLE?JSON.parse(i(__MSP_PRESET_STYLE)):{meta:{}},MSPanel.PEData=__MSP_PRESET_EFFECT?JSON.parse(i(__MSP_PRESET_EFFECT)):{meta:{}},MSPanel.PBData=__MSP_PRESET_BUTTON?JSON.parse(i(__MSP_PRESET_BUTTON)):{meta:{}},MSPanel.Settings.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.Slide.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.Layer.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.Style.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.Effect.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.Control.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.Callback.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.data}),MSPanel.PresetStyle.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.PSData}),MSPanel.PresetEffect.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.PEData}),MSPanel.ButtonStyle.adapter=Ember.OfflineAdapter.create({applicationData:MSPanel.PBData})}(),MSPanel.SliderTemplates=[{name:"Custom Template",value:"custom",className:"",img:__MSP_PATH+"images/templates/custom.gif",controls:null},{name:"3D Flow Carousel",value:"3d-flow-carousel",className:"ms-caro3d-template",img:__MSP_PATH+"images/templates/3d-flow-carousel.png",settings:{space:0,loop:!0,trView:"flow",layout:"partialview",dir:"h",wheel:!1},controls:null},{name:"3D Wave Carousel",value:"3d-wave-carousel",className:"ms-caro3d-template",img:__MSP_PATH+"images/templates/3d-wave-carousel.png",settings:{space:0,loop:!0,trView:"flow",layout:"partialview",dir:"h",wheel:!1},controls:null},{name:"Image Gallery with Thumbs",value:"image-gallery",className:"ms-gallery-template",img:__MSP_PATH+"images/templates/image-gallery.png",settings:{space:0,trView:"basic",skin:"ms-skin-black-2 round-skin"},controls:null,disableControls:!0},{name:"Slider with Bottom Aligned Thumbs",value:"slider-horizontal-thumbs",className:"ms-thumbs-template",img:__MSP_PATH+"images/templates/slider-bottom-thumbs.png",settings:{trView:"scale",space:0},controls:{arrows:{},scrollbar:{dir:"h"},thumblist:{autohide:!1,dir:"h",arrows:!1,align:"bottom",width:127,height:137,margin:5,space:5}}},{name:"Slider with Top Aligned Thumbs",value:"slider-top-thumbs",className:"ms-thumbs-template",img:__MSP_PATH+"images/templates/slider-top-thumbs.png",settings:{trView:"scale",space:0},controls:{arrows:{},scrollbar:{dir:"h"},thumblist:{autohide:!1,dir:"h",arrows:!1,align:"top",width:127,height:137,margin:5,space:5}}},{name:"Slider with Right Aligned Thumbs",value:"slider-vertical-thumbs",className:"ms-thumbs-template",img:__MSP_PATH+"images/templates/slider-right-thumbs.png",settings:null,controls:{arrows:{},scrollbar:{dir:"v"},thumblist:{autohide:!1,dir:"v",arrows:!1,align:"right",width:127,height:137,margin:5,space:5}}},{name:"Slider with Left Aligned Thumbs",value:"slider-left-thumbs",className:"ms-thumbs-template",img:__MSP_PATH+"images/templates/slider-left-thumbs.png",settings:null,controls:{arrows:{},scrollbar:{dir:"v"},thumblist:{autohide:!1,dir:"v",arrows:!1,align:"left",width:127,height:137,margin:5,space:5}}},{name:"Slider with Horizontal Tabs",value:"slider-horizontal-tabs",className:"ms-tabs-template",img:__MSP_PATH+"images/templates/slider-horizontal-tabs.png",settings:null,controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},thumblist:{autohide:!1,dir:"h",type:"tabs",width:240,height:120,align:"bottom",space:0,margin:-12,hideUnder:400}}},{name:"Slider with Vertical Tabs",value:"slider-vertical-tabs",className:"ms-tabs-template",img:__MSP_PATH+"images/templates/slider-vertical-tabs.png",settings:null,controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},thumblist:{autohide:!1,dir:"v",type:"tabs",align:"right",margin:-12,space:0,width:229,height:100,hideUnder:550}}},{name:"Partial View Slider V1",value:"partial-1",className:"ms-partialview-template",img:__MSP_PATH+"images/templates/partial-1.png",settings:{space:10,loop:!0,trView:"partialWave",layout:"partialview",dir:"h"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Partial View Slider V2",value:"partial-2",className:"ms-partialview-template",img:__MSP_PATH+"images/templates/partial-2.png",settings:{space:10,loop:!0,trView:"fadeWave",layout:"partialview",dir:"h"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Partial View Slider V3",value:"partial-3",className:"ms-partialview-template",img:__MSP_PATH+"images/templates/partial-3.png",settings:{space:10,loop:!0,trView:"fadeFlow",layout:"partialview",dir:"h"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Slider in Display",value:"display",className:"ms-display-template",img:__MSP_PATH+"images/templates/display.png",settings:{width:507,height:286,speed:20,space:2,trView:"flow",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Flat Display",value:"flat-display",className:"ms-display-template",img:__MSP_PATH+"images/templates/flat-display.png",settings:{width:507,height:286,speed:20,space:2,trView:"flow",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Laptop",value:"laptop",className:"ms-laptop-template",img:__MSP_PATH+"images/templates/laptop.png",settings:{width:492,height:309,speed:20,space:2,trView:"mask",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Flat Laptop",value:"flat-laptop",className:"ms-laptop-template",img:__MSP_PATH+"images/templates/flat-laptop.png",settings:{width:492,height:309,speed:20,space:2,trView:"mask",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Tablet",value:"tablet",className:"ms-tablet-template",img:__MSP_PATH+"images/templates/tablet.png",settings:{width:400,height:534,speed:20,space:2,trView:"wave",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Flat Tablet",value:"flat-tablet",className:"ms-tablet-template",img:__MSP_PATH+"images/templates/flat-tablet.png",settings:{width:400,height:534,speed:20,space:2,trView:"basic",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Landscape Tablet",value:"tablet-land",className:"ms-tablet-template ms-tablet-land",img:__MSP_PATH+"images/templates/tablet-land.png",settings:{width:632,height:476,speed:20,space:2,trView:"mask",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Flat Landscape Tablet",value:"flat-tablet-land",className:"ms-tablet-template ms-tablet-land",img:__MSP_PATH+"images/templates/flat-tablet-land.png",settings:{width:632,height:476,speed:20,space:2,trView:"mask",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Smart Phone",value:"phone",className:"ms-phone-template",img:__MSP_PATH+"images/templates/phone.png",settings:{width:258,height:456,speed:20,space:2,trView:"wave",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Flat Smart Phone",value:"flat-phone",className:"ms-phone-template",img:__MSP_PATH+"images/templates/flat-phone.png",settings:{width:258,height:456,speed:20,space:2,trView:"basic",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Landscape Smart Phone",value:"phone-land",className:"ms-phone-template ms-phone-land",img:__MSP_PATH+"images/templates/phone-land.png",settings:{width:456,height:258,speed:20,space:2,trView:"mask",dir:"h",layout:"boxed"},controls:{arrows:{},circletimer:{color:"#FFFFFF",stroke:9},bullets:{autohide:!1}},disableControls:!0},{name:"Slider in Flat Landscape Smart Phone",value:"flat-phone-land",className:"ms-phone-template ms-phone-land",img:__MSP_PATH+"images/templates/flat-phone-land.png",settings:{width:456,height:258,speed:20,space:2,trView:"mask",dir:"h",layout:"boxed"},controls:{arrows:{},bullets:{autohide:!1}},disableControls:!0},{name:"Vertical Slider",value:"vertical-slider",className:"ms-vertical-template",img:__MSP_PATH+"images/templates/vertical-slider.png",settings:{space:5,dir:"v"},controls:{arrows:{},scrollbar:{dir:"v"},circletimer:{color:"#FFFFFF",stroke:9},thumblist:{autohide:!1,dir:"v",space:5,margin:5,align:"right"}}},{name:"Staff Carousel V1",value:"staff-1",className:"ms-staff-carousel",img:__MSP_PATH+"images/templates/staff-1.png",settings:{loop:!0,width:240,height:240,speed:20,trView:"focus",layout:"partialview",space:0,wheel:!0,dir:"h"},controls:{arrows:{},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Staff Carousel V2",value:"staff-2",className:"ms-staff-carousel",img:__MSP_PATH+"images/templates/staff-2.png",settings:{loop:!0,width:240,height:240,speed:20,trView:"fadeBasic",layout:"partialview",space:0,dir:"h"},controls:{arrows:{},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Staff Carousel V3",value:"staff-3",className:"ms-staff-carousel ms-round",img:__MSP_PATH+"images/templates/staff-3.png",settings:{loop:!0,width:240,height:240,speed:20,trView:"focus",layout:"partialview",space:0,space:35,dir:"h"},controls:{arrows:{},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Staff Carousel V4",value:"staff-4",className:"ms-staff-carousel ms-round",img:__MSP_PATH+"images/templates/staff-4.png",settings:{loop:!0,width:240,height:240,speed:20,trView:"fadeBasic",layout:"partialview",space:0,space:45,dir:"h"},controls:{arrows:{},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Staff Carousel V5",value:"staff-5",className:"ms-staff-carousel",img:__MSP_PATH+"images/templates/staff-5.png",settings:{loop:!0,width:240,height:240,speed:20,trView:"wave",layout:"partialview",space:0,wheel:!0,dir:"h"},controls:{arrows:{},slideinfo:{autohide:!1,align:"bottom",size:160}}},{name:"Staff Carousel V6",value:"staff-6",className:"ms-staff-carousel",img:__MSP_PATH+"images/templates/staff-6.png",settings:{loop:!0,width:240,height:240,speed:20,trView:"flow",layout:"partialview",space:0,wheel:!0,dir:"h"},controls:{arrows:{},slideinfo:{autohide:!1,align:"bottom",size:160}}},],MSPanel.SlideFrame=Ember.View.extend({classNames:["msp-slideframe"],classNameBindings:["selected:active"],selected:!1,thumb_src:"",showbtnclass:"msp-ico msp-ico-whitehide",template:Ember.Handlebars.compile('<div class="msp-img-cont">{{#if view.hasImg}}<div class="msp-imgselect-preview" {{bind-attr style=view.preview}})"><\/div>{{/if}}<\/div><span class="msp-frame-slideorder">#{{view.order}}<\/span><div class="msp-framehandle"><ul><li><a title="'+__MSP_LAN.ui_001+'" href="#" {{action "hideswitch" target=view}}><span {{bind-attr class=view.showbtnclass}}><\/span><\/a><\/li><li><a title="'+__MSP_LAN.ui_002+'" href="#" {{action "duplicate" target=view}}><span class="msp-ico msp-ico-whiteduplicate"><\/span><\/a><\/li><li><a title="'+__MSP_LAN.ui_003+'" href="#" {{action "remove" target=view}}><span class="msp-ico msp-ico-whiteremove"><\/span><\/a><\/li><\/ul><\/div>'),click:function(){this.get("controller").send("select",this.get("slide"))},onValueChanged:function(){var n=!Ember.isEmpty(this.get("slide.bg"));this.beginPropertyChanges(),this.set("hasImg",n),n&&this.set("preview","background-image:url("+this.get("slide.bgThumb")+");"),this.endPropertyChanges()}.observes("slide.bg").on("didInsertElement"),onSelect:function(){var n=this.get("slide");this.set("selected",n===this.get("controller.currentSlide"))}.observes("controller.currentSlide").on("init"),hideChange:function(){this.get("slide.ishide")?this.set("showbtnclass","msp-ico msp-ico-whitehide msp-ico-whiteshow"):this.set("showbtnclass","msp-ico msp-ico-whitehide")}.observes("slide.ishide").on("init"),order:function(){return this.get("slide.order")+1}.property("slide.order"),actions:{duplicate:function(){this.get("controller").duplicateSlide(this.get("slide"))},hideswitch:function(){this.set("slide.ishide",!this.get("slide.ishide"))},remove:function(){confirm(__MSP_LAN.ui_004)&&this.get("controller").removeSlide(this.get("slide"))}}}),MSPanel.SlideList=Ember.View.extend({tagName:"ul",classNames:["msp-slides"],template:Ember.Handlebars.compile('{{#each item in controller}}<li class="msp-slideframe-item" {{bind-attr data-id=item.id}}>{{view MSPanel.SlideFrame slide=item}}<\/li>{{/each}}<li class="msp-addslide-cont"><div class="msp-addslide" {{action "newSlide"}}><span class="msp-ico msp-ico-grayaddlarge"><\/span><span class="msp-addslide-label">Add Slide<\/span><\/div><\/li>'),didInsertElement:function(){var n=this;this.$().sortable({placeholder:"msp-frames-srtplaceholder",items:">li:not(.msp-addslide-cont)",delay:100,update:function(){n.updateSort()},create:function(){n.updateSort()}})},updateSort:function(){var n={};$(".msp-slideframe-item").each(function(t){n[$(this).data("id")]=t}),this.$().sortable("cancel"),this.get("controller").updateSlidesSort(n)}}),MSPanel.ImgSelect=Ember.View.extend({classNames:["msp-imgselect"],value:"",hasImg:!1,frame:null,template:Ember.Handlebars.compile('<div class="msp-img-cont">{{#if view.hasImg}}<div class="msp-imgselect-preview" {{bind-attr style=view.preview}})"><\/div>{{/if}}<\/div>{{#if view.hasImg}}<button {{action removeImg target="view"}} class="msp-img-btn"><span class="msp-ico msp-ico-grayremove"><\/span><\/button>{{else}}<button {{action addImg target="view"}} class="msp-img-btn"><span class="msp-ico msp-ico-grayadd"><\/span><\/button>{{/if}}'),willDestroyElement:function(){var n=this.get("frame");n&&(n.detach(),n.remove(),n=null,this.set("frame",null))},onValueChanged:function(){this.beginPropertyChanges(),this.set("hasImg",!Ember.isEmpty(this.get("value"))),this.set("preview","background-image:url("+this.get("thumb")+");"),this.endPropertyChanges()}.observes("value").on("didInsertElement"),actions:{removeImg:function(){this.beginPropertyChanges(),this.set("value",undefined),this.set("thumb",undefined),this.endPropertyChanges()},addImg:function(){var t,n;if(typeof wp!="undefined"){if(t=this,n=this.get("frame"),n){n.open();return}n=wp.media.frames.frame=wp.media({title:"Select Image",multiple:!1,frame:"select",library:{type:"image"},button:{text:"Add Image"}});n.on("select",function(){var i=n.state().get("selection").first().toJSON();t.set("thumb",(i.sizes.thumbnail||i.sizes.full).url),t.set("value",i.url)});n.open(),this.set("frame",n)}}}}),MSPanel.Select=Ember.Select.extend({tagName:"div",classNames:["msp-ddlist"],layout:Ember.Handlebars.compile("<select>{{yield}}<\/select>"),value:null,width:100,didInsertElement:function(){var n=this;this.$("select").on("change",function(){var t=n.$("select option:selected");n.set("value",t.attr("value"))}).width(this.get("width")),this.onValueChanged()},onValueChanged:function(){Ember.isEmpty(this.get("value"))||this.$("select").val(this.get("value"))}.observes("value")}),MSPanel.URLTarget=MSPanel.Select.extend({onInit:function(){var n=[{lable:__MSP_LAN.ui_005,value:"_self"},{lable:__MSP_LAN.ui_006,value:"_blank"},{lable:__MSP_LAN.ui_007,value:"_parent"},{lable:__MSP_LAN.ui_008,value:"_top"}];this.set("content",n),this.set("optionValuePath","content.value"),this.set("optionLabelPath","content.lable"),this.set("width",200)}.on("init")}),MSPanel.Fillmode=Ember.View.extend({classNames:["msp-fill-dd"],type:"slide",value:"fill",index:1,template:Ember.Handlebars.compile("<select>{{#each item in view.contents}}<option {{bind-attr value=item.value data-imagesrc=item.img}}>{{item.text}}<\/option>{{/each}}<\/select>"),didInsertElement:function(){var t=this,n=!0;this.$("select").ddslick({width:154,onSelected:function(i){n||t.set("value",i.selectedData.value),n=!1}}),this.onValueChanged()},onValueChanged:function(){Ember.isEmpty(this.get("value"))||this.$(".dd-container").ddslick("select",{index:this.get("valuedic")[this.get("value")]})}.observes("value"),onInit:function(){var n,t;this.get("type")==="slide"?(n=[{value:"fill",text:__MSP_LAN.ui_009,img:__MSP_PATH+"images/fill.png"},{value:"fit",text:__MSP_LAN.ui_010,img:__MSP_PATH+"images/fit.png"},{value:"center",text:__MSP_LAN.ui_011,img:__MSP_PATH+"images/center.png"},{value:"stretch",text:__MSP_LAN.ui_012,img:__MSP_PATH+"images/stretch.png"},{value:"tile",text:__MSP_LAN.ui_013,img:__MSP_PATH+"images/tile.png"}],t={fill:0,fit:1,center:2,stretch:3,tile:4}):this.get("type")==="video"&&(n=[{value:"fill",text:__MSP_LAN.ui_009,img:__MSP_PATH+"images/fill.png"},{value:"fit",text:__MSP_LAN.ui_010,img:__MSP_PATH+"images/fit.png"}],t={fill:0,fit:1,none:2}),this.set("contents",n),this.set("valuedic",t)}.on("init")}),MSPanel.SimpleCodeBlock=Ember.View.extend({classNames:["msp-shortcode-box"],template:Ember.Handlebars.compile('<input type="text" readonly {{bind-attr value=view.value}}>'),width:150,didInsertElement:function(){this.$("input").on("click",function(){$(this).select()}).width(this.get("width"))}}),MSPanel.SettingsView=Ember.View.extend({didInsertElement:function(){this.set("controller.mainView",this)}}),MSPanel.SlidesView=Ember.View.extend({didInsertElement:function(){this.set("controller.mainView",this)}}),MSPanel.StageArea=Ember.View.extend({classNames:["msp-stage-area"],template:Ember.Handlebars.compile('{{view MSPanel.Stage}}{{#if noticeMsg}}<div class="msp-stage-msg"><span class="msp-ico msp-ico-notice"><\/span>{{{noticeMsg}}}<\/div>{{/if}}')}),MSPanel.Stage=Ember.View.extend({classNames:["msp-slide-stage"],attributeBindings:["style"],template:Ember.Handlebars.compile('<div id="stage-bg" class="msp-stage-bg"><\/div>'),resize:function(){var n=this.get("controller.sliderSettings.width"),t=this.get("controller.sliderSettings.height");this.set("width",n),this.set("height",t),this.$().css({width:n,height:t})}.observes("controller.sliderSettings.width","controller.sliderSettings.height").on("didInsertElement"),didInsertElement:function(){var i=this.$("#stage-bg"),n=$("<img/>"),t;n.css("visibelity","hidden").each($.jqLoadFix),t=new MSAligner(this.get("controller.currentSlide.fillMode"),i,n),this.set("bgAligner",t),this.set("bgImg",n),this.onBGChange()},onBGColorChange:function(){var n=this.get("controller.currentSlide.bgColor");Ember.isEmpty(n)?this.$("#stage-bg").css("background-color",""):this.$("#stage-bg").css("background-color",n)}.observes("controller.currentSlide.bgColor"),onBGChange:function(){var i=this.get("bgAligner"),t,n,r;i&&i.reset(),t=this.get("controller.currentSlide.bg"),n=this.get("bgImg"),Ember.isEmpty(t)?n.detach():(r=this,n.appendTo(this.$("#stage-bg")),n.preloadImg(t,function(n){r._onBGLoad(n)}),n.attr("src",t))}.observes("controller.currentSlide.bg"),_onBGLoad:function(n){var t=this.get("bgAligner");t&&(t.init(n.width,n.height),t.align(),this.get("bgImg").css("visibelity",""))},onFillModeChanged:function(){var n=this.get("bgAligner");n.changeType(this.get("controller.currentSlide.fillMode"))}.observes("controller.currentSlide.fillMode"),willDestroyElement:function(){this.set("bgAligner",null)}}),MSPanel.ControlBtn=Ember.View.extend({control:null,tagName:"div",active:!1,classNames:["msp-control-btn"],classNameBindings:["active:msp-blue-btn"],template:Ember.Handlebars.compile('<span class="msp-control-label">{{view.control.label}}<\/span><a href="#" {{action "removeControl" target=view bubbles=false}}><span class="msp-control-removes msp-ico msp-ico-whiteremove"><\/span><\/a>'),didInsertElement:function(){},onActiveChange:function(){this.set("active",this.get("controller.currentControl")===this.get("control")),this.get("active")&&this.get("controller").send("showControlOptions")}.observes("controller.currentControl").on("init"),click:function(){this.get("active")||this.set("controller.currentControl",this.get("control"))},actions:{removeControl:function(){confirm('Are you sure want to remvoe "'+this.get("control.label")+'" control?')&&this.get("controller").send("removeControl",this.get("control"))}}}),MSPanel.MetaBoxComponent=Ember.Component.extend({tagName:"div",classNames:["msp-metabox"],layout:Ember.Handlebars.compile('<div class="msp-metabox-handle"><h3 class="msp-metabox-title">{{title}}<\/h3><div class="msp-metabox-toggle"><\/div><\/div>{{yield}}<div class="clear"> <\/div>')}),Ember.TEMPLATES["components/tabs-panel"]=Ember.Handlebars.compile("{{yield}}"),MSPanel.TabsPanelComponent=Ember.Component.extend({tagName:"div",attributeBindings:["id"],classNames:["msp-metabox msp-metabox-tabs"],didInsertElement:function(){this.$().avertaLiveTabs()}}),MSPanel.SwitchBoxComponent=Ember.Component.extend({classNames:["msp-switchbox"],offlable:"OFF",onlable:"ON",value:!1,layout:Ember.Handlebars.compile('<div class="msp-switch-cont"><span class="msp-switch-off">{{view.offlable}}<\/span><div class="msp-switch-handle"><\/div><span class="msp-switch-on">{{view.onlable}}<\/span><\/div>'),click:function(){var n=this;n.set("value",!n.get("value"))},update:function(){this.get("value")?this.$().addClass("switched"):this.$().removeClass("switched")}.observes("value").on("didInsertElement")}),hiddenEditor=jQuery("#mspHiddenEditor")[0].outerHTML,__tmc_msp_id=0,MSPanel.WPEditor=Ember.View.extend({classNames:["msp-wp-editor"],_id:null,template:null,tab:null,tabs:null,onInit:function(){var n="msp-wpeditor-"+__tmc_msp_id;this.set("_id",n),this.set("template",Ember.Handlebars.compile(WPEditorTemplate(n))),__tmc_msp_id++}.on("init"),didInsertElement:function(){var n=this.get("tabs");if(Ember.isEmpty(n)){this.createEditor();return}$("#"+n).bind("avtTabChange",{that:this},this.refreshEditor)},refreshEditor:function(n,t){var i=n.data.that;i.get("tab")===t&&i.createEditor()},createEditor:function(){var t,i,n,r,u;if(this.get("inited")!==!0&&(this.set("inited",!0),t=this.get("_id"),i=this,window.tinymce&&(n=$.extend({},window.tinyMCEPreInit.mceInit["msp-hidden"]||{}),n.forced_root_block="",n.force_br_newlines=!0,n.force_p_newlines=!1,n.wpautop=!1,tinyMCE.majorVersion=="3"?(n.body_class=n.elements=t,tinymce.init(n),setTimeout(function(){i.initEditor(tinyMCE.getInstanceById(t))},50)):tinyMCE.majorVersion=="4"&&(n.body_class="content post-type-post post-status-auto-draft post-format-standard",n.selector="#"+t,tinymce.init(n),setTimeout(function(){i.initEditor(tinyMCE.get(t))},50)),n.setup=function(){}),r=$.extend({},window.tinyMCEPreInit.qtInit["msp-hidden"]||{}),r.id=t,typeof QTags=="function")){u=quicktags(r),QTags.buttonsInitDone=!1,QTags._buttonsInit(),i.set("qtags",u),switchEditors.go(t,"html");this.$("textarea#"+this.get("_id")).on("change keyup paste",function(){i.set("value",$(this).val())})}},initEditor:function(n){function t(){r.set("internalChange",!0),r.set("value",n.getContent()),r.set("internalChange",!1)}var i=this.get("_id"),u=this.get("value"),r=this;this.$(".wp-editor-wrap").on("mousedown",function(){wpActiveEditor=i});if(tinyMCE.majorVersion=="3")n.onChange.add(t),n.onKeyUp.add(t);else if(tinyMCE.majorVersion=="4"){n.on("change",t);n.on("keyup",t)}this.$().click(t),setTimeout(function(){switchEditors.go(i,"html"),switchEditors.go(i,"tmce")},100),this.set("mce",n),this.onValueChanged()},onValueChanged:function(){var n,t;if(this.get("inited")){if(n=this.get("value"),this.$("textarea#"+this.get("_id")).val(n),this.get("internalChange")){this.set("internalChange",!1);return}t=this.get("mce"),Ember.isEmpty(t)||n==null?n==null&&t.setContent(" "):t.setContent(n)}}.observes("value"),willDestroyElement:function(){var n,t;this.get("inited")&&(window.tinymce&&tinymce.remove(this.get("_id")),n=this.get("qtags"),n&&($(n.toolbar).remove(),n.toolbar=null,n=null,QTags.instances[this.get("_id")]&&delete QTags.instances[this.get("_id")],this.$("textarea#"+this.get("_id")).remove()),t=this.get("tabs"),Ember.isEmpty(t)||$("#"+t).unbind("avtTabChange",this.refreshEditor))}}),jQuery.ui&&jQuery.ui.spinner&&(jQuery.ui.spinner.prototype._events.mousewheel=function(n,t){if(t&&this.element.is(":focus")){if(!this.spinning&&!this._start(n))return!1;this._spin((t>0?1:-1)*this.options.step,n),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(n)},100),n.preventDefault()}}),MSPanel.NumberInputView=Ember.View.extend({step:1,min:0,tagName:"input",attributeBindings:["type"],lastValue:null,type:"text",didInsertElement:function(){var n=this,i=this.$(),t=function(){var t=i.spinner("value");n.set("internalChange",!0),isNaN(t)||t==null?n.set("value",undefined):n.set("value",parseFloat(t))};i.on("change",t).spinner({step:this.get("step"),numberFormat:"n",min:this.get("min"),max:this.get("max"),spin:t,stop:t}).spinner("value",this.get("value"))},onValueChanged:function(){if(this.get("internalChange")){this.set("internalChange",!1);return}this.$().spinner("value",this.get("value"))}.observes("value")}),Ember.Handlebars.helper("number-input",MSPanel.NumberInputView),MSPanel.ColorPickerComponent=Ember.Component.extend({tagName:"input",classNames:"msp-color-picker",value:null,didInsertElement:function(){var n=this;this.$().spectrum({color:this.get("value"),allowEmpty:!0,showInput:!0,showAlpha:!0,clickoutFiresChange:!0,preferredFormat:"hex6",change:function(t){t===null?n.set("value",null):n.set("value",t.toString())}})},willDestroyElement:function(){this.$().spectrum("destroy")},onValueChanged:function(){this.$().spectrum("set",this.get("value"))}.observes("value")}),MSPanel.DropdwonListComponent=Ember.Component.extend({tagName:"div",classNames:["msp-ddlist"],layout:Ember.Handlebars.compile("<select>{{yield}}<\/select>"),value:null,width:100,didInsertElement:function(){var n=this;this.$("select").on("change",function(){var t=n.$("select option:selected");n.set("value",t.attr("value"))}).width(this.get("width")),this.onValueChanged()},onValueChanged:function(){Ember.isEmpty(this.get("value"))||this.$("select").val(this.get("value"))}.observes("value")}),MSPanel.CodeMirrorComponent=Ember.Component.extend({classNames:["msp-codemirror"],width:250,height:200,mode:"css",tab:null,tabs:null,layout:Ember.Handlebars.compile("<textarea>{{yield}}<\/textarea>"),didInsertElement:function(){var t,n,i,r;this.$().width(this.get("width")).height(this.get("height")),t=this,n=CodeMirror.fromTextArea(this.$(">textarea")[0],{lineNumbers:!0,mode:this.get("mode")});n.on("change",function(){t.set("internalChange",!0),t.set("value",n.getValue())});this.set("editor",n),i=this.get("value"),Ember.isEmpty(i)||n.setValue(i),r=this.get("tabs"),Ember.isEmpty(r)||$("#"+r).bind("avtTabChange",{that:this},this.refreshEditor)},onValueChanged:function(){if(this.get("internalChange")===!0){this.set("internalChange",!1);return}this.get("editor").setValue(this.get("value")),this.set("internalChange",!1)}.observes("value"),refreshEditor:function(n,t){var i=n.data.that;i.get("tab")===t&&i.get("editor").refresh()},willDestroyElement:function(){var t=this.get("tabs"),n;Ember.isEmpty(t)||$("#"+t).unbind("avtTabChange",this.refreshEditor),n=this.get("editor"),n.toTextArea(),n=null,this.set("editor",null)}}),MSPanel.pushData=null,MSPanel.ApplicationController=Ember.Controller.extend({sliderId:MSPanel.SliderID,isSending:!1,statusMsg:"",hasError:!1,onInit:function(){MSPanel.Settings.find(),MSPanel.Slide.find(),MSPanel.Control.find(),MSPanel.Callback.find(),this.set("disableControls",MSPanel.Settings.find(0).get("disableControls"));var n=this;MSPanel.pushData=function(){n.prepareData()},__MSP_TYPE==="wc-product"&&__MSP_POST==null&&__WC_INSTALL_URL!=null&&(this.set("hasError",!0),this.set("errorTemplate","wooc-error"),this.set("wooLink",__WC_INSTALL_URL)),this.generateButtonStyles(),this.set("shortCode","[masterslider id="+this.get("sliderId")+"]"),this.set("phpFunction","<?php masterslider("+this.get("sliderId")+"); ?>"),jQuery("#panelLoading").remove()}.on("init"),prepareData:function(){var n={},i="",t;MSPanel.Style.find().forEach(function(t){var i=t.get("fontFamily"),r=t.get("fontWeight");Ember.isEmpty(i)||(n[i]||(n[i]=[]),r==="normal"&&(r="regular"),Ember.isEmpty(r)||n[i].indexOf(r)!==-1||n[i].push(r))});for(t in n)i+=t.replace(/\s/,"+")+":"+n[t].join(",")+"|";MSPanel.Settings.find(1).set("usedFonts",i.slice(0,-1)),this.saveRecords(MSPanel.Settings.find()),this.saveRecords(MSPanel.Slide.find()),this.saveRecords(MSPanel.Control.find()),this.saveRecords(MSPanel.Callback.find())},generateButtonStyles:function(){var i=MSPanel.ButtonStyle.find(),n="",t=$("#msp-buttons");i.forEach(function(t){n+="."+t.get("className")+" {"+t.get("normal")+"}\n."+t.get("className")+":hover {"+t.get("hover")+"}\n."+t.get("className")+":active {"+t.get("active")+"}\n"}),t.length===0?t=$('<style id="msp-buttons"><\/style>').text(n).appendTo($("head")):t.text(n)},actions:{saveAll:function(){this.prepareData(),this.sendData()},showPreview:function(n){window.lunchMastersliderPreview&&lunchMastersliderPreview(n)}},saveRecords:function(n){n.forEach(function(n){n.save()})},sendData:function(){this.set("statusMsg",__MSP_LAN.ap_001),this.set("isSending",!0);var n=this;jQuery.post(__MS.ajax_url,{action:"msp_panel_handler",nonce:jQuery("#msp-main-wrapper").data("nonce"),msp_data:B64.encode(JSON.stringify(MSPanel.data)),preset_style:B64.encode(JSON.stringify(MSPanel.PSData)),preset_effect:B64.encode(JSON.stringify(MSPanel.PEData)),buttons:B64.encode(JSON.stringify(MSPanel.PBData)),slider_id:MSPanel.SliderID},function(t){n.set("statusMsg",t.message),n.set("isSending",!1)})}}),MSPanel.SettingsController=Ember.ObjectController.extend({customSlider:window.__MSP_TYPE&&window.__MSP_TYPE==="custom",templateSlider:window.__MSP_TYPE&&(window.__MSP_TYPE==="flickr"||window.__MSP_TYPE==="post"||window.__MSP_TYPE==="wc-product"||window.__MSP_TYPE==="facebook"),sliderSkins:__MSP_SKINS,needs:["application","controls"],msTemplateName:null,msTemplateImg:null,draftMSTemplate:null,templates:MSPanel.SliderTemplates,showAutoHeight:!1,showNearbyNum:!1,showWrapperWidth:!1,preloadMethod:null,setup:function(){var n=this.get("preload");n==="all"||n==="-1"?this.set("preloadMethod",n):this.set("preloadMethod","nearby"),this.set("draftMSTemplate",this.get("msTemplate")),this.updateTemplate(!0)},sliderLayoutChanged:function(){var n=this.get("layout");n==="fullscreen"||n==="autofill"?(this.set("showAutoHeight",!1),this.set("autoHeight",!1)):this.set("showAutoHeight",!0),this.set("showWrapperWidth",n==="boxed"||n==="partialview"),this.set("showFSMargin",n==="fullscreen")}.observes("layout").on("setup"),preloadSetup:function(){var t=this.get("preloadMethod"),n;t==="nearby"?(this.set("showNearbyNum",!0),n=this.get("preload"),(n==="all"||n==="-1")&&this.set("preload","0")):(this.set("showNearbyNum",!1),this.set("preload",t))}.observes("preloadMethod").on("setup"),updateTemplate:function(n){var t,s=this.get("msTemplate"),r,f,e,i,u,o;if(this.get("templates").forEach(function(n){if(n.value===s){t=n;return}}),t){if(this.set("msTemplateName",t.name),this.set("msTemplateImg",t.img),this.set("msTemplateClass",t.className),this.set("controllers.application.disableControls",t.disableControls),this.set("disableControls",t.disableControls),!n){for(r=this.get("controllers.controls"),e=MSPanel.Control.find();e.get("firstObject");)i=e.get("firstObject"),r.findControlObj(i.get("name")).used=!1,i.deleteRecord();for(u in t.controls)f=r.findControlObj(u),i=MSPanel.Control.create($.extend(!0,r.getDefaultValues(u),t.controls[u])),i.set("label",f.label),f.used=!0,i.save();for(o in t.settings)this.set(o,t.settings[o])}}else this.set("draftMSTemplate","custom"),this.updateTemplate()},actions:{openTemplates:function(){var n=MSPanel.TemplatesView.create({controller:this});this.get("mainView").createChildView(n),this.set("templatesView",n),n.appendTo(MSPanel.rootElement)},closeTemplates:function(){this.get("templatesView").destroy(),this.set("draftMSTemplate",this.get("msTemplate"))},saveTemplate:function(){if(this.get("draftMSTemplate")===this.get("msTemplate")){this.send("closeTemplates");return}confirm(__MSP_LAN.tv_002)&&(this.set("msTemplate",this.get("draftMSTemplate")),this.send("closeTemplates"),this.updateTemplate())}}}),MSPanel.SlidesController=Ember.ArrayController.extend({customSlider:window.__MSP_TYPE&&window.__MSP_TYPE==="custom",_order:-1,sortProperties:["order"],mainView:null,currentSlide:null,setup:function(){if(this.get("length")===0)this.send("newSlide");else{var n=this.get("firstObject");this.set("currentSlide",n)}Ember.isEmpty(this.get("sliderSettings.type"))&&this.set("sliderSettings.type",__MSP_TYPE),this.set("sliderSettings.sliderId",MSPanel.SliderID),this.updateOrder()},duplicateSlide:function(n){var i=n.toJSON(),t;delete i.id,delete i.layers,t=MSPanel.Slide.create(i),t.set("order",n.get("order")+1),this.forEach(function(n){var i=n.get("order"),r=t.get("order");i>=r&&n!==t&&n.set("order",i+1)}),t.save(),this.updateOrder()},updateSlidesSort:function(n){this.beginPropertyChanges(),this.forEach(function(t){t.set("order",n[t.get("id")])},this),this.endPropertyChanges(),this.set("_order",this.get("lastObject.order"))},updateOrder:function(){var n=0;this.forEach(function(t){t.set("order",n++)}),this.set("_order",n-1)},removeSlide:function(n){n.deleteRecord(),this.get("length")===0?this.send("newSlide"):this.send("select",this.get("firstObject")),this.updateOrder()},actions:{newSlide:function(){var n=MSPanel.Slide.create({order:this.get("_order")+1});this.set("currentSlide",n),this.set("_order",this.get("_order")+1),n.save()},select:function(n){n!==this.get("currentSlide")&&this.set("currentSlide",n)}}}),MSPanel.ControlsController=Ember.ArrayController.extend({needs:"application",controls:[{used:!1,label:__MSP_LAN.cc_001,value:"arrows"},{used:!1,label:__MSP_LAN.cc_002,value:"timebar"},{used:!1,label:__MSP_LAN.cc_003,value:"bullets"},{used:!1,label:__MSP_LAN.cc_004,value:"circletimer"},{used:!1,label:__MSP_LAN.cc_005,value:"scrollbar"},{used:!1,label:__MSP_LAN.cc_006,value:"slideinfo"},{used:!1,label:__MSP_LAN.cc_007,value:"thumblist"}],selectedControl:null,availableControls:[],noMore:!1,currentControl:null,setup:function(){var n=this;this.forEach(function(t){n.findControlObj(t.get("name")).used=!0}),this.set("availableControls",this.findAvailableControls())},actions:{addControl:function(){var t=this.get("selectedControl"),i=this.findControlObj(t),n;n=MSPanel.Control.create(this.getDefaultValues(t)),n.set("label",i.label),i.used=!0,this.set("availableControls",this.findAvailableControls()),n.save(),this.set("currentControl",n)},removeControl:function(n){this.findControlObj(n.get("name")).used=!1,this.set("availableControls",this.findAvailableControls()),n.deleteRecord(),this.set("currentControl",this.get("firstObject")),this.send("showControlOptions")},showControlOptions:function(){var n=this.get("currentControl");Ember.isEmpty(n)?this.set("controlOptions","empty-template"):this.set("controlOptions",n.get("name")+"-options")}},findControlObj:function(n){for(var i=this.get("controls"),t=0,r=i.length;t!==r;t++)if(i[t].value===n)return i[t];return null},findAvailableControls:function(){for(var n=[],i=this.get("controls"),t=0,r=i.length;t!==r;t++)i[t].used||n.push(i[t]);return this.set("noMore",n.length===0),this.set("selectedControl",n[0]?n[0].value:null),n},getDefaultValues:function(n){var t={name:n};t.inset=!(n==="slideinfo"||n==="thumblist");switch(n){case"timebar":t.align="bottom",t.color="#FFFFFF",t.autoHide=!1,t.width=4;break;case"bullets":t.align="bottom",t.dir="h",t.margin=10;break;case"circletimer":t.color="#A2A2A2",t.stroke=10,t.radius=4,t.autoHide=!1;break;case"scrollbar":t.align="top",t.dir="h",t.color="#3D3D3D",t.margin=10,t.autoHide=!1,t.width=4;break;case"slideinfo":t.align="bottom",t.margin=10,t.autoHide=!1;break;case"thumblist":t.align="bottom",t.space=5,t.width=100,t.height=80,t.margin=10,t.fillMode="fill",t.autoHide=!1}return t}}),MSPanel.CallbacksController=Ember.ArrayController.extend({callbacks:[{used:!1,label:__MSP_LAN.cb_011,value:"INIT"},{used:!1,label:__MSP_LAN.cb_001,value:"CHANGE_START"},{used:!1,label:__MSP_LAN.cb_002,value:"CHANGE_END"},{used:!1,label:__MSP_LAN.cb_003,value:"WAITING"},{used:!1,label:__MSP_LAN.cb_004,value:"RESIZE"},{used:!1,label:__MSP_LAN.cb_005,value:"VIDEO_PLAY"},{used:!1,label:__MSP_LAN.cb_006,value:"VIDEO_CLOSE"},{used:!1,label:__MSP_LAN.cb_007,value:"SWIPE_START"},{used:!1,label:__MSP_LAN.cb_008,value:"SWIPE_MOVE"},{used:!1,label:__MSP_LAN.cb_009,value:"SWIPE_END"}],availableCallbacks:[],noMore:!1,selectedCallback:null,setup:function(){var n=this;this.forEach(function(t){n.findCallbackObj(t.get("name")).used=!0}),this.set("availableCallbacks",this.findAvailableCallbacks())},actions:{addCallback:function(){var i=this.get("selectedCallback"),n=this.findCallbackObj(i),t;t=MSPanel.Callback.create({name:n.value,label:n.label}),n.used=!0,this.set("availableCallbacks",this.findAvailableCallbacks()),t.save()},removeCallback:function(n){confirm(__MSP_LAN.cb_010.jfmt(n.get("label")))&&(this.findCallbackObj(n.get("name")).used=!1,this.set("availableCallbacks",this.findAvailableCallbacks()),n.deleteRecord())}},findCallbackObj:function(n){for(var i=this.get("callbacks"),t=0,r=i.length;t!==r;t++)if(i[t].value===n)return i[t];return null},findAvailableCallbacks:function(){for(var n=[],i=this.get("callbacks"),t=0,r=i.length;t!==r;t++)i[t].used||n.push(i[t]);return this.set("noMore",n.length===0),this.set("selectedCallback",n[0]?n[0].value:null),n}})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/views/slider-panel/js/msp.required.js CHANGED
@@ -1,945 +1,15 @@
1
- //js\libs\averta.base.js
2
-
3
- /*!
4
- * @overview Averta JavaScript Libraries
5
- * @copyright Copyright 2014 Averta Ltd.
6
- * http://www.averta.net
7
- */
8
- window.averta = {};
9
-
10
- ;(function($){
11
-
12
- //"use strict";
13
-
14
- window.package = function(name){
15
- if(!window[name]) window[name] = {};
16
- };
17
-
18
- // conflict with Emberjs
19
- /*var extend = function(target , object){
20
- for(var key in object) target[key] = object[key];
21
- };
22
-
23
- Function.prototype.extend = function(superclass){
24
- if(typeof superclass.prototype.constructor === "function"){
25
- extend(this.prototype , superclass.prototype);
26
- this.prototype.constructor = this;
27
- }else{
28
- this.prototype.extend(superclass);
29
- this.prototype.constructor = this;
30
- }
31
- };*/
32
-
33
- // Converts JS prefix to CSS prefix
34
- var trans = {
35
- 'Moz' : '-moz-',
36
- 'Webkit' : '-webkit-',
37
- 'Khtml' : '-khtml-' ,
38
- 'O' : '-o-',
39
- 'ms' : '-ms-',
40
- 'Icab' : '-icab-'
41
- };
42
-
43
- $(document).ready(function(){
44
- window._jcsspfx = getVendorPrefix(); // JS CSS VendorPrefix
45
- window._csspfx = trans[window._jcsspfx]; // CSS VendorPrefix
46
- window._cssanim = supportsTransitions();
47
- window._css3d = supports3DTransforms();
48
- window._css2d = supportsTransforms();
49
- window._mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
50
- window._touch = 'ontouchstart' in document;
51
- });
52
-
53
-
54
- // Thanks to LEA VEROU
55
- // http://lea.verou.me/2009/02/find-the-vendor-prefix-of-the-current-browser/
56
- function getVendorPrefix() {
57
-
58
- if('result' in arguments.callee) return arguments.callee.result;
59
-
60
- var regex = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/;
61
-
62
- var someScript = document.getElementsByTagName('script')[0];
63
-
64
- for(var prop in someScript.style)
65
- if(regex.test(prop))
66
- return arguments.callee.result = prop.match(regex)[0];
67
-
68
- if('WebkitOpacity' in someScript.style) return arguments.callee.result = 'Webkit';
69
- if('KhtmlOpacity' in someScript.style) return arguments.callee.result = 'Khtml';
70
-
71
- return arguments.callee.result = '';
72
- }
73
-
74
-
75
- // Thanks to Steven Benner.
76
- // http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
77
- window.parseQueryString = function(url){
78
- var queryString = {};
79
- url.replace(
80
- new RegExp("([^?=&]+)(=([^&]*))?", "g"),
81
- function($0, $1, $2, $3) { queryString[$1] = $3; }
82
- );
83
-
84
- return queryString;
85
- };
86
-
87
- function checkStyleValue(prop){
88
- var b = document.body || document.documentElement;
89
- var s = b.style;
90
- var p = prop;
91
- if(typeof s[p] == 'string') {return true; }
92
-
93
- // Tests for vendor specific prop
94
- v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'],
95
- p = p.charAt(0).toUpperCase() + p.substr(1);
96
- for(var i=0; i<v.length; i++) {
97
- if(typeof s[v[i] + p] == 'string') { return true; }
98
- }
99
- return false;
100
- }
101
-
102
- function supportsTransitions() {
103
- return checkStyleValue('transition');
104
- }
105
-
106
- function supportsTransforms(){
107
- return checkStyleValue('transform');
108
- }
109
-
110
- function supports3DTransforms(){
111
- if(!supportsTransforms()) return false;
112
- var el = document.createElement('p'),
113
- has3d,
114
- transforms = {
115
- 'WebkitTransform':'-webkit-transform',
116
- 'OTransform':'-o-transform',
117
- 'MSTransform':'-ms-transform',
118
- 'MozTransform':'-moz-transform',
119
- 'Transform':'transform'
120
- };
121
-
122
- // Add it to the body to get the computed style
123
- document.body.insertBefore(el, null);
124
-
125
- for(var t in transforms){
126
- if( el.style[t] !== undefined ){
127
- el.style[t] = 'translate3d(1px,1px,1px)';
128
- has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
129
- }
130
- }
131
-
132
- document.body.removeChild(el);
133
-
134
- return (has3d != null && has3d.length > 0 && has3d !== "none");
135
- }
136
-
137
- /**
138
- * Provides requestAnimationFrame in a cross browser way.
139
- * @author paulirish / http://paulirish.com/
140
- */
141
- var fps60 = 50/3;
142
-
143
- if ( !window.requestAnimationFrame ) {
144
-
145
- window.requestAnimationFrame = ( function() {
146
-
147
- return window.webkitRequestAnimationFrame ||
148
- window.mozRequestAnimationFrame ||
149
- window.oRequestAnimationFrame ||
150
- window.msRequestAnimationFrame ||
151
- function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
152
-
153
- window.setTimeout( callback, fps60 );
154
-
155
- };
156
-
157
- } )();
158
-
159
- }
160
-
161
- if (!window.getComputedStyle) {
162
- window.getComputedStyle = function(el, pseudo) {
163
- this.el = el;
164
- this.getPropertyValue = function(prop) {
165
- var re = /(\-([a-z]){1})/g;
166
- if (prop == 'float') prop = 'styleFloat';
167
- if (re.test(prop)) {
168
- prop = prop.replace(re, function () {
169
- return arguments[2].toUpperCase();
170
- });
171
- }
172
- return el.currentStyle[prop] ? el.currentStyle[prop] : null;
173
- };
174
- return el.currentStyle;
175
- };
176
- }
177
-
178
- if(jQuery){
179
- $.jqLoadFix = function(){
180
- if(this.complete){
181
- var that = this;
182
- setTimeout(function(){$(that).load();} , 1);
183
- }
184
- };
185
-
186
- jQuery.uaMatch = jQuery.uaMatch || function( ua ) {
187
- ua = ua.toLowerCase();
188
-
189
- var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
190
- /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
191
- /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
192
- /(msie) ([\w.]+)/.exec( ua ) ||
193
- ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
194
- [];
195
-
196
- return {
197
- browser: match[ 1 ] || "",
198
- version: match[ 2 ] || "0"
199
- };
200
- };
201
-
202
- // Don't clobber any existing jQuery.browser in case it's different
203
- if ( !jQuery.browser ) {
204
- matched = jQuery.uaMatch( navigator.userAgent );
205
- browser = {};
206
-
207
- if ( matched.browser ) {
208
- browser[ matched.browser ] = true;
209
- browser.version = matched.version;
210
- }
211
-
212
- // Chrome is Webkit, but Webkit is also Safari.
213
- if ( browser.chrome ) {
214
- browser.webkit = true;
215
- } else if ( browser.webkit ) {
216
- browser.safari = true;
217
- }
218
-
219
- jQuery.browser = browser;
220
-
221
- }
222
-
223
- $.fn.preloadImg = function(src , _event){
224
- this.each(function(){
225
- var $this = $(this);
226
- var self = this;
227
- var img = new Image();
228
- img.onload = function(event){
229
- $this.attr('src' , src);
230
- event.width = img.width;
231
- event.height = img.height;
232
- setTimeout(function(){_event.call(self , event);},50);
233
- img = null;
234
- };
235
- img.src = src;
236
- });
237
- return this;
238
- };
239
- }
240
-
241
-
242
- window.parseTransform = function(transformCSS_str) {
243
- if(transformCSS_str === null) return {};
244
-
245
- transformCSS_str = transformCSS_str.replace(/\s+/g, '');
246
-
247
- var fullFun_array = transformCSS_str.split(")");
248
- fullFun_array.pop();
249
-
250
- var parsed_obj = {};
251
-
252
- for( var i = 0 , l = fullFun_array.length ; i < l ; ++i){
253
- var fun = fullFun_array[i];
254
- parsed_obj[fun.slice(0, fun.indexOf("("))] = fun.slice(fun.indexOf("(")+1).split(",");
255
- }
256
-
257
- return parsed_obj;
258
- };
259
-
260
-
261
- /**
262
- * Converts CSS3 ease names to JTween ease functions
263
- * @param {string} easeName
264
- * @return {function}
265
- */
266
- window.convertEaseName = function(easeName){
267
- if(easeName === 'linear') return Linear.easeNone;
268
- var isInOut = easeName.indexOf('InOut') !== -1,
269
- isIn = easeName.indexOf('In') !== -1;
270
-
271
- if(isInOut) return window[easeName.slice(9)].easeInOut;
272
- if(isIn) return window[easeName.slice(6)].easeIn;
273
-
274
- return window[easeName.slice(7)].easeOut;
275
- };
276
-
277
- jQuery.fn.extend({
278
- insertAtCaret: function(myValue){
279
- return this.each(function(i) {
280
- if (document.selection) {
281
- //For browsers like Internet Explorer
282
- this.focus();
283
- var sel = document.selection.createRange();
284
- sel.text = myValue;
285
- this.focus();
286
- }
287
- else if (this.selectionStart || this.selectionStart == '0') {
288
- //For browsers like Firefox and Webkit based
289
- var startPos = this.selectionStart;
290
- var endPos = this.selectionEnd;
291
- var scrollTop = this.scrollTop;
292
- this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length);
293
- this.focus();
294
- this.selectionStart = startPos + myValue.length;
295
- this.selectionEnd = startPos + myValue.length;
296
- this.scrollTop = scrollTop;
297
- } else {
298
- this.value += myValue;
299
- this.focus();
300
- }
301
- });
302
- }
303
- });
304
- })(jQuery);
305
- //js\libs\averta.livetabs.js
306
-
307
- /**
308
- * AvertaLiveTabs v1.4
309
- * Plugin for enabling tabs
310
- * Copyright (c) averta | http://averta.net | 2011-2014
311
- * licensed under the MIT license
312
- **/
313
-
314
- /**
315
- * USAGE :
316
- * -----------------------------------------------------------------------------------------------------
317
- * HTML:
318
- <div id="container">
319
- <ul class="tabs">
320
- <li class="active"><a href="#s1">Tab1</a></li>
321
- <li><a href="#s2">Tab2</a></li>
322
- <li><a href="#s3">Tab3</a></li>
323
- </ul>
324
-
325
- <ul class="tabs-content">
326
- <li id="s1">Contnt1</li>
327
- <li id="s2">Contnt2</li>
328
- <li id="s3">Contnt3</li>
329
- </ul>
330
- </div>
331
- *
332
- * JS:
333
- $('#container').avertaLiveTabs({
334
- tabs: 'ul.tabs > li', // Tabs selector
335
- tabsActiveClass: 'active', // A Class that indicates active tab
336
- contents: 'ul.tabs-content > li', // Tabs content selector
337
- contentsActiveClass: 'active', // A Class that indicates active tab-content
338
- transition: 'fade', // Animation type white swiching tabs
339
- duration : '500', // Animation duration in mili seconds
340
- connectType: 'index', // connect tabs and contents by 'index' or 'id'
341
- enableHash: false , // check to select initial tab based on hash address
342
- updateHash: false , // update hash in browser while switching between tabs
343
- hashSuffix: '-tab' // suffix to add at the end of hash url to prevent page scroll
344
- });
345
-
346
- * ---------------------------------------------------------------------------------------------------------
347
- **/
348
-
349
- if(typeof Object.create !== 'function' ){ Object.create = function (obj){ function F(){} F.prototype = obj;return new F();};}
350
-
351
- ;(function($){
352
-
353
- var Container = {
354
-
355
- init : function(el, options){
356
- //cache this
357
- var self = this;
358
- self.options = $.extend({} ,$.fn.avertaLiveTabs.defaultOptions, options || {} );
359
-
360
- // Access to jQuery and DOM versions of element
361
- self.$el = $(el);
362
- self.el = el;
363
-
364
- self.$tabs = self.$el.find(self.options.tabs);
365
- self.$contents = self.$el.find(self.options.contents);
366
-
367
- self.setup();
368
- },
369
-
370
- setup: function(){
371
- var self = this,
372
- $active_tab,
373
- $active_content;
374
- // click event when new tab selected
375
- self.$tabs.on('click', {self:self}, self.onTabClicked);
376
-
377
- // if hash is enabled in options get current hash and select related tab
378
- if(self.options.enableHash && window.location.hash !== '') {
379
- var id = window.location.hash.substring(1);
380
- $active_tab = self.getTabById(id);
381
- } else {
382
- // find the tab with tabsActiveClass
383
- $active_tab = self.$tabs.filter('.'+self.options.tabsActiveClass);
384
- }
385
- // validate to select the active tab for start
386
- $active_tab = ($active_tab.length)?$active_tab:self.$tabs.first();
387
- $active_tab.trigger('click', true);
388
-
389
- },
390
-
391
- onTabClicked:function(event, fromSetup){
392
- event.preventDefault();
393
- var self = event.data.self,
394
- $this = $(this),
395
- $tab_content,
396
- active_id;
397
-
398
- if( !fromSetup && $this.hasClass('active') ){
399
- return;
400
- }
401
-
402
- self.$tabs.removeClass(self.options.tabsActiveClass);
403
- $this.addClass(self.options.tabsActiveClass);
404
-
405
- self.$contents.hide();
406
- if(self.options.connectType == 'id'){
407
- active_id = self.getIdByTab($this);
408
- $tab_content = self.getContentById(active_id);
409
- } else{
410
- $tab_content = self.$contents.eq($this.index());
411
- }
412
- $tab_content.fadeIn(self.options.duration);
413
-
414
- // update hash in page address if updateHash is enabled
415
- if(self.options.updateHash){
416
- active_id = self.getIdByTab($this);
417
- active_id = active_id?active_id+self.options.hashSuffix:'';
418
-
419
- if(window.history && window.history.pushState )
420
- window.history.pushState(null, null, window.location.href.split('#')[0]+'#'+active_id);
421
- else
422
- window.location.hash = active_id;
423
- }
424
-
425
- // trigger custom event
426
- self.$el.trigger('avtTabChange', $tab_content.attr('id'));
427
-
428
- },
429
-
430
- getTabById:function(id){
431
- // remove hashSuffix (if exist) from id hash to get real element id
432
- id = id.split(this.options.hashSuffix)[0];
433
- // search for hash in tabs markup - generaly should be direct children of tab
434
- // check for href="#id" format
435
- var $active_tab = this.$tabs.find('[href="#'+ id +'"]').eq(0);
436
- // if no match found, check for href="id" format too
437
- if(!$active_tab.length)
438
- $active_tab = this.$tabs.find('[href="'+ id +'"]').eq(0);
439
- // get the tab if hash found in it
440
- return $active_tab.length?$active_tab.parent():$active_tab;
441
- },
442
-
443
- getContentById:function(id){
444
- return this.$contents.filter('#'+id);
445
- },
446
-
447
- getIdByTab:function($tab){
448
- var $anchor = $tab.find('[href]').eq(0);
449
- return $anchor.length?$anchor.attr('href'):false;
450
- }
451
- };
452
-
453
-
454
- $.fn.avertaLiveTabs = function(options){
455
- return this.each(function(){
456
- var container = Object.create(Container);
457
- container.init(this, options);
458
- });
459
- };
460
-
461
- $.fn.avertaLiveTabs.defaultOptions = {
462
- tabs: 'ul.tabs > li', // Tabs selector
463
- tabsActiveClass: 'active', // A Class that indicates active tab
464
- contents: 'ul.tabs-content > li', // Tabs content selector
465
- contentsActiveClass: 'active', // A Class that indicates active tab-content
466
- transition: 'fade', // Animation type white swiching tabs
467
- duration : '500', // Animation duration in mili seconds
468
- connectType: 'index', // connect tabs and contents by 'index' or 'id'
469
- enableHash: false , // check to select initial tab based on hash address
470
- updateHash: false , // update hash in browser while switching between tabs
471
- hashSuffix: '-tab' // suffix to add at the end of hash url to prevent page scroll
472
- };
473
-
474
- })(jQuery);
475
- //js\libs\averta.aligner.js
476
-
477
- ;(function(){
478
-
479
- "use strict";
480
-
481
- window.MSAligner = function(type , $container , $img ){
482
-
483
- this.$container = $container;
484
- this.$img = $img;
485
-
486
- this.type = type || 'stretch'; // fill , fit , stretch , tile , center
487
-
488
- this.widthOnly = false;
489
- this.heightOnly = false;
490
- };
491
-
492
- var p = MSAligner.prototype;
493
-
494
- /*-------------- METHODS --------------*/
495
-
496
- p.init = function(w , h){
497
-
498
- this.baseWidth = w;
499
- this.baseHeight = h;
500
- this.imgRatio = w / h;
501
- this.imgRatio2 = h / w;
502
-
503
- switch(this.type){
504
- case 'tile':
505
- this.$container.css('background-image' , 'url('+ this.$img.attr('src') +')');
506
- this.$img.detach();
507
- break;
508
- case 'center':
509
- this.$container.css('background-image' , 'url('+ this.$img.attr('src') +')');
510
- this.$container.css({
511
- backgroundPosition : 'center center',
512
- backgroundRepeat : 'no-repeat'
513
- });
514
- this.$img.detach();
515
- break;
516
- case 'stretch':
517
- this.$img.css({
518
- width : '100%',
519
- height : '100%'
520
- });
521
- break;
522
- case 'fill':
523
- case 'fit' :
524
- this.needAlign = true;
525
- this.align();
526
- break;
527
- }
528
-
529
- };
530
-
531
- p.align = function(){
532
- if(!this.needAlign) return;
533
-
534
- var cont_w = this.$container.width();
535
- var cont_h = this.$container.height();
536
-
537
- var contRatio = cont_w / cont_h;
538
-
539
- if(this.type == 'fill'){
540
- if(this.imgRatio < contRatio ){
541
- this.$img.width(cont_w);
542
- this.$img.height(cont_w * this.imgRatio2);
543
- }else{
544
- this.$img.height(cont_h);
545
- this.$img.width(cont_h * this.imgRatio);
546
- }
547
-
548
- }else if(this.type == 'fit'){
549
-
550
- if(this.imgRatio < contRatio){
551
- this.$img.height(cont_h);
552
- this.$img.width(cont_h * this.imgRatio);
553
- }else{
554
- this.$img.width(cont_w);
555
- this.$img.height(cont_w * this.imgRatio2);
556
- }
557
- }
558
-
559
- this.setMargin();
560
-
561
- };
562
-
563
- p.changeType = function(type){
564
- this.reset();
565
- this.type = type;
566
- this.reinit();
567
- }
568
-
569
- p.reinit = function(){
570
- this.init(this.baseWidth , this.baseHeight);
571
- };
572
-
573
- p.reset = function(){
574
- if(this.type === 'center' || this.type === 'tile'){
575
- this.$container.css({
576
- 'background-image' : '',
577
- backgroundPosition : '',
578
- backgroundRepeat : ''
579
- });
580
- this.$img.appendTo(this.$container);
581
- }else{
582
- this.$img.css({
583
- width : '',
584
- height : '',
585
- 'margin-top' : '',
586
- 'margin-left': ''
587
- });
588
- }
589
- };
590
-
591
- p.setMargin = function(){
592
-
593
- var cont_w = this.$container.width();
594
- var cont_h = this.$container.height();
595
-
596
- this.$img.css('margin-top' , (cont_h - this.$img[0].offsetHeight) / 2 + 'px');
597
- this.$img.css('margin-left', (cont_w - this.$img[0].offsetWidth ) / 2 + 'px');
598
- };
599
-
600
- })();
601
- //js\libs\jquery.ddslick.js
602
-
603
- /*!
604
- * Custom DropDown plugin by PC
605
- * http://designwithpc.com/Plugins/ddslick
606
- * Author: PC
607
- */
608
-
609
- //Title: Custom DropDown plugin by PC
610
- //Documentation: http://designwithpc.com/Plugins/ddslick
611
- //Author: PC
612
- //Website: http://designwithpc.com
613
- //Twitter: http://twitter.com/chaudharyp
614
-
615
- (function ($) {
616
-
617
- $.fn.ddslick = function (method) {
618
- if (methods[method]) {
619
- return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
620
- } else if (typeof method === 'object' || !method) {
621
- return methods.init.apply(this, arguments);
622
- } else {
623
- $.error('Method ' + method + ' does not exists.');
624
- }
625
- };
626
-
627
- var methods = {},
628
-
629
- //Set defauls for the control
630
- defaults = {
631
- data: [],
632
- keepJSONItemsOnTop: false,
633
- width: 260,
634
- height: null,
635
- background: "#eee",
636
- selectText: "",
637
- defaultSelectedIndex: null,
638
- truncateDescription: true,
639
- imagePosition: "left",
640
- showSelectedHTML: true,
641
- clickOffToClose: true,
642
- onSelected: function () { }
643
- },
644
-
645
- ddSelectHtml = '<div class="dd-select"><input class="dd-selected-value" type="hidden" /><a class="dd-selected"></a><span class="dd-pointer dd-pointer-down"></span></div>',
646
- ddOptionsHtml = '<ul class="dd-options"></ul>';
647
-
648
- //CSS for ddSlick
649
- /* ddslickCSS = '<style id="css-ddslick" type="text/css">' +
650
- '.dd-select{ border-radius:2px; border:solid 1px #ccc; position:relative; cursor:pointer;}' +
651
- '.dd-desc { color:#aaa; display:block; overflow: hidden; font-weight:normal; line-height: 1.4em; }' +
652
- '.dd-selected{ overflow:hidden; display:block; padding:10px; font-weight:bold;}' +
653
- '.dd-pointer{ width:0; height:0; position:absolute; right:10px; top:50%; margin-top:-3px;}' +
654
- '.dd-pointer-down{ border:solid 5px transparent; border-top:solid 5px #000; }' +
655
- '.dd-pointer-up{border:solid 5px transparent !important; border-bottom:solid 5px #000 !important; margin-top:-8px;}' +
656
- '.dd-options{ border:solid 1px #ccc; border-top:none; list-style:none; box-shadow:0px 1px 5px #ddd; display:none; position:absolute; z-index:2000; margin:0; padding:0;background:#fff; overflow:auto;}' +
657
- '.dd-option{ padding:10px; display:block; border-bottom:solid 1px #ddd; overflow:hidden; text-decoration:none; color:#333; cursor:pointer;-webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out;-o-transition: all 0.25s ease-in-out;-ms-transition: all 0.25s ease-in-out; }' +
658
- '.dd-options > li:last-child > .dd-option{ border-bottom:none;}' +
659
- '.dd-option:hover{ background:#f3f3f3; color:#000;}' +
660
- '.dd-selected-description-truncated { text-overflow: ellipsis; white-space:nowrap; }' +
661
- '.dd-option-selected { background:#f6f6f6; }' +
662
- '.dd-option-image, .dd-selected-image { vertical-align:middle; float:left; margin-right:5px; max-width:64px;}' +
663
- '.dd-image-right { float:right; margin-right:15px; margin-left:5px;}' +
664
- '.dd-container{ position:relative;}​ .dd-selected-text { font-weight:bold}​</style>';
665
-
666
- //CSS styles are only added once.
667
- if ($('#css-ddslick').length <= 0) {
668
- $(ddslickCSS).appendTo('head');
669
- }*/
670
-
671
- //Public methods
672
- methods.init = function (options) {
673
- //Preserve the original defaults by passing an empty object as the target
674
- var options = $.extend({}, defaults, options);
675
-
676
- //Apply on all selected elements
677
- return this.each(function () {
678
- var obj = $(this),
679
- data = obj.data('ddslick');
680
- //If the plugin has not been initialized yet
681
- if (!data) {
682
-
683
- var ddSelect = [], ddJson = options.data;
684
-
685
- //Get data from HTML select options
686
- obj.find('option').each(function () {
687
- var $this = $(this), thisData = $this.data();
688
- ddSelect.push({
689
- text: $.trim($this.text()),
690
- value: $this.val(),
691
- selected: $this.is(':selected'),
692
- description: thisData.description,
693
- imageSrc: thisData.imagesrc //keep it lowercase for HTML5 data-attributes
694
- });
695
- });
696
-
697
- //Update Plugin data merging both HTML select data and JSON data for the dropdown
698
- if (options.keepJSONItemsOnTop)
699
- $.merge(options.data, ddSelect);
700
- else options.data = $.merge(ddSelect, options.data);
701
-
702
- //Replace HTML select with empty placeholder, keep the original
703
- var original = obj, placeholder = $('<div id="' + obj.attr('id') + '"></div>');
704
- obj.replaceWith(placeholder);
705
- obj = placeholder;
706
-
707
- //Add classes and append ddSelectHtml & ddOptionsHtml to the container
708
- obj.addClass('dd-container').append(ddSelectHtml).append(ddOptionsHtml);
709
-
710
- //Get newly created ddOptions and ddSelect to manipulate
711
- var ddSelect = obj.find('.dd-select'),
712
- ddOptions = obj.find('.dd-options');
713
-
714
- //Set widths
715
- ddOptions.css({ width: options.width });
716
- ddSelect.css({ width: options.width, background: options.background });
717
- obj.css({ width: options.width });
718
-
719
- //Set height
720
- if (options.height != null)
721
- ddOptions.css({ height: options.height, overflow: 'auto' });
722
-
723
- //Add ddOptions to the container. Replace with template engine later.
724
- $.each(options.data, function (index, item) {
725
- if (item.selected) options.defaultSelectedIndex = index;
726
- ddOptions.append('<li>' +
727
- '<a class="dd-option">' +
728
- (item.value ? ' <input class="dd-option-value" type="hidden" value="' + item.value + '" />' : '') +
729
- (item.imageSrc ? ' <img class="dd-option-image' + (options.imagePosition == "right" ? ' dd-image-right' : '') + '" src="' + item.imageSrc + '" />' : '') +
730
- (item.text ? ' <label class="dd-option-text">' + item.text + '</label>' : '') +
731
- (item.description ? ' <small class="dd-option-description dd-desc">' + item.description + '</small>' : '') +
732
- '</a>' +
733
- '</li>');
734
- });
735
-
736
- //Save plugin data.
737
- var pluginData = {
738
- settings: options,
739
- original: original,
740
- selectedIndex: -1,
741
- selectedItem: null,
742
- selectedData: null
743
- }
744
- obj.data('ddslick', pluginData);
745
-
746
- //Check if needs to show the select text, otherwise show selected or default selection
747
- if (options.selectText.length > 0 && options.defaultSelectedIndex == null) {
748
- obj.find('.dd-selected').html(options.selectText);
749
- }
750
- else {
751
- var index = (options.defaultSelectedIndex != null && options.defaultSelectedIndex >= 0 && options.defaultSelectedIndex < options.data.length)
752
- ? options.defaultSelectedIndex
753
- : 0;
754
- selectIndex(obj, index);
755
- }
756
-
757
- //EVENTS
758
- //Displaying options
759
- obj.find('.dd-select').on('click.ddslick', function () {
760
- open(obj);
761
- });
762
-
763
- //Selecting an option
764
- obj.find('.dd-option').on('click.ddslick', function () {
765
- selectIndex(obj, $(this).closest('li').index());
766
- });
767
-
768
- //Click anywhere to close
769
- if (options.clickOffToClose) {
770
- ddOptions.addClass('dd-click-off-close');
771
- obj.on('click.ddslick', function (e) { e.stopPropagation(); });
772
- $('body').on('click', function () {
773
- $('.dd-click-off-close').slideUp(50).siblings('.dd-select').find('.dd-pointer').removeClass('dd-pointer-up');
774
- });
775
- }
776
- }
777
- });
778
- };
779
-
780
- //Public method to select an option by its index
781
- methods.select = function (options) {
782
- return this.each(function () {
783
- if (options.index !== null)
784
- selectIndex($(this), options.index);
785
- });
786
- }
787
-
788
- //Public method to open drop down
789
- methods.open = function () {
790
- return this.each(function () {
791
- var $this = $(this),
792
- pluginData = $this.data('ddslick');
793
-
794
- //Check if plugin is initialized
795
- if (pluginData)
796
- open($this);
797
- });
798
- };
799
-
800
- //Public method to close drop down
801
- methods.close = function () {
802
- return this.each(function () {
803
- var $this = $(this),
804
- pluginData = $this.data('ddslick');
805
-
806
- //Check if plugin is initialized
807
- if (pluginData)
808
- close($this);
809
- });
810
- };
811
-
812
- //Public method to destroy. Unbind all events and restore the original Html select/options
813
- methods.destroy = function () {
814
- return this.each(function () {
815
- var $this = $(this),
816
- pluginData = $this.data('ddslick');
817
-
818
- //Check if already destroyed
819
- if (pluginData) {
820
- var originalElement = pluginData.original;
821
- $this.removeData('ddslick').unbind('.ddslick').replaceWith(originalElement);
822
- }
823
- });
824
- }
825
-
826
- //Private: Select index
827
- function selectIndex(obj, index) {
828
-
829
- //Get plugin data
830
- var pluginData = obj.data('ddslick');
831
-
832
- //Get required elements
833
- var ddSelected = obj.find('.dd-selected'),
834
- ddSelectedValue = ddSelected.siblings('.dd-selected-value'),
835
- ddOptions = obj.find('.dd-options'),
836
- ddPointer = ddSelected.siblings('.dd-pointer'),
837
- selectedOption = obj.find('.dd-option').eq(index),
838
- selectedLiItem = selectedOption.closest('li'),
839
- settings = pluginData.settings,
840
- selectedData = pluginData.settings.data[index];
841
-
842
- //Highlight selected option
843
- obj.find('.dd-option').removeClass('dd-option-selected');
844
- selectedOption.addClass('dd-option-selected');
845
-
846
- //Update or Set plugin data with new selection
847
- pluginData.selectedIndex = index;
848
- pluginData.selectedItem = selectedLiItem;
849
- pluginData.selectedData = selectedData;
850
-
851
- //If set to display to full html, add html
852
- if (settings.showSelectedHTML) {
853
- ddSelected.html(
854
- (selectedData.imageSrc ? '<img class="dd-selected-image' + (settings.imagePosition == "right" ? ' dd-image-right' : '') + '" src="' + selectedData.imageSrc + '" />' : '') +
855
- (selectedData.text ? '<label class="dd-selected-text">' + selectedData.text + '</label>' : '') +
856
- (selectedData.description ? '<small class="dd-selected-description dd-desc' + (settings.truncateDescription ? ' dd-selected-description-truncated' : '') + '" >' + selectedData.description + '</small>' : '')
857
- );
858
-
859
- }
860
- //Else only display text as selection
861
- else ddSelected.html(selectedData.text);
862
-
863
- //Updating selected option value
864
- ddSelectedValue.val(selectedData.value);
865
-
866
- //BONUS! Update the original element attribute with the new selection
867
- pluginData.original.val(selectedData.value);
868
- obj.data('ddslick', pluginData);
869
-
870
- //Close options on selection
871
- close(obj);
872
-
873
- //Adjust appearence for selected option
874
- adjustSelectedHeight(obj);
875
-
876
- //Callback function on selection
877
- if (typeof settings.onSelected == 'function') {
878
- settings.onSelected.call(this, pluginData);
879
- }
880
- }
881
-
882
- //Private: Close the drop down options
883
- function open(obj) {
884
-
885
- var $this = obj.find('.dd-select'),
886
- ddOptions = $this.siblings('.dd-options'),
887
- ddPointer = $this.find('.dd-pointer'),
888
- wasOpen = ddOptions.is(':visible');
889
-
890
- //Close all open options (multiple plugins) on the page
891
- $('.dd-click-off-close').not(ddOptions).slideUp(50);
892
- $('.dd-pointer').removeClass('dd-pointer-up');
893
-
894
- if (wasOpen) {
895
- ddOptions.slideUp('fast');
896
- ddPointer.removeClass('dd-pointer-up');
897
- }
898
- else {
899
- ddOptions.slideDown('fast');
900
- ddPointer.addClass('dd-pointer-up');
901
- }
902
-
903
- //Fix text height (i.e. display title in center), if there is no description
904
- adjustOptionsHeight(obj);
905
- }
906
-
907
- //Private: Close the drop down options
908
- function close(obj) {
909
- //Close drop down and adjust pointer direction
910
- obj.find('.dd-options').slideUp(50);
911
- obj.find('.dd-pointer').removeClass('dd-pointer-up').removeClass('dd-pointer-up');
912
- }
913
-
914
- //Private: Adjust appearence for selected option (move title to middle), when no desripction
915
- function adjustSelectedHeight(obj) {
916
-
917
- //Get height of dd-selected
918
- var lSHeight = obj.find('.dd-select').css('height');
919
-
920
- //Check if there is selected description
921
- var descriptionSelected = obj.find('.dd-selected-description');
922
- var imgSelected = obj.find('.dd-selected-image');
923
- if (descriptionSelected.length <= 0 && imgSelected.length > 0) {
924
- obj.find('.dd-selected-text').css('lineHeight', lSHeight);
925
- }
926
- }
927
-
928
- //Private: Adjust appearence for drop down options (move title to middle), when no desripction
929
- function adjustOptionsHeight(obj) {
930
- obj.find('.dd-option').each(function () {
931
- var $this = $(this);
932
- var lOHeight = $this.css('height');
933
- var descriptionOption = $this.find('.dd-option-description');
934
- var imgOption = obj.find('.dd-option-image');
935
- if (descriptionOption.length <= 0 && imgOption.length > 0) {
936
- $this.find('.dd-option-text').css('lineHeight', lOHeight);
937
- }
938
- });
939
- }
940
-
941
- })(jQuery);//js\libs\jquery.mousewheel.js
942
-
943
  /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
944
  * Licensed under the MIT License (LICENSE.txt).
945
  *
@@ -947,9984 +17,29 @@ if(typeof Object.create !== 'function' ){ Object.create = function (obj){ functi
947
  *
948
  * Requires: jQuery 1.2.2+
949
  */
950
-
951
- (function (factory) {
952
- if ( typeof define === 'function' && define.amd ) {
953
- // AMD. Register as an anonymous module.
954
- define(['jquery'], factory);
955
- } else if (typeof exports === 'object') {
956
- // Node/CommonJS style for Browserify
957
- module.exports = factory;
958
- } else {
959
- // Browser globals
960
- factory(jQuery);
961
- }
962
- }(function ($) {
963
-
964
- var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
965
- toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
966
- ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
967
- slice = Array.prototype.slice,
968
- nullLowestDeltaTimeout, lowestDelta;
969
-
970
- if ( $.event.fixHooks ) {
971
- for ( var i = toFix.length; i; ) {
972
- $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
973
- }
974
- }
975
-
976
- var special = $.event.special.mousewheel = {
977
- version: '3.1.9',
978
-
979
- setup: function() {
980
- if ( this.addEventListener ) {
981
- for ( var i = toBind.length; i; ) {
982
- this.addEventListener( toBind[--i], handler, false );
983
- }
984
- } else {
985
- this.onmousewheel = handler;
986
- }
987
- // Store the line height and page height for this particular element
988
- $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
989
- $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
990
- },
991
-
992
- teardown: function() {
993
- if ( this.removeEventListener ) {
994
- for ( var i = toBind.length; i; ) {
995
- this.removeEventListener( toBind[--i], handler, false );
996
- }
997
- } else {
998
- this.onmousewheel = null;
999
- }
1000
- },
1001
-
1002
- getLineHeight: function(elem) {
1003
- return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
1004
- },
1005
-
1006
- getPageHeight: function(elem) {
1007
- return $(elem).height();
1008
- },
1009
-
1010
- settings: {
1011
- adjustOldDeltas: true
1012
- }
1013
- };
1014
-
1015
- $.fn.extend({
1016
- mousewheel: function(fn) {
1017
- return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
1018
- },
1019
-
1020
- unmousewheel: function(fn) {
1021
- return this.unbind('mousewheel', fn);
1022
- }
1023
- });
1024
-
1025
-
1026
- function handler(event) {
1027
- var orgEvent = event || window.event,
1028
- args = slice.call(arguments, 1),
1029
- delta = 0,
1030
- deltaX = 0,
1031
- deltaY = 0,
1032
- absDelta = 0;
1033
- event = $.event.fix(orgEvent);
1034
- event.type = 'mousewheel';
1035
-
1036
- // Old school scrollwheel delta
1037
- if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
1038
- if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
1039
- if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
1040
- if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
1041
-
1042
- // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
1043
- if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
1044
- deltaX = deltaY * -1;
1045
- deltaY = 0;
1046
- }
1047
-
1048
- // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
1049
- delta = deltaY === 0 ? deltaX : deltaY;
1050
-
1051
- // New school wheel delta (wheel event)
1052
- if ( 'deltaY' in orgEvent ) {
1053
- deltaY = orgEvent.deltaY * -1;
1054
- delta = deltaY;
1055
- }
1056
- if ( 'deltaX' in orgEvent ) {
1057
- deltaX = orgEvent.deltaX;
1058
- if ( deltaY === 0 ) { delta = deltaX * -1; }
1059
- }
1060
-
1061
- // No change actually happened, no reason to go any further
1062
- if ( deltaY === 0 && deltaX === 0 ) { return; }
1063
-
1064
- // Need to convert lines and pages to pixels if we aren't already in pixels
1065
- // There are three delta modes:
1066
- // * deltaMode 0 is by pixels, nothing to do
1067
- // * deltaMode 1 is by lines
1068
- // * deltaMode 2 is by pages
1069
- if ( orgEvent.deltaMode === 1 ) {
1070
- var lineHeight = $.data(this, 'mousewheel-line-height');
1071
- delta *= lineHeight;
1072
- deltaY *= lineHeight;
1073
- deltaX *= lineHeight;
1074
- } else if ( orgEvent.deltaMode === 2 ) {
1075
- var pageHeight = $.data(this, 'mousewheel-page-height');
1076
- delta *= pageHeight;
1077
- deltaY *= pageHeight;
1078
- deltaX *= pageHeight;
1079
- }
1080
-
1081
- // Store lowest absolute delta to normalize the delta values
1082
- absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
1083
-
1084
- if ( !lowestDelta || absDelta < lowestDelta ) {
1085
- lowestDelta = absDelta;
1086
-
1087
- // Adjust older deltas if necessary
1088
- if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
1089
- lowestDelta /= 40;
1090
- }
1091
- }
1092
-
1093
- // Adjust older deltas if necessary
1094
- if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
1095
- // Divide all the things by 40!
1096
- delta /= 40;
1097
- deltaX /= 40;
1098
- deltaY /= 40;
1099
- }
1100
-
1101
- // Get a whole, normalized value for the deltas
1102
- delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
1103
- deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
1104
- deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
1105
-
1106
- // Add information to the event object
1107
- event.deltaX = deltaX;
1108
- event.deltaY = deltaY;
1109
- event.deltaFactor = lowestDelta;
1110
- // Go ahead and set deltaMode to 0 since we converted to pixels
1111
- // Although this is a little odd since we overwrite the deltaX/Y
1112
- // properties with normalized deltas.
1113
- event.deltaMode = 0;
1114
-
1115
- // Add event and delta to the front of the arguments
1116
- args.unshift(event, delta, deltaX, deltaY);
1117
-
1118
- // Clearout lowestDelta after sometime to better
1119
- // handle multiple device types that give different
1120
- // a different lowestDelta
1121
- // Ex: trackpad = 3 and mouse wheel = 120
1122
- if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
1123
- nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
1124
-
1125
- return ($.event.dispatch || $.event.handle).apply(this, args);
1126
- }
1127
-
1128
- function nullLowestDelta() {
1129
- lowestDelta = null;
1130
- }
1131
-
1132
- function shouldAdjustOldDeltas(orgEvent, absDelta) {
1133
- // If this is an older event and the delta is divisable by 120,
1134
- // then we are assuming that the browser is treating this as an
1135
- // older mouse wheel event and that we should divide the deltas
1136
- // by 40 to try and get a more usable deltaFactor.
1137
- // Side note, this actually impacts the reported scroll distance
1138
- // in older browsers and can cause scrolling to be slower than native.
1139
- // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
1140
- return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
1141
- }
1142
-
1143
- }));
1144
-
1145
- //js\libs\spectrum.js
1146
-
1147
  /*! Spectrum Colorpicker v1.3.2
1148
  * License: MIT
1149
  * Author: Brian Grinstead
1150
  * https://github.com/bgrins/spectrum
1151
  * Requires: jQuery
1152
  */
1153
-
1154
- // Spectrum Colorpicker v1.3.2
1155
- // https://github.com/bgrins/spectrum
1156
- // Author: Brian Grinstead
1157
- // License: MIT
1158
-
1159
- (function (window, $, undefined) {
1160
- var defaultOpts = {
1161
-
1162
- // Callbacks
1163
- beforeShow: noop,
1164
- move: noop,
1165
- change: noop,
1166
- show: noop,
1167
- hide: noop,
1168
-
1169
- // Options
1170
- color: false,
1171
- flat: false,
1172
- showInput: false,
1173
- allowEmpty: false,
1174
- showButtons: true,
1175
- clickoutFiresChange: false,
1176
- showInitial: false,
1177
- showPalette: false,
1178
- showPaletteOnly: false,
1179
- showSelectionPalette: true,
1180
- localStorageKey: false,
1181
- appendTo: "body",
1182
- maxSelectionSize: 7,
1183
- cancelText: "cancel",
1184
- chooseText: "choose",
1185
- clearText: "Clear Color Selection",
1186
- preferredFormat: false,
1187
- className: "",
1188
- showAlpha: false,
1189
- theme: "sp-light",
1190
- palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
1191
- selectionPalette: [],
1192
- disabled: false
1193
- },
1194
- spectrums = [],
1195
- IE = !!/msie/i.exec( window.navigator.userAgent ),
1196
- rgbaSupport = (function() {
1197
- function contains( str, substr ) {
1198
- return !!~('' + str).indexOf(substr);
1199
- }
1200
-
1201
- var elem = document.createElement('div');
1202
- var style = elem.style;
1203
- style.cssText = 'background-color:rgba(0,0,0,.5)';
1204
- return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
1205
- })(),
1206
- inputTypeColorSupport = (function() {
1207
- var colorInput = $("<input type='color' value='!' />")[0];
1208
- return colorInput.type === "color" && colorInput.value !== "!";
1209
- })(),
1210
- replaceInput = [
1211
- "<div class='sp-replacer'>",
1212
- "<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
1213
- "<div class='sp-dd'>&#9660;</div>",
1214
- "</div>"
1215
- ].join(''),
1216
- markup = (function () {
1217
-
1218
- // IE does not support gradients with multiple stops, so we need to simulate
1219
- // that for the rainbow slider with 8 divs that each have a single gradient
1220
- var gradientFix = "";
1221
- if (IE) {
1222
- for (var i = 1; i <= 6; i++) {
1223
- gradientFix += "<div class='sp-" + i + "'></div>";
1224
- }
1225
- }
1226
-
1227
- return [
1228
- "<div class='sp-container sp-hidden'>",
1229
- "<div class='sp-palette-container'>",
1230
- "<div class='sp-palette sp-thumb sp-cf'></div>",
1231
- "</div>",
1232
- "<div class='sp-picker-container'>",
1233
- "<div class='sp-top sp-cf'>",
1234
- "<div class='sp-fill'></div>",
1235
- "<div class='sp-top-inner'>",
1236
- "<div class='sp-color'>",
1237
- "<div class='sp-sat'>",
1238
- "<div class='sp-val'>",
1239
- "<div class='sp-dragger'></div>",
1240
- "</div>",
1241
- "</div>",
1242
- "</div>",
1243
- "<div class='sp-clear sp-clear-display'>",
1244
- "</div>",
1245
- "<div class='sp-hue'>",
1246
- "<div class='sp-slider'></div>",
1247
- gradientFix,
1248
- "</div>",
1249
- "</div>",
1250
- "<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>",
1251
- "</div>",
1252
- "<div class='sp-input-container sp-cf'>",
1253
- "<input class='sp-input' type='text' spellcheck='false' />",
1254
- "</div>",
1255
- "<div class='sp-initial sp-thumb sp-cf'></div>",
1256
- "<div class='sp-button-container sp-cf'>",
1257
- "<a class='sp-cancel' href='#'></a>",
1258
- "<button class='sp-choose'></button>",
1259
- "</div>",
1260
- "</div>",
1261
- "</div>"
1262
- ].join("");
1263
- })();
1264
-
1265
- function paletteTemplate (p, color, className) {
1266
- var html = [];
1267
- for (var i = 0; i < p.length; i++) {
1268
- var current = p[i];
1269
- if(current) {
1270
- var tiny = tinycolor(current);
1271
- var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
1272
- c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : "";
1273
-
1274
- var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
1275
- html.push('<span title="' + tiny.toRgbString() + '" data-color="' + tiny.toRgbString() + '" class="' + c + '"><span class="sp-thumb-inner" style="' + swatchStyle + ';" /></span>');
1276
- } else {
1277
- var cls = 'sp-clear-display';
1278
- html.push('<span title="No Color Selected" data-color="" style="background-color:transparent;" class="' + cls + '"></span>');
1279
- }
1280
- }
1281
- return "<div class='sp-cf " + className + "'>" + html.join('') + "</div>";
1282
- }
1283
-
1284
- function hideAll() {
1285
- for (var i = 0; i < spectrums.length; i++) {
1286
- if (spectrums[i]) {
1287
- spectrums[i].hide();
1288
- }
1289
- }
1290
- }
1291
-
1292
- function instanceOptions(o, callbackContext) {
1293
- var opts = $.extend({}, defaultOpts, o);
1294
- opts.callbacks = {
1295
- 'move': bind(opts.move, callbackContext),
1296
- 'change': bind(opts.change, callbackContext),
1297
- 'show': bind(opts.show, callbackContext),
1298
- 'hide': bind(opts.hide, callbackContext),
1299
- 'beforeShow': bind(opts.beforeShow, callbackContext)
1300
- };
1301
-
1302
- return opts;
1303
- }
1304
-
1305
- function spectrum(element, o) {
1306
-
1307
- var opts = instanceOptions(o, element),
1308
- flat = opts.flat,
1309
- showSelectionPalette = opts.showSelectionPalette,
1310
- localStorageKey = opts.localStorageKey,
1311
- theme = opts.theme,
1312
- callbacks = opts.callbacks,
1313
- resize = throttle(reflow, 10),
1314
- visible = false,
1315
- dragWidth = 0,
1316
- dragHeight = 0,
1317
- dragHelperHeight = 0,
1318
- slideHeight = 0,
1319
- slideWidth = 0,
1320
- alphaWidth = 0,
1321
- alphaSlideHelperWidth = 0,
1322
- slideHelperHeight = 0,
1323
- currentHue = 0,
1324
- currentSaturation = 0,
1325
- currentValue = 0,
1326
- currentAlpha = 1,
1327
- palette = [],
1328
- paletteArray = [],
1329
- paletteLookup = {},
1330
- selectionPalette = opts.selectionPalette.slice(0),
1331
- maxSelectionSize = opts.maxSelectionSize,
1332
- draggingClass = "sp-dragging",
1333
- shiftMovementDirection = null;
1334
-
1335
- var doc = element.ownerDocument,
1336
- body = doc.body,
1337
- boundElement = $(element),
1338
- disabled = false,
1339
- container = $(markup, doc).addClass(theme),
1340
- dragger = container.find(".sp-color"),
1341
- dragHelper = container.find(".sp-dragger"),
1342
- slider = container.find(".sp-hue"),
1343
- slideHelper = container.find(".sp-slider"),
1344
- alphaSliderInner = container.find(".sp-alpha-inner"),
1345
- alphaSlider = container.find(".sp-alpha"),
1346
- alphaSlideHelper = container.find(".sp-alpha-handle"),
1347
- textInput = container.find(".sp-input"),
1348
- paletteContainer = container.find(".sp-palette"),
1349
- initialColorContainer = container.find(".sp-initial"),
1350
- cancelButton = container.find(".sp-cancel"),
1351
- clearButton = container.find(".sp-clear"),
1352
- chooseButton = container.find(".sp-choose"),
1353
- isInput = boundElement.is("input"),
1354
- isInputTypeColor = isInput && inputTypeColorSupport && boundElement.attr("type") === "color",
1355
- shouldReplace = isInput && !flat,
1356
- replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className) : $([]),
1357
- offsetElement = (shouldReplace) ? replacer : boundElement,
1358
- previewElement = replacer.find(".sp-preview-inner"),
1359
- initialColor = opts.color || (isInput && boundElement.val()),
1360
- colorOnShow = false,
1361
- preferredFormat = opts.preferredFormat,
1362
- currentPreferredFormat = preferredFormat,
1363
- clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,
1364
- isEmpty = !initialColor,
1365
- allowEmpty = opts.allowEmpty && !isInputTypeColor;
1366
-
1367
- function applyOptions() {
1368
-
1369
- if (opts.showPaletteOnly) {
1370
- opts.showPalette = true;
1371
- }
1372
-
1373
- if (opts.palette) {
1374
- palette = opts.palette.slice(0);
1375
- paletteArray = $.isArray(palette[0]) ? palette : [palette];
1376
- paletteLookup = {};
1377
- for (var i = 0; i < paletteArray.length; i++) {
1378
- for (var j = 0; j < paletteArray[i].length; j++) {
1379
- var rgb = tinycolor(paletteArray[i][j]).toRgbString();
1380
- paletteLookup[rgb] = true;
1381
- }
1382
- }
1383
- }
1384
-
1385
- container.toggleClass("sp-flat", flat);
1386
- container.toggleClass("sp-input-disabled", !opts.showInput);
1387
- container.toggleClass("sp-alpha-enabled", opts.showAlpha);
1388
- container.toggleClass("sp-clear-enabled", allowEmpty);
1389
- container.toggleClass("sp-buttons-disabled", !opts.showButtons);
1390
- container.toggleClass("sp-palette-disabled", !opts.showPalette);
1391
- container.toggleClass("sp-palette-only", opts.showPaletteOnly);
1392
- container.toggleClass("sp-initial-disabled", !opts.showInitial);
1393
- container.addClass(opts.className);
1394
-
1395
- reflow();
1396
- }
1397
-
1398
- function initialize() {
1399
-
1400
- if (IE) {
1401
- container.find("*:not(input)").attr("unselectable", "on");
1402
- }
1403
-
1404
- applyOptions();
1405
-
1406
- if (shouldReplace) {
1407
- boundElement.after(replacer).hide();
1408
- }
1409
-
1410
- if (!allowEmpty) {
1411
- clearButton.hide();
1412
- }
1413
-
1414
- if (flat) {
1415
- boundElement.after(container).hide();
1416
- }
1417
- else {
1418
-
1419
- var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo);
1420
- if (appendTo.length !== 1) {
1421
- appendTo = $("body");
1422
- }
1423
-
1424
- appendTo.append(container);
1425
- }
1426
-
1427
- updateSelectionPaletteFromStorage();
1428
-
1429
- offsetElement.bind("click.spectrum touchstart.spectrum", function (e) {
1430
- if (!disabled) {
1431
- toggle();
1432
- }
1433
-
1434
- e.stopPropagation();
1435
-
1436
- if (!$(e.target).is("input")) {
1437
- e.preventDefault();
1438
- }
1439
- });
1440
-
1441
- if(boundElement.is(":disabled") || (opts.disabled === true)) {
1442
- disable();
1443
- }
1444
-
1445
- // Prevent clicks from bubbling up to document. This would cause it to be hidden.
1446
- container.click(stopPropagation);
1447
-
1448
- // Handle user typed input
1449
- textInput.change(setFromTextInput);
1450
- textInput.bind("paste", function () {
1451
- setTimeout(setFromTextInput, 1);
1452
- });
1453
- textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
1454
-
1455
- cancelButton.text(opts.cancelText);
1456
- cancelButton.bind("click.spectrum", function (e) {
1457
- e.stopPropagation();
1458
- e.preventDefault();
1459
- hide("cancel");
1460
- });
1461
-
1462
- clearButton.attr("title", opts.clearText);
1463
- clearButton.bind("click.spectrum", function (e) {
1464
- e.stopPropagation();
1465
- e.preventDefault();
1466
- isEmpty = true;
1467
- move();
1468
-
1469
- if(flat) {
1470
- //for the flat style, this is a change event
1471
- updateOriginalInput(true);
1472
- }
1473
- });
1474
-
1475
- chooseButton.text(opts.chooseText);
1476
- chooseButton.bind("click.spectrum", function (e) {
1477
- e.stopPropagation();
1478
- e.preventDefault();
1479
-
1480
- if (isValid()) {
1481
- updateOriginalInput(true);
1482
- hide();
1483
- }
1484
- });
1485
-
1486
- draggable(alphaSlider, function (dragX, dragY, e) {
1487
- currentAlpha = (dragX / alphaWidth);
1488
- isEmpty = false;
1489
- if (e.shiftKey) {
1490
- currentAlpha = Math.round(currentAlpha * 10) / 10;
1491
- }
1492
-
1493
- move();
1494
- }, dragStart, dragStop);
1495
-
1496
- draggable(slider, function (dragX, dragY) {
1497
- currentHue = parseFloat(dragY / slideHeight);
1498
- isEmpty = false;
1499
- if (!opts.showAlpha) {
1500
- currentAlpha = 1;
1501
- }
1502
- move();
1503
- }, dragStart, dragStop);
1504
-
1505
- draggable(dragger, function (dragX, dragY, e) {
1506
-
1507
- // shift+drag should snap the movement to either the x or y axis.
1508
- if (!e.shiftKey) {
1509
- shiftMovementDirection = null;
1510
- }
1511
- else if (!shiftMovementDirection) {
1512
- var oldDragX = currentSaturation * dragWidth;
1513
- var oldDragY = dragHeight - (currentValue * dragHeight);
1514
- var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);
1515
-
1516
- shiftMovementDirection = furtherFromX ? "x" : "y";
1517
- }
1518
-
1519
- var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x";
1520
- var setValue = !shiftMovementDirection || shiftMovementDirection === "y";
1521
-
1522
- if (setSaturation) {
1523
- currentSaturation = parseFloat(dragX / dragWidth);
1524
- }
1525
- if (setValue) {
1526
- currentValue = parseFloat((dragHeight - dragY) / dragHeight);
1527
- }
1528
-
1529
- isEmpty = false;
1530
- if (!opts.showAlpha) {
1531
- currentAlpha = 1;
1532
- }
1533
-
1534
- move();
1535
-
1536
- }, dragStart, dragStop);
1537
-
1538
- if (!!initialColor) {
1539
- set(initialColor);
1540
-
1541
- // In case color was black - update the preview UI and set the format
1542
- // since the set function will not run (default color is black).
1543
- updateUI();
1544
- currentPreferredFormat = preferredFormat || tinycolor(initialColor).format;
1545
-
1546
- addColorToSelectionPalette(initialColor);
1547
- }
1548
- else {
1549
- updateUI();
1550
- }
1551
-
1552
- if (flat) {
1553
- show();
1554
- }
1555
-
1556
- function palletElementClick(e) {
1557
- if (e.data && e.data.ignore) {
1558
- set($(this).data("color"));
1559
- move();
1560
- }
1561
- else {
1562
- set($(this).data("color"));
1563
- move();
1564
- updateOriginalInput(true);
1565
- hide();
1566
- }
1567
-
1568
- return false;
1569
- }
1570
-
1571
- var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
1572
- paletteContainer.delegate(".sp-thumb-el", paletteEvent, palletElementClick);
1573
- initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, palletElementClick);
1574
- }
1575
-
1576
- function updateSelectionPaletteFromStorage() {
1577
-
1578
- if (localStorageKey && window.localStorage) {
1579
-
1580
- // Migrate old palettes over to new format. May want to remove this eventually.
1581
- try {
1582
- var oldPalette = window.localStorage[localStorageKey].split(",#");
1583
- if (oldPalette.length > 1) {
1584
- delete window.localStorage[localStorageKey];
1585
- $.each(oldPalette, function(i, c) {
1586
- addColorToSelectionPalette(c);
1587
- });
1588
- }
1589
- }
1590
- catch(e) { }
1591
-
1592
- try {
1593
- selectionPalette = window.localStorage[localStorageKey].split(";");
1594
- }
1595
- catch (e) { }
1596
- }
1597
- }
1598
-
1599
- function addColorToSelectionPalette(color) {
1600
- if (showSelectionPalette) {
1601
- var rgb = tinycolor(color).toRgbString();
1602
- if (!paletteLookup[rgb] && selectionPalette.indexOf(rgb) === -1) {
1603
- selectionPalette.push(rgb);
1604
- while(selectionPalette.length > maxSelectionSize) {
1605
- selectionPalette.shift();
1606
- }
1607
- }
1608
-
1609
- if (localStorageKey && window.localStorage) {
1610
- try {
1611
- window.localStorage[localStorageKey] = selectionPalette.join(";");
1612
- }
1613
- catch(e) { }
1614
- }
1615
- }
1616
- }
1617
-
1618
- function getUniqueSelectionPalette() {
1619
- var unique = [];
1620
- if (opts.showPalette) {
1621
- for (i = 0; i < selectionPalette.length; i++) {
1622
- var rgb = tinycolor(selectionPalette[i]).toRgbString();
1623
-
1624
- if (!paletteLookup[rgb]) {
1625
- unique.push(selectionPalette[i]);
1626
- }
1627
- }
1628
- }
1629
-
1630
- return unique.reverse().slice(0, opts.maxSelectionSize);
1631
- }
1632
-
1633
- function drawPalette() {
1634
-
1635
- var currentColor = get();
1636
-
1637
- var html = $.map(paletteArray, function (palette, i) {
1638
- return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i);
1639
- });
1640
-
1641
- updateSelectionPaletteFromStorage();
1642
-
1643
- if (selectionPalette) {
1644
- html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection"));
1645
- }
1646
-
1647
- paletteContainer.html(html.join(""));
1648
- }
1649
-
1650
- function drawInitial() {
1651
- if (opts.showInitial) {
1652
- var initial = colorOnShow;
1653
- var current = get();
1654
- initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial"));
1655
- }
1656
- }
1657
-
1658
- function dragStart() {
1659
- if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
1660
- reflow();
1661
- }
1662
- container.addClass(draggingClass);
1663
- shiftMovementDirection = null;
1664
- boundElement.trigger('dragstart.spectrum', [ get() ]);
1665
- }
1666
-
1667
- function dragStop() {
1668
- container.removeClass(draggingClass);
1669
- boundElement.trigger('dragstop.spectrum', [ get() ]);
1670
- }
1671
-
1672
- function setFromTextInput() {
1673
-
1674
- var value = textInput.val();
1675
-
1676
- if ((value === null || value === "") && allowEmpty) {
1677
- set(null);
1678
- updateOriginalInput(true);
1679
- }
1680
- else {
1681
- var tiny = tinycolor(value);
1682
- if (tiny.ok) {
1683
- set(tiny);
1684
- updateOriginalInput(true);
1685
- }
1686
- else {
1687
- textInput.addClass("sp-validation-error");
1688
- }
1689
- }
1690
- }
1691
-
1692
- function toggle() {
1693
- if (visible) {
1694
- hide();
1695
- }
1696
- else {
1697
- show();
1698
- }
1699
- }
1700
-
1701
- function show() {
1702
- var event = $.Event('beforeShow.spectrum');
1703
-
1704
- if (visible) {
1705
- reflow();
1706
- return;
1707
- }
1708
-
1709
- boundElement.trigger(event, [ get() ]);
1710
-
1711
- if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {
1712
- return;
1713
- }
1714
-
1715
- hideAll();
1716
- visible = true;
1717
-
1718
- $(doc).bind("click.spectrum", hide);
1719
- $(window).bind("resize.spectrum", resize);
1720
- replacer.addClass("sp-active");
1721
- container.removeClass("sp-hidden");
1722
-
1723
- reflow();
1724
- updateUI();
1725
-
1726
- colorOnShow = get();
1727
-
1728
- drawInitial();
1729
- callbacks.show(colorOnShow);
1730
- boundElement.trigger('show.spectrum', [ colorOnShow ]);
1731
- }
1732
-
1733
- function hide(e) {
1734
-
1735
- // Return on right click
1736
- if (e && e.type == "click" && e.button == 2) { return; }
1737
-
1738
- // Return if hiding is unnecessary
1739
- if (!visible || flat) { return; }
1740
- visible = false;
1741
-
1742
- $(doc).unbind("click.spectrum", hide);
1743
- $(window).unbind("resize.spectrum", resize);
1744
-
1745
- replacer.removeClass("sp-active");
1746
- container.addClass("sp-hidden");
1747
-
1748
- var colorHasChanged = !tinycolor.equals(get(), colorOnShow);
1749
-
1750
- if (colorHasChanged) {
1751
- if (clickoutFiresChange && e !== "cancel") {
1752
- updateOriginalInput(true);
1753
- }
1754
- else {
1755
- revert();
1756
- }
1757
- }
1758
-
1759
- callbacks.hide(get());
1760
- boundElement.trigger('hide.spectrum', [ get() ]);
1761
- }
1762
-
1763
- function revert() {
1764
- set(colorOnShow, true);
1765
- }
1766
-
1767
- function set(color, ignoreFormatChange) {
1768
- if (tinycolor.equals(color, get())) {
1769
- // Update UI just in case a validation error needs
1770
- // to be cleared.
1771
- updateUI();
1772
- return;
1773
- }
1774
-
1775
- var newColor, newHsv;
1776
- if (!color && allowEmpty) {
1777
- isEmpty = true;
1778
- } else {
1779
- isEmpty = false;
1780
- newColor = tinycolor(color);
1781
- newHsv = newColor.toHsv();
1782
-
1783
- currentHue = (newHsv.h % 360) / 360;
1784
- currentSaturation = newHsv.s;
1785
- currentValue = newHsv.v;
1786
- currentAlpha = newHsv.a;
1787
- }
1788
- updateUI();
1789
-
1790
- if (newColor && newColor.ok && !ignoreFormatChange) {
1791
- currentPreferredFormat = preferredFormat || newColor.format;
1792
- }
1793
- }
1794
-
1795
- function get(opts) {
1796
- opts = opts || { };
1797
-
1798
- if (allowEmpty && isEmpty) {
1799
- return null;
1800
- }
1801
-
1802
- return tinycolor.fromRatio({
1803
- h: currentHue,
1804
- s: currentSaturation,
1805
- v: currentValue,
1806
- a: Math.round(currentAlpha * 100) / 100
1807
- }, { format: opts.format || currentPreferredFormat });
1808
- }
1809
-
1810
- function isValid() {
1811
- return !textInput.hasClass("sp-validation-error");
1812
- }
1813
-
1814
- function move() {
1815
- updateUI();
1816
-
1817
- callbacks.move(get());
1818
- boundElement.trigger('move.spectrum', [ get() ]);
1819
- }
1820
-
1821
- function updateUI() {
1822
-
1823
- textInput.removeClass("sp-validation-error");
1824
-
1825
- updateHelperLocations();
1826
-
1827
- // Update dragger background color (gradients take care of saturation and value).
1828
- var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });
1829
- dragger.css("background-color", flatColor.toHexString());
1830
-
1831
- // Get a format that alpha will be included in (hex and names ignore alpha)
1832
- var format = currentPreferredFormat;
1833
- if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) {
1834
- if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") {
1835
- format = "rgb";
1836
- }
1837
- }
1838
-
1839
- var realColor = get({ format: format }),
1840
- displayColor = '';
1841
-
1842
- //reset background info for preview element
1843
- previewElement.removeClass("sp-clear-display");
1844
- previewElement.css('background-color', 'transparent');
1845
-
1846
- if (!realColor && allowEmpty) {
1847
- // Update the replaced elements background with icon indicating no color selection
1848
- previewElement.addClass("sp-clear-display");
1849
- }
1850
- else {
1851
- var realHex = realColor.toHexString(),
1852
- realRgb = realColor.toRgbString();
1853
-
1854
- // Update the replaced elements background color (with actual selected color)
1855
- if (rgbaSupport || realColor.alpha === 1) {
1856
- previewElement.css("background-color", realRgb);
1857
- }
1858
- else {
1859
- previewElement.css("background-color", "transparent");
1860
- previewElement.css("filter", realColor.toFilter());
1861
- }
1862
-
1863
- if (opts.showAlpha) {
1864
- var rgb = realColor.toRgb();
1865
- rgb.a = 0;
1866
- var realAlpha = tinycolor(rgb).toRgbString();
1867
- var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
1868
-
1869
- if (IE) {
1870
- alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
1871
- }
1872
- else {
1873
- alphaSliderInner.css("background", "-webkit-" + gradient);
1874
- alphaSliderInner.css("background", "-moz-" + gradient);
1875
- alphaSliderInner.css("background", "-ms-" + gradient);
1876
- // Use current syntax gradient on unprefixed property.
1877
- alphaSliderInner.css("background",
1878
- "linear-gradient(to right, " + realAlpha + ", " + realHex + ")");
1879
- }
1880
- }
1881
-
1882
- displayColor = realColor.toString(format);
1883
- }
1884
-
1885
- // Update the text entry input as it changes happen
1886
- if (opts.showInput) {
1887
- textInput.val(displayColor);
1888
- }
1889
-
1890
- if (opts.showPalette) {
1891
- drawPalette();
1892
- }
1893
-
1894
- drawInitial();
1895
- }
1896
-
1897
- function updateHelperLocations() {
1898
- var s = currentSaturation;
1899
- var v = currentValue;
1900
-
1901
- if(allowEmpty && isEmpty) {
1902
- //if selected color is empty, hide the helpers
1903
- alphaSlideHelper.hide();
1904
- slideHelper.hide();
1905
- dragHelper.hide();
1906
- }
1907
- else {
1908
- //make sure helpers are visible
1909
- alphaSlideHelper.show();
1910
- slideHelper.show();
1911
- dragHelper.show();
1912
-
1913
- // Where to show the little circle in that displays your current selected color
1914
- var dragX = s * dragWidth;
1915
- var dragY = dragHeight - (v * dragHeight);
1916
- dragX = Math.max(
1917
- -dragHelperHeight,
1918
- Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
1919
- );
1920
- dragY = Math.max(
1921
- -dragHelperHeight,
1922
- Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
1923
- );
1924
- dragHelper.css({
1925
- "top": dragY + "px",
1926
- "left": dragX + "px"
1927
- });
1928
-
1929
- var alphaX = currentAlpha * alphaWidth;
1930
- alphaSlideHelper.css({
1931
- "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px"
1932
- });
1933
-
1934
- // Where to show the bar that displays your current selected hue
1935
- var slideY = (currentHue) * slideHeight;
1936
- slideHelper.css({
1937
- "top": (slideY - slideHelperHeight) + "px"
1938
- });
1939
- }
1940
- }
1941
-
1942
- function updateOriginalInput(fireCallback) {
1943
- var color = get(),
1944
- displayColor = '',
1945
- hasChanged = !tinycolor.equals(color, colorOnShow);
1946
-
1947
- if (color) {
1948
- displayColor = color.toString(currentPreferredFormat);
1949
- // Update the selection palette with the current color
1950
- addColorToSelectionPalette(color);
1951
- }
1952
-
1953
- if (isInput) {
1954
- boundElement.val(displayColor);
1955
- }
1956
-
1957
- colorOnShow = color;
1958
-
1959
- if (fireCallback && hasChanged) {
1960
- callbacks.change(color);
1961
- boundElement.trigger('change', [ color ]);
1962
- }
1963
- }
1964
-
1965
- function reflow() {
1966
- dragWidth = dragger.width();
1967
- dragHeight = dragger.height();
1968
- dragHelperHeight = dragHelper.height();
1969
- slideWidth = slider.width();
1970
- slideHeight = slider.height();
1971
- slideHelperHeight = slideHelper.height();
1972
- alphaWidth = alphaSlider.width();
1973
- alphaSlideHelperWidth = alphaSlideHelper.width();
1974
-
1975
- if (!flat) {
1976
- container.css("position", "absolute");
1977
- container.offset(getOffset(container, offsetElement));
1978
- }
1979
-
1980
- updateHelperLocations();
1981
-
1982
- if (opts.showPalette) {
1983
- drawPalette();
1984
- }
1985
-
1986
- boundElement.trigger('reflow.spectrum');
1987
- }
1988
-
1989
- function destroy() {
1990
- boundElement.show();
1991
- offsetElement.unbind("click.spectrum touchstart.spectrum");
1992
- container.remove();
1993
- replacer.remove();
1994
- spectrums[spect.id] = null;
1995
- }
1996
-
1997
- function option(optionName, optionValue) {
1998
- if (optionName === undefined) {
1999
- return $.extend({}, opts);
2000
- }
2001
- if (optionValue === undefined) {
2002
- return opts[optionName];
2003
- }
2004
-
2005
- opts[optionName] = optionValue;
2006
- applyOptions();
2007
- }
2008
-
2009
- function enable() {
2010
- disabled = false;
2011
- boundElement.attr("disabled", false);
2012
- offsetElement.removeClass("sp-disabled");
2013
- }
2014
-
2015
- function disable() {
2016
- hide();
2017
- disabled = true;
2018
- boundElement.attr("disabled", true);
2019
- offsetElement.addClass("sp-disabled");
2020
- }
2021
-
2022
- initialize();
2023
-
2024
- var spect = {
2025
- show: show,
2026
- hide: hide,
2027
- toggle: toggle,
2028
- reflow: reflow,
2029
- option: option,
2030
- enable: enable,
2031
- disable: disable,
2032
- set: function (c) {
2033
- set(c);
2034
- updateOriginalInput();
2035
- },
2036
- get: get,
2037
- destroy: destroy,
2038
- container: container
2039
- };
2040
-
2041
- spect.id = spectrums.push(spect) - 1;
2042
-
2043
- return spect;
2044
- }
2045
-
2046
- /**
2047
- * checkOffset - get the offset below/above and left/right element depending on screen position
2048
- * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
2049
- */
2050
- function getOffset(picker, input) {
2051
- var extraY = 0;
2052
- var dpWidth = picker.outerWidth();
2053
- var dpHeight = picker.outerHeight();
2054
- var inputHeight = input.outerHeight();
2055
- var doc = picker[0].ownerDocument;
2056
- var docElem = doc.documentElement;
2057
- var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
2058
- var viewHeight = docElem.clientHeight + $(doc).scrollTop();
2059
- var offset = input.offset();
2060
- offset.top += inputHeight;
2061
-
2062
- offset.left -=
2063
- Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
2064
- Math.abs(offset.left + dpWidth - viewWidth) : 0);
2065
-
2066
- offset.top -=
2067
- Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
2068
- Math.abs(dpHeight + inputHeight - extraY) : extraY));
2069
-
2070
- return offset;
2071
- }
2072
-
2073
- /**
2074
- * noop - do nothing
2075
- */
2076
- function noop() {
2077
-
2078
- }
2079
-
2080
- /**
2081
- * stopPropagation - makes the code only doing this a little easier to read in line
2082
- */
2083
- function stopPropagation(e) {
2084
- e.stopPropagation();
2085
- }
2086
-
2087
- /**
2088
- * Create a function bound to a given object
2089
- * Thanks to underscore.js
2090
- */
2091
- function bind(func, obj) {
2092
- var slice = Array.prototype.slice;
2093
- var args = slice.call(arguments, 2);
2094
- return function () {
2095
- return func.apply(obj, args.concat(slice.call(arguments)));
2096
- };
2097
- }
2098
-
2099
- /**
2100
- * Lightweight drag helper. Handles containment within the element, so that
2101
- * when dragging, the x is within [0,element.width] and y is within [0,element.height]
2102
- */
2103
- function draggable(element, onmove, onstart, onstop) {
2104
- onmove = onmove || function () { };
2105
- onstart = onstart || function () { };
2106
- onstop = onstop || function () { };
2107
- var doc = element.ownerDocument || document;
2108
- var dragging = false;
2109
- var offset = {};
2110
- var maxHeight = 0;
2111
- var maxWidth = 0;
2112
- var hasTouch = ('ontouchstart' in window);
2113
-
2114
- var duringDragEvents = {};
2115
- duringDragEvents["selectstart"] = prevent;
2116
- duringDragEvents["dragstart"] = prevent;
2117
- duringDragEvents["touchmove mousemove"] = move;
2118
- duringDragEvents["touchend mouseup"] = stop;
2119
-
2120
- function prevent(e) {
2121
- if (e.stopPropagation) {
2122
- e.stopPropagation();
2123
- }
2124
- if (e.preventDefault) {
2125
- e.preventDefault();
2126
- }
2127
- e.returnValue = false;
2128
- }
2129
-
2130
- function move(e) {
2131
- if (dragging) {
2132
- // Mouseup happened outside of window
2133
- if (IE && document.documentMode < 9 && !e.button) {
2134
- return stop();
2135
- }
2136
-
2137
- var touches = e.originalEvent.touches;
2138
- var pageX = touches ? touches[0].pageX : e.pageX;
2139
- var pageY = touches ? touches[0].pageY : e.pageY;
2140
-
2141
- var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
2142
- var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
2143
-
2144
- if (hasTouch) {
2145
- // Stop scrolling in iOS
2146
- prevent(e);
2147
- }
2148
-
2149
- onmove.apply(element, [dragX, dragY, e]);
2150
- }
2151
- }
2152
-
2153
- function start(e) {
2154
- var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
2155
- var touches = e.originalEvent.touches;
2156
-
2157
- if (!rightclick && !dragging) {
2158
- if (onstart.apply(element, arguments) !== false) {
2159
- dragging = true;
2160
- maxHeight = $(element).height();
2161
- maxWidth = $(element).width();
2162
- offset = $(element).offset();
2163
-
2164
- $(doc).bind(duringDragEvents);
2165
- $(doc.body).addClass("sp-dragging");
2166
-
2167
- if (!hasTouch) {
2168
- move(e);
2169
- }
2170
-
2171
- prevent(e);
2172
- }
2173
- }
2174
- }
2175
-
2176
- function stop() {
2177
- if (dragging) {
2178
- $(doc).unbind(duringDragEvents);
2179
- $(doc.body).removeClass("sp-dragging");
2180
- onstop.apply(element, arguments);
2181
- }
2182
- dragging = false;
2183
- }
2184
-
2185
- $(element).bind("touchstart mousedown", start);
2186
- }
2187
-
2188
- function throttle(func, wait, debounce) {
2189
- var timeout;
2190
- return function () {
2191
- var context = this, args = arguments;
2192
- var throttler = function () {
2193
- timeout = null;
2194
- func.apply(context, args);
2195
- };
2196
- if (debounce) clearTimeout(timeout);
2197
- if (debounce || !timeout) timeout = setTimeout(throttler, wait);
2198
- };
2199
- }
2200
-
2201
- function log(){/* jshint -W021 */if(window.console){if(Function.prototype.bind)log=Function.prototype.bind.call(console.log,console);else log=function(){Function.prototype.apply.call(console.log,console,arguments);};log.apply(this,arguments);}}
2202
-
2203
- /**
2204
- * Define a jQuery plugin
2205
- */
2206
- var dataID = "spectrum.id";
2207
- $.fn.spectrum = function (opts, extra) {
2208
-
2209
- if (typeof opts == "string") {
2210
-
2211
- var returnValue = this;
2212
- var args = Array.prototype.slice.call( arguments, 1 );
2213
-
2214
- this.each(function () {
2215
- var spect = spectrums[$(this).data(dataID)];
2216
- if (spect) {
2217
- var method = spect[opts];
2218
- if (!method) {
2219
- throw new Error( "Spectrum: no such method: '" + opts + "'" );
2220
- }
2221
-
2222
- if (opts == "get") {
2223
- returnValue = spect.get();
2224
- }
2225
- else if (opts == "container") {
2226
- returnValue = spect.container;
2227
- }
2228
- else if (opts == "option") {
2229
- returnValue = spect.option.apply(spect, args);
2230
- }
2231
- else if (opts == "destroy") {
2232
- spect.destroy();
2233
- $(this).removeData(dataID);
2234
- }
2235
- else {
2236
- method.apply(spect, args);
2237
- }
2238
- }
2239
- });
2240
-
2241
- return returnValue;
2242
- }
2243
-
2244
- // Initializing a new instance of spectrum
2245
- return this.spectrum("destroy").each(function () {
2246
- var options = $.extend({}, opts, $(this).data());
2247
- var spect = spectrum(this, options);
2248
- $(this).data(dataID, spect.id);
2249
- });
2250
- };
2251
-
2252
- $.fn.spectrum.load = true;
2253
- $.fn.spectrum.loadOpts = {};
2254
- $.fn.spectrum.draggable = draggable;
2255
- $.fn.spectrum.defaults = defaultOpts;
2256
-
2257
- $.spectrum = { };
2258
- $.spectrum.localization = { };
2259
- $.spectrum.palettes = { };
2260
-
2261
- $.fn.spectrum.processNativeColorInputs = function () {
2262
- if (!inputTypeColorSupport) {
2263
- $("input[type=color]").spectrum({
2264
- preferredFormat: "hex6"
2265
- });
2266
- }
2267
- };
2268
-
2269
- // TinyColor v0.9.17
2270
- // https://github.com/bgrins/TinyColor
2271
- // 2013-08-10, Brian Grinstead, MIT License
2272
-
2273
- (function() {
2274
-
2275
- var trimLeft = /^[\s,#]+/,
2276
- trimRight = /\s+$/,
2277
- tinyCounter = 0,
2278
- math = Math,
2279
- mathRound = math.round,
2280
- mathMin = math.min,
2281
- mathMax = math.max,
2282
- mathRandom = math.random;
2283
-
2284
- function tinycolor (color, opts) {
2285
-
2286
- color = (color) ? color : '';
2287
- opts = opts || { };
2288
-
2289
- // If input is already a tinycolor, return itself
2290
- if (typeof color == "object" && color.hasOwnProperty("_tc_id")) {
2291
- return color;
2292
- }
2293
-
2294
- var rgb = inputToRGB(color);
2295
- var r = rgb.r,
2296
- g = rgb.g,
2297
- b = rgb.b,
2298
- a = rgb.a,
2299
- roundA = mathRound(100*a) / 100,
2300
- format = opts.format || rgb.format;
2301
-
2302
- // Don't let the range of [0,255] come back in [0,1].
2303
- // Potentially lose a little bit of precision here, but will fix issues where
2304
- // .5 gets interpreted as half of the total, instead of half of 1
2305
- // If it was supposed to be 128, this was already taken care of by `inputToRgb`
2306
- if (r < 1) { r = mathRound(r); }
2307
- if (g < 1) { g = mathRound(g); }
2308
- if (b < 1) { b = mathRound(b); }
2309
-
2310
- return {
2311
- ok: rgb.ok,
2312
- format: format,
2313
- _tc_id: tinyCounter++,
2314
- alpha: a,
2315
- getAlpha: function() {
2316
- return a;
2317
- },
2318
- setAlpha: function(value) {
2319
- a = boundAlpha(value);
2320
- roundA = mathRound(100*a) / 100;
2321
- },
2322
- toHsv: function() {
2323
- var hsv = rgbToHsv(r, g, b);
2324
- return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: a };
2325
- },
2326
- toHsvString: function() {
2327
- var hsv = rgbToHsv(r, g, b);
2328
- var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
2329
- return (a == 1) ?
2330
- "hsv(" + h + ", " + s + "%, " + v + "%)" :
2331
- "hsva(" + h + ", " + s + "%, " + v + "%, "+ roundA + ")";
2332
- },
2333
- toHsl: function() {
2334
- var hsl = rgbToHsl(r, g, b);
2335
- return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: a };
2336
- },
2337
- toHslString: function() {
2338
- var hsl = rgbToHsl(r, g, b);
2339
- var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
2340
- return (a == 1) ?
2341
- "hsl(" + h + ", " + s + "%, " + l + "%)" :
2342
- "hsla(" + h + ", " + s + "%, " + l + "%, "+ roundA + ")";
2343
- },
2344
- toHex: function(allow3Char) {
2345
- return rgbToHex(r, g, b, allow3Char);
2346
- },
2347
- toHexString: function(allow3Char) {
2348
- return '#' + this.toHex(allow3Char);
2349
- },
2350
- toHex8: function() {
2351
- return rgbaToHex(r, g, b, a);
2352
- },
2353
- toHex8String: function() {
2354
- return '#' + this.toHex8();
2355
- },
2356
- toRgb: function() {
2357
- return { r: mathRound(r), g: mathRound(g), b: mathRound(b), a: a };
2358
- },
2359
- toRgbString: function() {
2360
- return (a == 1) ?
2361
- "rgb(" + mathRound(r) + ", " + mathRound(g) + ", " + mathRound(b) + ")" :
2362
- "rgba(" + mathRound(r) + ", " + mathRound(g) + ", " + mathRound(b) + ", " + roundA + ")";
2363
- },
2364
- toPercentageRgb: function() {
2365
- return { r: mathRound(bound01(r, 255) * 100) + "%", g: mathRound(bound01(g, 255) * 100) + "%", b: mathRound(bound01(b, 255) * 100) + "%", a: a };
2366
- },
2367
- toPercentageRgbString: function() {
2368
- return (a == 1) ?
2369
- "rgb(" + mathRound(bound01(r, 255) * 100) + "%, " + mathRound(bound01(g, 255) * 100) + "%, " + mathRound(bound01(b, 255) * 100) + "%)" :
2370
- "rgba(" + mathRound(bound01(r, 255) * 100) + "%, " + mathRound(bound01(g, 255) * 100) + "%, " + mathRound(bound01(b, 255) * 100) + "%, " + roundA + ")";
2371
- },
2372
- toName: function() {
2373
- if (a === 0) {
2374
- return "transparent";
2375
- }
2376
-
2377
- return hexNames[rgbToHex(r, g, b, true)] || false;
2378
- },
2379
- toFilter: function(secondColor) {
2380
- var hex8String = '#' + rgbaToHex(r, g, b, a);
2381
- var secondHex8String = hex8String;
2382
- var gradientType = opts && opts.gradientType ? "GradientType = 1, " : "";
2383
-
2384
- if (secondColor) {
2385
- var s = tinycolor(secondColor);
2386
- secondHex8String = s.toHex8String();
2387
- }
2388
-
2389
- return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
2390
- },
2391
- toString: function(format) {
2392
- var formatSet = !!format;
2393
- format = format || this.format;
2394
-
2395
- var formattedString = false;
2396
- var hasAlphaAndFormatNotSet = !formatSet && a < 1 && a > 0;
2397
- var formatWithAlpha = hasAlphaAndFormatNotSet && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
2398
-
2399
- if (format === "rgb") {
2400
- formattedString = this.toRgbString();
2401
- }
2402
- if (format === "prgb") {
2403
- formattedString = this.toPercentageRgbString();
2404
- }
2405
- if (format === "hex" || format === "hex6") {
2406
- formattedString = this.toHexString();
2407
- }
2408
- if (format === "hex3") {
2409
- formattedString = this.toHexString(true);
2410
- }
2411
- if (format === "hex8") {
2412
- formattedString = this.toHex8String();
2413
- }
2414
- if (format === "name") {
2415
- formattedString = this.toName();
2416
- }
2417
- if (format === "hsl") {
2418
- formattedString = this.toHslString();
2419
- }
2420
- if (format === "hsv") {
2421
- formattedString = this.toHsvString();
2422
- }
2423
-
2424
- if (formatWithAlpha) {
2425
- return this.toRgbString();
2426
- }
2427
-
2428
- return formattedString || this.toHexString();
2429
- }
2430
- };
2431
- }
2432
-
2433
- // If input is an object, force 1 into "1.0" to handle ratios properly
2434
- // String input requires "1.0" as input, so 1 will be treated as 1
2435
- tinycolor.fromRatio = function(color, opts) {
2436
- if (typeof color == "object") {
2437
- var newColor = {};
2438
- for (var i in color) {
2439
- if (color.hasOwnProperty(i)) {
2440
- if (i === "a") {
2441
- newColor[i] = color[i];
2442
- }
2443
- else {
2444
- newColor[i] = convertToPercentage(color[i]);
2445
- }
2446
- }
2447
- }
2448
- color = newColor;
2449
- }
2450
-
2451
- return tinycolor(color, opts);
2452
- };
2453
-
2454
- // Given a string or object, convert that input to RGB
2455
- // Possible string inputs:
2456
- //
2457
- // "red"
2458
- // "#f00" or "f00"
2459
- // "#ff0000" or "ff0000"
2460
- // "#ff000000" or "ff000000"
2461
- // "rgb 255 0 0" or "rgb (255, 0, 0)"
2462
- // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
2463
- // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
2464
- // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
2465
- // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
2466
- // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
2467
- // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
2468
- //
2469
- function inputToRGB(color) {
2470
-
2471
- var rgb = { r: 0, g: 0, b: 0 };
2472
- var a = 1;
2473
- var ok = false;
2474
- var format = false;
2475
-
2476
- if (typeof color == "string") {
2477
- color = stringInputToObject(color);
2478
- }
2479
-
2480
- if (typeof color == "object") {
2481
- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
2482
- rgb = rgbToRgb(color.r, color.g, color.b);
2483
- ok = true;
2484
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
2485
- }
2486
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
2487
- color.s = convertToPercentage(color.s);
2488
- color.v = convertToPercentage(color.v);
2489
- rgb = hsvToRgb(color.h, color.s, color.v);
2490
- ok = true;
2491
- format = "hsv";
2492
- }
2493
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
2494
- color.s = convertToPercentage(color.s);
2495
- color.l = convertToPercentage(color.l);
2496
- rgb = hslToRgb(color.h, color.s, color.l);
2497
- ok = true;
2498
- format = "hsl";
2499
- }
2500
-
2501
- if (color.hasOwnProperty("a")) {
2502
- a = color.a;
2503
- }
2504
- }
2505
-
2506
- a = boundAlpha(a);
2507
-
2508
- return {
2509
- ok: ok,
2510
- format: color.format || format,
2511
- r: mathMin(255, mathMax(rgb.r, 0)),
2512
- g: mathMin(255, mathMax(rgb.g, 0)),
2513
- b: mathMin(255, mathMax(rgb.b, 0)),
2514
- a: a
2515
- };
2516
- }
2517
-
2518
-
2519
- // Conversion Functions
2520
- // --------------------
2521
-
2522
- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
2523
- // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
2524
-
2525
- // `rgbToRgb`
2526
- // Handle bounds / percentage checking to conform to CSS color spec
2527
- // <http://www.w3.org/TR/css3-color/>
2528
- // *Assumes:* r, g, b in [0, 255] or [0, 1]
2529
- // *Returns:* { r, g, b } in [0, 255]
2530
- function rgbToRgb(r, g, b){
2531
- return {
2532
- r: bound01(r, 255) * 255,
2533
- g: bound01(g, 255) * 255,
2534
- b: bound01(b, 255) * 255
2535
- };
2536
- }
2537
-
2538
- // `rgbToHsl`
2539
- // Converts an RGB color value to HSL.
2540
- // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
2541
- // *Returns:* { h, s, l } in [0,1]
2542
- function rgbToHsl(r, g, b) {
2543
-
2544
- r = bound01(r, 255);
2545
- g = bound01(g, 255);
2546
- b = bound01(b, 255);
2547
-
2548
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
2549
- var h, s, l = (max + min) / 2;
2550
-
2551
- if(max == min) {
2552
- h = s = 0; // achromatic
2553
- }
2554
- else {
2555
- var d = max - min;
2556
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
2557
- switch(max) {
2558
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
2559
- case g: h = (b - r) / d + 2; break;
2560
- case b: h = (r - g) / d + 4; break;
2561
- }
2562
-
2563
- h /= 6;
2564
- }
2565
-
2566
- return { h: h, s: s, l: l };
2567
- }
2568
-
2569
- // `hslToRgb`
2570
- // Converts an HSL color value to RGB.
2571
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
2572
- // *Returns:* { r, g, b } in the set [0, 255]
2573
- function hslToRgb(h, s, l) {
2574
- var r, g, b;
2575
-
2576
- h = bound01(h, 360);
2577
- s = bound01(s, 100);
2578
- l = bound01(l, 100);
2579
-
2580
- function hue2rgb(p, q, t) {
2581
- if(t < 0) t += 1;
2582
- if(t > 1) t -= 1;
2583
- if(t < 1/6) return p + (q - p) * 6 * t;
2584
- if(t < 1/2) return q;
2585
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
2586
- return p;
2587
- }
2588
-
2589
- if(s === 0) {
2590
- r = g = b = l; // achromatic
2591
- }
2592
- else {
2593
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2594
- var p = 2 * l - q;
2595
- r = hue2rgb(p, q, h + 1/3);
2596
- g = hue2rgb(p, q, h);
2597
- b = hue2rgb(p, q, h - 1/3);
2598
- }
2599
-
2600
- return { r: r * 255, g: g * 255, b: b * 255 };
2601
- }
2602
-
2603
- // `rgbToHsv`
2604
- // Converts an RGB color value to HSV
2605
- // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
2606
- // *Returns:* { h, s, v } in [0,1]
2607
- function rgbToHsv(r, g, b) {
2608
-
2609
- r = bound01(r, 255);
2610
- g = bound01(g, 255);
2611
- b = bound01(b, 255);
2612
-
2613
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
2614
- var h, s, v = max;
2615
-
2616
- var d = max - min;
2617
- s = max === 0 ? 0 : d / max;
2618
-
2619
- if(max == min) {
2620
- h = 0; // achromatic
2621
- }
2622
- else {
2623
- switch(max) {
2624
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
2625
- case g: h = (b - r) / d + 2; break;
2626
- case b: h = (r - g) / d + 4; break;
2627
- }
2628
- h /= 6;
2629
- }
2630
- return { h: h, s: s, v: v };
2631
- }
2632
-
2633
- // `hsvToRgb`
2634
- // Converts an HSV color value to RGB.
2635
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
2636
- // *Returns:* { r, g, b } in the set [0, 255]
2637
- function hsvToRgb(h, s, v) {
2638
-
2639
- h = bound01(h, 360) * 6;
2640
- s = bound01(s, 100);
2641
- v = bound01(v, 100);
2642
-
2643
- var i = math.floor(h),
2644
- f = h - i,
2645
- p = v * (1 - s),
2646
- q = v * (1 - f * s),
2647
- t = v * (1 - (1 - f) * s),
2648
- mod = i % 6,
2649
- r = [v, q, p, p, t, v][mod],
2650
- g = [t, v, v, q, p, p][mod],
2651
- b = [p, p, t, v, v, q][mod];
2652
-
2653
- return { r: r * 255, g: g * 255, b: b * 255 };
2654
- }
2655
-
2656
- // `rgbToHex`
2657
- // Converts an RGB color to hex
2658
- // Assumes r, g, and b are contained in the set [0, 255]
2659
- // Returns a 3 or 6 character hex
2660
- function rgbToHex(r, g, b, allow3Char) {
2661
-
2662
- var hex = [
2663
- pad2(mathRound(r).toString(16)),
2664
- pad2(mathRound(g).toString(16)),
2665
- pad2(mathRound(b).toString(16))
2666
- ];
2667
-
2668
- // Return a 3 character hex if possible
2669
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
2670
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
2671
- }
2672
-
2673
- return hex.join("");
2674
- }
2675
- // `rgbaToHex`
2676
- // Converts an RGBA color plus alpha transparency to hex
2677
- // Assumes r, g, b and a are contained in the set [0, 255]
2678
- // Returns an 8 character hex
2679
- function rgbaToHex(r, g, b, a) {
2680
-
2681
- var hex = [
2682
- pad2(convertDecimalToHex(a)),
2683
- pad2(mathRound(r).toString(16)),
2684
- pad2(mathRound(g).toString(16)),
2685
- pad2(mathRound(b).toString(16))
2686
- ];
2687
-
2688
- return hex.join("");
2689
- }
2690
-
2691
- // `equals`
2692
- // Can be called with any tinycolor input
2693
- tinycolor.equals = function (color1, color2) {
2694
- if (!color1 || !color2) { return false; }
2695
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
2696
- };
2697
- tinycolor.random = function() {
2698
- return tinycolor.fromRatio({
2699
- r: mathRandom(),
2700
- g: mathRandom(),
2701
- b: mathRandom()
2702
- });
2703
- };
2704
-
2705
-
2706
- // Modification Functions
2707
- // ----------------------
2708
- // Thanks to less.js for some of the basics here
2709
- // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
2710
-
2711
- tinycolor.desaturate = function (color, amount) {
2712
- amount = (amount === 0) ? 0 : (amount || 10);
2713
- var hsl = tinycolor(color).toHsl();
2714
- hsl.s -= amount / 100;
2715
- hsl.s = clamp01(hsl.s);
2716
- return tinycolor(hsl);
2717
- };
2718
- tinycolor.saturate = function (color, amount) {
2719
- amount = (amount === 0) ? 0 : (amount || 10);
2720
- var hsl = tinycolor(color).toHsl();
2721
- hsl.s += amount / 100;
2722
- hsl.s = clamp01(hsl.s);
2723
- return tinycolor(hsl);
2724
- };
2725
- tinycolor.greyscale = function(color) {
2726
- return tinycolor.desaturate(color, 100);
2727
- };
2728
- tinycolor.lighten = function(color, amount) {
2729
- amount = (amount === 0) ? 0 : (amount || 10);
2730
- var hsl = tinycolor(color).toHsl();
2731
- hsl.l += amount / 100;
2732
- hsl.l = clamp01(hsl.l);
2733
- return tinycolor(hsl);
2734
- };
2735
- tinycolor.darken = function (color, amount) {
2736
- amount = (amount === 0) ? 0 : (amount || 10);
2737
- var hsl = tinycolor(color).toHsl();
2738
- hsl.l -= amount / 100;
2739
- hsl.l = clamp01(hsl.l);
2740
- return tinycolor(hsl);
2741
- };
2742
- tinycolor.complement = function(color) {
2743
- var hsl = tinycolor(color).toHsl();
2744
- hsl.h = (hsl.h + 180) % 360;
2745
- return tinycolor(hsl);
2746
- };
2747
-
2748
-
2749
- // Combination Functions
2750
- // ---------------------
2751
- // Thanks to jQuery xColor for some of the ideas behind these
2752
- // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
2753
-
2754
- tinycolor.triad = function(color) {
2755
- var hsl = tinycolor(color).toHsl();
2756
- var h = hsl.h;
2757
- return [
2758
- tinycolor(color),
2759
- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
2760
- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
2761
- ];
2762
- };
2763
- tinycolor.tetrad = function(color) {
2764
- var hsl = tinycolor(color).toHsl();
2765
- var h = hsl.h;
2766
- return [
2767
- tinycolor(color),
2768
- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
2769
- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
2770
- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
2771
- ];
2772
- };
2773
- tinycolor.splitcomplement = function(color) {
2774
- var hsl = tinycolor(color).toHsl();
2775
- var h = hsl.h;
2776
- return [
2777
- tinycolor(color),
2778
- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
2779
- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
2780
- ];
2781
- };
2782
- tinycolor.analogous = function(color, results, slices) {
2783
- results = results || 6;
2784
- slices = slices || 30;
2785
-
2786
- var hsl = tinycolor(color).toHsl();
2787
- var part = 360 / slices;
2788
- var ret = [tinycolor(color)];
2789
-
2790
- for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
2791
- hsl.h = (hsl.h + part) % 360;
2792
- ret.push(tinycolor(hsl));
2793
- }
2794
- return ret;
2795
- };
2796
- tinycolor.monochromatic = function(color, results) {
2797
- results = results || 6;
2798
- var hsv = tinycolor(color).toHsv();
2799
- var h = hsv.h, s = hsv.s, v = hsv.v;
2800
- var ret = [];
2801
- var modification = 1 / results;
2802
-
2803
- while (results--) {
2804
- ret.push(tinycolor({ h: h, s: s, v: v}));
2805
- v = (v + modification) % 1;
2806
- }
2807
-
2808
- return ret;
2809
- };
2810
-
2811
-
2812
- // Readability Functions
2813
- // ---------------------
2814
- // <http://www.w3.org/TR/AERT#color-contrast>
2815
-
2816
- // `readability`
2817
- // Analyze the 2 colors and returns an object with the following properties:
2818
- // `brightness`: difference in brightness between the two colors
2819
- // `color`: difference in color/hue between the two colors
2820
- tinycolor.readability = function(color1, color2) {
2821
- var a = tinycolor(color1).toRgb();
2822
- var b = tinycolor(color2).toRgb();
2823
- var brightnessA = (a.r * 299 + a.g * 587 + a.b * 114) / 1000;
2824
- var brightnessB = (b.r * 299 + b.g * 587 + b.b * 114) / 1000;
2825
- var colorDiff = (
2826
- Math.max(a.r, b.r) - Math.min(a.r, b.r) +
2827
- Math.max(a.g, b.g) - Math.min(a.g, b.g) +
2828
- Math.max(a.b, b.b) - Math.min(a.b, b.b)
2829
- );
2830
-
2831
- return {
2832
- brightness: Math.abs(brightnessA - brightnessB),
2833
- color: colorDiff
2834
- };
2835
- };
2836
-
2837
- // `readable`
2838
- // http://www.w3.org/TR/AERT#color-contrast
2839
- // Ensure that foreground and background color combinations provide sufficient contrast.
2840
- // *Example*
2841
- // tinycolor.readable("#000", "#111") => false
2842
- tinycolor.readable = function(color1, color2) {
2843
- var readability = tinycolor.readability(color1, color2);
2844
- return readability.brightness > 125 && readability.color > 500;
2845
- };
2846
-
2847
- // `mostReadable`
2848
- // Given a base color and a list of possible foreground or background
2849
- // colors for that base, returns the most readable color.
2850
- // *Example*
2851
- // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
2852
- tinycolor.mostReadable = function(baseColor, colorList) {
2853
- var bestColor = null;
2854
- var bestScore = 0;
2855
- var bestIsReadable = false;
2856
- for (var i=0; i < colorList.length; i++) {
2857
-
2858
- // We normalize both around the "acceptable" breaking point,
2859
- // but rank brightness constrast higher than hue.
2860
-
2861
- var readability = tinycolor.readability(baseColor, colorList[i]);
2862
- var readable = readability.brightness > 125 && readability.color > 500;
2863
- var score = 3 * (readability.brightness / 125) + (readability.color / 500);
2864
-
2865
- if ((readable && ! bestIsReadable) ||
2866
- (readable && bestIsReadable && score > bestScore) ||
2867
- ((! readable) && (! bestIsReadable) && score > bestScore)) {
2868
- bestIsReadable = readable;
2869
- bestScore = score;
2870
- bestColor = tinycolor(colorList[i]);
2871
- }
2872
- }
2873
- return bestColor;
2874
- };
2875
-
2876
-
2877
- // Big List of Colors
2878
- // ------------------
2879
- // <http://www.w3.org/TR/css3-color/#svg-color>
2880
- var names = tinycolor.names = {
2881
- aliceblue: "f0f8ff",
2882
- antiquewhite: "faebd7",
2883
- aqua: "0ff",
2884
- aquamarine: "7fffd4",
2885
- azure: "f0ffff",
2886
- beige: "f5f5dc",
2887
- bisque: "ffe4c4",
2888
- black: "000",
2889
- blanchedalmond: "ffebcd",
2890
- blue: "00f",
2891
- blueviolet: "8a2be2",
2892
- brown: "a52a2a",
2893
- burlywood: "deb887",
2894
- burntsienna: "ea7e5d",
2895
- cadetblue: "5f9ea0",
2896
- chartreuse: "7fff00",
2897
- chocolate: "d2691e",
2898
- coral: "ff7f50",
2899
- cornflowerblue: "6495ed",
2900
- cornsilk: "fff8dc",
2901
- crimson: "dc143c",
2902
- cyan: "0ff",
2903
- darkblue: "00008b",
2904
- darkcyan: "008b8b",
2905
- darkgoldenrod: "b8860b",
2906
- darkgray: "a9a9a9",
2907
- darkgreen: "006400",
2908
- darkgrey: "a9a9a9",
2909
- darkkhaki: "bdb76b",
2910
- darkmagenta: "8b008b",
2911
- darkolivegreen: "556b2f",
2912
- darkorange: "ff8c00",
2913
- darkorchid: "9932cc",
2914
- darkred: "8b0000",
2915
- darksalmon: "e9967a",
2916
- darkseagreen: "8fbc8f",
2917
- darkslateblue: "483d8b",
2918
- darkslategray: "2f4f4f",
2919
- darkslategrey: "2f4f4f",
2920
- darkturquoise: "00ced1",
2921
- darkviolet: "9400d3",
2922
- deeppink: "ff1493",
2923
- deepskyblue: "00bfff",
2924
- dimgray: "696969",
2925
- dimgrey: "696969",
2926
- dodgerblue: "1e90ff",
2927
- firebrick: "b22222",
2928
- floralwhite: "fffaf0",
2929
- forestgreen: "228b22",
2930
- fuchsia: "f0f",
2931
- gainsboro: "dcdcdc",
2932
- ghostwhite: "f8f8ff",
2933
- gold: "ffd700",
2934
- goldenrod: "daa520",
2935
- gray: "808080",
2936
- green: "008000",
2937
- greenyellow: "adff2f",
2938
- grey: "808080",
2939
- honeydew: "f0fff0",
2940
- hotpink: "ff69b4",
2941
- indianred: "cd5c5c",
2942
- indigo: "4b0082",
2943
- ivory: "fffff0",
2944
- khaki: "f0e68c",
2945
- lavender: "e6e6fa",
2946
- lavenderblush: "fff0f5",
2947
- lawngreen: "7cfc00",
2948
- lemonchiffon: "fffacd",
2949
- lightblue: "add8e6",
2950
- lightcoral: "f08080",
2951
- lightcyan: "e0ffff",
2952
- lightgoldenrodyellow: "fafad2",
2953
- lightgray: "d3d3d3",
2954
- lightgreen: "90ee90",
2955
- lightgrey: "d3d3d3",
2956
- lightpink: "ffb6c1",
2957
- lightsalmon: "ffa07a",
2958
- lightseagreen: "20b2aa",
2959
- lightskyblue: "87cefa",
2960
- lightslategray: "789",
2961
- lightslategrey: "789",
2962
- lightsteelblue: "b0c4de",
2963
- lightyellow: "ffffe0",
2964
- lime: "0f0",
2965
- limegreen: "32cd32",
2966
- linen: "faf0e6",
2967
- magenta: "f0f",
2968
- maroon: "800000",
2969
- mediumaquamarine: "66cdaa",
2970
- mediumblue: "0000cd",
2971
- mediumorchid: "ba55d3",
2972
- mediumpurple: "9370db",
2973
- mediumseagreen: "3cb371",
2974
- mediumslateblue: "7b68ee",
2975
- mediumspringgreen: "00fa9a",
2976
- mediumturquoise: "48d1cc",
2977
- mediumvioletred: "c71585",
2978
- midnightblue: "191970",
2979
- mintcream: "f5fffa",
2980
- mistyrose: "ffe4e1",
2981
- moccasin: "ffe4b5",
2982
- navajowhite: "ffdead",
2983
- navy: "000080",
2984
- oldlace: "fdf5e6",
2985
- olive: "808000",
2986
- olivedrab: "6b8e23",
2987
- orange: "ffa500",
2988
- orangered: "ff4500",
2989
- orchid: "da70d6",
2990
- palegoldenrod: "eee8aa",
2991
- palegreen: "98fb98",
2992
- paleturquoise: "afeeee",
2993
- palevioletred: "db7093",
2994
- papayawhip: "ffefd5",
2995
- peachpuff: "ffdab9",
2996
- peru: "cd853f",
2997
- pink: "ffc0cb",
2998
- plum: "dda0dd",
2999
- powderblue: "b0e0e6",
3000
- purple: "800080",
3001
- red: "f00",
3002
- rosybrown: "bc8f8f",
3003
- royalblue: "4169e1",
3004
- saddlebrown: "8b4513",
3005
- salmon: "fa8072",
3006
- sandybrown: "f4a460",
3007
- seagreen: "2e8b57",
3008
- seashell: "fff5ee",
3009
- sienna: "a0522d",
3010
- silver: "c0c0c0",
3011
- skyblue: "87ceeb",
3012
- slateblue: "6a5acd",
3013
- slategray: "708090",
3014
- slategrey: "708090",
3015
- snow: "fffafa",
3016
- springgreen: "00ff7f",
3017
- steelblue: "4682b4",
3018
- tan: "d2b48c",
3019
- teal: "008080",
3020
- thistle: "d8bfd8",
3021
- tomato: "ff6347",
3022
- turquoise: "40e0d0",
3023
- violet: "ee82ee",
3024
- wheat: "f5deb3",
3025
- white: "fff",
3026
- whitesmoke: "f5f5f5",
3027
- yellow: "ff0",
3028
- yellowgreen: "9acd32"
3029
- };
3030
-
3031
- // Make it easy to access colors via `hexNames[hex]`
3032
- var hexNames = tinycolor.hexNames = flip(names);
3033
-
3034
-
3035
- // Utilities
3036
- // ---------
3037
-
3038
- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
3039
- function flip(o) {
3040
- var flipped = { };
3041
- for (var i in o) {
3042
- if (o.hasOwnProperty(i)) {
3043
- flipped[o[i]] = i;
3044
- }
3045
- }
3046
- return flipped;
3047
- }
3048
-
3049
- // Return a valid alpha value [0,1] with all invalid values being set to 1
3050
- function boundAlpha(a) {
3051
- a = parseFloat(a);
3052
-
3053
- if (isNaN(a) || a < 0 || a > 1) {
3054
- a = 1;
3055
- }
3056
-
3057
- return a;
3058
- }
3059
-
3060
- // Take input from [0, n] and return it as [0, 1]
3061
- function bound01(n, max) {
3062
- if (isOnePointZero(n)) { n = "100%"; }
3063
-
3064
- var processPercent = isPercentage(n);
3065
- n = mathMin(max, mathMax(0, parseFloat(n)));
3066
-
3067
- // Automatically convert percentage into number
3068
- if (processPercent) {
3069
- n = parseInt(n * max, 10) / 100;
3070
- }
3071
-
3072
- // Handle floating point rounding errors
3073
- if ((math.abs(n - max) < 0.000001)) {
3074
- return 1;
3075
- }
3076
-
3077
- // Convert into [0, 1] range if it isn't already
3078
- return (n % max) / parseFloat(max);
3079
- }
3080
-
3081
- // Force a number between 0 and 1
3082
- function clamp01(val) {
3083
- return mathMin(1, mathMax(0, val));
3084
- }
3085
-
3086
- // Parse a base-16 hex value into a base-10 integer
3087
- function parseIntFromHex(val) {
3088
- return parseInt(val, 16);
3089
- }
3090
-
3091
- // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
3092
- // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
3093
- function isOnePointZero(n) {
3094
- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
3095
- }
3096
-
3097
- // Check to see if string passed in is a percentage
3098
- function isPercentage(n) {
3099
- return typeof n === "string" && n.indexOf('%') != -1;
3100
- }
3101
-
3102
- // Force a hex value to have 2 characters
3103
- function pad2(c) {
3104
- return c.length == 1 ? '0' + c : '' + c;
3105
- }
3106
-
3107
- // Replace a decimal with it's percentage value
3108
- function convertToPercentage(n) {
3109
- if (n <= 1) {
3110
- n = (n * 100) + "%";
3111
- }
3112
-
3113
- return n;
3114
- }
3115
-
3116
- // Converts a decimal to a hex value
3117
- function convertDecimalToHex(d) {
3118
- return Math.round(parseFloat(d) * 255).toString(16);
3119
- }
3120
- // Converts a hex value to a decimal
3121
- function convertHexToDecimal(h) {
3122
- return (parseIntFromHex(h) / 255);
3123
- }
3124
-
3125
- var matchers = (function() {
3126
-
3127
- // <http://www.w3.org/TR/css3-values/#integers>
3128
- var CSS_INTEGER = "[-\\+]?\\d+%?";
3129
-
3130
- // <http://www.w3.org/TR/css3-values/#number-value>
3131
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
3132
-
3133
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
3134
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
3135
-
3136
- // Actual matching.
3137
- // Parentheses and commas are optional, but not required.
3138
- // Whitespace can take the place of commas or opening paren
3139
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
3140
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
3141
-
3142
- return {
3143
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
3144
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
3145
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
3146
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
3147
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
3148
- hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
3149
- hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
3150
- hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
3151
- };
3152
- })();
3153
-
3154
- // `stringInputToObject`
3155
- // Permissive string parsing. Take in a number of formats, and output an object
3156
- // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
3157
- function stringInputToObject(color) {
3158
-
3159
- color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
3160
- var named = false;
3161
- if (names[color]) {
3162
- color = names[color];
3163
- named = true;
3164
- }
3165
- else if (color == 'transparent') {
3166
- return { r: 0, g: 0, b: 0, a: 0, format: "name" };
3167
- }
3168
-
3169
- // Try to match string input using regular expressions.
3170
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
3171
- // Just return an object and let the conversion functions handle that.
3172
- // This way the result will be the same whether the tinycolor is initialized with string or object.
3173
- var match;
3174
- if ((match = matchers.rgb.exec(color))) {
3175
- return { r: match[1], g: match[2], b: match[3] };
3176
- }
3177
- if ((match = matchers.rgba.exec(color))) {
3178
- return { r: match[1], g: match[2], b: match[3], a: match[4] };
3179
- }
3180
- if ((match = matchers.hsl.exec(color))) {
3181
- return { h: match[1], s: match[2], l: match[3] };
3182
- }
3183
- if ((match = matchers.hsla.exec(color))) {
3184
- return { h: match[1], s: match[2], l: match[3], a: match[4] };
3185
- }
3186
- if ((match = matchers.hsv.exec(color))) {
3187
- return { h: match[1], s: match[2], v: match[3] };
3188
- }
3189
- if ((match = matchers.hex8.exec(color))) {
3190
- return {
3191
- a: convertHexToDecimal(match[1]),
3192
- r: parseIntFromHex(match[2]),
3193
- g: parseIntFromHex(match[3]),
3194
- b: parseIntFromHex(match[4]),
3195
- format: named ? "name" : "hex8"
3196
- };
3197
- }
3198
- if ((match = matchers.hex6.exec(color))) {
3199
- return {
3200
- r: parseIntFromHex(match[1]),
3201
- g: parseIntFromHex(match[2]),
3202
- b: parseIntFromHex(match[3]),
3203
- format: named ? "name" : "hex"
3204
- };
3205
- }
3206
- if ((match = matchers.hex3.exec(color))) {
3207
- return {
3208
- r: parseIntFromHex(match[1] + '' + match[1]),
3209
- g: parseIntFromHex(match[2] + '' + match[2]),
3210
- b: parseIntFromHex(match[3] + '' + match[3]),
3211
- format: named ? "name" : "hex"
3212
- };
3213
- }
3214
-
3215
- return false;
3216
- }
3217
-
3218
- // Expose tinycolor to window, does not need to run in non-browser context.
3219
- window.tinycolor = tinycolor;
3220
-
3221
- })();
3222
-
3223
-
3224
- $(function () {
3225
- if ($.fn.spectrum.load) {
3226
- $.fn.spectrum.processNativeColorInputs();
3227
- }
3228
- });
3229
-
3230
- })(window, jQuery);
3231
- //js\libs\codemirror\codemirror.js
3232
-
3233
  /*!
3234
  * @overview CodeMirror version 3.22
3235
  * http://codemirror.net/
3236
  */
3237
-
3238
- // CodeMirror version 3.22
3239
- //
3240
- // CodeMirror is the only global var we claim
3241
- window.CodeMirror = (function() {
3242
- "use strict";
3243
-
3244
- // BROWSER SNIFFING
3245
-
3246
- // Crude, but necessary to handle a number of hard-to-feature-detect
3247
- // bugs and behavior differences.
3248
- var gecko = /gecko\/\d/i.test(navigator.userAgent);
3249
- // IE11 currently doesn't count as 'ie', since it has almost none of
3250
- // the same bugs as earlier versions. Use ie_gt10 to handle
3251
- // incompatibilities in that version.
3252
- var old_ie = /MSIE \d/.test(navigator.userAgent);
3253
- var ie_lt8 = old_ie && (document.documentMode == null || document.documentMode < 8);
3254
- var ie_lt9 = old_ie && (document.documentMode == null || document.documentMode < 9);
3255
- var ie_lt10 = old_ie && (document.documentMode == null || document.documentMode < 10);
3256
- var ie_gt10 = /Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent);
3257
- var ie = old_ie || ie_gt10;
3258
- var webkit = /WebKit\//.test(navigator.userAgent);
3259
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
3260
- var chrome = /Chrome\//.test(navigator.userAgent);
3261
- var opera = /Opera\//.test(navigator.userAgent);
3262
- var safari = /Apple Computer/.test(navigator.vendor);
3263
- var khtml = /KHTML\//.test(navigator.userAgent);
3264
- var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent);
3265
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
3266
- var phantom = /PhantomJS/.test(navigator.userAgent);
3267
-
3268
- var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
3269
- // This is woefully incomplete. Suggestions for alternative methods welcome.
3270
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
3271
- var mac = ios || /Mac/.test(navigator.platform);
3272
- var windows = /win/i.test(navigator.platform);
3273
-
3274
- var opera_version = opera && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
3275
- if (opera_version) opera_version = Number(opera_version[1]);
3276
- if (opera_version && opera_version >= 15) { opera = false; webkit = true; }
3277
- // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
3278
- var flipCtrlCmd = mac && (qtwebkit || opera && (opera_version == null || opera_version < 12.11));
3279
- var captureMiddleClick = gecko || (ie && !ie_lt9);
3280
-
3281
- // Optimize some code when these features are not used
3282
- var sawReadOnlySpans = false, sawCollapsedSpans = false;
3283
-
3284
- // CONSTRUCTOR
3285
-
3286
- function CodeMirror(place, options) {
3287
- if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
3288
-
3289
- this.options = options = options || {};
3290
- // Determine effective options based on given values and defaults.
3291
- for (var opt in defaults) if (!options.hasOwnProperty(opt) && defaults.hasOwnProperty(opt))
3292
- options[opt] = defaults[opt];
3293
- setGuttersForLineNumbers(options);
3294
-
3295
- var docStart = typeof options.value == "string" ? 0 : options.value.first;
3296
- var display = this.display = makeDisplay(place, docStart);
3297
- display.wrapper.CodeMirror = this;
3298
- updateGutters(this);
3299
- if (options.autofocus && !mobile) focusInput(this);
3300
-
3301
- this.state = {keyMaps: [],
3302
- overlays: [],
3303
- modeGen: 0,
3304
- overwrite: false, focused: false,
3305
- suppressEdits: false,
3306
- pasteIncoming: false, cutIncoming: false,
3307
- draggingText: false,
3308
- highlight: new Delayed()};
3309
-
3310
- themeChanged(this);
3311
- if (options.lineWrapping)
3312
- this.display.wrapper.className += " CodeMirror-wrap";
3313
-
3314
- var doc = options.value;
3315
- if (typeof doc == "string") doc = new Doc(options.value, options.mode);
3316
- operation(this, attachDoc)(this, doc);
3317
-
3318
- // Override magic textarea content restore that IE sometimes does
3319
- // on our hidden textarea on reload
3320
- if (old_ie) setTimeout(bind(resetInput, this, true), 20);
3321
-
3322
- registerEventHandlers(this);
3323
- // IE throws unspecified error in certain cases, when
3324
- // trying to access activeElement before onload
3325
- var hasFocus; try { hasFocus = (document.activeElement == display.input); } catch(e) { }
3326
- if (hasFocus || (options.autofocus && !mobile)) setTimeout(bind(onFocus, this), 20);
3327
- else onBlur(this);
3328
-
3329
- operation(this, function() {
3330
- for (var opt in optionHandlers)
3331
- if (optionHandlers.propertyIsEnumerable(opt))
3332
- optionHandlers[opt](this, options[opt], Init);
3333
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
3334
- })();
3335
- }
3336
-
3337
- // DISPLAY CONSTRUCTOR
3338
-
3339
- function makeDisplay(place, docStart) {
3340
- var d = {};
3341
-
3342
- var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
3343
- if (webkit) input.style.width = "1000px";
3344
- else input.setAttribute("wrap", "off");
3345
- // if border: 0; -- iOS fails to open keyboard (issue #1287)
3346
- if (ios) input.style.border = "1px solid black";
3347
- input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
3348
-
3349
- // Wraps and hides input textarea
3350
- d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
3351
- // The actual fake scrollbars.
3352
- d.scrollbarH = elt("div", [elt("div", null, null, "height: 1px")], "CodeMirror-hscrollbar");
3353
- d.scrollbarV = elt("div", [elt("div", null, null, "width: 1px")], "CodeMirror-vscrollbar");
3354
- d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
3355
- d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
3356
- // DIVs containing the selection and the actual code
3357
- d.lineDiv = elt("div", null, "CodeMirror-code");
3358
- d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
3359
- // Blinky cursor, and element used to ensure cursor fits at the end of a line
3360
- d.cursor = elt("div", "\u00a0", "CodeMirror-cursor");
3361
- // Secondary cursor, shown when on a 'jump' in bi-directional text
3362
- d.otherCursor = elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor");
3363
- // Used to measure text size
3364
- d.measure = elt("div", null, "CodeMirror-measure");
3365
- // Wraps everything that needs to exist inside the vertically-padded coordinate system
3366
- d.lineSpace = elt("div", [d.measure, d.selectionDiv, d.lineDiv, d.cursor, d.otherCursor],
3367
- null, "position: relative; outline: none");
3368
- // Moved around its parent to cover visible view
3369
- d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
3370
- // Set to the height of the text, causes scrolling
3371
- d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
3372
- // D is needed because behavior of elts with overflow: auto and padding is inconsistent across browsers
3373
- d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;");
3374
- // Will contain the gutters, if any
3375
- d.gutters = elt("div", null, "CodeMirror-gutters");
3376
- d.lineGutter = null;
3377
- // Provides scrolling
3378
- d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
3379
- d.scroller.setAttribute("tabIndex", "-1");
3380
- // The element in which the editor lives.
3381
- d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
3382
- d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
3383
- // Work around IE7 z-index bug
3384
- if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
3385
- if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper);
3386
-
3387
- // Needed to hide big blue blinking cursor on Mobile Safari
3388
- if (ios) input.style.width = "0px";
3389
- if (!webkit) d.scroller.draggable = true;
3390
- // Needed to handle Tab key in KHTML
3391
- if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; }
3392
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
3393
- else if (ie_lt8) d.scrollbarH.style.minWidth = d.scrollbarV.style.minWidth = "18px";
3394
-
3395
- // Current visible range (may be bigger than the view window).
3396
- d.viewOffset = d.lastSizeC = 0;
3397
- d.showingFrom = d.showingTo = docStart;
3398
-
3399
- // Used to only resize the line number gutter when necessary (when
3400
- // the amount of lines crosses a boundary that makes its width change)
3401
- d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
3402
- // See readInput and resetInput
3403
- d.prevInput = "";
3404
- // Set to true when a non-horizontal-scrolling widget is added. As
3405
- // an optimization, widget aligning is skipped when d is false.
3406
- d.alignWidgets = false;
3407
- // Flag that indicates whether we currently expect input to appear
3408
- // (after some event like 'keypress' or 'input') and are polling
3409
- // intensively.
3410
- d.pollingFast = false;
3411
- // Self-resetting timeout for the poller
3412
- d.poll = new Delayed();
3413
-
3414
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
3415
- d.measureLineCache = [];
3416
- d.measureLineCachePos = 0;
3417
-
3418
- // Tracks when resetInput has punted to just putting a short
3419
- // string instead of the (large) selection.
3420
- d.inaccurateSelection = false;
3421
-
3422
- // Tracks the maximum line length so that the horizontal scrollbar
3423
- // can be kept static when scrolling.
3424
- d.maxLine = null;
3425
- d.maxLineLength = 0;
3426
- d.maxLineChanged = false;
3427
-
3428
- // Used for measuring wheel scrolling granularity
3429
- d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
3430
-
3431
- return d;
3432
- }
3433
-
3434
- // STATE UPDATES
3435
-
3436
- // Used to get the editor into a consistent state again when options change.
3437
-
3438
- function loadMode(cm) {
3439
- cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
3440
- resetModeState(cm);
3441
- }
3442
-
3443
- function resetModeState(cm) {
3444
- cm.doc.iter(function(line) {
3445
- if (line.stateAfter) line.stateAfter = null;
3446
- if (line.styles) line.styles = null;
3447
- });
3448
- cm.doc.frontier = cm.doc.first;
3449
- startWorker(cm, 100);
3450
- cm.state.modeGen++;
3451
- if (cm.curOp) regChange(cm);
3452
- }
3453
-
3454
- function wrappingChanged(cm) {
3455
- if (cm.options.lineWrapping) {
3456
- cm.display.wrapper.className += " CodeMirror-wrap";
3457
- cm.display.sizer.style.minWidth = "";
3458
- } else {
3459
- cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-wrap", "");
3460
- computeMaxLength(cm);
3461
- }
3462
- estimateLineHeights(cm);
3463
- regChange(cm);
3464
- clearCaches(cm);
3465
- setTimeout(function(){updateScrollbars(cm);}, 100);
3466
- }
3467
-
3468
- function estimateHeight(cm) {
3469
- var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
3470
- var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
3471
- return function(line) {
3472
- if (lineIsHidden(cm.doc, line))
3473
- return 0;
3474
- else if (wrapping)
3475
- return (Math.ceil(line.text.length / perLine) || 1) * th;
3476
- else
3477
- return th;
3478
- };
3479
- }
3480
-
3481
- function estimateLineHeights(cm) {
3482
- var doc = cm.doc, est = estimateHeight(cm);
3483
- doc.iter(function(line) {
3484
- var estHeight = est(line);
3485
- if (estHeight != line.height) updateLineHeight(line, estHeight);
3486
- });
3487
- }
3488
-
3489
- function keyMapChanged(cm) {
3490
- var map = keyMap[cm.options.keyMap], style = map.style;
3491
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
3492
- (style ? " cm-keymap-" + style : "");
3493
- }
3494
-
3495
- function themeChanged(cm) {
3496
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
3497
- cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
3498
- clearCaches(cm);
3499
- }
3500
-
3501
- function guttersChanged(cm) {
3502
- updateGutters(cm);
3503
- regChange(cm);
3504
- setTimeout(function(){alignHorizontally(cm);}, 20);
3505
- }
3506
-
3507
- function updateGutters(cm) {
3508
- var gutters = cm.display.gutters, specs = cm.options.gutters;
3509
- removeChildren(gutters);
3510
- for (var i = 0; i < specs.length; ++i) {
3511
- var gutterClass = specs[i];
3512
- var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
3513
- if (gutterClass == "CodeMirror-linenumbers") {
3514
- cm.display.lineGutter = gElt;
3515
- gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
3516
- }
3517
- }
3518
- gutters.style.display = i ? "" : "none";
3519
- }
3520
-
3521
- function lineLength(doc, line) {
3522
- if (line.height == 0) return 0;
3523
- var len = line.text.length, merged, cur = line;
3524
- while (merged = collapsedSpanAtStart(cur)) {
3525
- var found = merged.find();
3526
- cur = getLine(doc, found.from.line);
3527
- len += found.from.ch - found.to.ch;
3528
- }
3529
- cur = line;
3530
- while (merged = collapsedSpanAtEnd(cur)) {
3531
- var found = merged.find();
3532
- len -= cur.text.length - found.from.ch;
3533
- cur = getLine(doc, found.to.line);
3534
- len += cur.text.length - found.to.ch;
3535
- }
3536
- return len;
3537
- }
3538
-
3539
- function computeMaxLength(cm) {
3540
- var d = cm.display, doc = cm.doc;
3541
- d.maxLine = getLine(doc, doc.first);
3542
- d.maxLineLength = lineLength(doc, d.maxLine);
3543
- d.maxLineChanged = true;
3544
- doc.iter(function(line) {
3545
- var len = lineLength(doc, line);
3546
- if (len > d.maxLineLength) {
3547
- d.maxLineLength = len;
3548
- d.maxLine = line;
3549
- }
3550
- });
3551
- }
3552
-
3553
- // Make sure the gutters options contains the element
3554
- // "CodeMirror-linenumbers" when the lineNumbers option is true.
3555
- function setGuttersForLineNumbers(options) {
3556
- var found = indexOf(options.gutters, "CodeMirror-linenumbers");
3557
- if (found == -1 && options.lineNumbers) {
3558
- options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
3559
- } else if (found > -1 && !options.lineNumbers) {
3560
- options.gutters = options.gutters.slice(0);
3561
- options.gutters.splice(found, 1);
3562
- }
3563
- }
3564
-
3565
- // SCROLLBARS
3566
-
3567
- // Re-synchronize the fake scrollbars with the actual size of the
3568
- // content. Optionally force a scrollTop.
3569
- function updateScrollbars(cm) {
3570
- var d = cm.display, docHeight = cm.doc.height;
3571
- var totalHeight = docHeight + paddingVert(d);
3572
- d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
3573
- d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px";
3574
- var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
3575
- var needsH = d.scroller.scrollWidth > (d.scroller.clientWidth + 1);
3576
- var needsV = scrollHeight > (d.scroller.clientHeight + 1);
3577
- if (needsV) {
3578
- d.scrollbarV.style.display = "block";
3579
- d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0";
3580
- // A bug in IE8 can cause this value to be negative, so guard it.
3581
- d.scrollbarV.firstChild.style.height =
3582
- Math.max(0, scrollHeight - d.scroller.clientHeight + d.scrollbarV.clientHeight) + "px";
3583
- } else {
3584
- d.scrollbarV.style.display = "";
3585
- d.scrollbarV.firstChild.style.height = "0";
3586
- }
3587
- if (needsH) {
3588
- d.scrollbarH.style.display = "block";
3589
- d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0";
3590
- d.scrollbarH.firstChild.style.width =
3591
- (d.scroller.scrollWidth - d.scroller.clientWidth + d.scrollbarH.clientWidth) + "px";
3592
- } else {
3593
- d.scrollbarH.style.display = "";
3594
- d.scrollbarH.firstChild.style.width = "0";
3595
- }
3596
- if (needsH && needsV) {
3597
- d.scrollbarFiller.style.display = "block";
3598
- d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
3599
- } else d.scrollbarFiller.style.display = "";
3600
- if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
3601
- d.gutterFiller.style.display = "block";
3602
- d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
3603
- d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
3604
- } else d.gutterFiller.style.display = "";
3605
-
3606
- if (mac_geLion && scrollbarWidth(d.measure) === 0) {
3607
- d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
3608
- d.scrollbarV.style.pointerEvents = d.scrollbarH.style.pointerEvents = "none";
3609
- }
3610
- }
3611
-
3612
- function visibleLines(display, doc, viewPort) {
3613
- var top = display.scroller.scrollTop, height = display.wrapper.clientHeight;
3614
- if (typeof viewPort == "number") top = viewPort;
3615
- else if (viewPort) {top = viewPort.top; height = viewPort.bottom - viewPort.top;}
3616
- top = Math.floor(top - paddingTop(display));
3617
- var bottom = Math.ceil(top + height);
3618
- return {from: lineAtHeight(doc, top), to: lineAtHeight(doc, bottom)};
3619
- }
3620
-
3621
- // LINE NUMBERS
3622
-
3623
- function alignHorizontally(cm) {
3624
- var display = cm.display;
3625
- if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
3626
- var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
3627
- var gutterW = display.gutters.offsetWidth, l = comp + "px";
3628
- for (var n = display.lineDiv.firstChild; n; n = n.nextSibling) if (n.alignable) {
3629
- for (var i = 0, a = n.alignable; i < a.length; ++i) a[i].style.left = l;
3630
- }
3631
- if (cm.options.fixedGutter)
3632
- display.gutters.style.left = (comp + gutterW) + "px";
3633
- }
3634
-
3635
- function maybeUpdateLineNumberWidth(cm) {
3636
- if (!cm.options.lineNumbers) return false;
3637
- var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
3638
- if (last.length != display.lineNumChars) {
3639
- var test = display.measure.appendChild(elt("div", [elt("div", last)],
3640
- "CodeMirror-linenumber CodeMirror-gutter-elt"));
3641
- var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
3642
- display.lineGutter.style.width = "";
3643
- display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
3644
- display.lineNumWidth = display.lineNumInnerWidth + padding;
3645
- display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
3646
- display.lineGutter.style.width = display.lineNumWidth + "px";
3647
- return true;
3648
- }
3649
- return false;
3650
- }
3651
-
3652
- function lineNumberFor(options, i) {
3653
- return String(options.lineNumberFormatter(i + options.firstLineNumber));
3654
- }
3655
- function compensateForHScroll(display) {
3656
- return getRect(display.scroller).left - getRect(display.sizer).left;
3657
- }
3658
-
3659
- // DISPLAY DRAWING
3660
-
3661
- function updateDisplay(cm, changes, viewPort, forced) {
3662
- var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo, updated;
3663
- var visible = visibleLines(cm.display, cm.doc, viewPort);
3664
- for (var first = true;; first = false) {
3665
- var oldWidth = cm.display.scroller.clientWidth;
3666
- if (!updateDisplayInner(cm, changes, visible, forced)) break;
3667
- updated = true;
3668
- changes = [];
3669
- updateSelection(cm);
3670
- updateScrollbars(cm);
3671
- if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) {
3672
- forced = true;
3673
- continue;
3674
- }
3675
- forced = false;
3676
-
3677
- // Clip forced viewport to actual scrollable area
3678
- if (viewPort)
3679
- viewPort = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight,
3680
- typeof viewPort == "number" ? viewPort : viewPort.top);
3681
- visible = visibleLines(cm.display, cm.doc, viewPort);
3682
- if (visible.from >= cm.display.showingFrom && visible.to <= cm.display.showingTo)
3683
- break;
3684
- }
3685
-
3686
- if (updated) {
3687
- signalLater(cm, "update", cm);
3688
- if (cm.display.showingFrom != oldFrom || cm.display.showingTo != oldTo)
3689
- signalLater(cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
3690
- }
3691
- return updated;
3692
- }
3693
-
3694
- // Uses a set of changes plus the current scroll position to
3695
- // determine which DOM updates have to be made, and makes the
3696
- // updates.
3697
- function updateDisplayInner(cm, changes, visible, forced) {
3698
- var display = cm.display, doc = cm.doc;
3699
- if (!display.wrapper.offsetWidth) {
3700
- display.showingFrom = display.showingTo = doc.first;
3701
- display.viewOffset = 0;
3702
- return;
3703
- }
3704
-
3705
- // Bail out if the visible area is already rendered and nothing changed.
3706
- if (!forced && changes.length == 0 &&
3707
- visible.from > display.showingFrom && visible.to < display.showingTo)
3708
- return;
3709
-
3710
- if (maybeUpdateLineNumberWidth(cm))
3711
- changes = [{from: doc.first, to: doc.first + doc.size}];
3712
- var gutterW = display.sizer.style.marginLeft = display.gutters.offsetWidth + "px";
3713
- display.scrollbarH.style.left = cm.options.fixedGutter ? gutterW : "0";
3714
-
3715
- // Used to determine which lines need their line numbers updated
3716
- var positionsChangedFrom = Infinity;
3717
- if (cm.options.lineNumbers)
3718
- for (var i = 0; i < changes.length; ++i)
3719
- if (changes[i].diff && changes[i].from < positionsChangedFrom) { positionsChangedFrom = changes[i].from; }
3720
-
3721
- var end = doc.first + doc.size;
3722
- var from = Math.max(visible.from - cm.options.viewportMargin, doc.first);
3723
- var to = Math.min(end, visible.to + cm.options.viewportMargin);
3724
- if (display.showingFrom < from && from - display.showingFrom < 20) from = Math.max(doc.first, display.showingFrom);
3725
- if (display.showingTo > to && display.showingTo - to < 20) to = Math.min(end, display.showingTo);
3726
- if (sawCollapsedSpans) {
3727
- from = lineNo(visualLine(doc, getLine(doc, from)));
3728
- while (to < end && lineIsHidden(doc, getLine(doc, to))) ++to;
3729
- }
3730
-
3731
- // Create a range of theoretically intact lines, and punch holes
3732
- // in that using the change info.
3733
- var intact = [{from: Math.max(display.showingFrom, doc.first),
3734
- to: Math.min(display.showingTo, end)}];
3735
- if (intact[0].from >= intact[0].to) intact = [];
3736
- else intact = computeIntact(intact, changes);
3737
- // When merged lines are present, we might have to reduce the
3738
- // intact ranges because changes in continued fragments of the
3739
- // intact lines do require the lines to be redrawn.
3740
- if (sawCollapsedSpans)
3741
- for (var i = 0; i < intact.length; ++i) {
3742
- var range = intact[i], merged;
3743
- while (merged = collapsedSpanAtEnd(getLine(doc, range.to - 1))) {
3744
- var newTo = merged.find().from.line;
3745
- if (newTo > range.from) range.to = newTo;
3746
- else { intact.splice(i--, 1); break; }
3747
- }
3748
- }
3749
-
3750
- // Clip off the parts that won't be visible
3751
- var intactLines = 0;
3752
- for (var i = 0; i < intact.length; ++i) {
3753
- var range = intact[i];
3754
- if (range.from < from) range.from = from;
3755
- if (range.to > to) range.to = to;
3756
- if (range.from >= range.to) intact.splice(i--, 1);
3757
- else intactLines += range.to - range.from;
3758
- }
3759
- if (!forced && intactLines == to - from && from == display.showingFrom && to == display.showingTo) {
3760
- updateViewOffset(cm);
3761
- return;
3762
- }
3763
- intact.sort(function(a, b) {return a.from - b.from;});
3764
-
3765
- // Avoid crashing on IE's "unspecified error" when in iframes
3766
- try {
3767
- var focused = document.activeElement;
3768
- } catch(e) {}
3769
- if (intactLines < (to - from) * .7) display.lineDiv.style.display = "none";
3770
- patchDisplay(cm, from, to, intact, positionsChangedFrom);
3771
- display.lineDiv.style.display = "";
3772
- if (focused && document.activeElement != focused && focused.offsetHeight) focused.focus();
3773
-
3774
- var different = from != display.showingFrom || to != display.showingTo ||
3775
- display.lastSizeC != display.wrapper.clientHeight;
3776
- // This is just a bogus formula that detects when the editor is
3777
- // resized or the font size changes.
3778
- if (different) {
3779
- display.lastSizeC = display.wrapper.clientHeight;
3780
- startWorker(cm, 400);
3781
- }
3782
- display.showingFrom = from; display.showingTo = to;
3783
-
3784
- display.gutters.style.height = "";
3785
- updateHeightsInViewport(cm);
3786
- updateViewOffset(cm);
3787
-
3788
- return true;
3789
- }
3790
-
3791
- function updateHeightsInViewport(cm) {
3792
- var display = cm.display;
3793
- var prevBottom = display.lineDiv.offsetTop;
3794
- for (var node = display.lineDiv.firstChild, height; node; node = node.nextSibling) if (node.lineObj) {
3795
- if (ie_lt8) {
3796
- var bot = node.offsetTop + node.offsetHeight;
3797
- height = bot - prevBottom;
3798
- prevBottom = bot;
3799
- } else {
3800
- var box = getRect(node);
3801
- height = box.bottom - box.top;
3802
- }
3803
- var diff = node.lineObj.height - height;
3804
- if (height < 2) height = textHeight(display);
3805
- if (diff > .001 || diff < -.001) {
3806
- updateLineHeight(node.lineObj, height);
3807
- var widgets = node.lineObj.widgets;
3808
- if (widgets) for (var i = 0; i < widgets.length; ++i)
3809
- widgets[i].height = widgets[i].node.offsetHeight;
3810
- }
3811
- }
3812
- }
3813
-
3814
- function updateViewOffset(cm) {
3815
- var off = cm.display.viewOffset = heightAtLine(cm, getLine(cm.doc, cm.display.showingFrom));
3816
- // Position the mover div to align with the current virtual scroll position
3817
- cm.display.mover.style.top = off + "px";
3818
- }
3819
-
3820
- function computeIntact(intact, changes) {
3821
- for (var i = 0, l = changes.length || 0; i < l; ++i) {
3822
- var change = changes[i], intact2 = [], diff = change.diff || 0;
3823
- for (var j = 0, l2 = intact.length; j < l2; ++j) {
3824
- var range = intact[j];
3825
- if (change.to <= range.from && change.diff) {
3826
- intact2.push({from: range.from + diff, to: range.to + diff});
3827
- } else if (change.to <= range.from || change.from >= range.to) {
3828
- intact2.push(range);
3829
- } else {
3830
- if (change.from > range.from)
3831
- intact2.push({from: range.from, to: change.from});
3832
- if (change.to < range.to)
3833
- intact2.push({from: change.to + diff, to: range.to + diff});
3834
- }
3835
- }
3836
- intact = intact2;
3837
- }
3838
- return intact;
3839
- }
3840
-
3841
- function getDimensions(cm) {
3842
- var d = cm.display, left = {}, width = {};
3843
- for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
3844
- left[cm.options.gutters[i]] = n.offsetLeft;
3845
- width[cm.options.gutters[i]] = n.offsetWidth;
3846
- }
3847
- return {fixedPos: compensateForHScroll(d),
3848
- gutterTotalWidth: d.gutters.offsetWidth,
3849
- gutterLeft: left,
3850
- gutterWidth: width,
3851
- wrapperWidth: d.wrapper.clientWidth};
3852
- }
3853
-
3854
- function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
3855
- var dims = getDimensions(cm);
3856
- var display = cm.display, lineNumbers = cm.options.lineNumbers;
3857
- if (!intact.length && (!webkit || !cm.display.currentWheelTarget))
3858
- removeChildren(display.lineDiv);
3859
- var container = display.lineDiv, cur = container.firstChild;
3860
-
3861
- function rm(node) {
3862
- var next = node.nextSibling;
3863
- if (webkit && mac && cm.display.currentWheelTarget == node) {
3864
- node.style.display = "none";
3865
- node.lineObj = null;
3866
- } else {
3867
- node.parentNode.removeChild(node);
3868
- }
3869
- return next;
3870
- }
3871
-
3872
- var nextIntact = intact.shift(), lineN = from;
3873
- cm.doc.iter(from, to, function(line) {
3874
- if (nextIntact && nextIntact.to == lineN) nextIntact = intact.shift();
3875
- if (lineIsHidden(cm.doc, line)) {
3876
- if (line.height != 0) updateLineHeight(line, 0);
3877
- if (line.widgets && cur && cur.previousSibling) for (var i = 0; i < line.widgets.length; ++i) {
3878
- var w = line.widgets[i];
3879
- if (w.showIfHidden) {
3880
- var prev = cur.previousSibling;
3881
- if (/pre/i.test(prev.nodeName)) {
3882
- var wrap = elt("div", null, null, "position: relative");
3883
- prev.parentNode.replaceChild(wrap, prev);
3884
- wrap.appendChild(prev);
3885
- prev = wrap;
3886
- }
3887
- var wnode = prev.appendChild(elt("div", [w.node], "CodeMirror-linewidget"));
3888
- if (!w.handleMouseEvents) wnode.ignoreEvents = true;
3889
- positionLineWidget(w, wnode, prev, dims);
3890
- }
3891
- }
3892
- } else if (nextIntact && nextIntact.from <= lineN && nextIntact.to > lineN) {
3893
- // This line is intact. Skip to the actual node. Update its
3894
- // line number if needed.
3895
- while (cur.lineObj != line) cur = rm(cur);
3896
- if (lineNumbers && updateNumbersFrom <= lineN && cur.lineNumber)
3897
- setTextContent(cur.lineNumber, lineNumberFor(cm.options, lineN));
3898
- cur = cur.nextSibling;
3899
- } else {
3900
- // For lines with widgets, make an attempt to find and reuse
3901
- // the existing element, so that widgets aren't needlessly
3902
- // removed and re-inserted into the dom
3903
- if (line.widgets) for (var j = 0, search = cur, reuse; search && j < 20; ++j, search = search.nextSibling)
3904
- if (search.lineObj == line && /div/i.test(search.nodeName)) { reuse = search; break; }
3905
- // This line needs to be generated.
3906
- var lineNode = buildLineElement(cm, line, lineN, dims, reuse);
3907
- if (lineNode != reuse) {
3908
- container.insertBefore(lineNode, cur);
3909
- } else {
3910
- while (cur != reuse) cur = rm(cur);
3911
- cur = cur.nextSibling;
3912
- }
3913
-
3914
- lineNode.lineObj = line;
3915
- }
3916
- ++lineN;
3917
- });
3918
- while (cur) cur = rm(cur);
3919
- }
3920
-
3921
- function buildLineElement(cm, line, lineNo, dims, reuse) {
3922
- var built = buildLineContent(cm, line), lineElement = built.pre;
3923
- var markers = line.gutterMarkers, display = cm.display, wrap;
3924
-
3925
- var bgClass = built.bgClass ? built.bgClass + " " + (line.bgClass || "") : line.bgClass;
3926
- if (!cm.options.lineNumbers && !markers && !bgClass && !line.wrapClass && !line.widgets)
3927
- return lineElement;
3928
-
3929
- // Lines with gutter elements, widgets or a background class need
3930
- // to be wrapped again, and have the extra elements added to the
3931
- // wrapper div
3932
-
3933
- if (reuse) {
3934
- reuse.alignable = null;
3935
- var isOk = true, widgetsSeen = 0, insertBefore = null;
3936
- for (var n = reuse.firstChild, next; n; n = next) {
3937
- next = n.nextSibling;
3938
- if (!/\bCodeMirror-linewidget\b/.test(n.className)) {
3939
- reuse.removeChild(n);
3940
- } else {
3941
- for (var i = 0; i < line.widgets.length; ++i) {
3942
- var widget = line.widgets[i];
3943
- if (widget.node == n.firstChild) {
3944
- if (!widget.above && !insertBefore) insertBefore = n;
3945
- positionLineWidget(widget, n, reuse, dims);
3946
- ++widgetsSeen;
3947
- break;
3948
- }
3949
- }
3950
- if (i == line.widgets.length) { isOk = false; break; }
3951
- }
3952
- }
3953
- reuse.insertBefore(lineElement, insertBefore);
3954
- if (isOk && widgetsSeen == line.widgets.length) {
3955
- wrap = reuse;
3956
- reuse.className = line.wrapClass || "";
3957
- }
3958
- }
3959
- if (!wrap) {
3960
- wrap = elt("div", null, line.wrapClass, "position: relative");
3961
- wrap.appendChild(lineElement);
3962
- }
3963
- // Kludge to make sure the styled element lies behind the selection (by z-index)
3964
- if (bgClass)
3965
- wrap.insertBefore(elt("div", null, bgClass + " CodeMirror-linebackground"), wrap.firstChild);
3966
- if (cm.options.lineNumbers || markers) {
3967
- var gutterWrap = wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " +
3968
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
3969
- lineElement);
3970
- if (cm.options.fixedGutter) (wrap.alignable || (wrap.alignable = [])).push(gutterWrap);
3971
- if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
3972
- wrap.lineNumber = gutterWrap.appendChild(
3973
- elt("div", lineNumberFor(cm.options, lineNo),
3974
- "CodeMirror-linenumber CodeMirror-gutter-elt",
3975
- "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
3976
- + display.lineNumInnerWidth + "px"));
3977
- if (markers)
3978
- for (var k = 0; k < cm.options.gutters.length; ++k) {
3979
- var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
3980
- if (found)
3981
- gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
3982
- dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
3983
- }
3984
- }
3985
- if (ie_lt8) wrap.style.zIndex = 2;
3986
- if (line.widgets && wrap != reuse) for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
3987
- var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
3988
- if (!widget.handleMouseEvents) node.ignoreEvents = true;
3989
- positionLineWidget(widget, node, wrap, dims);
3990
- if (widget.above)
3991
- wrap.insertBefore(node, cm.options.lineNumbers && line.height != 0 ? gutterWrap : lineElement);
3992
- else
3993
- wrap.appendChild(node);
3994
- signalLater(widget, "redraw");
3995
- }
3996
- return wrap;
3997
- }
3998
-
3999
- function positionLineWidget(widget, node, wrap, dims) {
4000
- if (widget.noHScroll) {
4001
- (wrap.alignable || (wrap.alignable = [])).push(node);
4002
- var width = dims.wrapperWidth;
4003
- node.style.left = dims.fixedPos + "px";
4004
- if (!widget.coverGutter) {
4005
- width -= dims.gutterTotalWidth;
4006
- node.style.paddingLeft = dims.gutterTotalWidth + "px";
4007
- }
4008
- node.style.width = width + "px";
4009
- }
4010
- if (widget.coverGutter) {
4011
- node.style.zIndex = 5;
4012
- node.style.position = "relative";
4013
- if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
4014
- }
4015
- }
4016
-
4017
- // SELECTION / CURSOR
4018
-
4019
- function updateSelection(cm) {
4020
- var display = cm.display;
4021
- var collapsed = posEq(cm.doc.sel.from, cm.doc.sel.to);
4022
- if (collapsed || cm.options.showCursorWhenSelecting)
4023
- updateSelectionCursor(cm);
4024
- else
4025
- display.cursor.style.display = display.otherCursor.style.display = "none";
4026
- if (!collapsed)
4027
- updateSelectionRange(cm);
4028
- else
4029
- display.selectionDiv.style.display = "none";
4030
-
4031
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
4032
- if (cm.options.moveInputWithCursor) {
4033
- var headPos = cursorCoords(cm, cm.doc.sel.head, "div");
4034
- var wrapOff = getRect(display.wrapper), lineOff = getRect(display.lineDiv);
4035
- display.inputDiv.style.top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
4036
- headPos.top + lineOff.top - wrapOff.top)) + "px";
4037
- display.inputDiv.style.left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
4038
- headPos.left + lineOff.left - wrapOff.left)) + "px";
4039
- }
4040
- }
4041
-
4042
- // No selection, plain cursor
4043
- function updateSelectionCursor(cm) {
4044
- var display = cm.display, pos = cursorCoords(cm, cm.doc.sel.head, "div");
4045
- display.cursor.style.left = pos.left + "px";
4046
- display.cursor.style.top = pos.top + "px";
4047
- display.cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
4048
- display.cursor.style.display = "";
4049
-
4050
- if (pos.other) {
4051
- display.otherCursor.style.display = "";
4052
- display.otherCursor.style.left = pos.other.left + "px";
4053
- display.otherCursor.style.top = pos.other.top + "px";
4054
- display.otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
4055
- } else { display.otherCursor.style.display = "none"; }
4056
- }
4057
-
4058
- // Highlight selection
4059
- function updateSelectionRange(cm) {
4060
- var display = cm.display, doc = cm.doc, sel = cm.doc.sel;
4061
- var fragment = document.createDocumentFragment();
4062
- var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - padding.right;
4063
-
4064
- function add(left, top, width, bottom) {
4065
- if (top < 0) top = 0;
4066
- fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
4067
- "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
4068
- "px; height: " + (bottom - top) + "px"));
4069
- }
4070
-
4071
- function drawForLine(line, fromArg, toArg) {
4072
- var lineObj = getLine(doc, line);
4073
- var lineLen = lineObj.text.length;
4074
- var start, end;
4075
- function coords(ch, bias) {
4076
- return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
4077
- }
4078
-
4079
- iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
4080
- var leftPos = coords(from, "left"), rightPos, left, right;
4081
- if (from == to) {
4082
- rightPos = leftPos;
4083
- left = right = leftPos.left;
4084
- } else {
4085
- rightPos = coords(to - 1, "right");
4086
- if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
4087
- left = leftPos.left;
4088
- right = rightPos.right;
4089
- }
4090
- if (fromArg == null && from == 0) left = leftSide;
4091
- if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
4092
- add(left, leftPos.top, null, leftPos.bottom);
4093
- left = leftSide;
4094
- if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
4095
- }
4096
- if (toArg == null && to == lineLen) right = rightSide;
4097
- if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
4098
- start = leftPos;
4099
- if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
4100
- end = rightPos;
4101
- if (left < leftSide + 1) left = leftSide;
4102
- add(left, rightPos.top, right - left, rightPos.bottom);
4103
- });
4104
- return {start: start, end: end};
4105
- }
4106
-
4107
- if (sel.from.line == sel.to.line) {
4108
- drawForLine(sel.from.line, sel.from.ch, sel.to.ch);
4109
- } else {
4110
- var fromLine = getLine(doc, sel.from.line), toLine = getLine(doc, sel.to.line);
4111
- var singleVLine = visualLine(doc, fromLine) == visualLine(doc, toLine);
4112
- var leftEnd = drawForLine(sel.from.line, sel.from.ch, singleVLine ? fromLine.text.length : null).end;
4113
- var rightStart = drawForLine(sel.to.line, singleVLine ? 0 : null, sel.to.ch).start;
4114
- if (singleVLine) {
4115
- if (leftEnd.top < rightStart.top - 2) {
4116
- add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
4117
- add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
4118
- } else {
4119
- add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
4120
- }
4121
- }
4122
- if (leftEnd.bottom < rightStart.top)
4123
- add(leftSide, leftEnd.bottom, null, rightStart.top);
4124
- }
4125
-
4126
- removeChildrenAndAdd(display.selectionDiv, fragment);
4127
- display.selectionDiv.style.display = "";
4128
- }
4129
-
4130
- // Cursor-blinking
4131
- function restartBlink(cm) {
4132
- if (!cm.state.focused) return;
4133
- var display = cm.display;
4134
- clearInterval(display.blinker);
4135
- var on = true;
4136
- display.cursor.style.visibility = display.otherCursor.style.visibility = "";
4137
- if (cm.options.cursorBlinkRate > 0)
4138
- display.blinker = setInterval(function() {
4139
- display.cursor.style.visibility = display.otherCursor.style.visibility = (on = !on) ? "" : "hidden";
4140
- }, cm.options.cursorBlinkRate);
4141
- }
4142
-
4143
- // HIGHLIGHT WORKER
4144
-
4145
- function startWorker(cm, time) {
4146
- if (cm.doc.mode.startState && cm.doc.frontier < cm.display.showingTo)
4147
- cm.state.highlight.set(time, bind(highlightWorker, cm));
4148
- }
4149
-
4150
- function highlightWorker(cm) {
4151
- var doc = cm.doc;
4152
- if (doc.frontier < doc.first) doc.frontier = doc.first;
4153
- if (doc.frontier >= cm.display.showingTo) return;
4154
- var end = +new Date + cm.options.workTime;
4155
- var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
4156
- var changed = [], prevChange;
4157
- doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.showingTo + 500), function(line) {
4158
- if (doc.frontier >= cm.display.showingFrom) { // Visible
4159
- var oldStyles = line.styles;
4160
- line.styles = highlightLine(cm, line, state, true);
4161
- var ischange = !oldStyles || oldStyles.length != line.styles.length;
4162
- for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
4163
- if (ischange) {
4164
- if (prevChange && prevChange.end == doc.frontier) prevChange.end++;
4165
- else changed.push(prevChange = {start: doc.frontier, end: doc.frontier + 1});
4166
- }
4167
- line.stateAfter = copyState(doc.mode, state);
4168
- } else {
4169
- processLine(cm, line.text, state);
4170
- line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
4171
- }
4172
- ++doc.frontier;
4173
- if (+new Date > end) {
4174
- startWorker(cm, cm.options.workDelay);
4175
- return true;
4176
- }
4177
- });
4178
- if (changed.length)
4179
- operation(cm, function() {
4180
- for (var i = 0; i < changed.length; ++i)
4181
- regChange(this, changed[i].start, changed[i].end);
4182
- })();
4183
- }
4184
-
4185
- // Finds the line to start with when starting a parse. Tries to
4186
- // find a line with a stateAfter, so that it can start with a
4187
- // valid state. If that fails, it returns the line with the
4188
- // smallest indentation, which tends to need the least context to
4189
- // parse correctly.
4190
- function findStartLine(cm, n, precise) {
4191
- var minindent, minline, doc = cm.doc;
4192
- var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
4193
- for (var search = n; search > lim; --search) {
4194
- if (search <= doc.first) return doc.first;
4195
- var line = getLine(doc, search - 1);
4196
- if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
4197
- var indented = countColumn(line.text, null, cm.options.tabSize);
4198
- if (minline == null || minindent > indented) {
4199
- minline = search - 1;
4200
- minindent = indented;
4201
- }
4202
- }
4203
- return minline;
4204
- }
4205
-
4206
- function getStateBefore(cm, n, precise) {
4207
- var doc = cm.doc, display = cm.display;
4208
- if (!doc.mode.startState) return true;
4209
- var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
4210
- if (!state) state = startState(doc.mode);
4211
- else state = copyState(doc.mode, state);
4212
- doc.iter(pos, n, function(line) {
4213
- processLine(cm, line.text, state);
4214
- var save = pos == n - 1 || pos % 5 == 0 || pos >= display.showingFrom && pos < display.showingTo;
4215
- line.stateAfter = save ? copyState(doc.mode, state) : null;
4216
- ++pos;
4217
- });
4218
- if (precise) doc.frontier = pos;
4219
- return state;
4220
- }
4221
-
4222
- // POSITION MEASUREMENT
4223
-
4224
- function paddingTop(display) {return display.lineSpace.offsetTop;}
4225
- function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
4226
- function paddingH(display) {
4227
- if (display.cachedPaddingH) return display.cachedPaddingH;
4228
- var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
4229
- var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
4230
- return display.cachedPaddingH = {left: parseInt(style.paddingLeft),
4231
- right: parseInt(style.paddingRight)};
4232
- }
4233
-
4234
- function measureChar(cm, line, ch, data, bias) {
4235
- var dir = -1;
4236
- data = data || measureLine(cm, line);
4237
- if (data.crude) {
4238
- var left = data.left + ch * data.width;
4239
- return {left: left, right: left + data.width, top: data.top, bottom: data.bottom};
4240
- }
4241
-
4242
- for (var pos = ch;; pos += dir) {
4243
- var r = data[pos];
4244
- if (r) break;
4245
- if (dir < 0 && pos == 0) dir = 1;
4246
- }
4247
- bias = pos > ch ? "left" : pos < ch ? "right" : bias;
4248
- if (bias == "left" && r.leftSide) r = r.leftSide;
4249
- else if (bias == "right" && r.rightSide) r = r.rightSide;
4250
- return {left: pos < ch ? r.right : r.left,
4251
- right: pos > ch ? r.left : r.right,
4252
- top: r.top,
4253
- bottom: r.bottom};
4254
- }
4255
-
4256
- function findCachedMeasurement(cm, line) {
4257
- var cache = cm.display.measureLineCache;
4258
- for (var i = 0; i < cache.length; ++i) {
4259
- var memo = cache[i];
4260
- if (memo.text == line.text && memo.markedSpans == line.markedSpans &&
4261
- cm.display.scroller.clientWidth == memo.width &&
4262
- memo.classes == line.textClass + "|" + line.wrapClass)
4263
- return memo;
4264
- }
4265
- }
4266
-
4267
- function clearCachedMeasurement(cm, line) {
4268
- var exists = findCachedMeasurement(cm, line);
4269
- if (exists) exists.text = exists.measure = exists.markedSpans = null;
4270
- }
4271
-
4272
- function measureLine(cm, line) {
4273
- // First look in the cache
4274
- var cached = findCachedMeasurement(cm, line);
4275
- if (cached) return cached.measure;
4276
-
4277
- // Failing that, recompute and store result in cache
4278
- var measure = measureLineInner(cm, line);
4279
- var cache = cm.display.measureLineCache;
4280
- var memo = {text: line.text, width: cm.display.scroller.clientWidth,
4281
- markedSpans: line.markedSpans, measure: measure,
4282
- classes: line.textClass + "|" + line.wrapClass};
4283
- if (cache.length == 16) cache[++cm.display.measureLineCachePos % 16] = memo;
4284
- else cache.push(memo);
4285
- return measure;
4286
- }
4287
-
4288
- function measureLineInner(cm, line) {
4289
- if (!cm.options.lineWrapping && line.text.length >= cm.options.crudeMeasuringFrom)
4290
- return crudelyMeasureLine(cm, line);
4291
-
4292
- var display = cm.display, measure = emptyArray(line.text.length);
4293
- var pre = buildLineContent(cm, line, measure, true).pre;
4294
-
4295
- // IE does not cache element positions of inline elements between
4296
- // calls to getBoundingClientRect. This makes the loop below,
4297
- // which gathers the positions of all the characters on the line,
4298
- // do an amount of layout work quadratic to the number of
4299
- // characters. When line wrapping is off, we try to improve things
4300
- // by first subdividing the line into a bunch of inline blocks, so
4301
- // that IE can reuse most of the layout information from caches
4302
- // for those blocks. This does interfere with line wrapping, so it
4303
- // doesn't work when wrapping is on, but in that case the
4304
- // situation is slightly better, since IE does cache line-wrapping
4305
- // information and only recomputes per-line.
4306
- if (old_ie && !ie_lt8 && !cm.options.lineWrapping && pre.childNodes.length > 100) {
4307
- var fragment = document.createDocumentFragment();
4308
- var chunk = 10, n = pre.childNodes.length;
4309
- for (var i = 0, chunks = Math.ceil(n / chunk); i < chunks; ++i) {
4310
- var wrap = elt("div", null, null, "display: inline-block");
4311
- for (var j = 0; j < chunk && n; ++j) {
4312
- wrap.appendChild(pre.firstChild);
4313
- --n;
4314
- }
4315
- fragment.appendChild(wrap);
4316
- }
4317
- pre.appendChild(fragment);
4318
- }
4319
-
4320
- removeChildrenAndAdd(display.measure, pre);
4321
-
4322
- var outer = getRect(display.lineDiv);
4323
- var vranges = [], data = emptyArray(line.text.length), maxBot = pre.offsetHeight;
4324
- // Work around an IE7/8 bug where it will sometimes have randomly
4325
- // replaced our pre with a clone at this point.
4326
- if (ie_lt9 && display.measure.first != pre)
4327
- removeChildrenAndAdd(display.measure, pre);
4328
-
4329
- function measureRect(rect) {
4330
- var top = rect.top - outer.top, bot = rect.bottom - outer.top;
4331
- if (bot > maxBot) bot = maxBot;
4332
- if (top < 0) top = 0;
4333
- for (var i = vranges.length - 2; i >= 0; i -= 2) {
4334
- var rtop = vranges[i], rbot = vranges[i+1];
4335
- if (rtop > bot || rbot < top) continue;
4336
- if (rtop <= top && rbot >= bot ||
4337
- top <= rtop && bot >= rbot ||
4338
- Math.min(bot, rbot) - Math.max(top, rtop) >= (bot - top) >> 1) {
4339
- vranges[i] = Math.min(top, rtop);
4340
- vranges[i+1] = Math.max(bot, rbot);
4341
- break;
4342
- }
4343
- }
4344
- if (i < 0) { i = vranges.length; vranges.push(top, bot); }
4345
- return {left: rect.left - outer.left,
4346
- right: rect.right - outer.left,
4347
- top: i, bottom: null};
4348
- }
4349
- function finishRect(rect) {
4350
- rect.bottom = vranges[rect.top+1];
4351
- rect.top = vranges[rect.top];
4352
- }
4353
-
4354
- for (var i = 0, cur; i < measure.length; ++i) if (cur = measure[i]) {
4355
- var node = cur, rect = null;
4356
- // A widget might wrap, needs special care
4357
- if (/\bCodeMirror-widget\b/.test(cur.className) && cur.getClientRects) {
4358
- if (cur.firstChild.nodeType == 1) node = cur.firstChild;
4359
- var rects = node.getClientRects();
4360
- if (rects.length > 1) {
4361
- rect = data[i] = measureRect(rects[0]);
4362
- rect.rightSide = measureRect(rects[rects.length - 1]);
4363
- }
4364
- }
4365
- if (!rect) rect = data[i] = measureRect(getRect(node));
4366
- if (cur.measureRight) rect.right = getRect(cur.measureRight).left - outer.left;
4367
- if (cur.leftSide) rect.leftSide = measureRect(getRect(cur.leftSide));
4368
- }
4369
- removeChildren(cm.display.measure);
4370
- for (var i = 0, cur; i < data.length; ++i) if (cur = data[i]) {
4371
- finishRect(cur);
4372
- if (cur.leftSide) finishRect(cur.leftSide);
4373
- if (cur.rightSide) finishRect(cur.rightSide);
4374
- }
4375
- return data;
4376
- }
4377
-
4378
- function crudelyMeasureLine(cm, line) {
4379
- var copy = new Line(line.text.slice(0, 100), null);
4380
- if (line.textClass) copy.textClass = line.textClass;
4381
- var measure = measureLineInner(cm, copy);
4382
- var left = measureChar(cm, copy, 0, measure, "left");
4383
- var right = measureChar(cm, copy, 99, measure, "right");
4384
- return {crude: true, top: left.top, left: left.left, bottom: left.bottom, width: (right.right - left.left) / 100};
4385
- }
4386
-
4387
- function measureLineWidth(cm, line) {
4388
- var hasBadSpan = false;
4389
- if (line.markedSpans) for (var i = 0; i < line.markedSpans; ++i) {
4390
- var sp = line.markedSpans[i];
4391
- if (sp.collapsed && (sp.to == null || sp.to == line.text.length)) hasBadSpan = true;
4392
- }
4393
- var cached = !hasBadSpan && findCachedMeasurement(cm, line);
4394
- if (cached || line.text.length >= cm.options.crudeMeasuringFrom)
4395
- return measureChar(cm, line, line.text.length, cached && cached.measure, "right").right;
4396
-
4397
- var pre = buildLineContent(cm, line, null, true).pre;
4398
- var end = pre.appendChild(zeroWidthElement(cm.display.measure));
4399
- removeChildrenAndAdd(cm.display.measure, pre);
4400
- return getRect(end).right - getRect(cm.display.lineDiv).left;
4401
- }
4402
-
4403
- function clearCaches(cm) {
4404
- cm.display.measureLineCache.length = cm.display.measureLineCachePos = 0;
4405
- cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
4406
- if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
4407
- cm.display.lineNumChars = null;
4408
- }
4409
-
4410
- function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
4411
- function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
4412
-
4413
- // Context is one of "line", "div" (display.lineDiv), "local"/null (editor), or "page"
4414
- function intoCoordSystem(cm, lineObj, rect, context) {
4415
- if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
4416
- var size = widgetHeight(lineObj.widgets[i]);
4417
- rect.top += size; rect.bottom += size;
4418
- }
4419
- if (context == "line") return rect;
4420
- if (!context) context = "local";
4421
- var yOff = heightAtLine(cm, lineObj);
4422
- if (context == "local") yOff += paddingTop(cm.display);
4423
- else yOff -= cm.display.viewOffset;
4424
- if (context == "page" || context == "window") {
4425
- var lOff = getRect(cm.display.lineSpace);
4426
- yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
4427
- var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
4428
- rect.left += xOff; rect.right += xOff;
4429
- }
4430
- rect.top += yOff; rect.bottom += yOff;
4431
- return rect;
4432
- }
4433
-
4434
- // Context may be "window", "page", "div", or "local"/null
4435
- // Result is in "div" coords
4436
- function fromCoordSystem(cm, coords, context) {
4437
- if (context == "div") return coords;
4438
- var left = coords.left, top = coords.top;
4439
- // First move into "page" coordinate system
4440
- if (context == "page") {
4441
- left -= pageScrollX();
4442
- top -= pageScrollY();
4443
- } else if (context == "local" || !context) {
4444
- var localBox = getRect(cm.display.sizer);
4445
- left += localBox.left;
4446
- top += localBox.top;
4447
- }
4448
-
4449
- var lineSpaceBox = getRect(cm.display.lineSpace);
4450
- return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
4451
- }
4452
-
4453
- function charCoords(cm, pos, context, lineObj, bias) {
4454
- if (!lineObj) lineObj = getLine(cm.doc, pos.line);
4455
- return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, null, bias), context);
4456
- }
4457
-
4458
- function cursorCoords(cm, pos, context, lineObj, measurement) {
4459
- lineObj = lineObj || getLine(cm.doc, pos.line);
4460
- if (!measurement) measurement = measureLine(cm, lineObj);
4461
- function get(ch, right) {
4462
- var m = measureChar(cm, lineObj, ch, measurement, right ? "right" : "left");
4463
- if (right) m.left = m.right; else m.right = m.left;
4464
- return intoCoordSystem(cm, lineObj, m, context);
4465
- }
4466
- function getBidi(ch, partPos) {
4467
- var part = order[partPos], right = part.level % 2;
4468
- if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
4469
- part = order[--partPos];
4470
- ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
4471
- right = true;
4472
- } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
4473
- part = order[++partPos];
4474
- ch = bidiLeft(part) - part.level % 2;
4475
- right = false;
4476
- }
4477
- if (right && ch == part.to && ch > part.from) return get(ch - 1);
4478
- return get(ch, right);
4479
- }
4480
- var order = getOrder(lineObj), ch = pos.ch;
4481
- if (!order) return get(ch);
4482
- var partPos = getBidiPartAt(order, ch);
4483
- var val = getBidi(ch, partPos);
4484
- if (bidiOther != null) val.other = getBidi(ch, bidiOther);
4485
- return val;
4486
- }
4487
-
4488
- function PosWithInfo(line, ch, outside, xRel) {
4489
- var pos = new Pos(line, ch);
4490
- pos.xRel = xRel;
4491
- if (outside) pos.outside = true;
4492
- return pos;
4493
- }
4494
-
4495
- // Coords must be lineSpace-local
4496
- function coordsChar(cm, x, y) {
4497
- var doc = cm.doc;
4498
- y += cm.display.viewOffset;
4499
- if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
4500
- var lineNo = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
4501
- if (lineNo > last)
4502
- return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
4503
- if (x < 0) x = 0;
4504
-
4505
- for (;;) {
4506
- var lineObj = getLine(doc, lineNo);
4507
- var found = coordsCharInner(cm, lineObj, lineNo, x, y);
4508
- var merged = collapsedSpanAtEnd(lineObj);
4509
- var mergedPos = merged && merged.find();
4510
- if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
4511
- lineNo = mergedPos.to.line;
4512
- else
4513
- return found;
4514
- }
4515
- }
4516
-
4517
- function coordsCharInner(cm, lineObj, lineNo, x, y) {
4518
- var innerOff = y - heightAtLine(cm, lineObj);
4519
- var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
4520
- var measurement = measureLine(cm, lineObj);
4521
-
4522
- function getX(ch) {
4523
- var sp = cursorCoords(cm, Pos(lineNo, ch), "line",
4524
- lineObj, measurement);
4525
- wrongLine = true;
4526
- if (innerOff > sp.bottom) return sp.left - adjust;
4527
- else if (innerOff < sp.top) return sp.left + adjust;
4528
- else wrongLine = false;
4529
- return sp.left;
4530
- }
4531
-
4532
- var bidi = getOrder(lineObj), dist = lineObj.text.length;
4533
- var from = lineLeft(lineObj), to = lineRight(lineObj);
4534
- var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
4535
-
4536
- if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
4537
- // Do a binary search between these bounds.
4538
- for (;;) {
4539
- if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
4540
- var ch = x < fromX || x - fromX <= toX - x ? from : to;
4541
- var xDiff = x - (ch == from ? fromX : toX);
4542
- while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
4543
- var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
4544
- xDiff < 0 ? -1 : xDiff ? 1 : 0);
4545
- return pos;
4546
- }
4547
- var step = Math.ceil(dist / 2), middle = from + step;
4548
- if (bidi) {
4549
- middle = from;
4550
- for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
4551
- }
4552
- var middleX = getX(middle);
4553
- if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
4554
- else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
4555
- }
4556
- }
4557
-
4558
- var measureText;
4559
- function textHeight(display) {
4560
- if (display.cachedTextHeight != null) return display.cachedTextHeight;
4561
- if (measureText == null) {
4562
- measureText = elt("pre");
4563
- // Measure a bunch of lines, for browsers that compute
4564
- // fractional heights.
4565
- for (var i = 0; i < 49; ++i) {
4566
- measureText.appendChild(document.createTextNode("x"));
4567
- measureText.appendChild(elt("br"));
4568
- }
4569
- measureText.appendChild(document.createTextNode("x"));
4570
- }
4571
- removeChildrenAndAdd(display.measure, measureText);
4572
- var height = measureText.offsetHeight / 50;
4573
- if (height > 3) display.cachedTextHeight = height;
4574
- removeChildren(display.measure);
4575
- return height || 1;
4576
- }
4577
-
4578
- function charWidth(display) {
4579
- if (display.cachedCharWidth != null) return display.cachedCharWidth;
4580
- var anchor = elt("span", "x");
4581
- var pre = elt("pre", [anchor]);
4582
- removeChildrenAndAdd(display.measure, pre);
4583
- var width = anchor.offsetWidth;
4584
- if (width > 2) display.cachedCharWidth = width;
4585
- return width || 10;
4586
- }
4587
-
4588
- // OPERATIONS
4589
-
4590
- // Operations are used to wrap changes in such a way that each
4591
- // change won't have to update the cursor and display (which would
4592
- // be awkward, slow, and error-prone), but instead updates are
4593
- // batched and then all combined and executed at once.
4594
-
4595
- var nextOpId = 0;
4596
- function startOperation(cm) {
4597
- cm.curOp = {
4598
- // An array of ranges of lines that have to be updated. See
4599
- // updateDisplay.
4600
- changes: [],
4601
- forceUpdate: false,
4602
- updateInput: null,
4603
- userSelChange: null,
4604
- textChanged: null,
4605
- selectionChanged: false,
4606
- cursorActivity: false,
4607
- updateMaxLine: false,
4608
- updateScrollPos: false,
4609
- id: ++nextOpId
4610
- };
4611
- if (!delayedCallbackDepth++) delayedCallbacks = [];
4612
- }
4613
-
4614
- function endOperation(cm) {
4615
- var op = cm.curOp, doc = cm.doc, display = cm.display;
4616
- cm.curOp = null;
4617
-
4618
- if (op.updateMaxLine) computeMaxLength(cm);
4619
- if (display.maxLineChanged && !cm.options.lineWrapping && display.maxLine) {
4620
- var width = measureLineWidth(cm, display.maxLine);
4621
- display.sizer.style.minWidth = Math.max(0, width + 3) + "px";
4622
- display.maxLineChanged = false;
4623
- var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + display.sizer.offsetWidth - display.scroller.clientWidth);
4624
- if (maxScrollLeft < doc.scrollLeft && !op.updateScrollPos)
4625
- setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true);
4626
- }
4627
- var newScrollPos, updated;
4628
- if (op.updateScrollPos) {
4629
- newScrollPos = op.updateScrollPos;
4630
- } else if (op.selectionChanged && display.scroller.clientHeight) { // don't rescroll if not visible
4631
- var coords = cursorCoords(cm, doc.sel.head);
4632
- newScrollPos = calculateScrollPos(cm, coords.left, coords.top, coords.left, coords.bottom);
4633
- }
4634
- if (op.changes.length || op.forceUpdate || newScrollPos && newScrollPos.scrollTop != null) {
4635
- updated = updateDisplay(cm, op.changes, newScrollPos && newScrollPos.scrollTop, op.forceUpdate);
4636
- if (cm.display.scroller.offsetHeight) cm.doc.scrollTop = cm.display.scroller.scrollTop;
4637
- }
4638
- if (!updated && op.selectionChanged) updateSelection(cm);
4639
- if (op.updateScrollPos) {
4640
- var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, newScrollPos.scrollTop));
4641
- var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, newScrollPos.scrollLeft));
4642
- display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top;
4643
- display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left;
4644
- alignHorizontally(cm);
4645
- if (op.scrollToPos)
4646
- scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos.from),
4647
- clipPos(cm.doc, op.scrollToPos.to), op.scrollToPos.margin);
4648
- } else if (newScrollPos) {
4649
- scrollCursorIntoView(cm);
4650
- }
4651
- if (op.selectionChanged) restartBlink(cm);
4652
-
4653
- if (cm.state.focused && op.updateInput)
4654
- resetInput(cm, op.userSelChange);
4655
-
4656
- var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
4657
- if (hidden) for (var i = 0; i < hidden.length; ++i)
4658
- if (!hidden[i].lines.length) signal(hidden[i], "hide");
4659
- if (unhidden) for (var i = 0; i < unhidden.length; ++i)
4660
- if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
4661
-
4662
- var delayed;
4663
- if (!--delayedCallbackDepth) {
4664
- delayed = delayedCallbacks;
4665
- delayedCallbacks = null;
4666
- }
4667
- if (op.textChanged)
4668
- signal(cm, "change", cm, op.textChanged);
4669
- if (op.cursorActivity) signal(cm, "cursorActivity", cm);
4670
- if (delayed) for (var i = 0; i < delayed.length; ++i) delayed[i]();
4671
- }
4672
-
4673
- // Wraps a function in an operation. Returns the wrapped function.
4674
- function operation(cm1, f) {
4675
- return function() {
4676
- var cm = cm1 || this, withOp = !cm.curOp;
4677
- if (withOp) startOperation(cm);
4678
- try { var result = f.apply(cm, arguments); }
4679
- finally { if (withOp) endOperation(cm); }
4680
- return result;
4681
- };
4682
- }
4683
- function docOperation(f) {
4684
- return function() {
4685
- var withOp = this.cm && !this.cm.curOp, result;
4686
- if (withOp) startOperation(this.cm);
4687
- try { result = f.apply(this, arguments); }
4688
- finally { if (withOp) endOperation(this.cm); }
4689
- return result;
4690
- };
4691
- }
4692
- function runInOp(cm, f) {
4693
- var withOp = !cm.curOp, result;
4694
- if (withOp) startOperation(cm);
4695
- try { result = f(); }
4696
- finally { if (withOp) endOperation(cm); }
4697
- return result;
4698
- }
4699
-
4700
- function regChange(cm, from, to, lendiff) {
4701
- if (from == null) from = cm.doc.first;
4702
- if (to == null) to = cm.doc.first + cm.doc.size;
4703
- cm.curOp.changes.push({from: from, to: to, diff: lendiff});
4704
- }
4705
-
4706
- // INPUT HANDLING
4707
-
4708
- function slowPoll(cm) {
4709
- if (cm.display.pollingFast) return;
4710
- cm.display.poll.set(cm.options.pollInterval, function() {
4711
- readInput(cm);
4712
- if (cm.state.focused) slowPoll(cm);
4713
- });
4714
- }
4715
-
4716
- function fastPoll(cm) {
4717
- var missed = false;
4718
- cm.display.pollingFast = true;
4719
- function p() {
4720
- var changed = readInput(cm);
4721
- if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}
4722
- else {cm.display.pollingFast = false; slowPoll(cm);}
4723
- }
4724
- cm.display.poll.set(20, p);
4725
- }
4726
-
4727
- // prevInput is a hack to work with IME. If we reset the textarea
4728
- // on every change, that breaks IME. So we look for changes
4729
- // compared to the previous content instead. (Modern browsers have
4730
- // events that indicate IME taking place, but these are not widely
4731
- // supported or compatible enough yet to rely on.)
4732
- function readInput(cm) {
4733
- var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc, sel = doc.sel;
4734
- if (!cm.state.focused || hasSelection(input) || isReadOnly(cm) || cm.options.disableInput) return false;
4735
- if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
4736
- input.value = input.value.substring(0, input.value.length - 1);
4737
- cm.state.fakedLastChar = false;
4738
- }
4739
- var text = input.value;
4740
- if (text == prevInput && posEq(sel.from, sel.to)) return false;
4741
- if (ie && !ie_lt9 && cm.display.inputHasSelection === text) {
4742
- resetInput(cm, true);
4743
- return false;
4744
- }
4745
-
4746
- var withOp = !cm.curOp;
4747
- if (withOp) startOperation(cm);
4748
- sel.shift = false;
4749
- var same = 0, l = Math.min(prevInput.length, text.length);
4750
- while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
4751
- var from = sel.from, to = sel.to;
4752
- var inserted = text.slice(same);
4753
- if (same < prevInput.length)
4754
- from = Pos(from.line, from.ch - (prevInput.length - same));
4755
- else if (cm.state.overwrite && posEq(from, to) && !cm.state.pasteIncoming)
4756
- to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + inserted.length));
4757
-
4758
- var updateInput = cm.curOp.updateInput;
4759
- var changeEvent = {from: from, to: to, text: splitLines(inserted),
4760
- origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
4761
- makeChange(cm.doc, changeEvent, "end");
4762
- cm.curOp.updateInput = updateInput;
4763
- signalLater(cm, "inputRead", cm, changeEvent);
4764
- if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
4765
- cm.options.smartIndent && sel.head.ch < 100) {
4766
- var electric = cm.getModeAt(sel.head).electricChars;
4767
- if (electric) for (var i = 0; i < electric.length; i++)
4768
- if (inserted.indexOf(electric.charAt(i)) > -1) {
4769
- indentLine(cm, sel.head.line, "smart");
4770
- break;
4771
- }
4772
- }
4773
-
4774
- if (text.length > 1000 || text.indexOf("\n") > -1) input.value = cm.display.prevInput = "";
4775
- else cm.display.prevInput = text;
4776
- if (withOp) endOperation(cm);
4777
- cm.state.pasteIncoming = cm.state.cutIncoming = false;
4778
- return true;
4779
- }
4780
-
4781
- function resetInput(cm, user) {
4782
- var minimal, selected, doc = cm.doc;
4783
- if (!posEq(doc.sel.from, doc.sel.to)) {
4784
- cm.display.prevInput = "";
4785
- minimal = hasCopyEvent &&
4786
- (doc.sel.to.line - doc.sel.from.line > 100 || (selected = cm.getSelection()).length > 1000);
4787
- var content = minimal ? "-" : selected || cm.getSelection();
4788
- cm.display.input.value = content;
4789
- if (cm.state.focused) selectInput(cm.display.input);
4790
- if (ie && !ie_lt9) cm.display.inputHasSelection = content;
4791
- } else if (user) {
4792
- cm.display.prevInput = cm.display.input.value = "";
4793
- if (ie && !ie_lt9) cm.display.inputHasSelection = null;
4794
- }
4795
- cm.display.inaccurateSelection = minimal;
4796
- }
4797
-
4798
- function focusInput(cm) {
4799
- if (cm.options.readOnly != "nocursor" && (!mobile || document.activeElement != cm.display.input))
4800
- cm.display.input.focus();
4801
- }
4802
-
4803
- function ensureFocus(cm) {
4804
- if (!cm.state.focused) { focusInput(cm); onFocus(cm); }
4805
- }
4806
-
4807
- function isReadOnly(cm) {
4808
- return cm.options.readOnly || cm.doc.cantEdit;
4809
- }
4810
-
4811
- // EVENT HANDLERS
4812
-
4813
- function registerEventHandlers(cm) {
4814
- var d = cm.display;
4815
- on(d.scroller, "mousedown", operation(cm, onMouseDown));
4816
- if (old_ie)
4817
- on(d.scroller, "dblclick", operation(cm, function(e) {
4818
- if (signalDOMEvent(cm, e)) return;
4819
- var pos = posFromMouse(cm, e);
4820
- if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
4821
- e_preventDefault(e);
4822
- var word = findWordAt(getLine(cm.doc, pos.line).text, pos);
4823
- extendSelection(cm.doc, word.from, word.to);
4824
- }));
4825
- else
4826
- on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
4827
- on(d.lineSpace, "selectstart", function(e) {
4828
- if (!eventInWidget(d, e)) e_preventDefault(e);
4829
- });
4830
- // Gecko browsers fire contextmenu *after* opening the menu, at
4831
- // which point we can't mess with it anymore. Context menu is
4832
- // handled in onMouseDown for Gecko.
4833
- if (!captureMiddleClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
4834
-
4835
- on(d.scroller, "scroll", function() {
4836
- if (d.scroller.clientHeight) {
4837
- setScrollTop(cm, d.scroller.scrollTop);
4838
- setScrollLeft(cm, d.scroller.scrollLeft, true);
4839
- signal(cm, "scroll", cm);
4840
- }
4841
- });
4842
- on(d.scrollbarV, "scroll", function() {
4843
- if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop);
4844
- });
4845
- on(d.scrollbarH, "scroll", function() {
4846
- if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft);
4847
- });
4848
-
4849
- on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
4850
- on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
4851
-
4852
- function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }
4853
- on(d.scrollbarH, "mousedown", reFocus);
4854
- on(d.scrollbarV, "mousedown", reFocus);
4855
- // Prevent wrapper from ever scrolling
4856
- on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
4857
-
4858
- var resizeTimer;
4859
- function onResize() {
4860
- if (resizeTimer == null) resizeTimer = setTimeout(function() {
4861
- resizeTimer = null;
4862
- // Might be a text scaling operation, clear size caches.
4863
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null;
4864
- clearCaches(cm);
4865
- runInOp(cm, bind(regChange, cm));
4866
- }, 100);
4867
- }
4868
- on(window, "resize", onResize);
4869
- // Above handler holds on to the editor and its data structures.
4870
- // Here we poll to unregister it when the editor is no longer in
4871
- // the document, so that it can be garbage-collected.
4872
- function unregister() {
4873
- for (var p = d.wrapper.parentNode; p && p != document.body; p = p.parentNode) {}
4874
- if (p) setTimeout(unregister, 5000);
4875
- else off(window, "resize", onResize);
4876
- }
4877
- setTimeout(unregister, 5000);
4878
-
4879
- on(d.input, "keyup", operation(cm, onKeyUp));
4880
- on(d.input, "input", function() {
4881
- if (ie && !ie_lt9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
4882
- fastPoll(cm);
4883
- });
4884
- on(d.input, "keydown", operation(cm, onKeyDown));
4885
- on(d.input, "keypress", operation(cm, onKeyPress));
4886
- on(d.input, "focus", bind(onFocus, cm));
4887
- on(d.input, "blur", bind(onBlur, cm));
4888
-
4889
- function drag_(e) {
4890
- if (signalDOMEvent(cm, e) || cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))) return;
4891
- e_stop(e);
4892
- }
4893
- if (cm.options.dragDrop) {
4894
- on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
4895
- on(d.scroller, "dragenter", drag_);
4896
- on(d.scroller, "dragover", drag_);
4897
- on(d.scroller, "drop", operation(cm, onDrop));
4898
- }
4899
- on(d.scroller, "paste", function(e) {
4900
- if (eventInWidget(d, e)) return;
4901
- focusInput(cm);
4902
- fastPoll(cm);
4903
- });
4904
- on(d.input, "paste", function() {
4905
- // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
4906
- // Add a char to the end of textarea before paste occur so that
4907
- // selection doesn't span to the end of textarea.
4908
- if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
4909
- var start = d.input.selectionStart, end = d.input.selectionEnd;
4910
- d.input.value += "$";
4911
- d.input.selectionStart = start;
4912
- d.input.selectionEnd = end;
4913
- cm.state.fakedLastChar = true;
4914
- }
4915
- cm.state.pasteIncoming = true;
4916
- fastPoll(cm);
4917
- });
4918
-
4919
- function prepareCopy(e) {
4920
- if (d.inaccurateSelection) {
4921
- d.prevInput = "";
4922
- d.inaccurateSelection = false;
4923
- d.input.value = cm.getSelection();
4924
- selectInput(d.input);
4925
- }
4926
- if (e.type == "cut") cm.state.cutIncoming = true;
4927
- }
4928
- on(d.input, "cut", prepareCopy);
4929
- on(d.input, "copy", prepareCopy);
4930
-
4931
- // Needed to handle Tab key in KHTML
4932
- if (khtml) on(d.sizer, "mouseup", function() {
4933
- if (document.activeElement == d.input) d.input.blur();
4934
- focusInput(cm);
4935
- });
4936
- }
4937
-
4938
- function eventInWidget(display, e) {
4939
- for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
4940
- if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true;
4941
- }
4942
- }
4943
-
4944
- function posFromMouse(cm, e, liberal) {
4945
- var display = cm.display;
4946
- if (!liberal) {
4947
- var target = e_target(e);
4948
- if (target == display.scrollbarH || target == display.scrollbarH.firstChild ||
4949
- target == display.scrollbarV || target == display.scrollbarV.firstChild ||
4950
- target == display.scrollbarFiller || target == display.gutterFiller) return null;
4951
- }
4952
- var x, y, space = getRect(display.lineSpace);
4953
- // Fails unpredictably on IE[67] when mouse is dragged around quickly.
4954
- try { x = e.clientX; y = e.clientY; } catch (e) { return null; }
4955
- return coordsChar(cm, x - space.left, y - space.top);
4956
- }
4957
-
4958
- var lastClick, lastDoubleClick;
4959
- function onMouseDown(e) {
4960
- if (signalDOMEvent(this, e)) return;
4961
- var cm = this, display = cm.display, doc = cm.doc, sel = doc.sel;
4962
- sel.shift = e.shiftKey;
4963
-
4964
- if (eventInWidget(display, e)) {
4965
- if (!webkit) {
4966
- display.scroller.draggable = false;
4967
- setTimeout(function(){display.scroller.draggable = true;}, 100);
4968
- }
4969
- return;
4970
- }
4971
- if (clickInGutter(cm, e)) return;
4972
- var start = posFromMouse(cm, e);
4973
- window.focus();
4974
-
4975
- switch (e_button(e)) {
4976
- case 3:
4977
- if (captureMiddleClick) onContextMenu.call(cm, cm, e);
4978
- return;
4979
- case 2:
4980
- if (webkit) cm.state.lastMiddleDown = +new Date;
4981
- if (start) extendSelection(cm.doc, start);
4982
- setTimeout(bind(focusInput, cm), 20);
4983
- e_preventDefault(e);
4984
- return;
4985
- }
4986
- // For button 1, if it was clicked inside the editor
4987
- // (posFromMouse returning non-null), we have to adjust the
4988
- // selection.
4989
- if (!start) {if (e_target(e) == display.scroller) e_preventDefault(e); return;}
4990
-
4991
- setTimeout(bind(ensureFocus, cm), 0);
4992
-
4993
- var now = +new Date, type = "single";
4994
- if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) {
4995
- type = "triple";
4996
- e_preventDefault(e);
4997
- setTimeout(bind(focusInput, cm), 20);
4998
- selectLine(cm, start.line);
4999
- } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) {
5000
- type = "double";
5001
- lastDoubleClick = {time: now, pos: start};
5002
- e_preventDefault(e);
5003
- var word = findWordAt(getLine(doc, start.line).text, start);
5004
- extendSelection(cm.doc, word.from, word.to);
5005
- } else { lastClick = {time: now, pos: start}; }
5006
-
5007
- var last = start;
5008
- if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) &&
5009
- !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
5010
- var dragEnd = operation(cm, function(e2) {
5011
- if (webkit) display.scroller.draggable = false;
5012
- cm.state.draggingText = false;
5013
- off(document, "mouseup", dragEnd);
5014
- off(display.scroller, "drop", dragEnd);
5015
- if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
5016
- e_preventDefault(e2);
5017
- extendSelection(cm.doc, start);
5018
- focusInput(cm);
5019
- // Work around unexplainable focus problem in IE9 (#2127)
5020
- if (old_ie && !ie_lt9)
5021
- setTimeout(function() {document.body.focus(); focusInput(cm);}, 20);
5022
- }
5023
- });
5024
- // Let the drag handler handle this.
5025
- if (webkit) display.scroller.draggable = true;
5026
- cm.state.draggingText = dragEnd;
5027
- // IE's approach to draggable
5028
- if (display.scroller.dragDrop) display.scroller.dragDrop();
5029
- on(document, "mouseup", dragEnd);
5030
- on(display.scroller, "drop", dragEnd);
5031
- return;
5032
- }
5033
- e_preventDefault(e);
5034
- if (type == "single") extendSelection(cm.doc, clipPos(doc, start));
5035
-
5036
- var startstart = sel.from, startend = sel.to, lastPos = start;
5037
-
5038
- function doSelect(cur) {
5039
- if (posEq(lastPos, cur)) return;
5040
- lastPos = cur;
5041
-
5042
- if (type == "single") {
5043
- extendSelection(cm.doc, clipPos(doc, start), cur);
5044
- return;
5045
- }
5046
-
5047
- startstart = clipPos(doc, startstart);
5048
- startend = clipPos(doc, startend);
5049
- if (type == "double") {
5050
- var word = findWordAt(getLine(doc, cur.line).text, cur);
5051
- if (posLess(cur, startstart)) extendSelection(cm.doc, word.from, startend);
5052
- else extendSelection(cm.doc, startstart, word.to);
5053
- } else if (type == "triple") {
5054
- if (posLess(cur, startstart)) extendSelection(cm.doc, startend, clipPos(doc, Pos(cur.line, 0)));
5055
- else extendSelection(cm.doc, startstart, clipPos(doc, Pos(cur.line + 1, 0)));
5056
- }
5057
- }
5058
-
5059
- var editorSize = getRect(display.wrapper);
5060
- // Used to ensure timeout re-tries don't fire when another extend
5061
- // happened in the meantime (clearTimeout isn't reliable -- at
5062
- // least on Chrome, the timeouts still happen even when cleared,
5063
- // if the clear happens after their scheduled firing time).
5064
- var counter = 0;
5065
-
5066
- function extend(e) {
5067
- var curCount = ++counter;
5068
- var cur = posFromMouse(cm, e, true);
5069
- if (!cur) return;
5070
- if (!posEq(cur, last)) {
5071
- ensureFocus(cm);
5072
- last = cur;
5073
- doSelect(cur);
5074
- var visible = visibleLines(display, doc);
5075
- if (cur.line >= visible.to || cur.line < visible.from)
5076
- setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
5077
- } else {
5078
- var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
5079
- if (outside) setTimeout(operation(cm, function() {
5080
- if (counter != curCount) return;
5081
- display.scroller.scrollTop += outside;
5082
- extend(e);
5083
- }), 50);
5084
- }
5085
- }
5086
-
5087
- function done(e) {
5088
- counter = Infinity;
5089
- e_preventDefault(e);
5090
- focusInput(cm);
5091
- off(document, "mousemove", move);
5092
- off(document, "mouseup", up);
5093
- }
5094
-
5095
- var move = operation(cm, function(e) {
5096
- if ((ie && !ie_lt10) ? !e.buttons : !e_button(e)) done(e);
5097
- else extend(e);
5098
- });
5099
- var up = operation(cm, done);
5100
- on(document, "mousemove", move);
5101
- on(document, "mouseup", up);
5102
- }
5103
-
5104
- function gutterEvent(cm, e, type, prevent, signalfn) {
5105
- try { var mX = e.clientX, mY = e.clientY; }
5106
- catch(e) { return false; }
5107
- if (mX >= Math.floor(getRect(cm.display.gutters).right)) return false;
5108
- if (prevent) e_preventDefault(e);
5109
-
5110
- var display = cm.display;
5111
- var lineBox = getRect(display.lineDiv);
5112
-
5113
- if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
5114
- mY -= lineBox.top - display.viewOffset;
5115
-
5116
- for (var i = 0; i < cm.options.gutters.length; ++i) {
5117
- var g = display.gutters.childNodes[i];
5118
- if (g && getRect(g).right >= mX) {
5119
- var line = lineAtHeight(cm.doc, mY);
5120
- var gutter = cm.options.gutters[i];
5121
- signalfn(cm, type, cm, line, gutter, e);
5122
- return e_defaultPrevented(e);
5123
- }
5124
- }
5125
- }
5126
-
5127
- function contextMenuInGutter(cm, e) {
5128
- if (!hasHandler(cm, "gutterContextMenu")) return false;
5129
- return gutterEvent(cm, e, "gutterContextMenu", false, signal);
5130
- }
5131
-
5132
- function clickInGutter(cm, e) {
5133
- return gutterEvent(cm, e, "gutterClick", true, signalLater);
5134
- }
5135
-
5136
- // Kludge to work around strange IE behavior where it'll sometimes
5137
- // re-fire a series of drag-related events right after the drop (#1551)
5138
- var lastDrop = 0;
5139
-
5140
- function onDrop(e) {
5141
- var cm = this;
5142
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))))
5143
- return;
5144
- e_preventDefault(e);
5145
- if (ie) lastDrop = +new Date;
5146
- var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
5147
- if (!pos || isReadOnly(cm)) return;
5148
- if (files && files.length && window.FileReader && window.File) {
5149
- var n = files.length, text = Array(n), read = 0;
5150
- var loadFile = function(file, i) {
5151
- var reader = new FileReader;
5152
- reader.onload = function() {
5153
- text[i] = reader.result;
5154
- if (++read == n) {
5155
- pos = clipPos(cm.doc, pos);
5156
- makeChange(cm.doc, {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}, "around");
5157
- }
5158
- };
5159
- reader.readAsText(file);
5160
- };
5161
- for (var i = 0; i < n; ++i) loadFile(files[i], i);
5162
- } else {
5163
- // Don't do a replace if the drop happened inside of the selected text.
5164
- if (cm.state.draggingText && !(posLess(pos, cm.doc.sel.from) || posLess(cm.doc.sel.to, pos))) {
5165
- cm.state.draggingText(e);
5166
- // Ensure the editor is re-focused
5167
- setTimeout(bind(focusInput, cm), 20);
5168
- return;
5169
- }
5170
- try {
5171
- var text = e.dataTransfer.getData("Text");
5172
- if (text) {
5173
- var curFrom = cm.doc.sel.from, curTo = cm.doc.sel.to;
5174
- setSelection(cm.doc, pos, pos);
5175
- if (cm.state.draggingText) replaceRange(cm.doc, "", curFrom, curTo, "paste");
5176
- cm.replaceSelection(text, null, "paste");
5177
- focusInput(cm);
5178
- }
5179
- }
5180
- catch(e){}
5181
- }
5182
- }
5183
-
5184
- function onDragStart(cm, e) {
5185
- if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
5186
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
5187
-
5188
- var txt = cm.getSelection();
5189
- e.dataTransfer.setData("Text", txt);
5190
-
5191
- // Use dummy image instead of default browsers image.
5192
- // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
5193
- if (e.dataTransfer.setDragImage && !safari) {
5194
- var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
5195
- img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
5196
- if (opera) {
5197
- img.width = img.height = 1;
5198
- cm.display.wrapper.appendChild(img);
5199
- // Force a relayout, or Opera won't use our image for some obscure reason
5200
- img._top = img.offsetTop;
5201
- }
5202
- e.dataTransfer.setDragImage(img, 0, 0);
5203
- if (opera) img.parentNode.removeChild(img);
5204
- }
5205
- }
5206
-
5207
- function setScrollTop(cm, val) {
5208
- if (Math.abs(cm.doc.scrollTop - val) < 2) return;
5209
- cm.doc.scrollTop = val;
5210
- if (!gecko) updateDisplay(cm, [], val);
5211
- if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
5212
- if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val;
5213
- if (gecko) updateDisplay(cm, []);
5214
- startWorker(cm, 100);
5215
- }
5216
- function setScrollLeft(cm, val, isScroller) {
5217
- if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
5218
- val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
5219
- cm.doc.scrollLeft = val;
5220
- alignHorizontally(cm);
5221
- if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
5222
- if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val;
5223
- }
5224
-
5225
- // Since the delta values reported on mouse wheel events are
5226
- // unstandardized between browsers and even browser versions, and
5227
- // generally horribly unpredictable, this code starts by measuring
5228
- // the scroll effect that the first few mouse wheel events have,
5229
- // and, from that, detects the way it can convert deltas to pixel
5230
- // offsets afterwards.
5231
- //
5232
- // The reason we want to know the amount a wheel event will scroll
5233
- // is that it gives us a chance to update the display before the
5234
- // actual scrolling happens, reducing flickering.
5235
-
5236
- var wheelSamples = 0, wheelPixelsPerUnit = null;
5237
- // Fill in a browser-detected starting value on browsers where we
5238
- // know one. These don't have to be accurate -- the result of them
5239
- // being wrong would just be a slight flicker on the first wheel
5240
- // scroll (if it is large enough).
5241
- if (ie) wheelPixelsPerUnit = -.53;
5242
- else if (gecko) wheelPixelsPerUnit = 15;
5243
- else if (chrome) wheelPixelsPerUnit = -.7;
5244
- else if (safari) wheelPixelsPerUnit = -1/3;
5245
-
5246
- function onScrollWheel(cm, e) {
5247
- var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
5248
- if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
5249
- if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
5250
- else if (dy == null) dy = e.wheelDelta;
5251
-
5252
- var display = cm.display, scroll = display.scroller;
5253
- // Quit if there's nothing to scroll here
5254
- if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
5255
- dy && scroll.scrollHeight > scroll.clientHeight)) return;
5256
-
5257
- // Webkit browsers on OS X abort momentum scrolls when the target
5258
- // of the scroll event is removed from the scrollable element.
5259
- // This hack (see related code in patchDisplay) makes sure the
5260
- // element is kept around.
5261
- if (dy && mac && webkit) {
5262
- for (var cur = e.target; cur != scroll; cur = cur.parentNode) {
5263
- if (cur.lineObj) {
5264
- cm.display.currentWheelTarget = cur;
5265
- break;
5266
- }
5267
- }
5268
- }
5269
-
5270
- // On some browsers, horizontal scrolling will cause redraws to
5271
- // happen before the gutter has been realigned, causing it to
5272
- // wriggle around in a most unseemly way. When we have an
5273
- // estimated pixels/delta value, we just handle horizontal
5274
- // scrolling entirely here. It'll be slightly off from native, but
5275
- // better than glitching out.
5276
- if (dx && !gecko && !opera && wheelPixelsPerUnit != null) {
5277
- if (dy)
5278
- setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
5279
- setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
5280
- e_preventDefault(e);
5281
- display.wheelStartX = null; // Abort measurement, if in progress
5282
- return;
5283
- }
5284
-
5285
- if (dy && wheelPixelsPerUnit != null) {
5286
- var pixels = dy * wheelPixelsPerUnit;
5287
- var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
5288
- if (pixels < 0) top = Math.max(0, top + pixels - 50);
5289
- else bot = Math.min(cm.doc.height, bot + pixels + 50);
5290
- updateDisplay(cm, [], {top: top, bottom: bot});
5291
- }
5292
-
5293
- if (wheelSamples < 20) {
5294
- if (display.wheelStartX == null) {
5295
- display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
5296
- display.wheelDX = dx; display.wheelDY = dy;
5297
- setTimeout(function() {
5298
- if (display.wheelStartX == null) return;
5299
- var movedX = scroll.scrollLeft - display.wheelStartX;
5300
- var movedY = scroll.scrollTop - display.wheelStartY;
5301
- var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
5302
- (movedX && display.wheelDX && movedX / display.wheelDX);
5303
- display.wheelStartX = display.wheelStartY = null;
5304
- if (!sample) return;
5305
- wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
5306
- ++wheelSamples;
5307
- }, 200);
5308
- } else {
5309
- display.wheelDX += dx; display.wheelDY += dy;
5310
- }
5311
- }
5312
- }
5313
-
5314
- function doHandleBinding(cm, bound, dropShift) {
5315
- if (typeof bound == "string") {
5316
- bound = commands[bound];
5317
- if (!bound) return false;
5318
- }
5319
- // Ensure previous input has been read, so that the handler sees a
5320
- // consistent view of the document
5321
- if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;
5322
- var doc = cm.doc, prevShift = doc.sel.shift, done = false;
5323
- try {
5324
- if (isReadOnly(cm)) cm.state.suppressEdits = true;
5325
- if (dropShift) doc.sel.shift = false;
5326
- done = bound(cm) != Pass;
5327
- } finally {
5328
- doc.sel.shift = prevShift;
5329
- cm.state.suppressEdits = false;
5330
- }
5331
- return done;
5332
- }
5333
-
5334
- function allKeyMaps(cm) {
5335
- var maps = cm.state.keyMaps.slice(0);
5336
- if (cm.options.extraKeys) maps.push(cm.options.extraKeys);
5337
- maps.push(cm.options.keyMap);
5338
- return maps;
5339
- }
5340
-
5341
- var maybeTransition;
5342
- function handleKeyBinding(cm, e) {
5343
- // Handle auto keymap transitions
5344
- var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
5345
- clearTimeout(maybeTransition);
5346
- if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
5347
- if (getKeyMap(cm.options.keyMap) == startMap) {
5348
- cm.options.keyMap = (next.call ? next.call(null, cm) : next);
5349
- keyMapChanged(cm);
5350
- }
5351
- }, 50);
5352
-
5353
- var name = keyName(e, true), handled = false;
5354
- if (!name) return false;
5355
- var keymaps = allKeyMaps(cm);
5356
-
5357
- if (e.shiftKey) {
5358
- // First try to resolve full name (including 'Shift-'). Failing
5359
- // that, see if there is a cursor-motion command (starting with
5360
- // 'go') bound to the keyname without 'Shift-'.
5361
- handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);})
5362
- || lookupKey(name, keymaps, function(b) {
5363
- if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
5364
- return doHandleBinding(cm, b);
5365
- });
5366
- } else {
5367
- handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); });
5368
- }
5369
-
5370
- if (handled) {
5371
- e_preventDefault(e);
5372
- restartBlink(cm);
5373
- if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
5374
- signalLater(cm, "keyHandled", cm, name, e);
5375
- }
5376
- return handled;
5377
- }
5378
-
5379
- function handleCharBinding(cm, e, ch) {
5380
- var handled = lookupKey("'" + ch + "'", allKeyMaps(cm),
5381
- function(b) { return doHandleBinding(cm, b, true); });
5382
- if (handled) {
5383
- e_preventDefault(e);
5384
- restartBlink(cm);
5385
- signalLater(cm, "keyHandled", cm, "'" + ch + "'", e);
5386
- }
5387
- return handled;
5388
- }
5389
-
5390
- function onKeyUp(e) {
5391
- var cm = this;
5392
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
5393
- if (e.keyCode == 16) cm.doc.sel.shift = false;
5394
- }
5395
-
5396
- var lastStoppedKey = null;
5397
- function onKeyDown(e) {
5398
- var cm = this;
5399
- ensureFocus(cm);
5400
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
5401
- if (old_ie && e.keyCode == 27) e.returnValue = false;
5402
- var code = e.keyCode;
5403
- // IE does strange things with escape.
5404
- cm.doc.sel.shift = code == 16 || e.shiftKey;
5405
- // First give onKeyEvent option a chance to handle this.
5406
- var handled = handleKeyBinding(cm, e);
5407
- if (opera) {
5408
- lastStoppedKey = handled ? code : null;
5409
- // Opera has no cut event... we try to at least catch the key combo
5410
- if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
5411
- cm.replaceSelection("");
5412
- }
5413
- }
5414
-
5415
- function onKeyPress(e) {
5416
- var cm = this;
5417
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
5418
- var keyCode = e.keyCode, charCode = e.charCode;
5419
- if (opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
5420
- if (((opera && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;
5421
- var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
5422
- if (handleCharBinding(cm, e, ch)) return;
5423
- if (ie && !ie_lt9) cm.display.inputHasSelection = null;
5424
- fastPoll(cm);
5425
- }
5426
-
5427
- function onFocus(cm) {
5428
- if (cm.options.readOnly == "nocursor") return;
5429
- if (!cm.state.focused) {
5430
- signal(cm, "focus", cm);
5431
- cm.state.focused = true;
5432
- if (cm.display.wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
5433
- cm.display.wrapper.className += " CodeMirror-focused";
5434
- if (!cm.curOp) {
5435
- resetInput(cm, true);
5436
- if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730
5437
- }
5438
- }
5439
- slowPoll(cm);
5440
- restartBlink(cm);
5441
- }
5442
- function onBlur(cm) {
5443
- if (cm.state.focused) {
5444
- signal(cm, "blur", cm);
5445
- cm.state.focused = false;
5446
- cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-focused", "");
5447
- }
5448
- clearInterval(cm.display.blinker);
5449
- setTimeout(function() {if (!cm.state.focused) cm.doc.sel.shift = false;}, 150);
5450
- }
5451
-
5452
- var detectingSelectAll;
5453
- function onContextMenu(cm, e) {
5454
- if (signalDOMEvent(cm, e, "contextmenu")) return;
5455
- var display = cm.display, sel = cm.doc.sel;
5456
- if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;
5457
-
5458
- var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
5459
- if (!pos || opera) return; // Opera is difficult.
5460
-
5461
- // Reset the current text selection only if the click is done outside of the selection
5462
- // and 'resetSelectionOnContextMenu' option is true.
5463
- var reset = cm.options.resetSelectionOnContextMenu;
5464
- if (reset && (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to)))
5465
- operation(cm, setSelection)(cm.doc, pos, pos);
5466
-
5467
- var oldCSS = display.input.style.cssText;
5468
- display.inputDiv.style.position = "absolute";
5469
- display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
5470
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: transparent; outline: none;" +
5471
- "border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);";
5472
- focusInput(cm);
5473
- resetInput(cm, true);
5474
- // Adds "Select all" to context menu in FF
5475
- if (posEq(sel.from, sel.to)) display.input.value = display.prevInput = " ";
5476
-
5477
- function prepareSelectAllHack() {
5478
- if (display.input.selectionStart != null) {
5479
- var extval = display.input.value = "\u200b" + (posEq(sel.from, sel.to) ? "" : display.input.value);
5480
- display.prevInput = "\u200b";
5481
- display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
5482
- }
5483
- }
5484
- function rehide() {
5485
- display.inputDiv.style.position = "relative";
5486
- display.input.style.cssText = oldCSS;
5487
- if (ie_lt9) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos;
5488
- slowPoll(cm);
5489
-
5490
- // Try to detect the user choosing select-all
5491
- if (display.input.selectionStart != null) {
5492
- if (!ie || ie_lt9) prepareSelectAllHack();
5493
- clearTimeout(detectingSelectAll);
5494
- var i = 0, poll = function(){
5495
- if (display.prevInput == "\u200b" && display.input.selectionStart == 0)
5496
- operation(cm, commands.selectAll)(cm);
5497
- else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
5498
- else resetInput(cm);
5499
- };
5500
- detectingSelectAll = setTimeout(poll, 200);
5501
- }
5502
- }
5503
-
5504
- if (ie && !ie_lt9) prepareSelectAllHack();
5505
- if (captureMiddleClick) {
5506
- e_stop(e);
5507
- var mouseup = function() {
5508
- off(window, "mouseup", mouseup);
5509
- setTimeout(rehide, 20);
5510
- };
5511
- on(window, "mouseup", mouseup);
5512
- } else {
5513
- setTimeout(rehide, 50);
5514
- }
5515
- }
5516
-
5517
- // UPDATING
5518
-
5519
- var changeEnd = CodeMirror.changeEnd = function(change) {
5520
- if (!change.text) return change.to;
5521
- return Pos(change.from.line + change.text.length - 1,
5522
- lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
5523
- };
5524
-
5525
- // Make sure a position will be valid after the given change.
5526
- function clipPostChange(doc, change, pos) {
5527
- if (!posLess(change.from, pos)) return clipPos(doc, pos);
5528
- var diff = (change.text.length - 1) - (change.to.line - change.from.line);
5529
- if (pos.line > change.to.line + diff) {
5530
- var preLine = pos.line - diff, lastLine = doc.first + doc.size - 1;
5531
- if (preLine > lastLine) return Pos(lastLine, getLine(doc, lastLine).text.length);
5532
- return clipToLen(pos, getLine(doc, preLine).text.length);
5533
- }
5534
- if (pos.line == change.to.line + diff)
5535
- return clipToLen(pos, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0) +
5536
- getLine(doc, change.to.line).text.length - change.to.ch);
5537
- var inside = pos.line - change.from.line;
5538
- return clipToLen(pos, change.text[inside].length + (inside ? 0 : change.from.ch));
5539
- }
5540
-
5541
- // Hint can be null|"end"|"start"|"around"|{anchor,head}
5542
- function computeSelAfterChange(doc, change, hint) {
5543
- if (hint && typeof hint == "object") // Assumed to be {anchor, head} object
5544
- return {anchor: clipPostChange(doc, change, hint.anchor),
5545
- head: clipPostChange(doc, change, hint.head)};
5546
-
5547
- if (hint == "start") return {anchor: change.from, head: change.from};
5548
-
5549
- var end = changeEnd(change);
5550
- if (hint == "around") return {anchor: change.from, head: end};
5551
- if (hint == "end") return {anchor: end, head: end};
5552
-
5553
- // hint is null, leave the selection alone as much as possible
5554
- var adjustPos = function(pos) {
5555
- if (posLess(pos, change.from)) return pos;
5556
- if (!posLess(change.to, pos)) return end;
5557
-
5558
- var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
5559
- if (pos.line == change.to.line) ch += end.ch - change.to.ch;
5560
- return Pos(line, ch);
5561
- };
5562
- return {anchor: adjustPos(doc.sel.anchor), head: adjustPos(doc.sel.head)};
5563
- }
5564
-
5565
- function filterChange(doc, change, update) {
5566
- var obj = {
5567
- canceled: false,
5568
- from: change.from,
5569
- to: change.to,
5570
- text: change.text,
5571
- origin: change.origin,
5572
- cancel: function() { this.canceled = true; }
5573
- };
5574
- if (update) obj.update = function(from, to, text, origin) {
5575
- if (from) this.from = clipPos(doc, from);
5576
- if (to) this.to = clipPos(doc, to);
5577
- if (text) this.text = text;
5578
- if (origin !== undefined) this.origin = origin;
5579
- };
5580
- signal(doc, "beforeChange", doc, obj);
5581
- if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
5582
-
5583
- if (obj.canceled) return null;
5584
- return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
5585
- }
5586
-
5587
- // Replace the range from from to to by the strings in replacement.
5588
- // change is a {from, to, text [, origin]} object
5589
- function makeChange(doc, change, selUpdate, ignoreReadOnly) {
5590
- if (doc.cm) {
5591
- if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, selUpdate, ignoreReadOnly);
5592
- if (doc.cm.state.suppressEdits) return;
5593
- }
5594
-
5595
- if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
5596
- change = filterChange(doc, change, true);
5597
- if (!change) return;
5598
- }
5599
-
5600
- // Possibly split or suppress the update based on the presence
5601
- // of read-only spans in its range.
5602
- var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
5603
- if (split) {
5604
- for (var i = split.length - 1; i >= 1; --i)
5605
- makeChangeNoReadonly(doc, {from: split[i].from, to: split[i].to, text: [""]});
5606
- if (split.length)
5607
- makeChangeNoReadonly(doc, {from: split[0].from, to: split[0].to, text: change.text}, selUpdate);
5608
- } else {
5609
- makeChangeNoReadonly(doc, change, selUpdate);
5610
- }
5611
- }
5612
-
5613
- function makeChangeNoReadonly(doc, change, selUpdate) {
5614
- if (change.text.length == 1 && change.text[0] == "" && posEq(change.from, change.to)) return;
5615
- var selAfter = computeSelAfterChange(doc, change, selUpdate);
5616
- addToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
5617
-
5618
- makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
5619
- var rebased = [];
5620
-
5621
- linkedDocs(doc, function(doc, sharedHist) {
5622
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
5623
- rebaseHist(doc.history, change);
5624
- rebased.push(doc.history);
5625
- }
5626
- makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
5627
- });
5628
- }
5629
-
5630
- function makeChangeFromHistory(doc, type) {
5631
- if (doc.cm && doc.cm.state.suppressEdits) return;
5632
-
5633
- var hist = doc.history;
5634
- var event = (type == "undo" ? hist.done : hist.undone).pop();
5635
- if (!event) return;
5636
-
5637
- var anti = {changes: [], anchorBefore: event.anchorAfter, headBefore: event.headAfter,
5638
- anchorAfter: event.anchorBefore, headAfter: event.headBefore,
5639
- generation: hist.generation};
5640
- (type == "undo" ? hist.undone : hist.done).push(anti);
5641
- hist.generation = event.generation || ++hist.maxGeneration;
5642
-
5643
- var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
5644
-
5645
- for (var i = event.changes.length - 1; i >= 0; --i) {
5646
- var change = event.changes[i];
5647
- change.origin = type;
5648
- if (filter && !filterChange(doc, change, false)) {
5649
- (type == "undo" ? hist.done : hist.undone).length = 0;
5650
- return;
5651
- }
5652
-
5653
- anti.changes.push(historyChangeFromChange(doc, change));
5654
-
5655
- var after = i ? computeSelAfterChange(doc, change, null)
5656
- : {anchor: event.anchorBefore, head: event.headBefore};
5657
- makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
5658
- var rebased = [];
5659
-
5660
- linkedDocs(doc, function(doc, sharedHist) {
5661
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
5662
- rebaseHist(doc.history, change);
5663
- rebased.push(doc.history);
5664
- }
5665
- makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
5666
- });
5667
- }
5668
- }
5669
-
5670
- function shiftDoc(doc, distance) {
5671
- function shiftPos(pos) {return Pos(pos.line + distance, pos.ch);}
5672
- doc.first += distance;
5673
- if (doc.cm) regChange(doc.cm, doc.first, doc.first, distance);
5674
- doc.sel.head = shiftPos(doc.sel.head); doc.sel.anchor = shiftPos(doc.sel.anchor);
5675
- doc.sel.from = shiftPos(doc.sel.from); doc.sel.to = shiftPos(doc.sel.to);
5676
- }
5677
-
5678
- function makeChangeSingleDoc(doc, change, selAfter, spans) {
5679
- if (doc.cm && !doc.cm.curOp)
5680
- return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
5681
-
5682
- if (change.to.line < doc.first) {
5683
- shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
5684
- return;
5685
- }
5686
- if (change.from.line > doc.lastLine()) return;
5687
-
5688
- // Clip the change to the size of this doc
5689
- if (change.from.line < doc.first) {
5690
- var shift = change.text.length - 1 - (doc.first - change.from.line);
5691
- shiftDoc(doc, shift);
5692
- change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
5693
- text: [lst(change.text)], origin: change.origin};
5694
- }
5695
- var last = doc.lastLine();
5696
- if (change.to.line > last) {
5697
- change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
5698
- text: [change.text[0]], origin: change.origin};
5699
- }
5700
-
5701
- change.removed = getBetween(doc, change.from, change.to);
5702
-
5703
- if (!selAfter) selAfter = computeSelAfterChange(doc, change, null);
5704
- if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans, selAfter);
5705
- else updateDoc(doc, change, spans, selAfter);
5706
- }
5707
-
5708
- function makeChangeSingleDocInEditor(cm, change, spans, selAfter) {
5709
- var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
5710
-
5711
- var recomputeMaxLength = false, checkWidthStart = from.line;
5712
- if (!cm.options.lineWrapping) {
5713
- checkWidthStart = lineNo(visualLine(doc, getLine(doc, from.line)));
5714
- doc.iter(checkWidthStart, to.line + 1, function(line) {
5715
- if (line == display.maxLine) {
5716
- recomputeMaxLength = true;
5717
- return true;
5718
- }
5719
- });
5720
- }
5721
-
5722
- if (!posLess(doc.sel.head, change.from) && !posLess(change.to, doc.sel.head))
5723
- cm.curOp.cursorActivity = true;
5724
-
5725
- updateDoc(doc, change, spans, selAfter, estimateHeight(cm));
5726
-
5727
- if (!cm.options.lineWrapping) {
5728
- doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
5729
- var len = lineLength(doc, line);
5730
- if (len > display.maxLineLength) {
5731
- display.maxLine = line;
5732
- display.maxLineLength = len;
5733
- display.maxLineChanged = true;
5734
- recomputeMaxLength = false;
5735
- }
5736
- });
5737
- if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
5738
- }
5739
-
5740
- // Adjust frontier, schedule worker
5741
- doc.frontier = Math.min(doc.frontier, from.line);
5742
- startWorker(cm, 400);
5743
-
5744
- var lendiff = change.text.length - (to.line - from.line) - 1;
5745
- // Remember that these lines changed, for updating the display
5746
- regChange(cm, from.line, to.line + 1, lendiff);
5747
-
5748
- if (hasHandler(cm, "change")) {
5749
- var changeObj = {from: from, to: to,
5750
- text: change.text,
5751
- removed: change.removed,
5752
- origin: change.origin};
5753
- if (cm.curOp.textChanged) {
5754
- for (var cur = cm.curOp.textChanged; cur.next; cur = cur.next) {}
5755
- cur.next = changeObj;
5756
- } else cm.curOp.textChanged = changeObj;
5757
- }
5758
- }
5759
-
5760
- function replaceRange(doc, code, from, to, origin) {
5761
- if (!to) to = from;
5762
- if (posLess(to, from)) { var tmp = to; to = from; from = tmp; }
5763
- if (typeof code == "string") code = splitLines(code);
5764
- makeChange(doc, {from: from, to: to, text: code, origin: origin}, null);
5765
- }
5766
-
5767
- // POSITION OBJECT
5768
-
5769
- function Pos(line, ch) {
5770
- if (!(this instanceof Pos)) return new Pos(line, ch);
5771
- this.line = line; this.ch = ch;
5772
- }
5773
- CodeMirror.Pos = Pos;
5774
-
5775
- function posEq(a, b) {return a.line == b.line && a.ch == b.ch;}
5776
- function posLess(a, b) {return a.line < b.line || (a.line == b.line && a.ch < b.ch);}
5777
- function cmp(a, b) {return a.line - b.line || a.ch - b.ch;}
5778
- function copyPos(x) {return Pos(x.line, x.ch);}
5779
-
5780
- // SELECTION
5781
-
5782
- function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
5783
- function clipPos(doc, pos) {
5784
- if (pos.line < doc.first) return Pos(doc.first, 0);
5785
- var last = doc.first + doc.size - 1;
5786
- if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
5787
- return clipToLen(pos, getLine(doc, pos.line).text.length);
5788
- }
5789
- function clipToLen(pos, linelen) {
5790
- var ch = pos.ch;
5791
- if (ch == null || ch > linelen) return Pos(pos.line, linelen);
5792
- else if (ch < 0) return Pos(pos.line, 0);
5793
- else return pos;
5794
- }
5795
- function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
5796
-
5797
- // If shift is held, this will move the selection anchor. Otherwise,
5798
- // it'll set the whole selection.
5799
- function extendSelection(doc, pos, other, bias) {
5800
- if (doc.sel.shift || doc.sel.extend) {
5801
- var anchor = doc.sel.anchor;
5802
- if (other) {
5803
- var posBefore = posLess(pos, anchor);
5804
- if (posBefore != posLess(other, anchor)) {
5805
- anchor = pos;
5806
- pos = other;
5807
- } else if (posBefore != posLess(pos, other)) {
5808
- pos = other;
5809
- }
5810
- }
5811
- setSelection(doc, anchor, pos, bias);
5812
- } else {
5813
- setSelection(doc, pos, other || pos, bias);
5814
- }
5815
- if (doc.cm) doc.cm.curOp.userSelChange = true;
5816
- }
5817
-
5818
- function filterSelectionChange(doc, anchor, head) {
5819
- var obj = {anchor: anchor, head: head};
5820
- signal(doc, "beforeSelectionChange", doc, obj);
5821
- if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
5822
- obj.anchor = clipPos(doc, obj.anchor); obj.head = clipPos(doc, obj.head);
5823
- return obj;
5824
- }
5825
-
5826
- // Update the selection. Last two args are only used by
5827
- // updateDoc, since they have to be expressed in the line
5828
- // numbers before the update.
5829
- function setSelection(doc, anchor, head, bias, checkAtomic) {
5830
- if (!checkAtomic && hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) {
5831
- var filtered = filterSelectionChange(doc, anchor, head);
5832
- head = filtered.head;
5833
- anchor = filtered.anchor;
5834
- }
5835
-
5836
- var sel = doc.sel;
5837
- sel.goalColumn = null;
5838
- if (bias == null) bias = posLess(head, sel.head) ? -1 : 1;
5839
- // Skip over atomic spans.
5840
- if (checkAtomic || !posEq(anchor, sel.anchor))
5841
- anchor = skipAtomic(doc, anchor, bias, checkAtomic != "push");
5842
- if (checkAtomic || !posEq(head, sel.head))
5843
- head = skipAtomic(doc, head, bias, checkAtomic != "push");
5844
-
5845
- if (posEq(sel.anchor, anchor) && posEq(sel.head, head)) return;
5846
-
5847
- sel.anchor = anchor; sel.head = head;
5848
- var inv = posLess(head, anchor);
5849
- sel.from = inv ? head : anchor;
5850
- sel.to = inv ? anchor : head;
5851
-
5852
- if (doc.cm)
5853
- doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged =
5854
- doc.cm.curOp.cursorActivity = true;
5855
-
5856
- signalLater(doc, "cursorActivity", doc);
5857
- }
5858
-
5859
- function reCheckSelection(cm) {
5860
- setSelection(cm.doc, cm.doc.sel.from, cm.doc.sel.to, null, "push");
5861
- }
5862
-
5863
- function skipAtomic(doc, pos, bias, mayClear) {
5864
- var flipped = false, curPos = pos;
5865
- var dir = bias || 1;
5866
- doc.cantEdit = false;
5867
- search: for (;;) {
5868
- var line = getLine(doc, curPos.line);
5869
- if (line.markedSpans) {
5870
- for (var i = 0; i < line.markedSpans.length; ++i) {
5871
- var sp = line.markedSpans[i], m = sp.marker;
5872
- if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
5873
- (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
5874
- if (mayClear) {
5875
- signal(m, "beforeCursorEnter");
5876
- if (m.explicitlyCleared) {
5877
- if (!line.markedSpans) break;
5878
- else {--i; continue;}
5879
- }
5880
- }
5881
- if (!m.atomic) continue;
5882
- var newPos = m.find()[dir < 0 ? "from" : "to"];
5883
- if (posEq(newPos, curPos)) {
5884
- newPos.ch += dir;
5885
- if (newPos.ch < 0) {
5886
- if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
5887
- else newPos = null;
5888
- } else if (newPos.ch > line.text.length) {
5889
- if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
5890
- else newPos = null;
5891
- }
5892
- if (!newPos) {
5893
- if (flipped) {
5894
- // Driven in a corner -- no valid cursor position found at all
5895
- // -- try again *with* clearing, if we didn't already
5896
- if (!mayClear) return skipAtomic(doc, pos, bias, true);
5897
- // Otherwise, turn off editing until further notice, and return the start of the doc
5898
- doc.cantEdit = true;
5899
- return Pos(doc.first, 0);
5900
- }
5901
- flipped = true; newPos = pos; dir = -dir;
5902
- }
5903
- }
5904
- curPos = newPos;
5905
- continue search;
5906
- }
5907
- }
5908
- }
5909
- return curPos;
5910
- }
5911
- }
5912
-
5913
- // SCROLLING
5914
-
5915
- function scrollCursorIntoView(cm) {
5916
- var coords = scrollPosIntoView(cm, cm.doc.sel.head, null, cm.options.cursorScrollMargin);
5917
- if (!cm.state.focused) return;
5918
- var display = cm.display, box = getRect(display.sizer), doScroll = null;
5919
- if (coords.top + box.top < 0) doScroll = true;
5920
- else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
5921
- if (doScroll != null && !phantom) {
5922
- var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
5923
- (coords.top - display.viewOffset) + "px; height: " +
5924
- (coords.bottom - coords.top + scrollerCutOff) + "px; left: " +
5925
- coords.left + "px; width: 2px;");
5926
- cm.display.lineSpace.appendChild(scrollNode);
5927
- scrollNode.scrollIntoView(doScroll);
5928
- cm.display.lineSpace.removeChild(scrollNode);
5929
- }
5930
- }
5931
-
5932
- function scrollPosIntoView(cm, pos, end, margin) {
5933
- if (margin == null) margin = 0;
5934
- for (;;) {
5935
- var changed = false, coords = cursorCoords(cm, pos);
5936
- var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
5937
- var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
5938
- Math.min(coords.top, endCoords.top) - margin,
5939
- Math.max(coords.left, endCoords.left),
5940
- Math.max(coords.bottom, endCoords.bottom) + margin);
5941
- var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
5942
- if (scrollPos.scrollTop != null) {
5943
- setScrollTop(cm, scrollPos.scrollTop);
5944
- if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
5945
- }
5946
- if (scrollPos.scrollLeft != null) {
5947
- setScrollLeft(cm, scrollPos.scrollLeft);
5948
- if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
5949
- }
5950
- if (!changed) return coords;
5951
- }
5952
- }
5953
-
5954
- function scrollIntoView(cm, x1, y1, x2, y2) {
5955
- var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
5956
- if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
5957
- if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
5958
- }
5959
-
5960
- function calculateScrollPos(cm, x1, y1, x2, y2) {
5961
- var display = cm.display, snapMargin = textHeight(cm.display);
5962
- if (y1 < 0) y1 = 0;
5963
- var screen = display.scroller.clientHeight - scrollerCutOff, screentop = display.scroller.scrollTop, result = {};
5964
- var docBottom = cm.doc.height + paddingVert(display);
5965
- var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
5966
- if (y1 < screentop) {
5967
- result.scrollTop = atTop ? 0 : y1;
5968
- } else if (y2 > screentop + screen) {
5969
- var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
5970
- if (newTop != screentop) result.scrollTop = newTop;
5971
- }
5972
-
5973
- var screenw = display.scroller.clientWidth - scrollerCutOff, screenleft = display.scroller.scrollLeft;
5974
- x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth;
5975
- var gutterw = display.gutters.offsetWidth;
5976
- var atLeft = x1 < gutterw + 10;
5977
- if (x1 < screenleft + gutterw || atLeft) {
5978
- if (atLeft) x1 = 0;
5979
- result.scrollLeft = Math.max(0, x1 - 10 - gutterw);
5980
- } else if (x2 > screenw + screenleft - 3) {
5981
- result.scrollLeft = x2 + 10 - screenw;
5982
- }
5983
- return result;
5984
- }
5985
-
5986
- function updateScrollPos(cm, left, top) {
5987
- cm.curOp.updateScrollPos = {scrollLeft: left == null ? cm.doc.scrollLeft : left,
5988
- scrollTop: top == null ? cm.doc.scrollTop : top};
5989
- }
5990
-
5991
- function addToScrollPos(cm, left, top) {
5992
- var pos = cm.curOp.updateScrollPos || (cm.curOp.updateScrollPos = {scrollLeft: cm.doc.scrollLeft, scrollTop: cm.doc.scrollTop});
5993
- var scroll = cm.display.scroller;
5994
- pos.scrollTop = Math.max(0, Math.min(scroll.scrollHeight - scroll.clientHeight, pos.scrollTop + top));
5995
- pos.scrollLeft = Math.max(0, Math.min(scroll.scrollWidth - scroll.clientWidth, pos.scrollLeft + left));
5996
- }
5997
-
5998
- // API UTILITIES
5999
-
6000
- function indentLine(cm, n, how, aggressive) {
6001
- var doc = cm.doc, state;
6002
- if (how == null) how = "add";
6003
- if (how == "smart") {
6004
- if (!cm.doc.mode.indent) how = "prev";
6005
- else state = getStateBefore(cm, n);
6006
- }
6007
-
6008
- var tabSize = cm.options.tabSize;
6009
- var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
6010
- if (line.stateAfter) line.stateAfter = null;
6011
- var curSpaceString = line.text.match(/^\s*/)[0], indentation;
6012
- if (!aggressive && !/\S/.test(line.text)) {
6013
- indentation = 0;
6014
- how = "not";
6015
- } else if (how == "smart") {
6016
- indentation = cm.doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
6017
- if (indentation == Pass) {
6018
- if (!aggressive) return;
6019
- how = "prev";
6020
- }
6021
- }
6022
- if (how == "prev") {
6023
- if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
6024
- else indentation = 0;
6025
- } else if (how == "add") {
6026
- indentation = curSpace + cm.options.indentUnit;
6027
- } else if (how == "subtract") {
6028
- indentation = curSpace - cm.options.indentUnit;
6029
- } else if (typeof how == "number") {
6030
- indentation = curSpace + how;
6031
- }
6032
- indentation = Math.max(0, indentation);
6033
-
6034
- var indentString = "", pos = 0;
6035
- if (cm.options.indentWithTabs)
6036
- for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
6037
- if (pos < indentation) indentString += spaceStr(indentation - pos);
6038
-
6039
- if (indentString != curSpaceString)
6040
- replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
6041
- else if (doc.sel.head.line == n && doc.sel.head.ch < curSpaceString.length)
6042
- setSelection(doc, Pos(n, curSpaceString.length), Pos(n, curSpaceString.length), 1);
6043
- line.stateAfter = null;
6044
- }
6045
-
6046
- function changeLine(cm, handle, op) {
6047
- var no = handle, line = handle, doc = cm.doc;
6048
- if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
6049
- else no = lineNo(handle);
6050
- if (no == null) return null;
6051
- if (op(line, no)) regChange(cm, no, no + 1);
6052
- else return null;
6053
- return line;
6054
- }
6055
-
6056
- function findPosH(doc, pos, dir, unit, visually) {
6057
- var line = pos.line, ch = pos.ch, origDir = dir;
6058
- var lineObj = getLine(doc, line);
6059
- var possible = true;
6060
- function findNextLine() {
6061
- var l = line + dir;
6062
- if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
6063
- line = l;
6064
- return lineObj = getLine(doc, l);
6065
- }
6066
- function moveOnce(boundToLine) {
6067
- var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
6068
- if (next == null) {
6069
- if (!boundToLine && findNextLine()) {
6070
- if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
6071
- else ch = dir < 0 ? lineObj.text.length : 0;
6072
- } else return (possible = false);
6073
- } else ch = next;
6074
- return true;
6075
- }
6076
-
6077
- if (unit == "char") moveOnce();
6078
- else if (unit == "column") moveOnce(true);
6079
- else if (unit == "word" || unit == "group") {
6080
- var sawType = null, group = unit == "group";
6081
- for (var first = true;; first = false) {
6082
- if (dir < 0 && !moveOnce(!first)) break;
6083
- var cur = lineObj.text.charAt(ch) || "\n";
6084
- var type = isWordChar(cur) ? "w"
6085
- : group && cur == "\n" ? "n"
6086
- : !group || /\s/.test(cur) ? null
6087
- : "p";
6088
- if (group && !first && !type) type = "s";
6089
- if (sawType && sawType != type) {
6090
- if (dir < 0) {dir = 1; moveOnce();}
6091
- break;
6092
- }
6093
-
6094
- if (type) sawType = type;
6095
- if (dir > 0 && !moveOnce(!first)) break;
6096
- }
6097
- }
6098
- var result = skipAtomic(doc, Pos(line, ch), origDir, true);
6099
- if (!possible) result.hitSide = true;
6100
- return result;
6101
- }
6102
-
6103
- function findPosV(cm, pos, dir, unit) {
6104
- var doc = cm.doc, x = pos.left, y;
6105
- if (unit == "page") {
6106
- var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
6107
- y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
6108
- } else if (unit == "line") {
6109
- y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
6110
- }
6111
- for (;;) {
6112
- var target = coordsChar(cm, x, y);
6113
- if (!target.outside) break;
6114
- if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
6115
- y += dir * 5;
6116
- }
6117
- return target;
6118
- }
6119
-
6120
- function findWordAt(line, pos) {
6121
- var start = pos.ch, end = pos.ch;
6122
- if (line) {
6123
- if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
6124
- var startChar = line.charAt(start);
6125
- var check = isWordChar(startChar) ? isWordChar
6126
- : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
6127
- : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
6128
- while (start > 0 && check(line.charAt(start - 1))) --start;
6129
- while (end < line.length && check(line.charAt(end))) ++end;
6130
- }
6131
- return {from: Pos(pos.line, start), to: Pos(pos.line, end)};
6132
- }
6133
-
6134
- function selectLine(cm, line) {
6135
- extendSelection(cm.doc, Pos(line, 0), clipPos(cm.doc, Pos(line + 1, 0)));
6136
- }
6137
-
6138
- // PROTOTYPE
6139
-
6140
- // The publicly visible API. Note that operation(null, f) means
6141
- // 'wrap f in an operation, performed on its `this` parameter'
6142
-
6143
- CodeMirror.prototype = {
6144
- constructor: CodeMirror,
6145
- focus: function(){window.focus(); focusInput(this); fastPoll(this);},
6146
-
6147
- setOption: function(option, value) {
6148
- var options = this.options, old = options[option];
6149
- if (options[option] == value && option != "mode") return;
6150
- options[option] = value;
6151
- if (optionHandlers.hasOwnProperty(option))
6152
- operation(this, optionHandlers[option])(this, value, old);
6153
- },
6154
-
6155
- getOption: function(option) {return this.options[option];},
6156
- getDoc: function() {return this.doc;},
6157
-
6158
- addKeyMap: function(map, bottom) {
6159
- this.state.keyMaps[bottom ? "push" : "unshift"](map);
6160
- },
6161
- removeKeyMap: function(map) {
6162
- var maps = this.state.keyMaps;
6163
- for (var i = 0; i < maps.length; ++i)
6164
- if (maps[i] == map || (typeof maps[i] != "string" && maps[i].name == map)) {
6165
- maps.splice(i, 1);
6166
- return true;
6167
- }
6168
- },
6169
-
6170
- addOverlay: operation(null, function(spec, options) {
6171
- var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
6172
- if (mode.startState) throw new Error("Overlays may not be stateful.");
6173
- this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
6174
- this.state.modeGen++;
6175
- regChange(this);
6176
- }),
6177
- removeOverlay: operation(null, function(spec) {
6178
- var overlays = this.state.overlays;
6179
- for (var i = 0; i < overlays.length; ++i) {
6180
- var cur = overlays[i].modeSpec;
6181
- if (cur == spec || typeof spec == "string" && cur.name == spec) {
6182
- overlays.splice(i, 1);
6183
- this.state.modeGen++;
6184
- regChange(this);
6185
- return;
6186
- }
6187
- }
6188
- }),
6189
-
6190
- indentLine: operation(null, function(n, dir, aggressive) {
6191
- if (typeof dir != "string" && typeof dir != "number") {
6192
- if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
6193
- else dir = dir ? "add" : "subtract";
6194
- }
6195
- if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
6196
- }),
6197
- indentSelection: operation(null, function(how) {
6198
- var sel = this.doc.sel;
6199
- if (posEq(sel.from, sel.to)) return indentLine(this, sel.from.line, how, true);
6200
- var e = sel.to.line - (sel.to.ch ? 0 : 1);
6201
- for (var i = sel.from.line; i <= e; ++i) indentLine(this, i, how);
6202
- }),
6203
-
6204
- // Fetch the parser token for a given character. Useful for hacks
6205
- // that want to inspect the mode state (say, for completion).
6206
- getTokenAt: function(pos, precise) {
6207
- var doc = this.doc;
6208
- pos = clipPos(doc, pos);
6209
- var state = getStateBefore(this, pos.line, precise), mode = this.doc.mode;
6210
- var line = getLine(doc, pos.line);
6211
- var stream = new StringStream(line.text, this.options.tabSize);
6212
- while (stream.pos < pos.ch && !stream.eol()) {
6213
- stream.start = stream.pos;
6214
- var style = mode.token(stream, state);
6215
- }
6216
- return {start: stream.start,
6217
- end: stream.pos,
6218
- string: stream.current(),
6219
- className: style || null, // Deprecated, use 'type' instead
6220
- type: style || null,
6221
- state: state};
6222
- },
6223
-
6224
- getTokenTypeAt: function(pos) {
6225
- pos = clipPos(this.doc, pos);
6226
- var styles = getLineStyles(this, getLine(this.doc, pos.line));
6227
- var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
6228
- if (ch == 0) return styles[2];
6229
- for (;;) {
6230
- var mid = (before + after) >> 1;
6231
- if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
6232
- else if (styles[mid * 2 + 1] < ch) before = mid + 1;
6233
- else return styles[mid * 2 + 2];
6234
- }
6235
- },
6236
-
6237
- getModeAt: function(pos) {
6238
- var mode = this.doc.mode;
6239
- if (!mode.innerMode) return mode;
6240
- return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
6241
- },
6242
-
6243
- getHelper: function(pos, type) {
6244
- return this.getHelpers(pos, type)[0];
6245
- },
6246
-
6247
- getHelpers: function(pos, type) {
6248
- var found = [];
6249
- if (!helpers.hasOwnProperty(type)) return helpers;
6250
- var help = helpers[type], mode = this.getModeAt(pos);
6251
- if (typeof mode[type] == "string") {
6252
- if (help[mode[type]]) found.push(help[mode[type]]);
6253
- } else if (mode[type]) {
6254
- for (var i = 0; i < mode[type].length; i++) {
6255
- var val = help[mode[type][i]];
6256
- if (val) found.push(val);
6257
- }
6258
- } else if (mode.helperType && help[mode.helperType]) {
6259
- found.push(help[mode.helperType]);
6260
- } else if (help[mode.name]) {
6261
- found.push(help[mode.name]);
6262
- }
6263
- for (var i = 0; i < help._global.length; i++) {
6264
- var cur = help._global[i];
6265
- if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
6266
- found.push(cur.val);
6267
- }
6268
- return found;
6269
- },
6270
-
6271
- getStateAfter: function(line, precise) {
6272
- var doc = this.doc;
6273
- line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
6274
- return getStateBefore(this, line + 1, precise);
6275
- },
6276
-
6277
- cursorCoords: function(start, mode) {
6278
- var pos, sel = this.doc.sel;
6279
- if (start == null) pos = sel.head;
6280
- else if (typeof start == "object") pos = clipPos(this.doc, start);
6281
- else pos = start ? sel.from : sel.to;
6282
- return cursorCoords(this, pos, mode || "page");
6283
- },
6284
-
6285
- charCoords: function(pos, mode) {
6286
- return charCoords(this, clipPos(this.doc, pos), mode || "page");
6287
- },
6288
-
6289
- coordsChar: function(coords, mode) {
6290
- coords = fromCoordSystem(this, coords, mode || "page");
6291
- return coordsChar(this, coords.left, coords.top);
6292
- },
6293
-
6294
- lineAtHeight: function(height, mode) {
6295
- height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
6296
- return lineAtHeight(this.doc, height + this.display.viewOffset);
6297
- },
6298
- heightAtLine: function(line, mode) {
6299
- var end = false, last = this.doc.first + this.doc.size - 1;
6300
- if (line < this.doc.first) line = this.doc.first;
6301
- else if (line > last) { line = last; end = true; }
6302
- var lineObj = getLine(this.doc, line);
6303
- return intoCoordSystem(this, getLine(this.doc, line), {top: 0, left: 0}, mode || "page").top +
6304
- (end ? lineObj.height : 0);
6305
- },
6306
-
6307
- defaultTextHeight: function() { return textHeight(this.display); },
6308
- defaultCharWidth: function() { return charWidth(this.display); },
6309
-
6310
- setGutterMarker: operation(null, function(line, gutterID, value) {
6311
- return changeLine(this, line, function(line) {
6312
- var markers = line.gutterMarkers || (line.gutterMarkers = {});
6313
- markers[gutterID] = value;
6314
- if (!value && isEmpty(markers)) line.gutterMarkers = null;
6315
- return true;
6316
- });
6317
- }),
6318
-
6319
- clearGutter: operation(null, function(gutterID) {
6320
- var cm = this, doc = cm.doc, i = doc.first;
6321
- doc.iter(function(line) {
6322
- if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
6323
- line.gutterMarkers[gutterID] = null;
6324
- regChange(cm, i, i + 1);
6325
- if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
6326
- }
6327
- ++i;
6328
- });
6329
- }),
6330
-
6331
- addLineClass: operation(null, function(handle, where, cls) {
6332
- return changeLine(this, handle, function(line) {
6333
- var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
6334
- if (!line[prop]) line[prop] = cls;
6335
- else if (new RegExp("(?:^|\\s)" + cls + "(?:$|\\s)").test(line[prop])) return false;
6336
- else line[prop] += " " + cls;
6337
- return true;
6338
- });
6339
- }),
6340
-
6341
- removeLineClass: operation(null, function(handle, where, cls) {
6342
- return changeLine(this, handle, function(line) {
6343
- var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
6344
- var cur = line[prop];
6345
- if (!cur) return false;
6346
- else if (cls == null) line[prop] = null;
6347
- else {
6348
- var found = cur.match(new RegExp("(?:^|\\s+)" + cls + "(?:$|\\s+)"));
6349
- if (!found) return false;
6350
- var end = found.index + found[0].length;
6351
- line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
6352
- }
6353
- return true;
6354
- });
6355
- }),
6356
-
6357
- addLineWidget: operation(null, function(handle, node, options) {
6358
- return addLineWidget(this, handle, node, options);
6359
- }),
6360
-
6361
- removeLineWidget: function(widget) { widget.clear(); },
6362
-
6363
- lineInfo: function(line) {
6364
- if (typeof line == "number") {
6365
- if (!isLine(this.doc, line)) return null;
6366
- var n = line;
6367
- line = getLine(this.doc, line);
6368
- if (!line) return null;
6369
- } else {
6370
- var n = lineNo(line);
6371
- if (n == null) return null;
6372
- }
6373
- return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
6374
- textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
6375
- widgets: line.widgets};
6376
- },
6377
-
6378
- getViewport: function() { return {from: this.display.showingFrom, to: this.display.showingTo};},
6379
-
6380
- addWidget: function(pos, node, scroll, vert, horiz) {
6381
- var display = this.display;
6382
- pos = cursorCoords(this, clipPos(this.doc, pos));
6383
- var top = pos.bottom, left = pos.left;
6384
- node.style.position = "absolute";
6385
- display.sizer.appendChild(node);
6386
- if (vert == "over") {
6387
- top = pos.top;
6388
- } else if (vert == "above" || vert == "near") {
6389
- var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
6390
- hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
6391
- // Default to positioning above (if specified and possible); otherwise default to positioning below
6392
- if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
6393
- top = pos.top - node.offsetHeight;
6394
- else if (pos.bottom + node.offsetHeight <= vspace)
6395
- top = pos.bottom;
6396
- if (left + node.offsetWidth > hspace)
6397
- left = hspace - node.offsetWidth;
6398
- }
6399
- node.style.top = top + "px";
6400
- node.style.left = node.style.right = "";
6401
- if (horiz == "right") {
6402
- left = display.sizer.clientWidth - node.offsetWidth;
6403
- node.style.right = "0px";
6404
- } else {
6405
- if (horiz == "left") left = 0;
6406
- else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
6407
- node.style.left = left + "px";
6408
- }
6409
- if (scroll)
6410
- scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
6411
- },
6412
-
6413
- triggerOnKeyDown: operation(null, onKeyDown),
6414
- triggerOnKeyPress: operation(null, onKeyPress),
6415
- triggerOnKeyUp: operation(null, onKeyUp),
6416
-
6417
- execCommand: function(cmd) {
6418
- if (commands.hasOwnProperty(cmd))
6419
- return commands[cmd](this);
6420
- },
6421
-
6422
- findPosH: function(from, amount, unit, visually) {
6423
- var dir = 1;
6424
- if (amount < 0) { dir = -1; amount = -amount; }
6425
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
6426
- cur = findPosH(this.doc, cur, dir, unit, visually);
6427
- if (cur.hitSide) break;
6428
- }
6429
- return cur;
6430
- },
6431
-
6432
- moveH: operation(null, function(dir, unit) {
6433
- var sel = this.doc.sel, pos;
6434
- if (sel.shift || sel.extend || posEq(sel.from, sel.to))
6435
- pos = findPosH(this.doc, sel.head, dir, unit, this.options.rtlMoveVisually);
6436
- else
6437
- pos = dir < 0 ? sel.from : sel.to;
6438
- extendSelection(this.doc, pos, pos, dir);
6439
- }),
6440
-
6441
- deleteH: operation(null, function(dir, unit) {
6442
- var sel = this.doc.sel;
6443
- if (!posEq(sel.from, sel.to)) replaceRange(this.doc, "", sel.from, sel.to, "+delete");
6444
- else replaceRange(this.doc, "", sel.from, findPosH(this.doc, sel.head, dir, unit, false), "+delete");
6445
- this.curOp.userSelChange = true;
6446
- }),
6447
-
6448
- findPosV: function(from, amount, unit, goalColumn) {
6449
- var dir = 1, x = goalColumn;
6450
- if (amount < 0) { dir = -1; amount = -amount; }
6451
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
6452
- var coords = cursorCoords(this, cur, "div");
6453
- if (x == null) x = coords.left;
6454
- else coords.left = x;
6455
- cur = findPosV(this, coords, dir, unit);
6456
- if (cur.hitSide) break;
6457
- }
6458
- return cur;
6459
- },
6460
-
6461
- moveV: operation(null, function(dir, unit) {
6462
- var sel = this.doc.sel, target, goal;
6463
- if (sel.shift || sel.extend || posEq(sel.from, sel.to)) {
6464
- var pos = cursorCoords(this, sel.head, "div");
6465
- if (sel.goalColumn != null) pos.left = sel.goalColumn;
6466
- target = findPosV(this, pos, dir, unit);
6467
- if (unit == "page") addToScrollPos(this, 0, charCoords(this, target, "div").top - pos.top);
6468
- goal = pos.left;
6469
- } else {
6470
- target = dir < 0 ? sel.from : sel.to;
6471
- }
6472
- extendSelection(this.doc, target, target, dir);
6473
- if (goal != null) sel.goalColumn = goal;
6474
- }),
6475
-
6476
- toggleOverwrite: function(value) {
6477
- if (value != null && value == this.state.overwrite) return;
6478
- if (this.state.overwrite = !this.state.overwrite)
6479
- this.display.cursor.className += " CodeMirror-overwrite";
6480
- else
6481
- this.display.cursor.className = this.display.cursor.className.replace(" CodeMirror-overwrite", "");
6482
-
6483
- signal(this, "overwriteToggle", this, this.state.overwrite);
6484
- },
6485
- hasFocus: function() { return document.activeElement == this.display.input; },
6486
-
6487
- scrollTo: operation(null, function(x, y) {
6488
- updateScrollPos(this, x, y);
6489
- }),
6490
- getScrollInfo: function() {
6491
- var scroller = this.display.scroller, co = scrollerCutOff;
6492
- return {left: scroller.scrollLeft, top: scroller.scrollTop,
6493
- height: scroller.scrollHeight - co, width: scroller.scrollWidth - co,
6494
- clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
6495
- },
6496
-
6497
- scrollIntoView: operation(null, function(range, margin) {
6498
- if (range == null) range = {from: this.doc.sel.head, to: null};
6499
- else if (typeof range == "number") range = {from: Pos(range, 0), to: null};
6500
- else if (range.from == null) range = {from: range, to: null};
6501
- if (!range.to) range.to = range.from;
6502
- if (!margin) margin = 0;
6503
-
6504
- var coords = range;
6505
- if (range.from.line != null) {
6506
- this.curOp.scrollToPos = {from: range.from, to: range.to, margin: margin};
6507
- coords = {from: cursorCoords(this, range.from),
6508
- to: cursorCoords(this, range.to)};
6509
- }
6510
- var sPos = calculateScrollPos(this, Math.min(coords.from.left, coords.to.left),
6511
- Math.min(coords.from.top, coords.to.top) - margin,
6512
- Math.max(coords.from.right, coords.to.right),
6513
- Math.max(coords.from.bottom, coords.to.bottom) + margin);
6514
- updateScrollPos(this, sPos.scrollLeft, sPos.scrollTop);
6515
- }),
6516
-
6517
- setSize: operation(null, function(width, height) {
6518
- function interpret(val) {
6519
- return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
6520
- }
6521
- if (width != null) this.display.wrapper.style.width = interpret(width);
6522
- if (height != null) this.display.wrapper.style.height = interpret(height);
6523
- if (this.options.lineWrapping)
6524
- this.display.measureLineCache.length = this.display.measureLineCachePos = 0;
6525
- this.curOp.forceUpdate = true;
6526
- signal(this, "refresh", this);
6527
- }),
6528
-
6529
- operation: function(f){return runInOp(this, f);},
6530
-
6531
- refresh: operation(null, function() {
6532
- var oldHeight = this.display.cachedTextHeight;
6533
- clearCaches(this);
6534
- updateScrollPos(this, this.doc.scrollLeft, this.doc.scrollTop);
6535
- regChange(this);
6536
- if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
6537
- estimateLineHeights(this);
6538
- signal(this, "refresh", this);
6539
- }),
6540
-
6541
- swapDoc: operation(null, function(doc) {
6542
- var old = this.doc;
6543
- old.cm = null;
6544
- attachDoc(this, doc);
6545
- clearCaches(this);
6546
- resetInput(this, true);
6547
- updateScrollPos(this, doc.scrollLeft, doc.scrollTop);
6548
- signalLater(this, "swapDoc", this, old);
6549
- return old;
6550
- }),
6551
-
6552
- getInputField: function(){return this.display.input;},
6553
- getWrapperElement: function(){return this.display.wrapper;},
6554
- getScrollerElement: function(){return this.display.scroller;},
6555
- getGutterElement: function(){return this.display.gutters;}
6556
- };
6557
- eventMixin(CodeMirror);
6558
-
6559
- // OPTION DEFAULTS
6560
-
6561
- var optionHandlers = CodeMirror.optionHandlers = {};
6562
-
6563
- // The default configuration options.
6564
- var defaults = CodeMirror.defaults = {};
6565
-
6566
- function option(name, deflt, handle, notOnInit) {
6567
- CodeMirror.defaults[name] = deflt;
6568
- if (handle) optionHandlers[name] =
6569
- notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
6570
- }
6571
-
6572
- var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
6573
-
6574
- // These two are, on init, called from the constructor because they
6575
- // have to be initialized before the editor can start at all.
6576
- option("value", "", function(cm, val) {
6577
- cm.setValue(val);
6578
- }, true);
6579
- option("mode", null, function(cm, val) {
6580
- cm.doc.modeOption = val;
6581
- loadMode(cm);
6582
- }, true);
6583
-
6584
- option("indentUnit", 2, loadMode, true);
6585
- option("indentWithTabs", false);
6586
- option("smartIndent", true);
6587
- option("tabSize", 4, function(cm) {
6588
- resetModeState(cm);
6589
- clearCaches(cm);
6590
- regChange(cm);
6591
- }, true);
6592
- option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function(cm, val) {
6593
- cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
6594
- cm.refresh();
6595
- }, true);
6596
- option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
6597
- option("electricChars", true);
6598
- option("rtlMoveVisually", !windows);
6599
- option("wholeLineUpdateBefore", true);
6600
-
6601
- option("theme", "default", function(cm) {
6602
- themeChanged(cm);
6603
- guttersChanged(cm);
6604
- }, true);
6605
- option("keyMap", "default", keyMapChanged);
6606
- option("extraKeys", null);
6607
-
6608
- option("onKeyEvent", null);
6609
- option("onDragEvent", null);
6610
-
6611
- option("lineWrapping", false, wrappingChanged, true);
6612
- option("gutters", [], function(cm) {
6613
- setGuttersForLineNumbers(cm.options);
6614
- guttersChanged(cm);
6615
- }, true);
6616
- option("fixedGutter", true, function(cm, val) {
6617
- cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
6618
- cm.refresh();
6619
- }, true);
6620
- option("coverGutterNextToScrollbar", false, updateScrollbars, true);
6621
- option("lineNumbers", false, function(cm) {
6622
- setGuttersForLineNumbers(cm.options);
6623
- guttersChanged(cm);
6624
- }, true);
6625
- option("firstLineNumber", 1, guttersChanged, true);
6626
- option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
6627
- option("showCursorWhenSelecting", false, updateSelection, true);
6628
-
6629
- option("resetSelectionOnContextMenu", true);
6630
-
6631
- option("readOnly", false, function(cm, val) {
6632
- if (val == "nocursor") {
6633
- onBlur(cm);
6634
- cm.display.input.blur();
6635
- cm.display.disabled = true;
6636
- } else {
6637
- cm.display.disabled = false;
6638
- if (!val) resetInput(cm, true);
6639
- }
6640
- });
6641
- option("disableInput", false, function(cm, val) {if (!val) resetInput(cm, true);}, true);
6642
- option("dragDrop", true);
6643
-
6644
- option("cursorBlinkRate", 530);
6645
- option("cursorScrollMargin", 0);
6646
- option("cursorHeight", 1);
6647
- option("workTime", 100);
6648
- option("workDelay", 100);
6649
- option("flattenSpans", true, resetModeState, true);
6650
- option("addModeClass", false, resetModeState, true);
6651
- option("pollInterval", 100);
6652
- option("undoDepth", 40, function(cm, val){cm.doc.history.undoDepth = val;});
6653
- option("historyEventDelay", 500);
6654
- option("viewportMargin", 10, function(cm){cm.refresh();}, true);
6655
- option("maxHighlightLength", 10000, resetModeState, true);
6656
- option("crudeMeasuringFrom", 10000);
6657
- option("moveInputWithCursor", true, function(cm, val) {
6658
- if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;
6659
- });
6660
-
6661
- option("tabindex", null, function(cm, val) {
6662
- cm.display.input.tabIndex = val || "";
6663
- });
6664
- option("autofocus", null);
6665
-
6666
- // MODE DEFINITION AND QUERYING
6667
-
6668
- // Known modes, by name and by MIME
6669
- var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
6670
-
6671
- CodeMirror.defineMode = function(name, mode) {
6672
- if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
6673
- if (arguments.length > 2) {
6674
- mode.dependencies = [];
6675
- for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
6676
- }
6677
- modes[name] = mode;
6678
- };
6679
-
6680
- CodeMirror.defineMIME = function(mime, spec) {
6681
- mimeModes[mime] = spec;
6682
- };
6683
-
6684
- CodeMirror.resolveMode = function(spec) {
6685
- if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
6686
- spec = mimeModes[spec];
6687
- } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
6688
- var found = mimeModes[spec.name];
6689
- if (typeof found == "string") found = {name: found};
6690
- spec = createObj(found, spec);
6691
- spec.name = found.name;
6692
- } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
6693
- return CodeMirror.resolveMode("application/xml");
6694
- }
6695
- if (typeof spec == "string") return {name: spec};
6696
- else return spec || {name: "null"};
6697
- };
6698
-
6699
- CodeMirror.getMode = function(options, spec) {
6700
- var spec = CodeMirror.resolveMode(spec);
6701
- var mfactory = modes[spec.name];
6702
- if (!mfactory) return CodeMirror.getMode(options, "text/plain");
6703
- var modeObj = mfactory(options, spec);
6704
- if (modeExtensions.hasOwnProperty(spec.name)) {
6705
- var exts = modeExtensions[spec.name];
6706
- for (var prop in exts) {
6707
- if (!exts.hasOwnProperty(prop)) continue;
6708
- if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
6709
- modeObj[prop] = exts[prop];
6710
- }
6711
- }
6712
- modeObj.name = spec.name;
6713
- if (spec.helperType) modeObj.helperType = spec.helperType;
6714
- if (spec.modeProps) for (var prop in spec.modeProps)
6715
- modeObj[prop] = spec.modeProps[prop];
6716
-
6717
- return modeObj;
6718
- };
6719
-
6720
- CodeMirror.defineMode("null", function() {
6721
- return {token: function(stream) {stream.skipToEnd();}};
6722
- });
6723
- CodeMirror.defineMIME("text/plain", "null");
6724
-
6725
- var modeExtensions = CodeMirror.modeExtensions = {};
6726
- CodeMirror.extendMode = function(mode, properties) {
6727
- var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
6728
- copyObj(properties, exts);
6729
- };
6730
-
6731
- // EXTENSIONS
6732
-
6733
- CodeMirror.defineExtension = function(name, func) {
6734
- CodeMirror.prototype[name] = func;
6735
- };
6736
- CodeMirror.defineDocExtension = function(name, func) {
6737
- Doc.prototype[name] = func;
6738
- };
6739
- CodeMirror.defineOption = option;
6740
-
6741
- var initHooks = [];
6742
- CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
6743
-
6744
- var helpers = CodeMirror.helpers = {};
6745
- CodeMirror.registerHelper = function(type, name, value) {
6746
- if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
6747
- helpers[type][name] = value;
6748
- };
6749
- CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
6750
- CodeMirror.registerHelper(type, name, value);
6751
- helpers[type]._global.push({pred: predicate, val: value});
6752
- };
6753
-
6754
- // UTILITIES
6755
-
6756
- CodeMirror.isWordChar = isWordChar;
6757
-
6758
- // MODE STATE HANDLING
6759
-
6760
- // Utility functions for working with state. Exported because modes
6761
- // sometimes need to do this.
6762
- function copyState(mode, state) {
6763
- if (state === true) return state;
6764
- if (mode.copyState) return mode.copyState(state);
6765
- var nstate = {};
6766
- for (var n in state) {
6767
- var val = state[n];
6768
- if (val instanceof Array) val = val.concat([]);
6769
- nstate[n] = val;
6770
- }
6771
- return nstate;
6772
- }
6773
- CodeMirror.copyState = copyState;
6774
-
6775
- function startState(mode, a1, a2) {
6776
- return mode.startState ? mode.startState(a1, a2) : true;
6777
- }
6778
- CodeMirror.startState = startState;
6779
-
6780
- CodeMirror.innerMode = function(mode, state) {
6781
- while (mode.innerMode) {
6782
- var info = mode.innerMode(state);
6783
- if (!info || info.mode == mode) break;
6784
- state = info.state;
6785
- mode = info.mode;
6786
- }
6787
- return info || {mode: mode, state: state};
6788
- };
6789
-
6790
- // STANDARD COMMANDS
6791
-
6792
- var commands = CodeMirror.commands = {
6793
- selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()));},
6794
- killLine: function(cm) {
6795
- var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
6796
- if (!sel && cm.getLine(from.line).length == from.ch)
6797
- cm.replaceRange("", from, Pos(from.line + 1, 0), "+delete");
6798
- else cm.replaceRange("", from, sel ? to : Pos(from.line), "+delete");
6799
- },
6800
- deleteLine: function(cm) {
6801
- var l = cm.getCursor().line;
6802
- cm.replaceRange("", Pos(l, 0), Pos(l + 1, 0), "+delete");
6803
- },
6804
- delLineLeft: function(cm) {
6805
- var cur = cm.getCursor();
6806
- cm.replaceRange("", Pos(cur.line, 0), cur, "+delete");
6807
- },
6808
- undo: function(cm) {cm.undo();},
6809
- redo: function(cm) {cm.redo();},
6810
- goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
6811
- goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
6812
- goLineStart: function(cm) {
6813
- cm.extendSelection(lineStart(cm, cm.getCursor().line));
6814
- },
6815
- goLineStartSmart: function(cm) {
6816
- var cur = cm.getCursor(), start = lineStart(cm, cur.line);
6817
- var line = cm.getLineHandle(start.line);
6818
- var order = getOrder(line);
6819
- if (!order || order[0].level == 0) {
6820
- var firstNonWS = Math.max(0, line.text.search(/\S/));
6821
- var inWS = cur.line == start.line && cur.ch <= firstNonWS && cur.ch;
6822
- cm.extendSelection(Pos(start.line, inWS ? 0 : firstNonWS));
6823
- } else cm.extendSelection(start);
6824
- },
6825
- goLineEnd: function(cm) {
6826
- cm.extendSelection(lineEnd(cm, cm.getCursor().line));
6827
- },
6828
- goLineRight: function(cm) {
6829
- var top = cm.charCoords(cm.getCursor(), "div").top + 5;
6830
- cm.extendSelection(cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"));
6831
- },
6832
- goLineLeft: function(cm) {
6833
- var top = cm.charCoords(cm.getCursor(), "div").top + 5;
6834
- cm.extendSelection(cm.coordsChar({left: 0, top: top}, "div"));
6835
- },
6836
- goLineUp: function(cm) {cm.moveV(-1, "line");},
6837
- goLineDown: function(cm) {cm.moveV(1, "line");},
6838
- goPageUp: function(cm) {cm.moveV(-1, "page");},
6839
- goPageDown: function(cm) {cm.moveV(1, "page");},
6840
- goCharLeft: function(cm) {cm.moveH(-1, "char");},
6841
- goCharRight: function(cm) {cm.moveH(1, "char");},
6842
- goColumnLeft: function(cm) {cm.moveH(-1, "column");},
6843
- goColumnRight: function(cm) {cm.moveH(1, "column");},
6844
- goWordLeft: function(cm) {cm.moveH(-1, "word");},
6845
- goGroupRight: function(cm) {cm.moveH(1, "group");},
6846
- goGroupLeft: function(cm) {cm.moveH(-1, "group");},
6847
- goWordRight: function(cm) {cm.moveH(1, "word");},
6848
- delCharBefore: function(cm) {cm.deleteH(-1, "char");},
6849
- delCharAfter: function(cm) {cm.deleteH(1, "char");},
6850
- delWordBefore: function(cm) {cm.deleteH(-1, "word");},
6851
- delWordAfter: function(cm) {cm.deleteH(1, "word");},
6852
- delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
6853
- delGroupAfter: function(cm) {cm.deleteH(1, "group");},
6854
- indentAuto: function(cm) {cm.indentSelection("smart");},
6855
- indentMore: function(cm) {cm.indentSelection("add");},
6856
- indentLess: function(cm) {cm.indentSelection("subtract");},
6857
- insertTab: function(cm) {
6858
- cm.replaceSelection("\t", "end", "+input");
6859
- },
6860
- defaultTab: function(cm) {
6861
- if (cm.somethingSelected()) cm.indentSelection("add");
6862
- else cm.replaceSelection("\t", "end", "+input");
6863
- },
6864
- transposeChars: function(cm) {
6865
- var cur = cm.getCursor(), line = cm.getLine(cur.line);
6866
- if (cur.ch > 0 && cur.ch < line.length - 1)
6867
- cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1),
6868
- Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
6869
- },
6870
- newlineAndIndent: function(cm) {
6871
- operation(cm, function() {
6872
- cm.replaceSelection("\n", "end", "+input");
6873
- cm.indentLine(cm.getCursor().line, null, true);
6874
- })();
6875
- },
6876
- toggleOverwrite: function(cm) {cm.toggleOverwrite();}
6877
- };
6878
-
6879
- // STANDARD KEYMAPS
6880
-
6881
- var keyMap = CodeMirror.keyMap = {};
6882
- keyMap.basic = {
6883
- "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
6884
- "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
6885
- "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
6886
- "Tab": "defaultTab", "Shift-Tab": "indentAuto",
6887
- "Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
6888
- };
6889
- // Note that the save and find-related commands aren't defined by
6890
- // default. Unknown commands are simply ignored.
6891
- keyMap.pcDefault = {
6892
- "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
6893
- "Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
6894
- "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
6895
- "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
6896
- "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
6897
- "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
6898
- fallthrough: "basic"
6899
- };
6900
- keyMap.macDefault = {
6901
- "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
6902
- "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
6903
- "Alt-Right": "goGroupRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delGroupBefore",
6904
- "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
6905
- "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
6906
- "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delLineLeft",
6907
- fallthrough: ["basic", "emacsy"]
6908
- };
6909
- keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
6910
- keyMap.emacsy = {
6911
- "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
6912
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
6913
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
6914
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
6915
- };
6916
-
6917
- // KEYMAP DISPATCH
6918
-
6919
- function getKeyMap(val) {
6920
- if (typeof val == "string") return keyMap[val];
6921
- else return val;
6922
- }
6923
-
6924
- function lookupKey(name, maps, handle) {
6925
- function lookup(map) {
6926
- map = getKeyMap(map);
6927
- var found = map[name];
6928
- if (found === false) return "stop";
6929
- if (found != null && handle(found)) return true;
6930
- if (map.nofallthrough) return "stop";
6931
-
6932
- var fallthrough = map.fallthrough;
6933
- if (fallthrough == null) return false;
6934
- if (Object.prototype.toString.call(fallthrough) != "[object Array]")
6935
- return lookup(fallthrough);
6936
- for (var i = 0, e = fallthrough.length; i < e; ++i) {
6937
- var done = lookup(fallthrough[i]);
6938
- if (done) return done;
6939
- }
6940
- return false;
6941
- }
6942
-
6943
- for (var i = 0; i < maps.length; ++i) {
6944
- var done = lookup(maps[i]);
6945
- if (done) return done != "stop";
6946
- }
6947
- }
6948
- function isModifierKey(event) {
6949
- var name = keyNames[event.keyCode];
6950
- return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
6951
- }
6952
- function keyName(event, noShift) {
6953
- if (opera && event.keyCode == 34 && event["char"]) return false;
6954
- var name = keyNames[event.keyCode];
6955
- if (name == null || event.altGraphKey) return false;
6956
- if (event.altKey) name = "Alt-" + name;
6957
- if (flipCtrlCmd ? event.metaKey : event.ctrlKey) name = "Ctrl-" + name;
6958
- if (flipCtrlCmd ? event.ctrlKey : event.metaKey) name = "Cmd-" + name;
6959
- if (!noShift && event.shiftKey) name = "Shift-" + name;
6960
- return name;
6961
- }
6962
- CodeMirror.lookupKey = lookupKey;
6963
- CodeMirror.isModifierKey = isModifierKey;
6964
- CodeMirror.keyName = keyName;
6965
-
6966
- // FROMTEXTAREA
6967
-
6968
- CodeMirror.fromTextArea = function(textarea, options) {
6969
- if (!options) options = {};
6970
- options.value = textarea.value;
6971
- if (!options.tabindex && textarea.tabindex)
6972
- options.tabindex = textarea.tabindex;
6973
- if (!options.placeholder && textarea.placeholder)
6974
- options.placeholder = textarea.placeholder;
6975
- // Set autofocus to true if this textarea is focused, or if it has
6976
- // autofocus and no other element is focused.
6977
- if (options.autofocus == null) {
6978
- var hasFocus = document.body;
6979
- // doc.activeElement occasionally throws on IE
6980
- try { hasFocus = document.activeElement; } catch(e) {}
6981
- options.autofocus = hasFocus == textarea ||
6982
- textarea.getAttribute("autofocus") != null && hasFocus == document.body;
6983
- }
6984
-
6985
- function save() {textarea.value = cm.getValue();}
6986
- if (textarea.form) {
6987
- on(textarea.form, "submit", save);
6988
- // Deplorable hack to make the submit method do the right thing.
6989
- if (!options.leaveSubmitMethodAlone) {
6990
- var form = textarea.form, realSubmit = form.submit;
6991
- try {
6992
- var wrappedSubmit = form.submit = function() {
6993
- save();
6994
- form.submit = realSubmit;
6995
- form.submit();
6996
- form.submit = wrappedSubmit;
6997
- };
6998
- } catch(e) {}
6999
- }
7000
- }
7001
-
7002
- textarea.style.display = "none";
7003
- var cm = CodeMirror(function(node) {
7004
- textarea.parentNode.insertBefore(node, textarea.nextSibling);
7005
- }, options);
7006
- cm.save = save;
7007
- cm.getTextArea = function() { return textarea; };
7008
- cm.toTextArea = function() {
7009
- save();
7010
- textarea.parentNode.removeChild(cm.getWrapperElement());
7011
- textarea.style.display = "";
7012
- if (textarea.form) {
7013
- off(textarea.form, "submit", save);
7014
- if (typeof textarea.form.submit == "function")
7015
- textarea.form.submit = realSubmit;
7016
- }
7017
- };
7018
- return cm;
7019
- };
7020
-
7021
- // STRING STREAM
7022
-
7023
- // Fed to the mode parsers, provides helper functions to make
7024
- // parsers more succinct.
7025
-
7026
- // The character stream used by a mode's parser.
7027
- function StringStream(string, tabSize) {
7028
- this.pos = this.start = 0;
7029
- this.string = string;
7030
- this.tabSize = tabSize || 8;
7031
- this.lastColumnPos = this.lastColumnValue = 0;
7032
- this.lineStart = 0;
7033
- }
7034
-
7035
- StringStream.prototype = {
7036
- eol: function() {return this.pos >= this.string.length;},
7037
- sol: function() {return this.pos == this.lineStart;},
7038
- peek: function() {return this.string.charAt(this.pos) || undefined;},
7039
- next: function() {
7040
- if (this.pos < this.string.length)
7041
- return this.string.charAt(this.pos++);
7042
- },
7043
- eat: function(match) {
7044
- var ch = this.string.charAt(this.pos);
7045
- if (typeof match == "string") var ok = ch == match;
7046
- else var ok = ch && (match.test ? match.test(ch) : match(ch));
7047
- if (ok) {++this.pos; return ch;}
7048
- },
7049
- eatWhile: function(match) {
7050
- var start = this.pos;
7051
- while (this.eat(match)){}
7052
- return this.pos > start;
7053
- },
7054
- eatSpace: function() {
7055
- var start = this.pos;
7056
- while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
7057
- return this.pos > start;
7058
- },
7059
- skipToEnd: function() {this.pos = this.string.length;},
7060
- skipTo: function(ch) {
7061
- var found = this.string.indexOf(ch, this.pos);
7062
- if (found > -1) {this.pos = found; return true;}
7063
- },
7064
- backUp: function(n) {this.pos -= n;},
7065
- column: function() {
7066
- if (this.lastColumnPos < this.start) {
7067
- this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
7068
- this.lastColumnPos = this.start;
7069
- }
7070
- return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
7071
- },
7072
- indentation: function() {
7073
- return countColumn(this.string, null, this.tabSize) -
7074
- (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
7075
- },
7076
- match: function(pattern, consume, caseInsensitive) {
7077
- if (typeof pattern == "string") {
7078
- var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
7079
- var substr = this.string.substr(this.pos, pattern.length);
7080
- if (cased(substr) == cased(pattern)) {
7081
- if (consume !== false) this.pos += pattern.length;
7082
- return true;
7083
- }
7084
- } else {
7085
- var match = this.string.slice(this.pos).match(pattern);
7086
- if (match && match.index > 0) return null;
7087
- if (match && consume !== false) this.pos += match[0].length;
7088
- return match;
7089
- }
7090
- },
7091
- current: function(){return this.string.slice(this.start, this.pos);},
7092
- hideFirstChars: function(n, inner) {
7093
- this.lineStart += n;
7094
- try { return inner(); }
7095
- finally { this.lineStart -= n; }
7096
- }
7097
- };
7098
- CodeMirror.StringStream = StringStream;
7099
-
7100
- // TEXTMARKERS
7101
-
7102
- function TextMarker(doc, type) {
7103
- this.lines = [];
7104
- this.type = type;
7105
- this.doc = doc;
7106
- }
7107
- CodeMirror.TextMarker = TextMarker;
7108
- eventMixin(TextMarker);
7109
-
7110
- TextMarker.prototype.clear = function() {
7111
- if (this.explicitlyCleared) return;
7112
- var cm = this.doc.cm, withOp = cm && !cm.curOp;
7113
- if (withOp) startOperation(cm);
7114
- if (hasHandler(this, "clear")) {
7115
- var found = this.find();
7116
- if (found) signalLater(this, "clear", found.from, found.to);
7117
- }
7118
- var min = null, max = null;
7119
- for (var i = 0; i < this.lines.length; ++i) {
7120
- var line = this.lines[i];
7121
- var span = getMarkedSpanFor(line.markedSpans, this);
7122
- if (span.to != null) max = lineNo(line);
7123
- line.markedSpans = removeMarkedSpan(line.markedSpans, span);
7124
- if (span.from != null)
7125
- min = lineNo(line);
7126
- else if (this.collapsed && !lineIsHidden(this.doc, line) && cm)
7127
- updateLineHeight(line, textHeight(cm.display));
7128
- }
7129
- if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
7130
- var visual = visualLine(cm.doc, this.lines[i]), len = lineLength(cm.doc, visual);
7131
- if (len > cm.display.maxLineLength) {
7132
- cm.display.maxLine = visual;
7133
- cm.display.maxLineLength = len;
7134
- cm.display.maxLineChanged = true;
7135
- }
7136
- }
7137
-
7138
- if (min != null && cm) regChange(cm, min, max + 1);
7139
- this.lines.length = 0;
7140
- this.explicitlyCleared = true;
7141
- if (this.atomic && this.doc.cantEdit) {
7142
- this.doc.cantEdit = false;
7143
- if (cm) reCheckSelection(cm);
7144
- }
7145
- if (withOp) endOperation(cm);
7146
- };
7147
-
7148
- TextMarker.prototype.find = function(bothSides) {
7149
- var from, to;
7150
- for (var i = 0; i < this.lines.length; ++i) {
7151
- var line = this.lines[i];
7152
- var span = getMarkedSpanFor(line.markedSpans, this);
7153
- if (span.from != null || span.to != null) {
7154
- var found = lineNo(line);
7155
- if (span.from != null) from = Pos(found, span.from);
7156
- if (span.to != null) to = Pos(found, span.to);
7157
- }
7158
- }
7159
- if (this.type == "bookmark" && !bothSides) return from;
7160
- return from && {from: from, to: to};
7161
- };
7162
-
7163
- TextMarker.prototype.changed = function() {
7164
- var pos = this.find(), cm = this.doc.cm;
7165
- if (!pos || !cm) return;
7166
- if (this.type != "bookmark") pos = pos.from;
7167
- var line = getLine(this.doc, pos.line);
7168
- clearCachedMeasurement(cm, line);
7169
- if (pos.line >= cm.display.showingFrom && pos.line < cm.display.showingTo) {
7170
- for (var node = cm.display.lineDiv.firstChild; node; node = node.nextSibling) if (node.lineObj == line) {
7171
- if (node.offsetHeight != line.height) updateLineHeight(line, node.offsetHeight);
7172
- break;
7173
- }
7174
- runInOp(cm, function() {
7175
- cm.curOp.selectionChanged = cm.curOp.forceUpdate = cm.curOp.updateMaxLine = true;
7176
- });
7177
- }
7178
- };
7179
-
7180
- TextMarker.prototype.attachLine = function(line) {
7181
- if (!this.lines.length && this.doc.cm) {
7182
- var op = this.doc.cm.curOp;
7183
- if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
7184
- (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
7185
- }
7186
- this.lines.push(line);
7187
- };
7188
- TextMarker.prototype.detachLine = function(line) {
7189
- this.lines.splice(indexOf(this.lines, line), 1);
7190
- if (!this.lines.length && this.doc.cm) {
7191
- var op = this.doc.cm.curOp;
7192
- (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
7193
- }
7194
- };
7195
-
7196
- var nextMarkerId = 0;
7197
-
7198
- function markText(doc, from, to, options, type) {
7199
- if (options && options.shared) return markTextShared(doc, from, to, options, type);
7200
- if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
7201
-
7202
- var marker = new TextMarker(doc, type);
7203
- if (options) copyObj(options, marker);
7204
- if (posLess(to, from) || posEq(from, to) && marker.clearWhenEmpty !== false)
7205
- return marker;
7206
- if (marker.replacedWith) {
7207
- marker.collapsed = true;
7208
- marker.replacedWith = elt("span", [marker.replacedWith], "CodeMirror-widget");
7209
- if (!options.handleMouseEvents) marker.replacedWith.ignoreEvents = true;
7210
- }
7211
- if (marker.collapsed) {
7212
- if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
7213
- from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
7214
- throw new Error("Inserting collapsed marker partially overlapping an existing one");
7215
- sawCollapsedSpans = true;
7216
- }
7217
-
7218
- if (marker.addToHistory)
7219
- addToHistory(doc, {from: from, to: to, origin: "markText"},
7220
- {head: doc.sel.head, anchor: doc.sel.anchor}, NaN);
7221
-
7222
- var curLine = from.line, cm = doc.cm, updateMaxLine;
7223
- doc.iter(curLine, to.line + 1, function(line) {
7224
- if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(doc, line) == cm.display.maxLine)
7225
- updateMaxLine = true;
7226
- var span = {from: null, to: null, marker: marker};
7227
- if (curLine == from.line) span.from = from.ch;
7228
- if (curLine == to.line) span.to = to.ch;
7229
- if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
7230
- addMarkedSpan(line, span);
7231
- ++curLine;
7232
- });
7233
- if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
7234
- if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
7235
- });
7236
-
7237
- if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
7238
-
7239
- if (marker.readOnly) {
7240
- sawReadOnlySpans = true;
7241
- if (doc.history.done.length || doc.history.undone.length)
7242
- doc.clearHistory();
7243
- }
7244
- if (marker.collapsed) {
7245
- marker.id = ++nextMarkerId;
7246
- marker.atomic = true;
7247
- }
7248
- if (cm) {
7249
- if (updateMaxLine) cm.curOp.updateMaxLine = true;
7250
- if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.collapsed)
7251
- regChange(cm, from.line, to.line + 1);
7252
- if (marker.atomic) reCheckSelection(cm);
7253
- }
7254
- return marker;
7255
- }
7256
-
7257
- // SHARED TEXTMARKERS
7258
-
7259
- function SharedTextMarker(markers, primary) {
7260
- this.markers = markers;
7261
- this.primary = primary;
7262
- for (var i = 0, me = this; i < markers.length; ++i) {
7263
- markers[i].parent = this;
7264
- on(markers[i], "clear", function(){me.clear();});
7265
- }
7266
- }
7267
- CodeMirror.SharedTextMarker = SharedTextMarker;
7268
- eventMixin(SharedTextMarker);
7269
-
7270
- SharedTextMarker.prototype.clear = function() {
7271
- if (this.explicitlyCleared) return;
7272
- this.explicitlyCleared = true;
7273
- for (var i = 0; i < this.markers.length; ++i)
7274
- this.markers[i].clear();
7275
- signalLater(this, "clear");
7276
- };
7277
- SharedTextMarker.prototype.find = function() {
7278
- return this.primary.find();
7279
- };
7280
-
7281
- function markTextShared(doc, from, to, options, type) {
7282
- options = copyObj(options);
7283
- options.shared = false;
7284
- var markers = [markText(doc, from, to, options, type)], primary = markers[0];
7285
- var widget = options.replacedWith;
7286
- linkedDocs(doc, function(doc) {
7287
- if (widget) options.replacedWith = widget.cloneNode(true);
7288
- markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
7289
- for (var i = 0; i < doc.linked.length; ++i)
7290
- if (doc.linked[i].isParent) return;
7291
- primary = lst(markers);
7292
- });
7293
- return new SharedTextMarker(markers, primary);
7294
- }
7295
-
7296
- // TEXTMARKER SPANS
7297
-
7298
- function getMarkedSpanFor(spans, marker) {
7299
- if (spans) for (var i = 0; i < spans.length; ++i) {
7300
- var span = spans[i];
7301
- if (span.marker == marker) return span;
7302
- }
7303
- }
7304
- function removeMarkedSpan(spans, span) {
7305
- for (var r, i = 0; i < spans.length; ++i)
7306
- if (spans[i] != span) (r || (r = [])).push(spans[i]);
7307
- return r;
7308
- }
7309
- function addMarkedSpan(line, span) {
7310
- line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
7311
- span.marker.attachLine(line);
7312
- }
7313
-
7314
- function markedSpansBefore(old, startCh, isInsert) {
7315
- if (old) for (var i = 0, nw; i < old.length; ++i) {
7316
- var span = old[i], marker = span.marker;
7317
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
7318
- if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
7319
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
7320
- (nw || (nw = [])).push({from: span.from,
7321
- to: endsAfter ? null : span.to,
7322
- marker: marker});
7323
- }
7324
- }
7325
- return nw;
7326
- }
7327
-
7328
- function markedSpansAfter(old, endCh, isInsert) {
7329
- if (old) for (var i = 0, nw; i < old.length; ++i) {
7330
- var span = old[i], marker = span.marker;
7331
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
7332
- if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
7333
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
7334
- (nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh,
7335
- to: span.to == null ? null : span.to - endCh,
7336
- marker: marker});
7337
- }
7338
- }
7339
- return nw;
7340
- }
7341
-
7342
- function stretchSpansOverChange(doc, change) {
7343
- var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
7344
- var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
7345
- if (!oldFirst && !oldLast) return null;
7346
-
7347
- var startCh = change.from.ch, endCh = change.to.ch, isInsert = posEq(change.from, change.to);
7348
- // Get the spans that 'stick out' on both sides
7349
- var first = markedSpansBefore(oldFirst, startCh, isInsert);
7350
- var last = markedSpansAfter(oldLast, endCh, isInsert);
7351
-
7352
- // Next, merge those two ends
7353
- var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
7354
- if (first) {
7355
- // Fix up .to properties of first
7356
- for (var i = 0; i < first.length; ++i) {
7357
- var span = first[i];
7358
- if (span.to == null) {
7359
- var found = getMarkedSpanFor(last, span.marker);
7360
- if (!found) span.to = startCh;
7361
- else if (sameLine) span.to = found.to == null ? null : found.to + offset;
7362
- }
7363
- }
7364
- }
7365
- if (last) {
7366
- // Fix up .from in last (or move them into first in case of sameLine)
7367
- for (var i = 0; i < last.length; ++i) {
7368
- var span = last[i];
7369
- if (span.to != null) span.to += offset;
7370
- if (span.from == null) {
7371
- var found = getMarkedSpanFor(first, span.marker);
7372
- if (!found) {
7373
- span.from = offset;
7374
- if (sameLine) (first || (first = [])).push(span);
7375
- }
7376
- } else {
7377
- span.from += offset;
7378
- if (sameLine) (first || (first = [])).push(span);
7379
- }
7380
- }
7381
- }
7382
- // Make sure we didn't create any zero-length spans
7383
- if (first) first = clearEmptySpans(first);
7384
- if (last && last != first) last = clearEmptySpans(last);
7385
-
7386
- var newMarkers = [first];
7387
- if (!sameLine) {
7388
- // Fill gap with whole-line-spans
7389
- var gap = change.text.length - 2, gapMarkers;
7390
- if (gap > 0 && first)
7391
- for (var i = 0; i < first.length; ++i)
7392
- if (first[i].to == null)
7393
- (gapMarkers || (gapMarkers = [])).push({from: null, to: null, marker: first[i].marker});
7394
- for (var i = 0; i < gap; ++i)
7395
- newMarkers.push(gapMarkers);
7396
- newMarkers.push(last);
7397
- }
7398
- return newMarkers;
7399
- }
7400
-
7401
- function clearEmptySpans(spans) {
7402
- for (var i = 0; i < spans.length; ++i) {
7403
- var span = spans[i];
7404
- if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
7405
- spans.splice(i--, 1);
7406
- }
7407
- if (!spans.length) return null;
7408
- return spans;
7409
- }
7410
-
7411
- function mergeOldSpans(doc, change) {
7412
- var old = getOldSpans(doc, change);
7413
- var stretched = stretchSpansOverChange(doc, change);
7414
- if (!old) return stretched;
7415
- if (!stretched) return old;
7416
-
7417
- for (var i = 0; i < old.length; ++i) {
7418
- var oldCur = old[i], stretchCur = stretched[i];
7419
- if (oldCur && stretchCur) {
7420
- spans: for (var j = 0; j < stretchCur.length; ++j) {
7421
- var span = stretchCur[j];
7422
- for (var k = 0; k < oldCur.length; ++k)
7423
- if (oldCur[k].marker == span.marker) continue spans;
7424
- oldCur.push(span);
7425
- }
7426
- } else if (stretchCur) {
7427
- old[i] = stretchCur;
7428
- }
7429
- }
7430
- return old;
7431
- }
7432
-
7433
- function removeReadOnlyRanges(doc, from, to) {
7434
- var markers = null;
7435
- doc.iter(from.line, to.line + 1, function(line) {
7436
- if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
7437
- var mark = line.markedSpans[i].marker;
7438
- if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
7439
- (markers || (markers = [])).push(mark);
7440
- }
7441
- });
7442
- if (!markers) return null;
7443
- var parts = [{from: from, to: to}];
7444
- for (var i = 0; i < markers.length; ++i) {
7445
- var mk = markers[i], m = mk.find();
7446
- for (var j = 0; j < parts.length; ++j) {
7447
- var p = parts[j];
7448
- if (posLess(p.to, m.from) || posLess(m.to, p.from)) continue;
7449
- var newParts = [j, 1];
7450
- if (posLess(p.from, m.from) || !mk.inclusiveLeft && posEq(p.from, m.from))
7451
- newParts.push({from: p.from, to: m.from});
7452
- if (posLess(m.to, p.to) || !mk.inclusiveRight && posEq(p.to, m.to))
7453
- newParts.push({from: m.to, to: p.to});
7454
- parts.splice.apply(parts, newParts);
7455
- j += newParts.length - 1;
7456
- }
7457
- }
7458
- return parts;
7459
- }
7460
-
7461
- function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
7462
- function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
7463
-
7464
- function compareCollapsedMarkers(a, b) {
7465
- var lenDiff = a.lines.length - b.lines.length;
7466
- if (lenDiff != 0) return lenDiff;
7467
- var aPos = a.find(), bPos = b.find();
7468
- var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
7469
- if (fromCmp) return -fromCmp;
7470
- var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
7471
- if (toCmp) return toCmp;
7472
- return b.id - a.id;
7473
- }
7474
-
7475
- function collapsedSpanAtSide(line, start) {
7476
- var sps = sawCollapsedSpans && line.markedSpans, found;
7477
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
7478
- sp = sps[i];
7479
- if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
7480
- (!found || compareCollapsedMarkers(found, sp.marker) < 0))
7481
- found = sp.marker;
7482
- }
7483
- return found;
7484
- }
7485
- function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
7486
- function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
7487
-
7488
- function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
7489
- var line = getLine(doc, lineNo);
7490
- var sps = sawCollapsedSpans && line.markedSpans;
7491
- if (sps) for (var i = 0; i < sps.length; ++i) {
7492
- var sp = sps[i];
7493
- if (!sp.marker.collapsed) continue;
7494
- var found = sp.marker.find(true);
7495
- var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
7496
- var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
7497
- if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
7498
- if (fromCmp <= 0 && (cmp(found.to, from) || extraRight(sp.marker) - extraLeft(marker)) > 0 ||
7499
- fromCmp >= 0 && (cmp(found.from, to) || extraLeft(sp.marker) - extraRight(marker)) < 0)
7500
- return true;
7501
- }
7502
- }
7503
-
7504
- function visualLine(doc, line) {
7505
- var merged;
7506
- while (merged = collapsedSpanAtStart(line))
7507
- line = getLine(doc, merged.find().from.line);
7508
- return line;
7509
- }
7510
-
7511
- function lineIsHidden(doc, line) {
7512
- var sps = sawCollapsedSpans && line.markedSpans;
7513
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
7514
- sp = sps[i];
7515
- if (!sp.marker.collapsed) continue;
7516
- if (sp.from == null) return true;
7517
- if (sp.marker.replacedWith) continue;
7518
- if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
7519
- return true;
7520
- }
7521
- }
7522
- function lineIsHiddenInner(doc, line, span) {
7523
- if (span.to == null) {
7524
- var end = span.marker.find().to, endLine = getLine(doc, end.line);
7525
- return lineIsHiddenInner(doc, endLine, getMarkedSpanFor(endLine.markedSpans, span.marker));
7526
- }
7527
- if (span.marker.inclusiveRight && span.to == line.text.length)
7528
- return true;
7529
- for (var sp, i = 0; i < line.markedSpans.length; ++i) {
7530
- sp = line.markedSpans[i];
7531
- if (sp.marker.collapsed && !sp.marker.replacedWith && sp.from == span.to &&
7532
- (sp.to == null || sp.to != span.from) &&
7533
- (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
7534
- lineIsHiddenInner(doc, line, sp)) return true;
7535
- }
7536
- }
7537
-
7538
- function detachMarkedSpans(line) {
7539
- var spans = line.markedSpans;
7540
- if (!spans) return;
7541
- for (var i = 0; i < spans.length; ++i)
7542
- spans[i].marker.detachLine(line);
7543
- line.markedSpans = null;
7544
- }
7545
-
7546
- function attachMarkedSpans(line, spans) {
7547
- if (!spans) return;
7548
- for (var i = 0; i < spans.length; ++i)
7549
- spans[i].marker.attachLine(line);
7550
- line.markedSpans = spans;
7551
- }
7552
-
7553
- // LINE WIDGETS
7554
-
7555
- var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
7556
- if (options) for (var opt in options) if (options.hasOwnProperty(opt))
7557
- this[opt] = options[opt];
7558
- this.cm = cm;
7559
- this.node = node;
7560
- };
7561
- eventMixin(LineWidget);
7562
- function widgetOperation(f) {
7563
- return function() {
7564
- var withOp = !this.cm.curOp;
7565
- if (withOp) startOperation(this.cm);
7566
- try {var result = f.apply(this, arguments);}
7567
- finally {if (withOp) endOperation(this.cm);}
7568
- return result;
7569
- };
7570
- }
7571
- LineWidget.prototype.clear = widgetOperation(function() {
7572
- var ws = this.line.widgets, no = lineNo(this.line);
7573
- if (no == null || !ws) return;
7574
- for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
7575
- if (!ws.length) this.line.widgets = null;
7576
- var aboveVisible = heightAtLine(this.cm, this.line) < this.cm.doc.scrollTop;
7577
- updateLineHeight(this.line, Math.max(0, this.line.height - widgetHeight(this)));
7578
- if (aboveVisible) addToScrollPos(this.cm, 0, -this.height);
7579
- regChange(this.cm, no, no + 1);
7580
- });
7581
- LineWidget.prototype.changed = widgetOperation(function() {
7582
- var oldH = this.height;
7583
- this.height = null;
7584
- var diff = widgetHeight(this) - oldH;
7585
- if (!diff) return;
7586
- updateLineHeight(this.line, this.line.height + diff);
7587
- var no = lineNo(this.line);
7588
- regChange(this.cm, no, no + 1);
7589
- });
7590
-
7591
- function widgetHeight(widget) {
7592
- if (widget.height != null) return widget.height;
7593
- if (!widget.node.parentNode || widget.node.parentNode.nodeType != 1)
7594
- removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, "position: relative"));
7595
- return widget.height = widget.node.offsetHeight;
7596
- }
7597
-
7598
- function addLineWidget(cm, handle, node, options) {
7599
- var widget = new LineWidget(cm, node, options);
7600
- if (widget.noHScroll) cm.display.alignWidgets = true;
7601
- changeLine(cm, handle, function(line) {
7602
- var widgets = line.widgets || (line.widgets = []);
7603
- if (widget.insertAt == null) widgets.push(widget);
7604
- else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
7605
- widget.line = line;
7606
- if (!lineIsHidden(cm.doc, line) || widget.showIfHidden) {
7607
- var aboveVisible = heightAtLine(cm, line) < cm.doc.scrollTop;
7608
- updateLineHeight(line, line.height + widgetHeight(widget));
7609
- if (aboveVisible) addToScrollPos(cm, 0, widget.height);
7610
- cm.curOp.forceUpdate = true;
7611
- }
7612
- return true;
7613
- });
7614
- return widget;
7615
- }
7616
-
7617
- // LINE DATA STRUCTURE
7618
-
7619
- // Line objects. These hold state related to a line, including
7620
- // highlighting info (the styles array).
7621
- var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
7622
- this.text = text;
7623
- attachMarkedSpans(this, markedSpans);
7624
- this.height = estimateHeight ? estimateHeight(this) : 1;
7625
- };
7626
- eventMixin(Line);
7627
- Line.prototype.lineNo = function() { return lineNo(this); };
7628
-
7629
- function updateLine(line, text, markedSpans, estimateHeight) {
7630
- line.text = text;
7631
- if (line.stateAfter) line.stateAfter = null;
7632
- if (line.styles) line.styles = null;
7633
- if (line.order != null) line.order = null;
7634
- detachMarkedSpans(line);
7635
- attachMarkedSpans(line, markedSpans);
7636
- var estHeight = estimateHeight ? estimateHeight(line) : 1;
7637
- if (estHeight != line.height) updateLineHeight(line, estHeight);
7638
- }
7639
-
7640
- function cleanUpLine(line) {
7641
- line.parent = null;
7642
- detachMarkedSpans(line);
7643
- }
7644
-
7645
- // Run the given mode's parser over a line, update the styles
7646
- // array, which contains alternating fragments of text and CSS
7647
- // classes.
7648
- function runMode(cm, text, mode, state, f, forceToEnd) {
7649
- var flattenSpans = mode.flattenSpans;
7650
- if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
7651
- var curStart = 0, curStyle = null;
7652
- var stream = new StringStream(text, cm.options.tabSize), style;
7653
- if (text == "" && mode.blankLine) mode.blankLine(state);
7654
- while (!stream.eol()) {
7655
- if (stream.pos > cm.options.maxHighlightLength) {
7656
- flattenSpans = false;
7657
- if (forceToEnd) processLine(cm, text, state, stream.pos);
7658
- stream.pos = text.length;
7659
- style = null;
7660
- } else {
7661
- style = mode.token(stream, state);
7662
- }
7663
- if (cm.options.addModeClass) {
7664
- var mName = CodeMirror.innerMode(mode, state).mode.name;
7665
- if (mName) style = "m-" + (style ? mName + " " + style : mName);
7666
- }
7667
- if (!flattenSpans || curStyle != style) {
7668
- if (curStart < stream.start) f(stream.start, curStyle);
7669
- curStart = stream.start; curStyle = style;
7670
- }
7671
- stream.start = stream.pos;
7672
- }
7673
- while (curStart < stream.pos) {
7674
- // Webkit seems to refuse to render text nodes longer than 57444 characters
7675
- var pos = Math.min(stream.pos, curStart + 50000);
7676
- f(pos, curStyle);
7677
- curStart = pos;
7678
- }
7679
- }
7680
-
7681
- function highlightLine(cm, line, state, forceToEnd) {
7682
- // A styles array always starts with a number identifying the
7683
- // mode/overlays that it is based on (for easy invalidation).
7684
- var st = [cm.state.modeGen];
7685
- // Compute the base array of styles
7686
- runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
7687
- st.push(end, style);
7688
- }, forceToEnd);
7689
-
7690
- // Run overlays, adjust style array.
7691
- for (var o = 0; o < cm.state.overlays.length; ++o) {
7692
- var overlay = cm.state.overlays[o], i = 1, at = 0;
7693
- runMode(cm, line.text, overlay.mode, true, function(end, style) {
7694
- var start = i;
7695
- // Ensure there's a token end at the current position, and that i points at it
7696
- while (at < end) {
7697
- var i_end = st[i];
7698
- if (i_end > end)
7699
- st.splice(i, 1, end, st[i+1], i_end);
7700
- i += 2;
7701
- at = Math.min(end, i_end);
7702
- }
7703
- if (!style) return;
7704
- if (overlay.opaque) {
7705
- st.splice(start, i - start, end, style);
7706
- i = start + 2;
7707
- } else {
7708
- for (; start < i; start += 2) {
7709
- var cur = st[start+1];
7710
- st[start+1] = cur ? cur + " " + style : style;
7711
- }
7712
- }
7713
- });
7714
- }
7715
-
7716
- return st;
7717
- }
7718
-
7719
- function getLineStyles(cm, line) {
7720
- if (!line.styles || line.styles[0] != cm.state.modeGen)
7721
- line.styles = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
7722
- return line.styles;
7723
- }
7724
-
7725
- // Lightweight form of highlight -- proceed over this line and
7726
- // update state, but don't save a style array.
7727
- function processLine(cm, text, state, startAt) {
7728
- var mode = cm.doc.mode;
7729
- var stream = new StringStream(text, cm.options.tabSize);
7730
- stream.start = stream.pos = startAt || 0;
7731
- if (text == "" && mode.blankLine) mode.blankLine(state);
7732
- while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
7733
- mode.token(stream, state);
7734
- stream.start = stream.pos;
7735
- }
7736
- }
7737
-
7738
- var styleToClassCache = {}, styleToClassCacheWithMode = {};
7739
- function interpretTokenStyle(style, builder) {
7740
- if (!style) return null;
7741
- for (;;) {
7742
- var lineClass = style.match(/(?:^|\s+)line-(background-)?(\S+)/);
7743
- if (!lineClass) break;
7744
- style = style.slice(0, lineClass.index) + style.slice(lineClass.index + lineClass[0].length);
7745
- var prop = lineClass[1] ? "bgClass" : "textClass";
7746
- if (builder[prop] == null)
7747
- builder[prop] = lineClass[2];
7748
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(builder[prop]))
7749
- builder[prop] += " " + lineClass[2];
7750
- }
7751
- if (/^\s*$/.test(style)) return null;
7752
- var cache = builder.cm.options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
7753
- return cache[style] ||
7754
- (cache[style] = style.replace(/\S+/g, "cm-$&"));
7755
- }
7756
-
7757
- function buildLineContent(cm, realLine, measure, copyWidgets) {
7758
- var merged, line = realLine, empty = true;
7759
- while (merged = collapsedSpanAtStart(line))
7760
- line = getLine(cm.doc, merged.find().from.line);
7761
-
7762
- var builder = {pre: elt("pre"), col: 0, pos: 0,
7763
- measure: null, measuredSomething: false, cm: cm,
7764
- copyWidgets: copyWidgets};
7765
-
7766
- do {
7767
- if (line.text) empty = false;
7768
- builder.measure = line == realLine && measure;
7769
- builder.pos = 0;
7770
- builder.addToken = builder.measure ? buildTokenMeasure : buildToken;
7771
- if ((ie || webkit) && cm.getOption("lineWrapping"))
7772
- builder.addToken = buildTokenSplitSpaces(builder.addToken);
7773
- var next = insertLineContent(line, builder, getLineStyles(cm, line));
7774
- if (measure && line == realLine && !builder.measuredSomething) {
7775
- measure[0] = builder.pre.appendChild(zeroWidthElement(cm.display.measure));
7776
- builder.measuredSomething = true;
7777
- }
7778
- if (next) line = getLine(cm.doc, next.to.line);
7779
- } while (next);
7780
-
7781
- if (measure && !builder.measuredSomething && !measure[0])
7782
- measure[0] = builder.pre.appendChild(empty ? elt("span", "\u00a0") : zeroWidthElement(cm.display.measure));
7783
- if (!builder.pre.firstChild && !lineIsHidden(cm.doc, realLine))
7784
- builder.pre.appendChild(document.createTextNode("\u00a0"));
7785
-
7786
- var order;
7787
- // Work around problem with the reported dimensions of single-char
7788
- // direction spans on IE (issue #1129). See also the comment in
7789
- // cursorCoords.
7790
- if (measure && ie && (order = getOrder(line))) {
7791
- var l = order.length - 1;
7792
- if (order[l].from == order[l].to) --l;
7793
- var last = order[l], prev = order[l - 1];
7794
- if (last.from + 1 == last.to && prev && last.level < prev.level) {
7795
- var span = measure[builder.pos - 1];
7796
- if (span) span.parentNode.insertBefore(span.measureRight = zeroWidthElement(cm.display.measure),
7797
- span.nextSibling);
7798
- }
7799
- }
7800
-
7801
- var textClass = builder.textClass ? builder.textClass + " " + (realLine.textClass || "") : realLine.textClass;
7802
- if (textClass) builder.pre.className = textClass;
7803
-
7804
- signal(cm, "renderLine", cm, realLine, builder.pre);
7805
- return builder;
7806
- }
7807
-
7808
- function defaultSpecialCharPlaceholder(ch) {
7809
- var token = elt("span", "\u2022", "cm-invalidchar");
7810
- token.title = "\\u" + ch.charCodeAt(0).toString(16);
7811
- return token;
7812
- }
7813
-
7814
- function buildToken(builder, text, style, startStyle, endStyle, title) {
7815
- if (!text) return;
7816
- var special = builder.cm.options.specialChars;
7817
- if (!special.test(text)) {
7818
- builder.col += text.length;
7819
- var content = document.createTextNode(text);
7820
- } else {
7821
- var content = document.createDocumentFragment(), pos = 0;
7822
- while (true) {
7823
- special.lastIndex = pos;
7824
- var m = special.exec(text);
7825
- var skipped = m ? m.index - pos : text.length - pos;
7826
- if (skipped) {
7827
- content.appendChild(document.createTextNode(text.slice(pos, pos + skipped)));
7828
- builder.col += skipped;
7829
- }
7830
- if (!m) break;
7831
- pos += skipped + 1;
7832
- if (m[0] == "\t") {
7833
- var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
7834
- content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
7835
- builder.col += tabWidth;
7836
- } else {
7837
- var token = builder.cm.options.specialCharPlaceholder(m[0]);
7838
- content.appendChild(token);
7839
- builder.col += 1;
7840
- }
7841
- }
7842
- }
7843
- if (style || startStyle || endStyle || builder.measure) {
7844
- var fullStyle = style || "";
7845
- if (startStyle) fullStyle += startStyle;
7846
- if (endStyle) fullStyle += endStyle;
7847
- var token = elt("span", [content], fullStyle);
7848
- if (title) token.title = title;
7849
- return builder.pre.appendChild(token);
7850
- }
7851
- builder.pre.appendChild(content);
7852
- }
7853
-
7854
- function buildTokenMeasure(builder, text, style, startStyle, endStyle) {
7855
- var wrapping = builder.cm.options.lineWrapping;
7856
- for (var i = 0; i < text.length; ++i) {
7857
- var start = i == 0, to = i + 1;
7858
- while (to < text.length && isExtendingChar(text.charAt(to))) ++to;
7859
- var ch = text.slice(i, to);
7860
- i = to - 1;
7861
- if (i && wrapping && spanAffectsWrapping(text, i))
7862
- builder.pre.appendChild(elt("wbr"));
7863
- var old = builder.measure[builder.pos];
7864
- var span = builder.measure[builder.pos] =
7865
- buildToken(builder, ch, style,
7866
- start && startStyle, i == text.length - 1 && endStyle);
7867
- if (old) span.leftSide = old.leftSide || old;
7868
- // In IE single-space nodes wrap differently than spaces
7869
- // embedded in larger text nodes, except when set to
7870
- // white-space: normal (issue #1268).
7871
- if (old_ie && wrapping && ch == " " && i && !/\s/.test(text.charAt(i - 1)) &&
7872
- i < text.length - 1 && !/\s/.test(text.charAt(i + 1)))
7873
- span.style.whiteSpace = "normal";
7874
- builder.pos += ch.length;
7875
- }
7876
- if (text.length) builder.measuredSomething = true;
7877
- }
7878
-
7879
- function buildTokenSplitSpaces(inner) {
7880
- function split(old) {
7881
- var out = " ";
7882
- for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
7883
- out += " ";
7884
- return out;
7885
- }
7886
- return function(builder, text, style, startStyle, endStyle, title) {
7887
- return inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
7888
- };
7889
- }
7890
-
7891
- function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
7892
- var widget = !ignoreWidget && marker.replacedWith;
7893
- if (widget) {
7894
- if (builder.copyWidgets) widget = widget.cloneNode(true);
7895
- builder.pre.appendChild(widget);
7896
- if (builder.measure) {
7897
- if (size) {
7898
- builder.measure[builder.pos] = widget;
7899
- } else {
7900
- var elt = zeroWidthElement(builder.cm.display.measure);
7901
- if (marker.type == "bookmark" && !marker.insertLeft)
7902
- builder.measure[builder.pos] = builder.pre.appendChild(elt);
7903
- else if (builder.measure[builder.pos])
7904
- return;
7905
- else
7906
- builder.measure[builder.pos] = builder.pre.insertBefore(elt, widget);
7907
- }
7908
- builder.measuredSomething = true;
7909
- }
7910
- }
7911
- builder.pos += size;
7912
- }
7913
-
7914
- // Outputs a number of spans to make up a line, taking highlighting
7915
- // and marked text into account.
7916
- function insertLineContent(line, builder, styles) {
7917
- var spans = line.markedSpans, allText = line.text, at = 0;
7918
- if (!spans) {
7919
- for (var i = 1; i < styles.length; i+=2)
7920
- builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder));
7921
- return;
7922
- }
7923
-
7924
- var len = allText.length, pos = 0, i = 1, text = "", style;
7925
- var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
7926
- for (;;) {
7927
- if (nextChange == pos) { // Update current marker set
7928
- spanStyle = spanEndStyle = spanStartStyle = title = "";
7929
- collapsed = null; nextChange = Infinity;
7930
- var foundBookmarks = [];
7931
- for (var j = 0; j < spans.length; ++j) {
7932
- var sp = spans[j], m = sp.marker;
7933
- if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
7934
- if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
7935
- if (m.className) spanStyle += " " + m.className;
7936
- if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
7937
- if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
7938
- if (m.title && !title) title = m.title;
7939
- if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
7940
- collapsed = sp;
7941
- } else if (sp.from > pos && nextChange > sp.from) {
7942
- nextChange = sp.from;
7943
- }
7944
- if (m.type == "bookmark" && sp.from == pos && m.replacedWith) foundBookmarks.push(m);
7945
- }
7946
- if (collapsed && (collapsed.from || 0) == pos) {
7947
- buildCollapsedSpan(builder, (collapsed.to == null ? len : collapsed.to) - pos,
7948
- collapsed.marker, collapsed.from == null);
7949
- if (collapsed.to == null) return collapsed.marker.find();
7950
- }
7951
- if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
7952
- buildCollapsedSpan(builder, 0, foundBookmarks[j]);
7953
- }
7954
- if (pos >= len) break;
7955
-
7956
- var upto = Math.min(len, nextChange);
7957
- while (true) {
7958
- if (text) {
7959
- var end = pos + text.length;
7960
- if (!collapsed) {
7961
- var tokenText = end > upto ? text.slice(0, upto - pos) : text;
7962
- builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
7963
- spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title);
7964
- }
7965
- if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
7966
- pos = end;
7967
- spanStartStyle = "";
7968
- }
7969
- text = allText.slice(at, at = styles[i++]);
7970
- style = interpretTokenStyle(styles[i++], builder);
7971
- }
7972
- }
7973
- }
7974
-
7975
- // DOCUMENT DATA STRUCTURE
7976
-
7977
- function updateDoc(doc, change, markedSpans, selAfter, estimateHeight) {
7978
- function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
7979
- function update(line, text, spans) {
7980
- updateLine(line, text, spans, estimateHeight);
7981
- signalLater(line, "change", line, change);
7982
- }
7983
-
7984
- var from = change.from, to = change.to, text = change.text;
7985
- var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
7986
- var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
7987
-
7988
- // First adjust the line structure
7989
- if (from.ch == 0 && to.ch == 0 && lastText == "" &&
7990
- (!doc.cm || doc.cm.options.wholeLineUpdateBefore)) {
7991
- // This is a whole-line replace. Treated specially to make
7992
- // sure line objects move the way they are supposed to.
7993
- for (var i = 0, e = text.length - 1, added = []; i < e; ++i)
7994
- added.push(new Line(text[i], spansFor(i), estimateHeight));
7995
- update(lastLine, lastLine.text, lastSpans);
7996
- if (nlines) doc.remove(from.line, nlines);
7997
- if (added.length) doc.insert(from.line, added);
7998
- } else if (firstLine == lastLine) {
7999
- if (text.length == 1) {
8000
- update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
8001
- } else {
8002
- for (var added = [], i = 1, e = text.length - 1; i < e; ++i)
8003
- added.push(new Line(text[i], spansFor(i), estimateHeight));
8004
- added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
8005
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
8006
- doc.insert(from.line + 1, added);
8007
- }
8008
- } else if (text.length == 1) {
8009
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
8010
- doc.remove(from.line + 1, nlines);
8011
- } else {
8012
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
8013
- update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
8014
- for (var i = 1, e = text.length - 1, added = []; i < e; ++i)
8015
- added.push(new Line(text[i], spansFor(i), estimateHeight));
8016
- if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
8017
- doc.insert(from.line + 1, added);
8018
- }
8019
-
8020
- signalLater(doc, "change", doc, change);
8021
- setSelection(doc, selAfter.anchor, selAfter.head, null, true);
8022
- }
8023
-
8024
- function LeafChunk(lines) {
8025
- this.lines = lines;
8026
- this.parent = null;
8027
- for (var i = 0, e = lines.length, height = 0; i < e; ++i) {
8028
- lines[i].parent = this;
8029
- height += lines[i].height;
8030
- }
8031
- this.height = height;
8032
- }
8033
-
8034
- LeafChunk.prototype = {
8035
- chunkSize: function() { return this.lines.length; },
8036
- removeInner: function(at, n) {
8037
- for (var i = at, e = at + n; i < e; ++i) {
8038
- var line = this.lines[i];
8039
- this.height -= line.height;
8040
- cleanUpLine(line);
8041
- signalLater(line, "delete");
8042
- }
8043
- this.lines.splice(at, n);
8044
- },
8045
- collapse: function(lines) {
8046
- lines.splice.apply(lines, [lines.length, 0].concat(this.lines));
8047
- },
8048
- insertInner: function(at, lines, height) {
8049
- this.height += height;
8050
- this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
8051
- for (var i = 0, e = lines.length; i < e; ++i) lines[i].parent = this;
8052
- },
8053
- iterN: function(at, n, op) {
8054
- for (var e = at + n; at < e; ++at)
8055
- if (op(this.lines[at])) return true;
8056
- }
8057
- };
8058
-
8059
- function BranchChunk(children) {
8060
- this.children = children;
8061
- var size = 0, height = 0;
8062
- for (var i = 0, e = children.length; i < e; ++i) {
8063
- var ch = children[i];
8064
- size += ch.chunkSize(); height += ch.height;
8065
- ch.parent = this;
8066
- }
8067
- this.size = size;
8068
- this.height = height;
8069
- this.parent = null;
8070
- }
8071
-
8072
- BranchChunk.prototype = {
8073
- chunkSize: function() { return this.size; },
8074
- removeInner: function(at, n) {
8075
- this.size -= n;
8076
- for (var i = 0; i < this.children.length; ++i) {
8077
- var child = this.children[i], sz = child.chunkSize();
8078
- if (at < sz) {
8079
- var rm = Math.min(n, sz - at), oldHeight = child.height;
8080
- child.removeInner(at, rm);
8081
- this.height -= oldHeight - child.height;
8082
- if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
8083
- if ((n -= rm) == 0) break;
8084
- at = 0;
8085
- } else at -= sz;
8086
- }
8087
- if (this.size - n < 25) {
8088
- var lines = [];
8089
- this.collapse(lines);
8090
- this.children = [new LeafChunk(lines)];
8091
- this.children[0].parent = this;
8092
- }
8093
- },
8094
- collapse: function(lines) {
8095
- for (var i = 0, e = this.children.length; i < e; ++i) this.children[i].collapse(lines);
8096
- },
8097
- insertInner: function(at, lines, height) {
8098
- this.size += lines.length;
8099
- this.height += height;
8100
- for (var i = 0, e = this.children.length; i < e; ++i) {
8101
- var child = this.children[i], sz = child.chunkSize();
8102
- if (at <= sz) {
8103
- child.insertInner(at, lines, height);
8104
- if (child.lines && child.lines.length > 50) {
8105
- while (child.lines.length > 50) {
8106
- var spilled = child.lines.splice(child.lines.length - 25, 25);
8107
- var newleaf = new LeafChunk(spilled);
8108
- child.height -= newleaf.height;
8109
- this.children.splice(i + 1, 0, newleaf);
8110
- newleaf.parent = this;
8111
- }
8112
- this.maybeSpill();
8113
- }
8114
- break;
8115
- }
8116
- at -= sz;
8117
- }
8118
- },
8119
- maybeSpill: function() {
8120
- if (this.children.length <= 10) return;
8121
- var me = this;
8122
- do {
8123
- var spilled = me.children.splice(me.children.length - 5, 5);
8124
- var sibling = new BranchChunk(spilled);
8125
- if (!me.parent) { // Become the parent node
8126
- var copy = new BranchChunk(me.children);
8127
- copy.parent = me;
8128
- me.children = [copy, sibling];
8129
- me = copy;
8130
- } else {
8131
- me.size -= sibling.size;
8132
- me.height -= sibling.height;
8133
- var myIndex = indexOf(me.parent.children, me);
8134
- me.parent.children.splice(myIndex + 1, 0, sibling);
8135
- }
8136
- sibling.parent = me.parent;
8137
- } while (me.children.length > 10);
8138
- me.parent.maybeSpill();
8139
- },
8140
- iterN: function(at, n, op) {
8141
- for (var i = 0, e = this.children.length; i < e; ++i) {
8142
- var child = this.children[i], sz = child.chunkSize();
8143
- if (at < sz) {
8144
- var used = Math.min(n, sz - at);
8145
- if (child.iterN(at, used, op)) return true;
8146
- if ((n -= used) == 0) break;
8147
- at = 0;
8148
- } else at -= sz;
8149
- }
8150
- }
8151
- };
8152
-
8153
- var nextDocId = 0;
8154
- var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
8155
- if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
8156
- if (firstLine == null) firstLine = 0;
8157
-
8158
- BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
8159
- this.first = firstLine;
8160
- this.scrollTop = this.scrollLeft = 0;
8161
- this.cantEdit = false;
8162
- this.history = makeHistory();
8163
- this.cleanGeneration = 1;
8164
- this.frontier = firstLine;
8165
- var start = Pos(firstLine, 0);
8166
- this.sel = {from: start, to: start, head: start, anchor: start, shift: false, extend: false, goalColumn: null};
8167
- this.id = ++nextDocId;
8168
- this.modeOption = mode;
8169
-
8170
- if (typeof text == "string") text = splitLines(text);
8171
- updateDoc(this, {from: start, to: start, text: text}, null, {head: start, anchor: start});
8172
- };
8173
-
8174
- Doc.prototype = createObj(BranchChunk.prototype, {
8175
- constructor: Doc,
8176
- iter: function(from, to, op) {
8177
- if (op) this.iterN(from - this.first, to - from, op);
8178
- else this.iterN(this.first, this.first + this.size, from);
8179
- },
8180
-
8181
- insert: function(at, lines) {
8182
- var height = 0;
8183
- for (var i = 0, e = lines.length; i < e; ++i) height += lines[i].height;
8184
- this.insertInner(at - this.first, lines, height);
8185
- },
8186
- remove: function(at, n) { this.removeInner(at - this.first, n); },
8187
-
8188
- getValue: function(lineSep) {
8189
- var lines = getLines(this, this.first, this.first + this.size);
8190
- if (lineSep === false) return lines;
8191
- return lines.join(lineSep || "\n");
8192
- },
8193
- setValue: function(code) {
8194
- var top = Pos(this.first, 0), last = this.first + this.size - 1;
8195
- makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
8196
- text: splitLines(code), origin: "setValue"},
8197
- {head: top, anchor: top}, true);
8198
- },
8199
- replaceRange: function(code, from, to, origin) {
8200
- from = clipPos(this, from);
8201
- to = to ? clipPos(this, to) : from;
8202
- replaceRange(this, code, from, to, origin);
8203
- },
8204
- getRange: function(from, to, lineSep) {
8205
- var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
8206
- if (lineSep === false) return lines;
8207
- return lines.join(lineSep || "\n");
8208
- },
8209
-
8210
- getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
8211
- setLine: function(line, text) {
8212
- if (isLine(this, line))
8213
- replaceRange(this, text, Pos(line, 0), clipPos(this, Pos(line)));
8214
- },
8215
- removeLine: function(line) {
8216
- if (line) replaceRange(this, "", clipPos(this, Pos(line - 1)), clipPos(this, Pos(line)));
8217
- else replaceRange(this, "", Pos(0, 0), clipPos(this, Pos(1, 0)));
8218
- },
8219
-
8220
- getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
8221
- getLineNumber: function(line) {return lineNo(line);},
8222
-
8223
- getLineHandleVisualStart: function(line) {
8224
- if (typeof line == "number") line = getLine(this, line);
8225
- return visualLine(this, line);
8226
- },
8227
-
8228
- lineCount: function() {return this.size;},
8229
- firstLine: function() {return this.first;},
8230
- lastLine: function() {return this.first + this.size - 1;},
8231
-
8232
- clipPos: function(pos) {return clipPos(this, pos);},
8233
-
8234
- getCursor: function(start) {
8235
- var sel = this.sel, pos;
8236
- if (start == null || start == "head") pos = sel.head;
8237
- else if (start == "anchor") pos = sel.anchor;
8238
- else if (start == "end" || start === false) pos = sel.to;
8239
- else pos = sel.from;
8240
- return copyPos(pos);
8241
- },
8242
- somethingSelected: function() {return !posEq(this.sel.head, this.sel.anchor);},
8243
-
8244
- setCursor: docOperation(function(line, ch, extend) {
8245
- var pos = clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line);
8246
- if (extend) extendSelection(this, pos);
8247
- else setSelection(this, pos, pos);
8248
- }),
8249
- setSelection: docOperation(function(anchor, head, bias) {
8250
- setSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), bias);
8251
- }),
8252
- extendSelection: docOperation(function(from, to, bias) {
8253
- extendSelection(this, clipPos(this, from), to && clipPos(this, to), bias);
8254
- }),
8255
-
8256
- getSelection: function(lineSep) {return this.getRange(this.sel.from, this.sel.to, lineSep);},
8257
- replaceSelection: function(code, collapse, origin) {
8258
- makeChange(this, {from: this.sel.from, to: this.sel.to, text: splitLines(code), origin: origin}, collapse || "around");
8259
- },
8260
- undo: docOperation(function() {makeChangeFromHistory(this, "undo");}),
8261
- redo: docOperation(function() {makeChangeFromHistory(this, "redo");}),
8262
-
8263
- setExtending: function(val) {this.sel.extend = val;},
8264
-
8265
- historySize: function() {
8266
- var hist = this.history;
8267
- return {undo: hist.done.length, redo: hist.undone.length};
8268
- },
8269
- clearHistory: function() {this.history = makeHistory(this.history.maxGeneration);},
8270
-
8271
- markClean: function() {
8272
- this.cleanGeneration = this.changeGeneration(true);
8273
- },
8274
- changeGeneration: function(forceSplit) {
8275
- if (forceSplit)
8276
- this.history.lastOp = this.history.lastOrigin = null;
8277
- return this.history.generation;
8278
- },
8279
- isClean: function (gen) {
8280
- return this.history.generation == (gen || this.cleanGeneration);
8281
- },
8282
-
8283
- getHistory: function() {
8284
- return {done: copyHistoryArray(this.history.done),
8285
- undone: copyHistoryArray(this.history.undone)};
8286
- },
8287
- setHistory: function(histData) {
8288
- var hist = this.history = makeHistory(this.history.maxGeneration);
8289
- hist.done = histData.done.slice(0);
8290
- hist.undone = histData.undone.slice(0);
8291
- },
8292
-
8293
- markText: function(from, to, options) {
8294
- return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
8295
- },
8296
- setBookmark: function(pos, options) {
8297
- var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
8298
- insertLeft: options && options.insertLeft,
8299
- clearWhenEmpty: false};
8300
- pos = clipPos(this, pos);
8301
- return markText(this, pos, pos, realOpts, "bookmark");
8302
- },
8303
- findMarksAt: function(pos) {
8304
- pos = clipPos(this, pos);
8305
- var markers = [], spans = getLine(this, pos.line).markedSpans;
8306
- if (spans) for (var i = 0; i < spans.length; ++i) {
8307
- var span = spans[i];
8308
- if ((span.from == null || span.from <= pos.ch) &&
8309
- (span.to == null || span.to >= pos.ch))
8310
- markers.push(span.marker.parent || span.marker);
8311
- }
8312
- return markers;
8313
- },
8314
- findMarks: function(from, to) {
8315
- from = clipPos(this, from); to = clipPos(this, to);
8316
- var found = [], lineNo = from.line;
8317
- this.iter(from.line, to.line + 1, function(line) {
8318
- var spans = line.markedSpans;
8319
- if (spans) for (var i = 0; i < spans.length; i++) {
8320
- var span = spans[i];
8321
- if (!(lineNo == from.line && from.ch > span.to ||
8322
- span.from == null && lineNo != from.line||
8323
- lineNo == to.line && span.from > to.ch))
8324
- found.push(span.marker.parent || span.marker);
8325
- }
8326
- ++lineNo;
8327
- });
8328
- return found;
8329
- },
8330
- getAllMarks: function() {
8331
- var markers = [];
8332
- this.iter(function(line) {
8333
- var sps = line.markedSpans;
8334
- if (sps) for (var i = 0; i < sps.length; ++i)
8335
- if (sps[i].from != null) markers.push(sps[i].marker);
8336
- });
8337
- return markers;
8338
- },
8339
-
8340
- posFromIndex: function(off) {
8341
- var ch, lineNo = this.first;
8342
- this.iter(function(line) {
8343
- var sz = line.text.length + 1;
8344
- if (sz > off) { ch = off; return true; }
8345
- off -= sz;
8346
- ++lineNo;
8347
- });
8348
- return clipPos(this, Pos(lineNo, ch));
8349
- },
8350
- indexFromPos: function (coords) {
8351
- coords = clipPos(this, coords);
8352
- var index = coords.ch;
8353
- if (coords.line < this.first || coords.ch < 0) return 0;
8354
- this.iter(this.first, coords.line, function (line) {
8355
- index += line.text.length + 1;
8356
- });
8357
- return index;
8358
- },
8359
-
8360
- copy: function(copyHistory) {
8361
- var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
8362
- doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
8363
- doc.sel = {from: this.sel.from, to: this.sel.to, head: this.sel.head, anchor: this.sel.anchor,
8364
- shift: this.sel.shift, extend: false, goalColumn: this.sel.goalColumn};
8365
- if (copyHistory) {
8366
- doc.history.undoDepth = this.history.undoDepth;
8367
- doc.setHistory(this.getHistory());
8368
- }
8369
- return doc;
8370
- },
8371
-
8372
- linkedDoc: function(options) {
8373
- if (!options) options = {};
8374
- var from = this.first, to = this.first + this.size;
8375
- if (options.from != null && options.from > from) from = options.from;
8376
- if (options.to != null && options.to < to) to = options.to;
8377
- var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
8378
- if (options.sharedHist) copy.history = this.history;
8379
- (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
8380
- copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
8381
- return copy;
8382
- },
8383
- unlinkDoc: function(other) {
8384
- if (other instanceof CodeMirror) other = other.doc;
8385
- if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
8386
- var link = this.linked[i];
8387
- if (link.doc != other) continue;
8388
- this.linked.splice(i, 1);
8389
- other.unlinkDoc(this);
8390
- break;
8391
- }
8392
- // If the histories were shared, split them again
8393
- if (other.history == this.history) {
8394
- var splitIds = [other.id];
8395
- linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
8396
- other.history = makeHistory();
8397
- other.history.done = copyHistoryArray(this.history.done, splitIds);
8398
- other.history.undone = copyHistoryArray(this.history.undone, splitIds);
8399
- }
8400
- },
8401
- iterLinkedDocs: function(f) {linkedDocs(this, f);},
8402
-
8403
- getMode: function() {return this.mode;},
8404
- getEditor: function() {return this.cm;}
8405
- });
8406
-
8407
- Doc.prototype.eachLine = Doc.prototype.iter;
8408
-
8409
- // The Doc methods that should be available on CodeMirror instances
8410
- var dontDelegate = "iter insert remove copy getEditor".split(" ");
8411
- for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
8412
- CodeMirror.prototype[prop] = (function(method) {
8413
- return function() {return method.apply(this.doc, arguments);};
8414
- })(Doc.prototype[prop]);
8415
-
8416
- eventMixin(Doc);
8417
-
8418
- function linkedDocs(doc, f, sharedHistOnly) {
8419
- function propagate(doc, skip, sharedHist) {
8420
- if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
8421
- var rel = doc.linked[i];
8422
- if (rel.doc == skip) continue;
8423
- var shared = sharedHist && rel.sharedHist;
8424
- if (sharedHistOnly && !shared) continue;
8425
- f(rel.doc, shared);
8426
- propagate(rel.doc, doc, shared);
8427
- }
8428
- }
8429
- propagate(doc, null, true);
8430
- }
8431
-
8432
- function attachDoc(cm, doc) {
8433
- if (doc.cm) throw new Error("This document is already in use.");
8434
- cm.doc = doc;
8435
- doc.cm = cm;
8436
- estimateLineHeights(cm);
8437
- loadMode(cm);
8438
- if (!cm.options.lineWrapping) computeMaxLength(cm);
8439
- cm.options.mode = doc.modeOption;
8440
- regChange(cm);
8441
- }
8442
-
8443
- // LINE UTILITIES
8444
-
8445
- function getLine(chunk, n) {
8446
- n -= chunk.first;
8447
- while (!chunk.lines) {
8448
- for (var i = 0;; ++i) {
8449
- var child = chunk.children[i], sz = child.chunkSize();
8450
- if (n < sz) { chunk = child; break; }
8451
- n -= sz;
8452
- }
8453
- }
8454
- return chunk.lines[n];
8455
- }
8456
-
8457
- function getBetween(doc, start, end) {
8458
- var out = [], n = start.line;
8459
- doc.iter(start.line, end.line + 1, function(line) {
8460
- var text = line.text;
8461
- if (n == end.line) text = text.slice(0, end.ch);
8462
- if (n == start.line) text = text.slice(start.ch);
8463
- out.push(text);
8464
- ++n;
8465
- });
8466
- return out;
8467
- }
8468
- function getLines(doc, from, to) {
8469
- var out = [];
8470
- doc.iter(from, to, function(line) { out.push(line.text); });
8471
- return out;
8472
- }
8473
-
8474
- function updateLineHeight(line, height) {
8475
- var diff = height - line.height;
8476
- for (var n = line; n; n = n.parent) n.height += diff;
8477
- }
8478
-
8479
- function lineNo(line) {
8480
- if (line.parent == null) return null;
8481
- var cur = line.parent, no = indexOf(cur.lines, line);
8482
- for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
8483
- for (var i = 0;; ++i) {
8484
- if (chunk.children[i] == cur) break;
8485
- no += chunk.children[i].chunkSize();
8486
- }
8487
- }
8488
- return no + cur.first;
8489
- }
8490
-
8491
- function lineAtHeight(chunk, h) {
8492
- var n = chunk.first;
8493
- outer: do {
8494
- for (var i = 0, e = chunk.children.length; i < e; ++i) {
8495
- var child = chunk.children[i], ch = child.height;
8496
- if (h < ch) { chunk = child; continue outer; }
8497
- h -= ch;
8498
- n += child.chunkSize();
8499
- }
8500
- return n;
8501
- } while (!chunk.lines);
8502
- for (var i = 0, e = chunk.lines.length; i < e; ++i) {
8503
- var line = chunk.lines[i], lh = line.height;
8504
- if (h < lh) break;
8505
- h -= lh;
8506
- }
8507
- return n + i;
8508
- }
8509
-
8510
- function heightAtLine(cm, lineObj) {
8511
- lineObj = visualLine(cm.doc, lineObj);
8512
-
8513
- var h = 0, chunk = lineObj.parent;
8514
- for (var i = 0; i < chunk.lines.length; ++i) {
8515
- var line = chunk.lines[i];
8516
- if (line == lineObj) break;
8517
- else h += line.height;
8518
- }
8519
- for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
8520
- for (var i = 0; i < p.children.length; ++i) {
8521
- var cur = p.children[i];
8522
- if (cur == chunk) break;
8523
- else h += cur.height;
8524
- }
8525
- }
8526
- return h;
8527
- }
8528
-
8529
- function getOrder(line) {
8530
- var order = line.order;
8531
- if (order == null) order = line.order = bidiOrdering(line.text);
8532
- return order;
8533
- }
8534
-
8535
- // HISTORY
8536
-
8537
- function makeHistory(startGen) {
8538
- return {
8539
- // Arrays of history events. Doing something adds an event to
8540
- // done and clears undo. Undoing moves events from done to
8541
- // undone, redoing moves them in the other direction.
8542
- done: [], undone: [], undoDepth: Infinity,
8543
- // Used to track when changes can be merged into a single undo
8544
- // event
8545
- lastTime: 0, lastOp: null, lastOrigin: null,
8546
- // Used by the isClean() method
8547
- generation: startGen || 1, maxGeneration: startGen || 1
8548
- };
8549
- }
8550
-
8551
- function attachLocalSpans(doc, change, from, to) {
8552
- var existing = change["spans_" + doc.id], n = 0;
8553
- doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
8554
- if (line.markedSpans)
8555
- (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
8556
- ++n;
8557
- });
8558
- }
8559
-
8560
- function historyChangeFromChange(doc, change) {
8561
- var from = { line: change.from.line, ch: change.from.ch };
8562
- var histChange = {from: from, to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
8563
- attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
8564
- linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
8565
- return histChange;
8566
- }
8567
-
8568
- function addToHistory(doc, change, selAfter, opId) {
8569
- var hist = doc.history;
8570
- hist.undone.length = 0;
8571
- var time = +new Date, cur = lst(hist.done);
8572
-
8573
- if (cur &&
8574
- (hist.lastOp == opId ||
8575
- hist.lastOrigin == change.origin && change.origin &&
8576
- ((change.origin.charAt(0) == "+" && doc.cm && hist.lastTime > time - doc.cm.options.historyEventDelay) ||
8577
- change.origin.charAt(0) == "*"))) {
8578
- // Merge this change into the last event
8579
- var last = lst(cur.changes);
8580
- if (posEq(change.from, change.to) && posEq(change.from, last.to)) {
8581
- // Optimized case for simple insertion -- don't want to add
8582
- // new changesets for every character typed
8583
- last.to = changeEnd(change);
8584
- } else {
8585
- // Add new sub-event
8586
- cur.changes.push(historyChangeFromChange(doc, change));
8587
- }
8588
- cur.anchorAfter = selAfter.anchor; cur.headAfter = selAfter.head;
8589
- } else {
8590
- // Can not be merged, start a new event.
8591
- cur = {changes: [historyChangeFromChange(doc, change)],
8592
- generation: hist.generation,
8593
- anchorBefore: doc.sel.anchor, headBefore: doc.sel.head,
8594
- anchorAfter: selAfter.anchor, headAfter: selAfter.head};
8595
- hist.done.push(cur);
8596
- while (hist.done.length > hist.undoDepth)
8597
- hist.done.shift();
8598
- }
8599
- hist.generation = ++hist.maxGeneration;
8600
- hist.lastTime = time;
8601
- hist.lastOp = opId;
8602
- hist.lastOrigin = change.origin;
8603
-
8604
- if (!last) signal(doc, "historyAdded");
8605
- }
8606
-
8607
- function removeClearedSpans(spans) {
8608
- if (!spans) return null;
8609
- for (var i = 0, out; i < spans.length; ++i) {
8610
- if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
8611
- else if (out) out.push(spans[i]);
8612
- }
8613
- return !out ? spans : out.length ? out : null;
8614
- }
8615
-
8616
- function getOldSpans(doc, change) {
8617
- var found = change["spans_" + doc.id];
8618
- if (!found) return null;
8619
- for (var i = 0, nw = []; i < change.text.length; ++i)
8620
- nw.push(removeClearedSpans(found[i]));
8621
- return nw;
8622
- }
8623
-
8624
- // Used both to provide a JSON-safe object in .getHistory, and, when
8625
- // detaching a document, to split the history in two
8626
- function copyHistoryArray(events, newGroup) {
8627
- for (var i = 0, copy = []; i < events.length; ++i) {
8628
- var event = events[i], changes = event.changes, newChanges = [];
8629
- copy.push({changes: newChanges, anchorBefore: event.anchorBefore, headBefore: event.headBefore,
8630
- anchorAfter: event.anchorAfter, headAfter: event.headAfter});
8631
- for (var j = 0; j < changes.length; ++j) {
8632
- var change = changes[j], m;
8633
- newChanges.push({from: change.from, to: change.to, text: change.text});
8634
- if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
8635
- if (indexOf(newGroup, Number(m[1])) > -1) {
8636
- lst(newChanges)[prop] = change[prop];
8637
- delete change[prop];
8638
- }
8639
- }
8640
- }
8641
- }
8642
- return copy;
8643
- }
8644
-
8645
- // Rebasing/resetting history to deal with externally-sourced changes
8646
-
8647
- function rebaseHistSel(pos, from, to, diff) {
8648
- if (to < pos.line) {
8649
- pos.line += diff;
8650
- } else if (from < pos.line) {
8651
- pos.line = from;
8652
- pos.ch = 0;
8653
- }
8654
- }
8655
-
8656
- // Tries to rebase an array of history events given a change in the
8657
- // document. If the change touches the same lines as the event, the
8658
- // event, and everything 'behind' it, is discarded. If the change is
8659
- // before the event, the event's positions are updated. Uses a
8660
- // copy-on-write scheme for the positions, to avoid having to
8661
- // reallocate them all on every rebase, but also avoid problems with
8662
- // shared position objects being unsafely updated.
8663
- function rebaseHistArray(array, from, to, diff) {
8664
- for (var i = 0; i < array.length; ++i) {
8665
- var sub = array[i], ok = true;
8666
- for (var j = 0; j < sub.changes.length; ++j) {
8667
- var cur = sub.changes[j];
8668
- if (!sub.copied) { cur.from = copyPos(cur.from); cur.to = copyPos(cur.to); }
8669
- if (to < cur.from.line) {
8670
- cur.from.line += diff;
8671
- cur.to.line += diff;
8672
- } else if (from <= cur.to.line) {
8673
- ok = false;
8674
- break;
8675
- }
8676
- }
8677
- if (!sub.copied) {
8678
- sub.anchorBefore = copyPos(sub.anchorBefore); sub.headBefore = copyPos(sub.headBefore);
8679
- sub.anchorAfter = copyPos(sub.anchorAfter); sub.readAfter = copyPos(sub.headAfter);
8680
- sub.copied = true;
8681
- }
8682
- if (!ok) {
8683
- array.splice(0, i + 1);
8684
- i = 0;
8685
- } else {
8686
- rebaseHistSel(sub.anchorBefore); rebaseHistSel(sub.headBefore);
8687
- rebaseHistSel(sub.anchorAfter); rebaseHistSel(sub.headAfter);
8688
- }
8689
- }
8690
- }
8691
-
8692
- function rebaseHist(hist, change) {
8693
- var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
8694
- rebaseHistArray(hist.done, from, to, diff);
8695
- rebaseHistArray(hist.undone, from, to, diff);
8696
- }
8697
-
8698
- // EVENT OPERATORS
8699
-
8700
- function stopMethod() {e_stop(this);}
8701
- // Ensure an event has a stop method.
8702
- function addStop(event) {
8703
- if (!event.stop) event.stop = stopMethod;
8704
- return event;
8705
- }
8706
-
8707
- function e_preventDefault(e) {
8708
- if (e.preventDefault) e.preventDefault();
8709
- else e.returnValue = false;
8710
- }
8711
- function e_stopPropagation(e) {
8712
- if (e.stopPropagation) e.stopPropagation();
8713
- else e.cancelBubble = true;
8714
- }
8715
- function e_defaultPrevented(e) {
8716
- return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
8717
- }
8718
- function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
8719
- CodeMirror.e_stop = e_stop;
8720
- CodeMirror.e_preventDefault = e_preventDefault;
8721
- CodeMirror.e_stopPropagation = e_stopPropagation;
8722
-
8723
- function e_target(e) {return e.target || e.srcElement;}
8724
- function e_button(e) {
8725
- var b = e.which;
8726
- if (b == null) {
8727
- if (e.button & 1) b = 1;
8728
- else if (e.button & 2) b = 3;
8729
- else if (e.button & 4) b = 2;
8730
- }
8731
- if (mac && e.ctrlKey && b == 1) b = 3;
8732
- return b;
8733
- }
8734
-
8735
- // EVENT HANDLING
8736
-
8737
- function on(emitter, type, f) {
8738
- if (emitter.addEventListener)
8739
- emitter.addEventListener(type, f, false);
8740
- else if (emitter.attachEvent)
8741
- emitter.attachEvent("on" + type, f);
8742
- else {
8743
- var map = emitter._handlers || (emitter._handlers = {});
8744
- var arr = map[type] || (map[type] = []);
8745
- arr.push(f);
8746
- }
8747
- }
8748
-
8749
- function off(emitter, type, f) {
8750
- if (emitter.removeEventListener)
8751
- emitter.removeEventListener(type, f, false);
8752
- else if (emitter.detachEvent)
8753
- emitter.detachEvent("on" + type, f);
8754
- else {
8755
- var arr = emitter._handlers && emitter._handlers[type];
8756
- if (!arr) return;
8757
- for (var i = 0; i < arr.length; ++i)
8758
- if (arr[i] == f) { arr.splice(i, 1); break; }
8759
- }
8760
- }
8761
-
8762
- function signal(emitter, type /*, values...*/) {
8763
- var arr = emitter._handlers && emitter._handlers[type];
8764
- if (!arr) return;
8765
- var args = Array.prototype.slice.call(arguments, 2);
8766
- for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
8767
- }
8768
-
8769
- var delayedCallbacks, delayedCallbackDepth = 0;
8770
- function signalLater(emitter, type /*, values...*/) {
8771
- var arr = emitter._handlers && emitter._handlers[type];
8772
- if (!arr) return;
8773
- var args = Array.prototype.slice.call(arguments, 2);
8774
- if (!delayedCallbacks) {
8775
- ++delayedCallbackDepth;
8776
- delayedCallbacks = [];
8777
- setTimeout(fireDelayed, 0);
8778
- }
8779
- function bnd(f) {return function(){f.apply(null, args);};};
8780
- for (var i = 0; i < arr.length; ++i)
8781
- delayedCallbacks.push(bnd(arr[i]));
8782
- }
8783
-
8784
- function signalDOMEvent(cm, e, override) {
8785
- signal(cm, override || e.type, cm, e);
8786
- return e_defaultPrevented(e) || e.codemirrorIgnore;
8787
- }
8788
-
8789
- function fireDelayed() {
8790
- --delayedCallbackDepth;
8791
- var delayed = delayedCallbacks;
8792
- delayedCallbacks = null;
8793
- for (var i = 0; i < delayed.length; ++i) delayed[i]();
8794
- }
8795
-
8796
- function hasHandler(emitter, type) {
8797
- var arr = emitter._handlers && emitter._handlers[type];
8798
- return arr && arr.length > 0;
8799
- }
8800
-
8801
- CodeMirror.on = on; CodeMirror.off = off; CodeMirror.signal = signal;
8802
-
8803
- function eventMixin(ctor) {
8804
- ctor.prototype.on = function(type, f) {on(this, type, f);};
8805
- ctor.prototype.off = function(type, f) {off(this, type, f);};
8806
- }
8807
-
8808
- // MISC UTILITIES
8809
-
8810
- // Number of pixels added to scroller and sizer to hide scrollbar
8811
- var scrollerCutOff = 30;
8812
-
8813
- // Returned or thrown by various protocols to signal 'I'm not
8814
- // handling this'.
8815
- var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
8816
-
8817
- function Delayed() {this.id = null;}
8818
- Delayed.prototype = {set: function(ms, f) {clearTimeout(this.id); this.id = setTimeout(f, ms);}};
8819
-
8820
- // Counts the column offset in a string, taking tabs into account.
8821
- // Used mostly to find indentation.
8822
- function countColumn(string, end, tabSize, startIndex, startValue) {
8823
- if (end == null) {
8824
- end = string.search(/[^\s\u00a0]/);
8825
- if (end == -1) end = string.length;
8826
- }
8827
- for (var i = startIndex || 0, n = startValue || 0; i < end; ++i) {
8828
- if (string.charAt(i) == "\t") n += tabSize - (n % tabSize);
8829
- else ++n;
8830
- }
8831
- return n;
8832
- }
8833
- CodeMirror.countColumn = countColumn;
8834
-
8835
- var spaceStrs = [""];
8836
- function spaceStr(n) {
8837
- while (spaceStrs.length <= n)
8838
- spaceStrs.push(lst(spaceStrs) + " ");
8839
- return spaceStrs[n];
8840
- }
8841
-
8842
- function lst(arr) { return arr[arr.length-1]; }
8843
-
8844
- function selectInput(node) {
8845
- if (ios) { // Mobile Safari apparently has a bug where select() is broken.
8846
- node.selectionStart = 0;
8847
- node.selectionEnd = node.value.length;
8848
- } else {
8849
- // Suppress mysterious IE10 errors
8850
- try { node.select(); }
8851
- catch(_e) {}
8852
- }
8853
- }
8854
-
8855
- function indexOf(collection, elt) {
8856
- if (collection.indexOf) return collection.indexOf(elt);
8857
- for (var i = 0, e = collection.length; i < e; ++i)
8858
- if (collection[i] == elt) return i;
8859
- return -1;
8860
- }
8861
-
8862
- function createObj(base, props) {
8863
- function Obj() {}
8864
- Obj.prototype = base;
8865
- var inst = new Obj();
8866
- if (props) copyObj(props, inst);
8867
- return inst;
8868
- }
8869
-
8870
- function copyObj(obj, target) {
8871
- if (!target) target = {};
8872
- for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop];
8873
- return target;
8874
- }
8875
-
8876
- function emptyArray(size) {
8877
- for (var a = [], i = 0; i < size; ++i) a.push(undefined);
8878
- return a;
8879
- }
8880
-
8881
- function bind(f) {
8882
- var args = Array.prototype.slice.call(arguments, 1);
8883
- return function(){return f.apply(null, args);};
8884
- }
8885
-
8886
- var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
8887
- function isWordChar(ch) {
8888
- return /\w/.test(ch) || ch > "\x80" &&
8889
- (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
8890
- }
8891
-
8892
- function isEmpty(obj) {
8893
- for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
8894
- return true;
8895
- }
8896
-
8897
- 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]/;
8898
- function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
8899
-
8900
- // DOM UTILITIES
8901
-
8902
- function elt(tag, content, className, style) {
8903
- var e = document.createElement(tag);
8904
- if (className) e.className = className;
8905
- if (style) e.style.cssText = style;
8906
- if (typeof content == "string") setTextContent(e, content);
8907
- else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
8908
- return e;
8909
- }
8910
-
8911
- function removeChildren(e) {
8912
- for (var count = e.childNodes.length; count > 0; --count)
8913
- e.removeChild(e.firstChild);
8914
- return e;
8915
- }
8916
-
8917
- function removeChildrenAndAdd(parent, e) {
8918
- return removeChildren(parent).appendChild(e);
8919
- }
8920
-
8921
- function setTextContent(e, str) {
8922
- if (ie_lt9) {
8923
- e.innerHTML = "";
8924
- e.appendChild(document.createTextNode(str));
8925
- } else e.textContent = str;
8926
- }
8927
-
8928
- function getRect(node) {
8929
- return node.getBoundingClientRect();
8930
- }
8931
- CodeMirror.replaceGetRect = function(f) { getRect = f; };
8932
-
8933
- // FEATURE DETECTION
8934
-
8935
- // Detect drag-and-drop
8936
- var dragAndDrop = function() {
8937
- // There is *some* kind of drag-and-drop support in IE6-8, but I
8938
- // couldn't get it to work yet.
8939
- if (ie_lt9) return false;
8940
- var div = elt('div');
8941
- return "draggable" in div || "dragDrop" in div;
8942
- }();
8943
-
8944
- // For a reason I have yet to figure out, some browsers disallow
8945
- // word wrapping between certain characters *only* if a new inline
8946
- // element is started between them. This makes it hard to reliably
8947
- // measure the position of things, since that requires inserting an
8948
- // extra span. This terribly fragile set of tests matches the
8949
- // character combinations that suffer from this phenomenon on the
8950
- // various browsers.
8951
- function spanAffectsWrapping() { return false; }
8952
- if (gecko) // Only for "$'"
8953
- spanAffectsWrapping = function(str, i) {
8954
- return str.charCodeAt(i - 1) == 36 && str.charCodeAt(i) == 39;
8955
- };
8956
- else if (safari && !/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent))
8957
- spanAffectsWrapping = function(str, i) {
8958
- return /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));
8959
- };
8960
- else if (webkit && /Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent))
8961
- spanAffectsWrapping = function(str, i) {
8962
- var code = str.charCodeAt(i - 1);
8963
- return code >= 8208 && code <= 8212;
8964
- };
8965
- else if (webkit)
8966
- spanAffectsWrapping = function(str, i) {
8967
- if (i > 1 && str.charCodeAt(i - 1) == 45) {
8968
- if (/\w/.test(str.charAt(i - 2)) && /[^\-?\.]/.test(str.charAt(i))) return true;
8969
- if (i > 2 && /[\d\.,]/.test(str.charAt(i - 2)) && /[\d\.,]/.test(str.charAt(i))) return false;
8970
- }
8971
- return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|\u2026[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
8972
- };
8973
-
8974
- var knownScrollbarWidth;
8975
- function scrollbarWidth(measure) {
8976
- if (knownScrollbarWidth != null) return knownScrollbarWidth;
8977
- var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll");
8978
- removeChildrenAndAdd(measure, test);
8979
- if (test.offsetWidth)
8980
- knownScrollbarWidth = test.offsetHeight - test.clientHeight;
8981
- return knownScrollbarWidth || 0;
8982
- }
8983
-
8984
- var zwspSupported;
8985
- function zeroWidthElement(measure) {
8986
- if (zwspSupported == null) {
8987
- var test = elt("span", "\u200b");
8988
- removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
8989
- if (measure.firstChild.offsetHeight != 0)
8990
- zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_lt8;
8991
- }
8992
- if (zwspSupported) return elt("span", "\u200b");
8993
- else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
8994
- }
8995
-
8996
- // See if "".split is the broken IE version, if so, provide an
8997
- // alternative way to split lines.
8998
- var splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
8999
- var pos = 0, result = [], l = string.length;
9000
- while (pos <= l) {
9001
- var nl = string.indexOf("\n", pos);
9002
- if (nl == -1) nl = string.length;
9003
- var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
9004
- var rt = line.indexOf("\r");
9005
- if (rt != -1) {
9006
- result.push(line.slice(0, rt));
9007
- pos += rt + 1;
9008
- } else {
9009
- result.push(line);
9010
- pos = nl + 1;
9011
- }
9012
- }
9013
- return result;
9014
- } : function(string){return string.split(/\r\n?|\n/);};
9015
- CodeMirror.splitLines = splitLines;
9016
-
9017
- var hasSelection = window.getSelection ? function(te) {
9018
- try { return te.selectionStart != te.selectionEnd; }
9019
- catch(e) { return false; }
9020
- } : function(te) {
9021
- try {var range = te.ownerDocument.selection.createRange();}
9022
- catch(e) {}
9023
- if (!range || range.parentElement() != te) return false;
9024
- return range.compareEndPoints("StartToEnd", range) != 0;
9025
- };
9026
-
9027
- var hasCopyEvent = (function() {
9028
- var e = elt("div");
9029
- if ("oncopy" in e) return true;
9030
- e.setAttribute("oncopy", "return;");
9031
- return typeof e.oncopy == 'function';
9032
- })();
9033
-
9034
- // KEY NAMING
9035
-
9036
- var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
9037
- 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
9038
- 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
9039
- 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
9040
- 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
9041
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
9042
- 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
9043
- CodeMirror.keyNames = keyNames;
9044
- (function() {
9045
- // Number keys
9046
- for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
9047
- // Alphabetic keys
9048
- for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
9049
- // Function keys
9050
- for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
9051
- })();
9052
-
9053
- // BIDI HELPERS
9054
-
9055
- function iterateBidiSections(order, from, to, f) {
9056
- if (!order) return f(from, to, "ltr");
9057
- var found = false;
9058
- for (var i = 0; i < order.length; ++i) {
9059
- var part = order[i];
9060
- if (part.from < to && part.to > from || from == to && part.to == from) {
9061
- f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
9062
- found = true;
9063
- }
9064
- }
9065
- if (!found) f(from, to, "ltr");
9066
- }
9067
-
9068
- function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
9069
- function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
9070
-
9071
- function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
9072
- function lineRight(line) {
9073
- var order = getOrder(line);
9074
- if (!order) return line.text.length;
9075
- return bidiRight(lst(order));
9076
- }
9077
-
9078
- function lineStart(cm, lineN) {
9079
- var line = getLine(cm.doc, lineN);
9080
- var visual = visualLine(cm.doc, line);
9081
- if (visual != line) lineN = lineNo(visual);
9082
- var order = getOrder(visual);
9083
- var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
9084
- return Pos(lineN, ch);
9085
- }
9086
- function lineEnd(cm, lineN) {
9087
- var merged, line;
9088
- while (merged = collapsedSpanAtEnd(line = getLine(cm.doc, lineN)))
9089
- lineN = merged.find().to.line;
9090
- var order = getOrder(line);
9091
- var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
9092
- return Pos(lineN, ch);
9093
- }
9094
-
9095
- function compareBidiLevel(order, a, b) {
9096
- var linedir = order[0].level;
9097
- if (a == linedir) return true;
9098
- if (b == linedir) return false;
9099
- return a < b;
9100
- }
9101
- var bidiOther;
9102
- function getBidiPartAt(order, pos) {
9103
- bidiOther = null;
9104
- for (var i = 0, found; i < order.length; ++i) {
9105
- var cur = order[i];
9106
- if (cur.from < pos && cur.to > pos) return i;
9107
- if ((cur.from == pos || cur.to == pos)) {
9108
- if (found == null) {
9109
- found = i;
9110
- } else if (compareBidiLevel(order, cur.level, order[found].level)) {
9111
- if (cur.from != cur.to) bidiOther = found;
9112
- return i;
9113
- } else {
9114
- if (cur.from != cur.to) bidiOther = i;
9115
- return found;
9116
- }
9117
- }
9118
- }
9119
- return found;
9120
- }
9121
-
9122
- function moveInLine(line, pos, dir, byUnit) {
9123
- if (!byUnit) return pos + dir;
9124
- do pos += dir;
9125
- while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
9126
- return pos;
9127
- }
9128
-
9129
- // This is somewhat involved. It is needed in order to move
9130
- // 'visually' through bi-directional text -- i.e., pressing left
9131
- // should make the cursor go left, even when in RTL text. The
9132
- // tricky part is the 'jumps', where RTL and LTR text touch each
9133
- // other. This often requires the cursor offset to move more than
9134
- // one unit, in order to visually move one unit.
9135
- function moveVisually(line, start, dir, byUnit) {
9136
- var bidi = getOrder(line);
9137
- if (!bidi) return moveLogically(line, start, dir, byUnit);
9138
- var pos = getBidiPartAt(bidi, start), part = bidi[pos];
9139
- var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
9140
-
9141
- for (;;) {
9142
- if (target > part.from && target < part.to) return target;
9143
- if (target == part.from || target == part.to) {
9144
- if (getBidiPartAt(bidi, target) == pos) return target;
9145
- part = bidi[pos += dir];
9146
- return (dir > 0) == part.level % 2 ? part.to : part.from;
9147
- } else {
9148
- part = bidi[pos += dir];
9149
- if (!part) return null;
9150
- if ((dir > 0) == part.level % 2)
9151
- target = moveInLine(line, part.to, -1, byUnit);
9152
- else
9153
- target = moveInLine(line, part.from, 1, byUnit);
9154
- }
9155
- }
9156
- }
9157
-
9158
- function moveLogically(line, start, dir, byUnit) {
9159
- var target = start + dir;
9160
- if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
9161
- return target < 0 || target > line.text.length ? null : target;
9162
- }
9163
-
9164
- // Bidirectional ordering algorithm
9165
- // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
9166
- // that this (partially) implements.
9167
-
9168
- // One-char codes used for character types:
9169
- // L (L): Left-to-Right
9170
- // R (R): Right-to-Left
9171
- // r (AL): Right-to-Left Arabic
9172
- // 1 (EN): European Number
9173
- // + (ES): European Number Separator
9174
- // % (ET): European Number Terminator
9175
- // n (AN): Arabic Number
9176
- // , (CS): Common Number Separator
9177
- // m (NSM): Non-Spacing Mark
9178
- // b (BN): Boundary Neutral
9179
- // s (B): Paragraph Separator
9180
- // t (S): Segment Separator
9181
- // w (WS): Whitespace
9182
- // N (ON): Other Neutrals
9183
-
9184
- // Returns null if characters are ordered as they appear
9185
- // (left-to-right), or an array of sections ({from, to, level}
9186
- // objects) in the order in which they occur visually.
9187
- var bidiOrdering = (function() {
9188
- // Character types for codepoints 0 to 0xff
9189
- var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL";
9190
- // Character types for codepoints 0x600 to 0x6ff
9191
- var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr";
9192
- function charType(code) {
9193
- if (code <= 0xff) return lowTypes.charAt(code);
9194
- else if (0x590 <= code && code <= 0x5f4) return "R";
9195
- else if (0x600 <= code && code <= 0x6ff) return arabicTypes.charAt(code - 0x600);
9196
- else if (0x700 <= code && code <= 0x8ac) return "r";
9197
- else return "L";
9198
- }
9199
-
9200
- var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
9201
- var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
9202
- // Browsers seem to always treat the boundaries of block elements as being L.
9203
- var outerType = "L";
9204
-
9205
- return function(str) {
9206
- if (!bidiRE.test(str)) return false;
9207
- var len = str.length, types = [];
9208
- for (var i = 0, type; i < len; ++i)
9209
- types.push(type = charType(str.charCodeAt(i)));
9210
-
9211
- // W1. Examine each non-spacing mark (NSM) in the level run, and
9212
- // change the type of the NSM to the type of the previous
9213
- // character. If the NSM is at the start of the level run, it will
9214
- // get the type of sor.
9215
- for (var i = 0, prev = outerType; i < len; ++i) {
9216
- var type = types[i];
9217
- if (type == "m") types[i] = prev;
9218
- else prev = type;
9219
- }
9220
-
9221
- // W2. Search backwards from each instance of a European number
9222
- // until the first strong type (R, L, AL, or sor) is found. If an
9223
- // AL is found, change the type of the European number to Arabic
9224
- // number.
9225
- // W3. Change all ALs to R.
9226
- for (var i = 0, cur = outerType; i < len; ++i) {
9227
- var type = types[i];
9228
- if (type == "1" && cur == "r") types[i] = "n";
9229
- else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
9230
- }
9231
-
9232
- // W4. A single European separator between two European numbers
9233
- // changes to a European number. A single common separator between
9234
- // two numbers of the same type changes to that type.
9235
- for (var i = 1, prev = types[0]; i < len - 1; ++i) {
9236
- var type = types[i];
9237
- if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
9238
- else if (type == "," && prev == types[i+1] &&
9239
- (prev == "1" || prev == "n")) types[i] = prev;
9240
- prev = type;
9241
- }
9242
-
9243
- // W5. A sequence of European terminators adjacent to European
9244
- // numbers changes to all European numbers.
9245
- // W6. Otherwise, separators and terminators change to Other
9246
- // Neutral.
9247
- for (var i = 0; i < len; ++i) {
9248
- var type = types[i];
9249
- if (type == ",") types[i] = "N";
9250
- else if (type == "%") {
9251
- for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
9252
- var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
9253
- for (var j = i; j < end; ++j) types[j] = replace;
9254
- i = end - 1;
9255
- }
9256
- }
9257
-
9258
- // W7. Search backwards from each instance of a European number
9259
- // until the first strong type (R, L, or sor) is found. If an L is
9260
- // found, then change the type of the European number to L.
9261
- for (var i = 0, cur = outerType; i < len; ++i) {
9262
- var type = types[i];
9263
- if (cur == "L" && type == "1") types[i] = "L";
9264
- else if (isStrong.test(type)) cur = type;
9265
- }
9266
-
9267
- // N1. A sequence of neutrals takes the direction of the
9268
- // surrounding strong text if the text on both sides has the same
9269
- // direction. European and Arabic numbers act as if they were R in
9270
- // terms of their influence on neutrals. Start-of-level-run (sor)
9271
- // and end-of-level-run (eor) are used at level run boundaries.
9272
- // N2. Any remaining neutrals take the embedding direction.
9273
- for (var i = 0; i < len; ++i) {
9274
- if (isNeutral.test(types[i])) {
9275
- for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
9276
- var before = (i ? types[i-1] : outerType) == "L";
9277
- var after = (end < len ? types[end] : outerType) == "L";
9278
- var replace = before || after ? "L" : "R";
9279
- for (var j = i; j < end; ++j) types[j] = replace;
9280
- i = end - 1;
9281
- }
9282
- }
9283
-
9284
- // Here we depart from the documented algorithm, in order to avoid
9285
- // building up an actual levels array. Since there are only three
9286
- // levels (0, 1, 2) in an implementation that doesn't take
9287
- // explicit embedding into account, we can build up the order on
9288
- // the fly, without following the level-based algorithm.
9289
- var order = [], m;
9290
- for (var i = 0; i < len;) {
9291
- if (countsAsLeft.test(types[i])) {
9292
- var start = i;
9293
- for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
9294
- order.push({from: start, to: i, level: 0});
9295
- } else {
9296
- var pos = i, at = order.length;
9297
- for (++i; i < len && types[i] != "L"; ++i) {}
9298
- for (var j = pos; j < i;) {
9299
- if (countsAsNum.test(types[j])) {
9300
- if (pos < j) order.splice(at, 0, {from: pos, to: j, level: 1});
9301
- var nstart = j;
9302
- for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
9303
- order.splice(at, 0, {from: nstart, to: j, level: 2});
9304
- pos = j;
9305
- } else ++j;
9306
- }
9307
- if (pos < i) order.splice(at, 0, {from: pos, to: i, level: 1});
9308
- }
9309
- }
9310
- if (order[0].level == 1 && (m = str.match(/^\s+/))) {
9311
- order[0].from = m[0].length;
9312
- order.unshift({from: 0, to: m[0].length, level: 0});
9313
- }
9314
- if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
9315
- lst(order).to -= m[0].length;
9316
- order.push({from: len - m[0].length, to: len, level: 0});
9317
- }
9318
- if (order[0].level != lst(order).level)
9319
- order.push({from: len, to: len, level: order[0].level});
9320
-
9321
- return order;
9322
- };
9323
- })();
9324
-
9325
- // THE END
9326
-
9327
- CodeMirror.version = "3.22.0";
9328
-
9329
- return CodeMirror;
9330
- })();
9331
- //js\libs\codemirror\modes\css.js
9332
-
9333
- CodeMirror.defineMode("css", function(config, parserConfig) {
9334
- "use strict";
9335
-
9336
- if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
9337
-
9338
- var indentUnit = config.indentUnit,
9339
- tokenHooks = parserConfig.tokenHooks,
9340
- mediaTypes = parserConfig.mediaTypes || {},
9341
- mediaFeatures = parserConfig.mediaFeatures || {},
9342
- propertyKeywords = parserConfig.propertyKeywords || {},
9343
- colorKeywords = parserConfig.colorKeywords || {},
9344
- valueKeywords = parserConfig.valueKeywords || {},
9345
- fontProperties = parserConfig.fontProperties || {},
9346
- allowNested = parserConfig.allowNested;
9347
-
9348
- var type, override;
9349
- function ret(style, tp) { type = tp; return style; }
9350
-
9351
- // Tokenizers
9352
-
9353
- function tokenBase(stream, state) {
9354
- var ch = stream.next();
9355
- if (tokenHooks[ch]) {
9356
- var result = tokenHooks[ch](stream, state);
9357
- if (result !== false) return result;
9358
- }
9359
- if (ch == "@") {
9360
- stream.eatWhile(/[\w\\\-]/);
9361
- return ret("def", stream.current());
9362
- } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
9363
- return ret(null, "compare");
9364
- } else if (ch == "\"" || ch == "'") {
9365
- state.tokenize = tokenString(ch);
9366
- return state.tokenize(stream, state);
9367
- } else if (ch == "#") {
9368
- stream.eatWhile(/[\w\\\-]/);
9369
- return ret("atom", "hash");
9370
- } else if (ch == "!") {
9371
- stream.match(/^\s*\w*/);
9372
- return ret("keyword", "important");
9373
- } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
9374
- stream.eatWhile(/[\w.%]/);
9375
- return ret("number", "unit");
9376
- } else if (ch === "-") {
9377
- if (/[\d.]/.test(stream.peek())) {
9378
- stream.eatWhile(/[\w.%]/);
9379
- return ret("number", "unit");
9380
- } else if (stream.match(/^[^-]+-/)) {
9381
- return ret("meta", "meta");
9382
- }
9383
- } else if (/[,+>*\/]/.test(ch)) {
9384
- return ret(null, "select-op");
9385
- } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
9386
- return ret("qualifier", "qualifier");
9387
- } else if (/[:;{}\[\]\(\)]/.test(ch)) {
9388
- return ret(null, ch);
9389
- } else if (ch == "u" && stream.match("rl(")) {
9390
- stream.backUp(1);
9391
- state.tokenize = tokenParenthesized;
9392
- return ret("property", "word");
9393
- } else if (/[\w\\\-]/.test(ch)) {
9394
- stream.eatWhile(/[\w\\\-]/);
9395
- return ret("property", "word");
9396
- } else {
9397
- return ret(null, null);
9398
- }
9399
- }
9400
-
9401
- function tokenString(quote) {
9402
- return function(stream, state) {
9403
- var escaped = false, ch;
9404
- while ((ch = stream.next()) != null) {
9405
- if (ch == quote && !escaped) {
9406
- if (quote == ")") stream.backUp(1);
9407
- break;
9408
- }
9409
- escaped = !escaped && ch == "\\";
9410
- }
9411
- if (ch == quote || !escaped && quote != ")") state.tokenize = null;
9412
- return ret("string", "string");
9413
- };
9414
- }
9415
-
9416
- function tokenParenthesized(stream, state) {
9417
- stream.next(); // Must be '('
9418
- if (!stream.match(/\s*[\"\']/, false))
9419
- state.tokenize = tokenString(")");
9420
- else
9421
- state.tokenize = null;
9422
- return ret(null, "(");
9423
- }
9424
-
9425
- // Context management
9426
-
9427
- function Context(type, indent, prev) {
9428
- this.type = type;
9429
- this.indent = indent;
9430
- this.prev = prev;
9431
- }
9432
-
9433
- function pushContext(state, stream, type) {
9434
- state.context = new Context(type, stream.indentation() + indentUnit, state.context);
9435
- return type;
9436
- }
9437
-
9438
- function popContext(state) {
9439
- state.context = state.context.prev;
9440
- return state.context.type;
9441
- }
9442
-
9443
- function pass(type, stream, state) {
9444
- return states[state.context.type](type, stream, state);
9445
- }
9446
- function popAndPass(type, stream, state, n) {
9447
- for (var i = n || 1; i > 0; i--)
9448
- state.context = state.context.prev;
9449
- return pass(type, stream, state);
9450
- }
9451
-
9452
- // Parser
9453
-
9454
- function wordAsValue(stream) {
9455
- var word = stream.current().toLowerCase();
9456
- if (valueKeywords.hasOwnProperty(word))
9457
- override = "atom";
9458
- else if (colorKeywords.hasOwnProperty(word))
9459
- override = "keyword";
9460
- else
9461
- override = "variable";
9462
- }
9463
-
9464
- var states = {};
9465
-
9466
- states.top = function(type, stream, state) {
9467
- if (type == "{") {
9468
- return pushContext(state, stream, "block");
9469
- } else if (type == "}" && state.context.prev) {
9470
- return popContext(state);
9471
- } else if (type == "@media") {
9472
- return pushContext(state, stream, "media");
9473
- } else if (type == "@font-face") {
9474
- return "font_face_before";
9475
- } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
9476
- return "keyframes";
9477
- } else if (type && type.charAt(0) == "@") {
9478
- return pushContext(state, stream, "at");
9479
- } else if (type == "hash") {
9480
- override = "builtin";
9481
- } else if (type == "word") {
9482
- override = "tag";
9483
- } else if (type == "variable-definition") {
9484
- return "maybeprop";
9485
- } else if (type == "interpolation") {
9486
- return pushContext(state, stream, "interpolation");
9487
- } else if (type == ":") {
9488
- return "pseudo";
9489
- } else if (allowNested && type == "(") {
9490
- return pushContext(state, stream, "params");
9491
- }
9492
- return state.context.type;
9493
- };
9494
-
9495
- states.block = function(type, stream, state) {
9496
- if (type == "word") {
9497
- if (propertyKeywords.hasOwnProperty(stream.current().toLowerCase())) {
9498
- override = "property";
9499
- return "maybeprop";
9500
- } else if (allowNested) {
9501
- override = stream.match(/^\s*:/, false) ? "property" : "tag";
9502
- return "block";
9503
- } else {
9504
- override += " error";
9505
- return "maybeprop";
9506
- }
9507
- } else if (type == "meta") {
9508
- return "block";
9509
- } else if (!allowNested && (type == "hash" || type == "qualifier")) {
9510
- override = "error";
9511
- return "block";
9512
- } else {
9513
- return states.top(type, stream, state);
9514
- }
9515
- };
9516
-
9517
- states.maybeprop = function(type, stream, state) {
9518
- if (type == ":") return pushContext(state, stream, "prop");
9519
- return pass(type, stream, state);
9520
- };
9521
-
9522
- states.prop = function(type, stream, state) {
9523
- if (type == ";") return popContext(state);
9524
- if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
9525
- if (type == "}" || type == "{") return popAndPass(type, stream, state);
9526
- if (type == "(") return pushContext(state, stream, "parens");
9527
-
9528
- if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
9529
- override += " error";
9530
- } else if (type == "word") {
9531
- wordAsValue(stream);
9532
- } else if (type == "interpolation") {
9533
- return pushContext(state, stream, "interpolation");
9534
- }
9535
- return "prop";
9536
- };
9537
-
9538
- states.propBlock = function(type, _stream, state) {
9539
- if (type == "}") return popContext(state);
9540
- if (type == "word") { override = "property"; return "maybeprop"; }
9541
- return state.context.type;
9542
- };
9543
-
9544
- states.parens = function(type, stream, state) {
9545
- if (type == "{" || type == "}") return popAndPass(type, stream, state);
9546
- if (type == ")") return popContext(state);
9547
- return "parens";
9548
- };
9549
-
9550
- states.pseudo = function(type, stream, state) {
9551
- if (type == "word") {
9552
- override = "variable-3";
9553
- return state.context.type;
9554
- }
9555
- return pass(type, stream, state);
9556
- };
9557
-
9558
- states.media = function(type, stream, state) {
9559
- if (type == "(") return pushContext(state, stream, "media_parens");
9560
- if (type == "}") return popAndPass(type, stream, state);
9561
- if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
9562
-
9563
- if (type == "word") {
9564
- var word = stream.current().toLowerCase();
9565
- if (word == "only" || word == "not" || word == "and")
9566
- override = "keyword";
9567
- else if (mediaTypes.hasOwnProperty(word))
9568
- override = "attribute";
9569
- else if (mediaFeatures.hasOwnProperty(word))
9570
- override = "property";
9571
- else
9572
- override = "error";
9573
- }
9574
- return state.context.type;
9575
- };
9576
-
9577
- states.media_parens = function(type, stream, state) {
9578
- if (type == ")") return popContext(state);
9579
- if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
9580
- return states.media(type, stream, state);
9581
- };
9582
-
9583
- states.font_face_before = function(type, stream, state) {
9584
- if (type == "{")
9585
- return pushContext(state, stream, "font_face");
9586
- return pass(type, stream, state);
9587
- };
9588
-
9589
- states.font_face = function(type, stream, state) {
9590
- if (type == "}") return popContext(state);
9591
- if (type == "word") {
9592
- if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
9593
- override = "error";
9594
- else
9595
- override = "property";
9596
- return "maybeprop";
9597
- }
9598
- return "font_face";
9599
- };
9600
-
9601
- states.keyframes = function(type, stream, state) {
9602
- if (type == "word") { override = "variable"; return "keyframes"; }
9603
- if (type == "{") return pushContext(state, stream, "top");
9604
- return pass(type, stream, state);
9605
- };
9606
-
9607
- states.at = function(type, stream, state) {
9608
- if (type == ";") return popContext(state);
9609
- if (type == "{" || type == "}") return popAndPass(type, stream, state);
9610
- if (type == "word") override = "tag";
9611
- else if (type == "hash") override = "builtin";
9612
- return "at";
9613
- };
9614
-
9615
- states.interpolation = function(type, stream, state) {
9616
- if (type == "}") return popContext(state);
9617
- if (type == "{" || type == ";") return popAndPass(type, stream, state);
9618
- if (type != "variable") override = "error";
9619
- return "interpolation";
9620
- };
9621
-
9622
- states.params = function(type, stream, state) {
9623
- if (type == ")") return popContext(state);
9624
- if (type == "{" || type == "}") return popAndPass(type, stream, state);
9625
- if (type == "word") wordAsValue(stream);
9626
- return "params";
9627
- };
9628
-
9629
- return {
9630
- startState: function(base) {
9631
- return {tokenize: null,
9632
- state: "top",
9633
- context: new Context("top", base || 0, null)};
9634
- },
9635
-
9636
- token: function(stream, state) {
9637
- if (!state.tokenize && stream.eatSpace()) return null;
9638
- var style = (state.tokenize || tokenBase)(stream, state);
9639
- if (style && typeof style == "object") {
9640
- type = style[1];
9641
- style = style[0];
9642
- }
9643
- override = style;
9644
- state.state = states[state.state](type, stream, state);
9645
- return override;
9646
- },
9647
-
9648
- indent: function(state, textAfter) {
9649
- var cx = state.context, ch = textAfter && textAfter.charAt(0);
9650
- var indent = cx.indent;
9651
- if (cx.type == "prop" && ch == "}") cx = cx.prev;
9652
- if (cx.prev &&
9653
- (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
9654
- ch == ")" && (cx.type == "parens" || cx.type == "params" || cx.type == "media_parens") ||
9655
- ch == "{" && (cx.type == "at" || cx.type == "media"))) {
9656
- indent = cx.indent - indentUnit;
9657
- cx = cx.prev;
9658
- }
9659
- return indent;
9660
- },
9661
-
9662
- electricChars: "}",
9663
- blockCommentStart: "/*",
9664
- blockCommentEnd: "*/",
9665
- fold: "brace"
9666
- };
9667
- });
9668
-
9669
- (function() {
9670
- function keySet(array) {
9671
- var keys = {};
9672
- for (var i = 0; i < array.length; ++i) {
9673
- keys[array[i]] = true;
9674
- }
9675
- return keys;
9676
- }
9677
-
9678
- var mediaTypes_ = [
9679
- "all", "aural", "braille", "handheld", "print", "projection", "screen",
9680
- "tty", "tv", "embossed"
9681
- ], mediaTypes = keySet(mediaTypes_);
9682
-
9683
- var mediaFeatures_ = [
9684
- "width", "min-width", "max-width", "height", "min-height", "max-height",
9685
- "device-width", "min-device-width", "max-device-width", "device-height",
9686
- "min-device-height", "max-device-height", "aspect-ratio",
9687
- "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
9688
- "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
9689
- "max-color", "color-index", "min-color-index", "max-color-index",
9690
- "monochrome", "min-monochrome", "max-monochrome", "resolution",
9691
- "min-resolution", "max-resolution", "scan", "grid"
9692
- ], mediaFeatures = keySet(mediaFeatures_);
9693
-
9694
- var propertyKeywords_ = [
9695
- "align-content", "align-items", "align-self", "alignment-adjust",
9696
- "alignment-baseline", "anchor-point", "animation", "animation-delay",
9697
- "animation-direction", "animation-duration", "animation-fill-mode",
9698
- "animation-iteration-count", "animation-name", "animation-play-state",
9699
- "animation-timing-function", "appearance", "azimuth", "backface-visibility",
9700
- "background", "background-attachment", "background-clip", "background-color",
9701
- "background-image", "background-origin", "background-position",
9702
- "background-repeat", "background-size", "baseline-shift", "binding",
9703
- "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
9704
- "bookmark-target", "border", "border-bottom", "border-bottom-color",
9705
- "border-bottom-left-radius", "border-bottom-right-radius",
9706
- "border-bottom-style", "border-bottom-width", "border-collapse",
9707
- "border-color", "border-image", "border-image-outset",
9708
- "border-image-repeat", "border-image-slice", "border-image-source",
9709
- "border-image-width", "border-left", "border-left-color",
9710
- "border-left-style", "border-left-width", "border-radius", "border-right",
9711
- "border-right-color", "border-right-style", "border-right-width",
9712
- "border-spacing", "border-style", "border-top", "border-top-color",
9713
- "border-top-left-radius", "border-top-right-radius", "border-top-style",
9714
- "border-top-width", "border-width", "bottom", "box-decoration-break",
9715
- "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
9716
- "caption-side", "clear", "clip", "color", "color-profile", "column-count",
9717
- "column-fill", "column-gap", "column-rule", "column-rule-color",
9718
- "column-rule-style", "column-rule-width", "column-span", "column-width",
9719
- "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
9720
- "cue-after", "cue-before", "cursor", "direction", "display",
9721
- "dominant-baseline", "drop-initial-after-adjust",
9722
- "drop-initial-after-align", "drop-initial-before-adjust",
9723
- "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
9724
- "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
9725
- "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
9726
- "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
9727
- "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
9728
- "font-stretch", "font-style", "font-synthesis", "font-variant",
9729
- "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
9730
- "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
9731
- "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
9732
- "grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
9733
- "grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
9734
- "grid-template", "grid-template-areas", "grid-template-columns",
9735
- "grid-template-rows", "hanging-punctuation", "height", "hyphens",
9736
- "icon", "image-orientation", "image-rendering", "image-resolution",
9737
- "inline-box-align", "justify-content", "left", "letter-spacing",
9738
- "line-break", "line-height", "line-stacking", "line-stacking-ruby",
9739
- "line-stacking-shift", "line-stacking-strategy", "list-style",
9740
- "list-style-image", "list-style-position", "list-style-type", "margin",
9741
- "margin-bottom", "margin-left", "margin-right", "margin-top",
9742
- "marker-offset", "marks", "marquee-direction", "marquee-loop",
9743
- "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
9744
- "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
9745
- "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
9746
- "outline-color", "outline-offset", "outline-style", "outline-width",
9747
- "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
9748
- "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
9749
- "page", "page-break-after", "page-break-before", "page-break-inside",
9750
- "page-policy", "pause", "pause-after", "pause-before", "perspective",
9751
- "perspective-origin", "pitch", "pitch-range", "play-during", "position",
9752
- "presentation-level", "punctuation-trim", "quotes", "region-break-after",
9753
- "region-break-before", "region-break-inside", "region-fragment",
9754
- "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
9755
- "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
9756
- "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
9757
- "speak", "speak-as", "speak-header",
9758
- "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
9759
- "tab-size", "table-layout", "target", "target-name", "target-new",
9760
- "target-position", "text-align", "text-align-last", "text-decoration",
9761
- "text-decoration-color", "text-decoration-line", "text-decoration-skip",
9762
- "text-decoration-style", "text-emphasis", "text-emphasis-color",
9763
- "text-emphasis-position", "text-emphasis-style", "text-height",
9764
- "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
9765
- "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
9766
- "text-wrap", "top", "transform", "transform-origin", "transform-style",
9767
- "transition", "transition-delay", "transition-duration",
9768
- "transition-property", "transition-timing-function", "unicode-bidi",
9769
- "vertical-align", "visibility", "voice-balance", "voice-duration",
9770
- "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
9771
- "voice-volume", "volume", "white-space", "widows", "width", "word-break",
9772
- "word-spacing", "word-wrap", "z-index", "zoom",
9773
- // SVG-specific
9774
- "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
9775
- "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
9776
- "color-interpolation", "color-interpolation-filters", "color-profile",
9777
- "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
9778
- "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
9779
- "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
9780
- "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
9781
- "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
9782
- "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
9783
- ], propertyKeywords = keySet(propertyKeywords_);
9784
-
9785
- var colorKeywords_ = [
9786
- "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
9787
- "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
9788
- "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
9789
- "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
9790
- "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
9791
- "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
9792
- "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
9793
- "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
9794
- "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
9795
- "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
9796
- "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
9797
- "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
9798
- "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
9799
- "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
9800
- "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
9801
- "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
9802
- "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
9803
- "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
9804
- "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
9805
- "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
9806
- "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
9807
- "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
9808
- "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
9809
- "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
9810
- "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
9811
- "whitesmoke", "yellow", "yellowgreen"
9812
- ], colorKeywords = keySet(colorKeywords_);
9813
-
9814
- var valueKeywords_ = [
9815
- "above", "absolute", "activeborder", "activecaption", "afar",
9816
- "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
9817
- "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
9818
- "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
9819
- "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
9820
- "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
9821
- "both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
9822
- "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
9823
- "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
9824
- "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
9825
- "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
9826
- "col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
9827
- "content-box", "context-menu", "continuous", "copy", "cover", "crop",
9828
- "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
9829
- "decimal-leading-zero", "default", "default-button", "destination-atop",
9830
- "destination-in", "destination-out", "destination-over", "devanagari",
9831
- "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
9832
- "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
9833
- "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
9834
- "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
9835
- "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
9836
- "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
9837
- "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
9838
- "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
9839
- "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
9840
- "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
9841
- "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
9842
- "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
9843
- "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
9844
- "help", "hidden", "hide", "higher", "highlight", "highlighttext",
9845
- "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
9846
- "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
9847
- "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
9848
- "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
9849
- "italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
9850
- "landscape", "lao", "large", "larger", "left", "level", "lighter",
9851
- "line-through", "linear", "lines", "list-item", "listbox", "listitem",
9852
- "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
9853
- "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
9854
- "lower-roman", "lowercase", "ltr", "malayalam", "match",
9855
- "media-controls-background", "media-current-time-display",
9856
- "media-fullscreen-button", "media-mute-button", "media-play-button",
9857
- "media-return-to-realtime-button", "media-rewind-button",
9858
- "media-seek-back-button", "media-seek-forward-button", "media-slider",
9859
- "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
9860
- "media-volume-slider-container", "media-volume-sliderthumb", "medium",
9861
- "menu", "menulist", "menulist-button", "menulist-text",
9862
- "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
9863
- "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
9864
- "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
9865
- "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
9866
- "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
9867
- "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
9868
- "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
9869
- "painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
9870
- "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
9871
- "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
9872
- "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
9873
- "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
9874
- "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
9875
- "searchfield-cancel-button", "searchfield-decoration",
9876
- "searchfield-results-button", "searchfield-results-decoration",
9877
- "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
9878
- "single", "skip-white-space", "slide", "slider-horizontal",
9879
- "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
9880
- "small", "small-caps", "small-caption", "smaller", "solid", "somali",
9881
- "source-atop", "source-in", "source-out", "source-over", "space", "square",
9882
- "square-button", "start", "static", "status-bar", "stretch", "stroke",
9883
- "sub", "subpixel-antialiased", "super", "sw-resize", "table",
9884
- "table-caption", "table-cell", "table-column", "table-column-group",
9885
- "table-footer-group", "table-header-group", "table-row", "table-row-group",
9886
- "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
9887
- "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
9888
- "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
9889
- "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
9890
- "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
9891
- "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
9892
- "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
9893
- "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
9894
- "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
9895
- "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
9896
- "xx-large", "xx-small"
9897
- ], valueKeywords = keySet(valueKeywords_);
9898
-
9899
- var fontProperties_ = [
9900
- "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
9901
- "font-stretch", "font-weight", "font-style"
9902
- ], fontProperties = keySet(fontProperties_);
9903
-
9904
- var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
9905
- CodeMirror.registerHelper("hintWords", "css", allWords);
9906
-
9907
- function tokenCComment(stream, state) {
9908
- var maybeEnd = false, ch;
9909
- while ((ch = stream.next()) != null) {
9910
- if (maybeEnd && ch == "/") {
9911
- state.tokenize = null;
9912
- break;
9913
- }
9914
- maybeEnd = (ch == "*");
9915
- }
9916
- return ["comment", "comment"];
9917
- }
9918
-
9919
- function tokenSGMLComment(stream, state) {
9920
- if (stream.skipTo("-->")) {
9921
- stream.match("-->");
9922
- state.tokenize = null;
9923
- } else {
9924
- stream.skipToEnd();
9925
- }
9926
- return ["comment", "comment"];
9927
- }
9928
-
9929
- CodeMirror.defineMIME("text/css", {
9930
- mediaTypes: mediaTypes,
9931
- mediaFeatures: mediaFeatures,
9932
- propertyKeywords: propertyKeywords,
9933
- colorKeywords: colorKeywords,
9934
- valueKeywords: valueKeywords,
9935
- fontProperties: fontProperties,
9936
- tokenHooks: {
9937
- "<": function(stream, state) {
9938
- if (!stream.match("!--")) return false;
9939
- state.tokenize = tokenSGMLComment;
9940
- return tokenSGMLComment(stream, state);
9941
- },
9942
- "/": function(stream, state) {
9943
- if (!stream.eat("*")) return false;
9944
- state.tokenize = tokenCComment;
9945
- return tokenCComment(stream, state);
9946
- }
9947
- },
9948
- name: "css"
9949
- });
9950
-
9951
- CodeMirror.defineMIME("text/x-scss", {
9952
- mediaTypes: mediaTypes,
9953
- mediaFeatures: mediaFeatures,
9954
- propertyKeywords: propertyKeywords,
9955
- colorKeywords: colorKeywords,
9956
- valueKeywords: valueKeywords,
9957
- fontProperties: fontProperties,
9958
- allowNested: true,
9959
- tokenHooks: {
9960
- "/": function(stream, state) {
9961
- if (stream.eat("/")) {
9962
- stream.skipToEnd();
9963
- return ["comment", "comment"];
9964
- } else if (stream.eat("*")) {
9965
- state.tokenize = tokenCComment;
9966
- return tokenCComment(stream, state);
9967
- } else {
9968
- return ["operator", "operator"];
9969
- }
9970
- },
9971
- ":": function(stream) {
9972
- if (stream.match(/\s*{/))
9973
- return [null, "{"];
9974
- return false;
9975
- },
9976
- "$": function(stream) {
9977
- stream.match(/^[\w-]+/);
9978
- if (stream.match(/^\s*:/, false))
9979
- return ["variable-2", "variable-definition"];
9980
- return ["variable-2", "variable"];
9981
- },
9982
- "#": function(stream) {
9983
- if (!stream.eat("{")) return false;
9984
- return [null, "interpolation"];
9985
- }
9986
- },
9987
- name: "css",
9988
- helperType: "scss"
9989
- });
9990
-
9991
- CodeMirror.defineMIME("text/x-less", {
9992
- mediaTypes: mediaTypes,
9993
- mediaFeatures: mediaFeatures,
9994
- propertyKeywords: propertyKeywords,
9995
- colorKeywords: colorKeywords,
9996
- valueKeywords: valueKeywords,
9997
- fontProperties: fontProperties,
9998
- allowNested: true,
9999
- tokenHooks: {
10000
- "/": function(stream, state) {
10001
- if (stream.eat("/")) {
10002
- stream.skipToEnd();
10003
- return ["comment", "comment"];
10004
- } else if (stream.eat("*")) {
10005
- state.tokenize = tokenCComment;
10006
- return tokenCComment(stream, state);
10007
- } else {
10008
- return ["operator", "operator"];
10009
- }
10010
- },
10011
- "@": function(stream) {
10012
- if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
10013
- stream.eatWhile(/[\w\\\-]/);
10014
- if (stream.match(/^\s*:/, false))
10015
- return ["variable-2", "variable-definition"];
10016
- return ["variable-2", "variable"];
10017
- },
10018
- "&": function() {
10019
- return ["atom", "atom"];
10020
- }
10021
- },
10022
- name: "css",
10023
- helperType: "less"
10024
- });
10025
- })();
10026
- //js\libs\codemirror\modes\javascript.js
10027
-
10028
- // TODO actually recognize syntax of TypeScript constructs
10029
-
10030
- (function(mod) {
10031
- if (typeof exports == "object" && typeof module == "object") // CommonJS
10032
- mod(require("../../lib/codemirror"));
10033
- else if (typeof define == "function" && define.amd) // AMD
10034
- define(["../../lib/codemirror"], mod);
10035
- else // Plain browser env
10036
- mod(CodeMirror);
10037
- })(function(CodeMirror) {
10038
- "use strict";
10039
-
10040
- CodeMirror.defineMode("javascript", function(config, parserConfig) {
10041
- var indentUnit = config.indentUnit;
10042
- var statementIndent = parserConfig.statementIndent;
10043
- var jsonldMode = parserConfig.jsonld;
10044
- var jsonMode = parserConfig.json || jsonldMode;
10045
- var isTS = parserConfig.typescript;
10046
-
10047
- // Tokenizer
10048
-
10049
- var keywords = function(){
10050
- function kw(type) {return {type: type, style: "keyword"};}
10051
- var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
10052
- var operator = kw("operator"), atom = {type: "atom", style: "atom"};
10053
-
10054
- var jsKeywords = {
10055
- "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
10056
- "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
10057
- "var": kw("var"), "const": kw("var"), "let": kw("var"),
10058
- "function": kw("function"), "catch": kw("catch"),
10059
- "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
10060
- "in": operator, "typeof": operator, "instanceof": operator,
10061
- "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
10062
- "this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
10063
- "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
10064
- };
10065
-
10066
- // Extend the 'normal' keywords with the TypeScript language extensions
10067
- if (isTS) {
10068
- var type = {type: "variable", style: "variable-3"};
10069
- var tsKeywords = {
10070
- // object-like things
10071
- "interface": kw("interface"),
10072
- "extends": kw("extends"),
10073
- "constructor": kw("constructor"),
10074
-
10075
- // scope modifiers
10076
- "public": kw("public"),
10077
- "private": kw("private"),
10078
- "protected": kw("protected"),
10079
- "static": kw("static"),
10080
-
10081
- // types
10082
- "string": type, "number": type, "bool": type, "any": type
10083
- };
10084
-
10085
- for (var attr in tsKeywords) {
10086
- jsKeywords[attr] = tsKeywords[attr];
10087
- }
10088
- }
10089
-
10090
- return jsKeywords;
10091
- }();
10092
-
10093
- var isOperatorChar = /[+\-*&%=<>!?|~^]/;
10094
- var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
10095
-
10096
- function readRegexp(stream) {
10097
- var escaped = false, next, inSet = false;
10098
- while ((next = stream.next()) != null) {
10099
- if (!escaped) {
10100
- if (next == "/" && !inSet) return;
10101
- if (next == "[") inSet = true;
10102
- else if (inSet && next == "]") inSet = false;
10103
- }
10104
- escaped = !escaped && next == "\\";
10105
- }
10106
- }
10107
-
10108
- // Used as scratch variables to communicate multiple values without
10109
- // consing up tons of objects.
10110
- var type, content;
10111
- function ret(tp, style, cont) {
10112
- type = tp; content = cont;
10113
- return style;
10114
- }
10115
- function tokenBase(stream, state) {
10116
- var ch = stream.next();
10117
- if (ch == '"' || ch == "'") {
10118
- state.tokenize = tokenString(ch);
10119
- return state.tokenize(stream, state);
10120
- } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
10121
- return ret("number", "number");
10122
- } else if (ch == "." && stream.match("..")) {
10123
- return ret("spread", "meta");
10124
- } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
10125
- return ret(ch);
10126
- } else if (ch == "=" && stream.eat(">")) {
10127
- return ret("=>", "operator");
10128
- } else if (ch == "0" && stream.eat(/x/i)) {
10129
- stream.eatWhile(/[\da-f]/i);
10130
- return ret("number", "number");
10131
- } else if (/\d/.test(ch)) {
10132
- stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
10133
- return ret("number", "number");
10134
- } else if (ch == "/") {
10135
- if (stream.eat("*")) {
10136
- state.tokenize = tokenComment;
10137
- return tokenComment(stream, state);
10138
- } else if (stream.eat("/")) {
10139
- stream.skipToEnd();
10140
- return ret("comment", "comment");
10141
- } else if (state.lastType == "operator" || state.lastType == "keyword c" ||
10142
- state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
10143
- readRegexp(stream);
10144
- stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
10145
- return ret("regexp", "string-2");
10146
- } else {
10147
- stream.eatWhile(isOperatorChar);
10148
- return ret("operator", "operator", stream.current());
10149
- }
10150
- } else if (ch == "`") {
10151
- state.tokenize = tokenQuasi;
10152
- return tokenQuasi(stream, state);
10153
- } else if (ch == "#") {
10154
- stream.skipToEnd();
10155
- return ret("error", "error");
10156
- } else if (isOperatorChar.test(ch)) {
10157
- stream.eatWhile(isOperatorChar);
10158
- return ret("operator", "operator", stream.current());
10159
- } else {
10160
- stream.eatWhile(/[\w\$_]/);
10161
- var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
10162
- return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
10163
- ret("variable", "variable", word);
10164
- }
10165
- }
10166
-
10167
- function tokenString(quote) {
10168
- return function(stream, state) {
10169
- var escaped = false, next;
10170
- if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
10171
- state.tokenize = tokenBase;
10172
- return ret("jsonld-keyword", "meta");
10173
- }
10174
- while ((next = stream.next()) != null) {
10175
- if (next == quote && !escaped) break;
10176
- escaped = !escaped && next == "\\";
10177
- }
10178
- if (!escaped) state.tokenize = tokenBase;
10179
- return ret("string", "string");
10180
- };
10181
- }
10182
-
10183
- function tokenComment(stream, state) {
10184
- var maybeEnd = false, ch;
10185
- while (ch = stream.next()) {
10186
- if (ch == "/" && maybeEnd) {
10187
- state.tokenize = tokenBase;
10188
- break;
10189
- }
10190
- maybeEnd = (ch == "*");
10191
- }
10192
- return ret("comment", "comment");
10193
- }
10194
-
10195
- function tokenQuasi(stream, state) {
10196
- var escaped = false, next;
10197
- while ((next = stream.next()) != null) {
10198
- if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
10199
- state.tokenize = tokenBase;
10200
- break;
10201
- }
10202
- escaped = !escaped && next == "\\";
10203
- }
10204
- return ret("quasi", "string-2", stream.current());
10205
- }
10206
-
10207
- var brackets = "([{}])";
10208
- // This is a crude lookahead trick to try and notice that we're
10209
- // parsing the argument patterns for a fat-arrow function before we
10210
- // actually hit the arrow token. It only works if the arrow is on
10211
- // the same line as the arguments and there's no strange noise
10212
- // (comments) in between. Fallback is to only notice when we hit the
10213
- // arrow, and not declare the arguments as locals for the arrow
10214
- // body.
10215
- function findFatArrow(stream, state) {
10216
- if (state.fatArrowAt) state.fatArrowAt = null;
10217
- var arrow = stream.string.indexOf("=>", stream.start);
10218
- if (arrow < 0) return;
10219
-
10220
- var depth = 0, sawSomething = false;
10221
- for (var pos = arrow - 1; pos >= 0; --pos) {
10222
- var ch = stream.string.charAt(pos);
10223
- var bracket = brackets.indexOf(ch);
10224
- if (bracket >= 0 && bracket < 3) {
10225
- if (!depth) { ++pos; break; }
10226
- if (--depth == 0) break;
10227
- } else if (bracket >= 3 && bracket < 6) {
10228
- ++depth;
10229
- } else if (/[$\w]/.test(ch)) {
10230
- sawSomething = true;
10231
- } else if (sawSomething && !depth) {
10232
- ++pos;
10233
- break;
10234
- }
10235
- }
10236
- if (sawSomething && !depth) state.fatArrowAt = pos;
10237
- }
10238
-
10239
- // Parser
10240
-
10241
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
10242
-
10243
- function JSLexical(indented, column, type, align, prev, info) {
10244
- this.indented = indented;
10245
- this.column = column;
10246
- this.type = type;
10247
- this.prev = prev;
10248
- this.info = info;
10249
- if (align != null) this.align = align;
10250
- }
10251
-
10252
- function inScope(state, varname) {
10253
- for (var v = state.localVars; v; v = v.next)
10254
- if (v.name == varname) return true;
10255
- for (var cx = state.context; cx; cx = cx.prev) {
10256
- for (var v = cx.vars; v; v = v.next)
10257
- if (v.name == varname) return true;
10258
- }
10259
- }
10260
-
10261
- function parseJS(state, style, type, content, stream) {
10262
- var cc = state.cc;
10263
- // Communicate our context to the combinators.
10264
- // (Less wasteful than consing up a hundred closures on every call.)
10265
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
10266
-
10267
- if (!state.lexical.hasOwnProperty("align"))
10268
- state.lexical.align = true;
10269
-
10270
- while(true) {
10271
- var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
10272
- if (combinator(type, content)) {
10273
- while(cc.length && cc[cc.length - 1].lex)
10274
- cc.pop()();
10275
- if (cx.marked) return cx.marked;
10276
- if (type == "variable" && inScope(state, content)) return "variable-2";
10277
- return style;
10278
- }
10279
- }
10280
- }
10281
-
10282
- // Combinator utils
10283
-
10284
- var cx = {state: null, column: null, marked: null, cc: null};
10285
- function pass() {
10286
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
10287
- }
10288
- function cont() {
10289
- pass.apply(null, arguments);
10290
- return true;
10291
- }
10292
- function register(varname) {
10293
- function inList(list) {
10294
- for (var v = list; v; v = v.next)
10295
- if (v.name == varname) return true;
10296
- return false;
10297
- }
10298
- var state = cx.state;
10299
- if (state.context) {
10300
- cx.marked = "def";
10301
- if (inList(state.localVars)) return;
10302
- state.localVars = {name: varname, next: state.localVars};
10303
- } else {
10304
- if (inList(state.globalVars)) return;
10305
- if (parserConfig.globalVars)
10306
- state.globalVars = {name: varname, next: state.globalVars};
10307
- }
10308
- }
10309
-
10310
- // Combinators
10311
-
10312
- var defaultVars = {name: "this", next: {name: "arguments"}};
10313
- function pushcontext() {
10314
- cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
10315
- cx.state.localVars = defaultVars;
10316
- }
10317
- function popcontext() {
10318
- cx.state.localVars = cx.state.context.vars;
10319
- cx.state.context = cx.state.context.prev;
10320
- }
10321
- function pushlex(type, info) {
10322
- var result = function() {
10323
- var state = cx.state, indent = state.indented;
10324
- if (state.lexical.type == "stat") indent = state.lexical.indented;
10325
- state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
10326
- };
10327
- result.lex = true;
10328
- return result;
10329
- }
10330
- function poplex() {
10331
- var state = cx.state;
10332
- if (state.lexical.prev) {
10333
- if (state.lexical.type == ")")
10334
- state.indented = state.lexical.indented;
10335
- state.lexical = state.lexical.prev;
10336
- }
10337
- }
10338
- poplex.lex = true;
10339
-
10340
- function expect(wanted) {
10341
- function exp(type) {
10342
- if (type == wanted) return cont();
10343
- else if (wanted == ";") return pass();
10344
- else return cont(exp);
10345
- };
10346
- return exp;
10347
- }
10348
-
10349
- function statement(type, value) {
10350
- if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
10351
- if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
10352
- if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
10353
- if (type == "{") return cont(pushlex("}"), block, poplex);
10354
- if (type == ";") return cont();
10355
- if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse);
10356
- if (type == "function") return cont(functiondef);
10357
- if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
10358
- if (type == "variable") return cont(pushlex("stat"), maybelabel);
10359
- if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
10360
- block, poplex, poplex);
10361
- if (type == "case") return cont(expression, expect(":"));
10362
- if (type == "default") return cont(expect(":"));
10363
- if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
10364
- statement, poplex, popcontext);
10365
- if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);
10366
- if (type == "class") return cont(pushlex("form"), className, objlit, poplex);
10367
- if (type == "export") return cont(pushlex("form"), afterExport, poplex);
10368
- if (type == "import") return cont(pushlex("form"), afterImport, poplex);
10369
- return pass(pushlex("stat"), expression, expect(";"), poplex);
10370
- }
10371
- function expression(type) {
10372
- return expressionInner(type, false);
10373
- }
10374
- function expressionNoComma(type) {
10375
- return expressionInner(type, true);
10376
- }
10377
- function expressionInner(type, noComma) {
10378
- if (cx.state.fatArrowAt == cx.stream.start) {
10379
- var body = noComma ? arrowBodyNoComma : arrowBody;
10380
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
10381
- else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
10382
- }
10383
-
10384
- var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
10385
- if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
10386
- if (type == "function") return cont(functiondef, maybeop);
10387
- if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
10388
- if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
10389
- if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
10390
- if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
10391
- if (type == "{") return contCommasep(objprop, "}", null, maybeop);
10392
- return cont();
10393
- }
10394
- function maybeexpression(type) {
10395
- if (type.match(/[;\}\)\],]/)) return pass();
10396
- return pass(expression);
10397
- }
10398
- function maybeexpressionNoComma(type) {
10399
- if (type.match(/[;\}\)\],]/)) return pass();
10400
- return pass(expressionNoComma);
10401
- }
10402
-
10403
- function maybeoperatorComma(type, value) {
10404
- if (type == ",") return cont(expression);
10405
- return maybeoperatorNoComma(type, value, false);
10406
- }
10407
- function maybeoperatorNoComma(type, value, noComma) {
10408
- var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
10409
- var expr = noComma == false ? expression : expressionNoComma;
10410
- if (value == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
10411
- if (type == "operator") {
10412
- if (/\+\+|--/.test(value)) return cont(me);
10413
- if (value == "?") return cont(expression, expect(":"), expr);
10414
- return cont(expr);
10415
- }
10416
- if (type == "quasi") { cx.cc.push(me); return quasi(value); }
10417
- if (type == ";") return;
10418
- if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
10419
- if (type == ".") return cont(property, me);
10420
- if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
10421
- }
10422
- function quasi(value) {
10423
- if (value.slice(value.length - 2) != "${") return cont();
10424
- return cont(expression, continueQuasi);
10425
- }
10426
- function continueQuasi(type) {
10427
- if (type == "}") {
10428
- cx.marked = "string-2";
10429
- cx.state.tokenize = tokenQuasi;
10430
- return cont();
10431
- }
10432
- }
10433
- function arrowBody(type) {
10434
- findFatArrow(cx.stream, cx.state);
10435
- if (type == "{") return pass(statement);
10436
- return pass(expression);
10437
- }
10438
- function arrowBodyNoComma(type) {
10439
- findFatArrow(cx.stream, cx.state);
10440
- if (type == "{") return pass(statement);
10441
- return pass(expressionNoComma);
10442
- }
10443
- function maybelabel(type) {
10444
- if (type == ":") return cont(poplex, statement);
10445
- return pass(maybeoperatorComma, expect(";"), poplex);
10446
- }
10447
- function property(type) {
10448
- if (type == "variable") {cx.marked = "property"; return cont();}
10449
- }
10450
- function objprop(type, value) {
10451
- if (type == "variable") {
10452
- cx.marked = "property";
10453
- if (value == "get" || value == "set") return cont(getterSetter);
10454
- } else if (type == "number" || type == "string") {
10455
- cx.marked = jsonldMode ? "property" : (type + " property");
10456
- } else if (type == "[") {
10457
- return cont(expression, expect("]"), afterprop);
10458
- }
10459
- if (atomicTypes.hasOwnProperty(type)) return cont(afterprop);
10460
- }
10461
- function getterSetter(type) {
10462
- if (type != "variable") return pass(afterprop);
10463
- cx.marked = "property";
10464
- return cont(functiondef);
10465
- }
10466
- function afterprop(type) {
10467
- if (type == ":") return cont(expressionNoComma);
10468
- if (type == "(") return pass(functiondef);
10469
- }
10470
- function commasep(what, end) {
10471
- function proceed(type) {
10472
- if (type == ",") {
10473
- var lex = cx.state.lexical;
10474
- if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
10475
- return cont(what, proceed);
10476
- }
10477
- if (type == end) return cont();
10478
- return cont(expect(end));
10479
- }
10480
- return function(type) {
10481
- if (type == end) return cont();
10482
- return pass(what, proceed);
10483
- };
10484
- }
10485
- function contCommasep(what, end, info) {
10486
- for (var i = 3; i < arguments.length; i++)
10487
- cx.cc.push(arguments[i]);
10488
- return cont(pushlex(end, info), commasep(what, end), poplex);
10489
- }
10490
- function block(type) {
10491
- if (type == "}") return cont();
10492
- return pass(statement, block);
10493
- }
10494
- function maybetype(type) {
10495
- if (isTS && type == ":") return cont(typedef);
10496
- }
10497
- function typedef(type) {
10498
- if (type == "variable"){cx.marked = "variable-3"; return cont();}
10499
- }
10500
- function vardef() {
10501
- return pass(pattern, maybetype, maybeAssign, vardefCont);
10502
- }
10503
- function pattern(type, value) {
10504
- if (type == "variable") { register(value); return cont(); }
10505
- if (type == "[") return contCommasep(pattern, "]");
10506
- if (type == "{") return contCommasep(proppattern, "}");
10507
- }
10508
- function proppattern(type, value) {
10509
- if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
10510
- register(value);
10511
- return cont(maybeAssign);
10512
- }
10513
- if (type == "variable") cx.marked = "property";
10514
- return cont(expect(":"), pattern, maybeAssign);
10515
- }
10516
- function maybeAssign(_type, value) {
10517
- if (value == "=") return cont(expressionNoComma);
10518
- }
10519
- function vardefCont(type) {
10520
- if (type == ",") return cont(vardef);
10521
- }
10522
- function maybeelse(type, value) {
10523
- if (type == "keyword b" && value == "else") return cont(pushlex("form"), statement, poplex);
10524
- }
10525
- function forspec(type) {
10526
- if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
10527
- }
10528
- function forspec1(type) {
10529
- if (type == "var") return cont(vardef, expect(";"), forspec2);
10530
- if (type == ";") return cont(forspec2);
10531
- if (type == "variable") return cont(formaybeinof);
10532
- return pass(expression, expect(";"), forspec2);
10533
- }
10534
- function formaybeinof(_type, value) {
10535
- if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
10536
- return cont(maybeoperatorComma, forspec2);
10537
- }
10538
- function forspec2(type, value) {
10539
- if (type == ";") return cont(forspec3);
10540
- if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
10541
- return pass(expression, expect(";"), forspec3);
10542
- }
10543
- function forspec3(type) {
10544
- if (type != ")") cont(expression);
10545
- }
10546
- function functiondef(type, value) {
10547
- if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
10548
- if (type == "variable") {register(value); return cont(functiondef);}
10549
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
10550
- }
10551
- function funarg(type) {
10552
- if (type == "spread") return cont(funarg);
10553
- return pass(pattern, maybetype);
10554
- }
10555
- function className(type, value) {
10556
- if (type == "variable") {register(value); return cont(classNameAfter);}
10557
- }
10558
- function classNameAfter(_type, value) {
10559
- if (value == "extends") return cont(expression);
10560
- }
10561
- function objlit(type) {
10562
- if (type == "{") return contCommasep(objprop, "}");
10563
- }
10564
- function afterModule(type, value) {
10565
- if (type == "string") return cont(statement);
10566
- if (type == "variable") { register(value); return cont(maybeFrom); }
10567
- }
10568
- function afterExport(_type, value) {
10569
- if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
10570
- if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
10571
- return pass(statement);
10572
- }
10573
- function afterImport(type) {
10574
- if (type == "string") return cont();
10575
- return pass(importSpec, maybeFrom);
10576
- }
10577
- function importSpec(type, value) {
10578
- if (type == "{") return contCommasep(importSpec, "}");
10579
- if (type == "variable") register(value);
10580
- return cont();
10581
- }
10582
- function maybeFrom(_type, value) {
10583
- if (value == "from") { cx.marked = "keyword"; return cont(expression); }
10584
- }
10585
- function arrayLiteral(type) {
10586
- if (type == "]") return cont();
10587
- return pass(expressionNoComma, maybeArrayComprehension);
10588
- }
10589
- function maybeArrayComprehension(type) {
10590
- if (type == "for") return pass(comprehension, expect("]"));
10591
- if (type == ",") return cont(commasep(expressionNoComma, "]"));
10592
- return pass(commasep(expressionNoComma, "]"));
10593
- }
10594
- function comprehension(type) {
10595
- if (type == "for") return cont(forspec, comprehension);
10596
- if (type == "if") return cont(expression, comprehension);
10597
- }
10598
-
10599
- // Interface
10600
-
10601
- return {
10602
- startState: function(basecolumn) {
10603
- var state = {
10604
- tokenize: tokenBase,
10605
- lastType: "sof",
10606
- cc: [],
10607
- lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
10608
- localVars: parserConfig.localVars,
10609
- context: parserConfig.localVars && {vars: parserConfig.localVars},
10610
- indented: 0
10611
- };
10612
- if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
10613
- state.globalVars = parserConfig.globalVars;
10614
- return state;
10615
- },
10616
-
10617
- token: function(stream, state) {
10618
- if (stream.sol()) {
10619
- if (!state.lexical.hasOwnProperty("align"))
10620
- state.lexical.align = false;
10621
- state.indented = stream.indentation();
10622
- findFatArrow(stream, state);
10623
- }
10624
- if (state.tokenize != tokenComment && stream.eatSpace()) return null;
10625
- var style = state.tokenize(stream, state);
10626
- if (type == "comment") return style;
10627
- state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
10628
- return parseJS(state, style, type, content, stream);
10629
- },
10630
-
10631
- indent: function(state, textAfter) {
10632
- if (state.tokenize == tokenComment) return CodeMirror.Pass;
10633
- if (state.tokenize != tokenBase) return 0;
10634
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
10635
- // Kludge to prevent 'maybelse' from blocking lexical scope pops
10636
- for (var i = state.cc.length - 1; i >= 0; --i) {
10637
- var c = state.cc[i];
10638
- if (c == poplex) lexical = lexical.prev;
10639
- else if (c != maybeelse) break;
10640
- }
10641
- if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
10642
- if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
10643
- lexical = lexical.prev;
10644
- var type = lexical.type, closing = firstChar == type;
10645
-
10646
- if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
10647
- else if (type == "form" && firstChar == "{") return lexical.indented;
10648
- else if (type == "form") return lexical.indented + indentUnit;
10649
- else if (type == "stat")
10650
- return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
10651
- else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
10652
- return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
10653
- else if (lexical.align) return lexical.column + (closing ? 0 : 1);
10654
- else return lexical.indented + (closing ? 0 : indentUnit);
10655
- },
10656
-
10657
- electricChars: ":{}",
10658
- blockCommentStart: jsonMode ? null : "/*",
10659
- blockCommentEnd: jsonMode ? null : "*/",
10660
- lineComment: jsonMode ? null : "//",
10661
- fold: "brace",
10662
-
10663
- helperType: jsonMode ? "json" : "javascript",
10664
- jsonldMode: jsonldMode,
10665
- jsonMode: jsonMode
10666
- };
10667
- });
10668
-
10669
- CodeMirror.defineMIME("text/javascript", "javascript");
10670
- CodeMirror.defineMIME("text/ecmascript", "javascript");
10671
- CodeMirror.defineMIME("application/javascript", "javascript");
10672
- CodeMirror.defineMIME("application/ecmascript", "javascript");
10673
- CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
10674
- CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
10675
- CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
10676
- CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
10677
- CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
10678
-
10679
- });
10680
- //js\libs\averta.em-offline-adapter.js
10681
-
10682
- /**
10683
- * Offline Adapter for Ember-Model, based on Ember-Model Localstorage
10684
- * Copyright © All Rights Reserved. Averta Ltd,
10685
- * @author Averta
10686
- * @version 1.0
10687
- */
10688
-
10689
- ;(function(){
10690
- var Promise = Ember.RSVP.Promise;
10691
-
10692
- function classToString(klass) {
10693
- return klass.toString().split('.')[1];
10694
- }
10695
-
10696
- Ember.OfflineAdapter = Ember.Adapter.extend({
10697
-
10698
- find: function(record, id) {
10699
- var data = this._getItem(record.constructor, id);
10700
-
10701
- return new Promise(function(resolve, reject) {
10702
- if (data) {
10703
- record.load(id, data);
10704
- resolve(record);
10705
- } else {
10706
- reject(record);
10707
- }
10708
- });
10709
- },
10710
-
10711
- findAll: function(klass, records) {
10712
- var self = this,
10713
- applicationData = this.applicationData;
10714
-
10715
- return new Promise(function(resolve, reject) {
10716
- var ids = applicationData.meta[classToString(klass) + '!ids'],
10717
- data = [];
10718
-
10719
- if (ids) {
10720
- ids = ids.split(',');
10721
-
10722
- for (var i = 0, l = ids.length; i < l; i++) {
10723
- data.push(self._getItem(klass, ids[i]));
10724
- }
10725
- }
10726
-
10727
- records.load(klass, data);
10728
- resolve(records);
10729
- });
10730
- },
10731
-
10732
- createRecord: function(record) {
10733
- var self = this,
10734
- klass = record.constructor,
10735
- applicationData = this.applicationData;
10736
-
10737
- return new Promise(function(resolve, reject) {
10738
- var newId = applicationData.meta[classToString(klass) + '!nextId'] || '1';
10739
- record.set(klass.primaryKey, newId);
10740
- var data = record.toJSON();
10741
- self._setItem(klass, newId, data);
10742
-
10743
- self._updateIds(klass, newId);
10744
- applicationData.meta[classToString(klass) + '!nextId'] = parseInt(newId, 10) + 1;
10745
-
10746
- record.load(newId, data);
10747
- record.didCreateRecord();
10748
- resolve(record);
10749
- });
10750
- },
10751
-
10752
- saveRecord: function(record) {
10753
- var self = this,
10754
- klass = record.constructor;
10755
-
10756
- return new Promise(function(resolve, reject) {
10757
- self._setItem(klass, record.get(klass.primaryKey), record.toJSON());
10758
- record.didSaveRecord();
10759
- resolve(record);
10760
- });
10761
- },
10762
-
10763
- deleteRecord: function(record) {
10764
- var self = this,
10765
- klass = record.constructor;
10766
-
10767
- return new Promise(function(resolve, reject) {
10768
- self._deleteItem(klass, record.get(klass.primaryKey));
10769
- record.didDeleteRecord();
10770
- resolve(record);
10771
- });
10772
- },
10773
-
10774
- _getItem: function(klass, id) {
10775
- var value = this.applicationData[klass][id];
10776
- return value && JSON.parse(value);
10777
- },
10778
-
10779
- _setItem: function(klass, id, data) {
10780
- if(!this.applicationData[klass]) this.applicationData[klass] = {};
10781
- this.applicationData[klass][id] = JSON.stringify(data);
10782
- },
10783
-
10784
- _deleteItem: function(klass, id) {
10785
- delete this.applicationData[klass][id];
10786
-
10787
- var idsKey = classToString(klass) + '!ids',
10788
- ids = this.applicationData.meta[idsKey].split(',');
10789
-
10790
- for (var i = 0, l = ids.length; i < l; i++) {
10791
- if (ids[i] === ''+id) { // handling id being a number or string
10792
- ids.splice(i, 1);
10793
- break;
10794
- }
10795
- }
10796
-
10797
- this.applicationData.meta[idsKey] = ids.join(',');
10798
- },
10799
-
10800
- _updateIds: function(klass, newId) {
10801
- newId = String(newId);
10802
- var key = classToString(klass) + '!ids',
10803
- currentIds = this.applicationData.meta[key];
10804
- if (currentIds) {
10805
- this.applicationData.meta[key] += ',' + newId;
10806
- } else {
10807
- this.applicationData.meta[key] = newId;
10808
- }
10809
- }
10810
- });
10811
- })();
10812
- //js\libs\base64.js
10813
-
10814
- /*!
10815
- Copyright Vassilis Petroulias [DRDigit]
10816
-
10817
- Licensed under the Apache License, Version 2.0 (the "License");
10818
- you may not use this file except in compliance with the License.
10819
- You may obtain a copy of the License at
10820
-
10821
- http://www.apache.org/licenses/LICENSE-2.0
10822
-
10823
- Unless required by applicable law or agreed to in writing, software
10824
- distributed under the License is distributed on an "AS IS" BASIS,
10825
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10826
- See the License for the specific language governing permissions and
10827
- limitations under the License.
10828
- */
10829
- var B64 = {
10830
- alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
10831
- lookup: null,
10832
- ie: /MSIE /.test(navigator.userAgent),
10833
- ieo: /MSIE [67]/.test(navigator.userAgent),
10834
- encode: function (s) {
10835
- var buffer = B64.toUtf8(s),
10836
- position = -1,
10837
- len = buffer.length,
10838
- nan1, nan2, enc = [, , , ];
10839
- if (B64.ie) {
10840
- var result = [];
10841
- while (++position < len) {
10842
- nan1 = buffer[position + 1], nan2 = buffer[position + 2];
10843
- enc[0] = buffer[position] >> 2;
10844
- enc[1] = ((buffer[position] & 3) << 4) | (buffer[++position] >> 4);
10845
- if (isNaN(nan1)) enc[2] = enc[3] = 64;
10846
- else {
10847
- enc[2] = ((buffer[position] & 15) << 2) | (buffer[++position] >> 6);
10848
- enc[3] = (isNaN(nan2)) ? 64 : buffer[position] & 63;
10849
- }
10850
- result.push(B64.alphabet[enc[0]], B64.alphabet[enc[1]], B64.alphabet[enc[2]], B64.alphabet[enc[3]]);
10851
- }
10852
- return result.join('');
10853
- } else {
10854
- result = '';
10855
- while (++position < len) {
10856
- nan1 = buffer[position + 1], nan2 = buffer[position + 2];
10857
- enc[0] = buffer[position] >> 2;
10858
- enc[1] = ((buffer[position] & 3) << 4) | (buffer[++position] >> 4);
10859
- if (isNaN(nan1)) enc[2] = enc[3] = 64;
10860
- else {
10861
- enc[2] = ((buffer[position] & 15) << 2) | (buffer[++position] >> 6);
10862
- enc[3] = (isNaN(nan2)) ? 64 : buffer[position] & 63;
10863
- }
10864
- result += B64.alphabet[enc[0]] + B64.alphabet[enc[1]] + B64.alphabet[enc[2]] + B64.alphabet[enc[3]];
10865
- }
10866
- return result;
10867
- }
10868
- },
10869
- decode: function (s) {
10870
- var buffer = B64.fromUtf8(s),
10871
- position = 0,
10872
- len = buffer.length;
10873
- if (B64.ieo) {
10874
- result = [];
10875
- while (position < len) {
10876
- if (buffer[position] < 128) result.push(String.fromCharCode(buffer[position++]));
10877
- else if (buffer[position] > 191 && buffer[position] < 224) result.push(String.fromCharCode(((buffer[position++] & 31) << 6) | (buffer[position++] & 63)));
10878
- else result.push(String.fromCharCode(((buffer[position++] & 15) << 12) | ((buffer[position++] & 63) << 6) | (buffer[position++] & 63)));
10879
- }
10880
- return result.join('');
10881
- } else {
10882
- result = '';
10883
- while (position < len) {
10884
- if (buffer[position] < 128) result += String.fromCharCode(buffer[position++]);
10885
- else if (buffer[position] > 191 && buffer[position] < 224) result += String.fromCharCode(((buffer[position++] & 31) << 6) | (buffer[position++] & 63));
10886
- else result += String.fromCharCode(((buffer[position++] & 15) << 12) | ((buffer[position++] & 63) << 6) | (buffer[position++] & 63));
10887
- }
10888
- return result;
10889
- }
10890
- },
10891
- toUtf8: function (s) {
10892
- var position = -1,
10893
- len = s.length,
10894
- chr, buffer = [];
10895
- if (/^[\x00-\x7f]*$/.test(s)) while (++position < len)
10896
- buffer.push(s.charCodeAt(position));
10897
- else while (++position < len) {
10898
- chr = s.charCodeAt(position);
10899
- if (chr < 128) buffer.push(chr);
10900
- else if (chr < 2048) buffer.push((chr >> 6) | 192, (chr & 63) | 128);
10901
- else buffer.push((chr >> 12) | 224, ((chr >> 6) & 63) | 128, (chr & 63) | 128);
10902
- }
10903
- return buffer;
10904
- },
10905
- fromUtf8: function (s) {
10906
- var position = -1,
10907
- len, buffer = [],
10908
- enc = [, , , ];
10909
- if (!B64.lookup) {
10910
- len = B64.alphabet.length;
10911
- B64.lookup = {};
10912
- while (++position < len)
10913
- B64.lookup[B64.alphabet[position]] = position;
10914
- position = -1;
10915
- }
10916
- len = s.length;
10917
- while (position < len) {
10918
- enc[0] = B64.lookup[s.charAt(++position)];
10919
- enc[1] = B64.lookup[s.charAt(++position)];
10920
- buffer.push((enc[0] << 2) | (enc[1] >> 4));
10921
- enc[2] = B64.lookup[s.charAt(++position)];
10922
- if (enc[2] == 64) break;
10923
- buffer.push(((enc[1] & 15) << 4) | (enc[2] >> 2));
10924
- enc[3] = B64.lookup[s.charAt(++position)];
10925
- if (enc[3] == 64) break;
10926
- buffer.push(((enc[2] & 3) << 6) | enc[3]);
10927
- }
10928
- return buffer;
10929
- }
10930
- };
1
+ /*!
2
+ * @overview Averta JavaScript Libraries
3
+ * @copyright Copyright 2014 Averta Ltd.
4
+ * http://www.averta.net
5
+ */
6
+ window.averta={},function(n){function f(){var t,n,i;if("result"in arguments.callee)return arguments.callee.result;t=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0];for(i in n.style)if(t.test(i))return arguments.callee.result=i.match(t)[0];return arguments.callee.result="WebkitOpacity"in n.style?"Webkit":"KhtmlOpacity"in n.style?"Khtml":""}function i(n){var u=document.body||document.documentElement,r=u.style,t=n,i;if(typeof r[t]=="string")return!0;for(v=["Moz","Webkit","Khtml","O","ms"],t=t.charAt(0).toUpperCase()+t.substr(1),i=0;i<v.length;i++)if(typeof r[v[i]+t]=="string")return!0;return!1}function e(){return i("transition")}function r(){return i("transform")}function o(){var n,t,u,i;if(!r())return!1;n=document.createElement("p"),u={WebkitTransform:"-webkit-transform",OTransform:"-o-transform",MSTransform:"-ms-transform",MozTransform:"-moz-transform",Transform:"transform"},document.body.insertBefore(n,null);for(i in u)n.style[i]!==undefined&&(n.style[i]="translate3d(1px,1px,1px)",t=window.getComputedStyle(n).getPropertyValue(u[i]));return document.body.removeChild(n),t!=null&&t.length>0&&t!=="none"}var t,u;window.package=function(n){window[n]||(window[n]={})},t={Moz:"-moz-",Webkit:"-webkit-",Khtml:"-khtml-",O:"-o-",ms:"-ms-",Icab:"-icab-"},n(document).ready(function(){window._jcsspfx=f(),window._csspfx=t[window._jcsspfx],window._cssanim=e(),window._css3d=o(),window._css2d=r(),window._mobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),window._touch="ontouchstart"in document}),window.parseQueryString=function(n){var t={};return n.replace(new RegExp("([^?=&]+)(=([^&]*))?","g"),function(n,i,r,u){t[i]=u}),t},u=50/3,window.requestAnimationFrame||(window.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(n){window.setTimeout(n,u)}}()),window.getComputedStyle||(window.getComputedStyle=function(n){return this.el=n,this.getPropertyValue=function(t){var i=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),i.test(t)&&(t=t.replace(i,function(){return arguments[2].toUpperCase()})),n.currentStyle[t]?n.currentStyle[t]:null},n.currentStyle}),jQuery&&(n.jqLoadFix=function(){if(this.complete){var t=this;setTimeout(function(){n(t).load()},1)}},jQuery.uaMatch=jQuery.uaMatch||function(n){n=n.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(n)||/(webkit)[ \/]([\w.]+)/.exec(n)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(n)||/(msie) ([\w.]+)/.exec(n)||n.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(n)||[];return{browser:t[1]||"",version:t[2]||"0"}},jQuery.browser||(matched=jQuery.uaMatch(navigator.userAgent),browser={},matched.browser&&(browser[matched.browser]=!0,browser.version=matched.version),browser.chrome?browser.webkit=!0:browser.webkit&&(browser.safari=!0),jQuery.browser=browser),n.fn.preloadImg=function(t,i){return this.each(function(){var u=n(this),f=this,r=new Image;r.onload=function(n){u.attr("src",t),n.width=r.width,n.height=r.height,setTimeout(function(){i.call(f,n)},50),r=null},r.src=t}),this}),window.parseTransform=function(n){var i,u,r,f,t;if(n===null)return{};for(n=n.replace(/\s+/g,""),i=n.split(")"),i.pop(),u={},r=0,f=i.length;r<f;++r)t=i[r],u[t.slice(0,t.indexOf("("))]=t.slice(t.indexOf("(")+1).split(",");return u},window.convertEaseName=function(n){if(n==="linear")return Linear.easeNone;var t=n.indexOf("InOut")!==-1,i=n.indexOf("In")!==-1;return t?window[n.slice(9)].easeInOut:i?window[n.slice(6)].easeIn:window[n.slice(7)].easeOut},jQuery.fn.extend({insertAtCaret:function(n){return this.each(function(){var i;if(document.selection)this.focus(),i=document.selection.createRange(),i.text=n,this.focus();else if(this.selectionStart||this.selectionStart=="0"){var t=this.selectionStart,r=this.selectionEnd,u=this.scrollTop;this.value=this.value.substring(0,t)+n+this.value.substring(r,this.value.length),this.focus(),this.selectionStart=t+n.length,this.selectionEnd=t+n.length,this.scrollTop=u}else this.value+=n,this.focus()})}})}(jQuery),typeof Object.create!="function"&&(Object.create=function(n){function t(){}return t.prototype=n,new t}),function(n){var t={init:function(t,i){var r=this;r.options=n.extend({},n.fn.avertaLiveTabs.defaultOptions,i||{}),r.$el=n(t),r.el=t,r.$tabs=r.$el.find(r.options.tabs),r.$contents=r.$el.find(r.options.contents),r.setup()},setup:function(){var n=this,t,i;n.$tabs.on("click",{self:n},n.onTabClicked);n.options.enableHash&&window.location.hash!==""?(i=window.location.hash.substring(1),t=n.getTabById(i)):t=n.$tabs.filter("."+n.options.tabsActiveClass),t=t.length?t:n.$tabs.first(),t.trigger("click",!0)},onTabClicked:function(t,i){t.preventDefault();var r=t.data.self,f=n(this),e,u;(i||!f.hasClass("active"))&&(r.$tabs.removeClass(r.options.tabsActiveClass),f.addClass(r.options.tabsActiveClass),r.$contents.hide(),r.options.connectType=="id"?(u=r.getIdByTab(f),e=r.getContentById(u)):e=r.$contents.eq(f.index()),e.fadeIn(r.options.duration),r.options.updateHash&&(u=r.getIdByTab(f),u=u?u+r.options.hashSuffix:"",window.history&&window.history.pushState?window.history.pushState(null,null,window.location.href.split("#")[0]+"#"+u):window.location.hash=u),r.$el.trigger("avtTabChange",e.attr("id")))},getTabById:function(n){n=n.split(this.options.hashSuffix)[0];var t=this.$tabs.find('[href="#'+n+'"]').eq(0);return t.length||(t=this.$tabs.find('[href="'+n+'"]').eq(0)),t.length?t.parent():t},getContentById:function(n){return this.$contents.filter("#"+n)},getIdByTab:function(n){var t=n.find("[href]").eq(0);return t.length?t.attr("href"):!1}};n.fn.avertaLiveTabs=function(n){return this.each(function(){var i=Object.create(t);i.init(this,n)})},n.fn.avertaLiveTabs.defaultOptions={tabs:"ul.tabs > li",tabsActiveClass:"active",contents:"ul.tabs-content > li",contentsActiveClass:"active",transition:"fade",duration:"500",connectType:"index",enableHash:!1,updateHash:!1,hashSuffix:"-tab"}}(jQuery),function(){"use strict";window.MSAligner=function(n,t,i){this.$container=t,this.$img=i,this.type=n||"stretch",this.widthOnly=!1,this.heightOnly=!1};var n=MSAligner.prototype;n.init=function(n,t){this.baseWidth=n,this.baseHeight=t,this.imgRatio=n/t,this.imgRatio2=t/n;switch(this.type){case"tile":this.$container.css("background-image","url("+this.$img.attr("src")+")"),this.$img.detach();break;case"center":this.$container.css("background-image","url("+this.$img.attr("src")+")"),this.$container.css({backgroundPosition:"center center",backgroundRepeat:"no-repeat"}),this.$img.detach();break;case"stretch":this.$img.css({width:"100%",height:"100%"});break;case"fill":case"fit":this.needAlign=!0,this.align()}},n.align=function(){if(this.needAlign){var n=this.$container.width(),t=this.$container.height(),i=n/t;this.type=="fill"?this.imgRatio<i?(this.$img.width(n),this.$img.height(n*this.imgRatio2)):(this.$img.height(t),this.$img.width(t*this.imgRatio)):this.type=="fit"&&(this.imgRatio<i?(this.$img.height(t),this.$img.width(t*this.imgRatio)):(this.$img.width(n),this.$img.height(n*this.imgRatio2))),this.setMargin()}},n.changeType=function(n){this.reset(),this.type=n,this.reinit()},n.reinit=function(){this.init(this.baseWidth,this.baseHeight)},n.reset=function(){this.type==="center"||this.type==="tile"?(this.$container.css({"background-image":"",backgroundPosition:"",backgroundRepeat:""}),this.$img.appendTo(this.$container)):this.$img.css({width:"",height:"","margin-top":"","margin-left":""})},n.setMargin=function(){var n=this.$container.width(),t=this.$container.height();this.$img.css("margin-top",(t-this.$img[0].offsetHeight)/2+"px"),this.$img.css("margin-left",(n-this.$img[0].offsetWidth)/2+"px")}}();
7
+ /*!
8
+ * Custom DropDown plugin by PC
9
+ * http://designwithpc.com/Plugins/ddslick
10
+ * Author: PC
11
+ */
12
+ (function(n){function i(n,t){var r=n.data("ddslick"),e=n.find(".dd-selected"),h=e.siblings(".dd-selected-value"),l=n.find(".dd-options"),a=e.siblings(".dd-pointer"),o=n.find(".dd-option").eq(t),c=o.closest("li"),f=r.settings,i=r.settings.data[t];n.find(".dd-option").removeClass("dd-option-selected"),o.addClass("dd-option-selected"),r.selectedIndex=t,r.selectedItem=c,r.selectedData=i,f.showSelectedHTML?e.html((i.imageSrc?'<img class="dd-selected-image'+(f.imagePosition=="right"?" dd-image-right":"")+'" src="'+i.imageSrc+'" />':"")+(i.text?'<label class="dd-selected-text">'+i.text+"<\/label>":"")+(i.description?'<small class="dd-selected-description dd-desc'+(f.truncateDescription?" dd-selected-description-truncated":"")+'" >'+i.description+"<\/small>":"")):e.html(i.text),h.val(i.value),r.original.val(i.value),n.data("ddslick",r),u(n),s(n),typeof f.onSelected=="function"&&f.onSelected.call(this,r)}function r(t){var r=t.find(".dd-select"),i=r.siblings(".dd-options"),u=r.find(".dd-pointer"),f=i.is(":visible");n(".dd-click-off-close").not(i).slideUp(50),n(".dd-pointer").removeClass("dd-pointer-up"),f?(i.slideUp("fast"),u.removeClass("dd-pointer-up")):(i.slideDown("fast"),u.addClass("dd-pointer-up")),h(t)}function u(n){n.find(".dd-options").slideUp(50),n.find(".dd-pointer").removeClass("dd-pointer-up").removeClass("dd-pointer-up")}function s(n){var t=n.find(".dd-select").css("height"),i=n.find(".dd-selected-description"),r=n.find(".dd-selected-image");i.length<=0&&r.length>0&&n.find(".dd-selected-text").css("lineHeight",t)}function h(t){t.find(".dd-option").each(function(){var i=n(this),r=i.css("height"),u=i.find(".dd-option-description"),f=t.find(".dd-option-image");u.length<=0&&f.length>0&&i.find(".dd-option-text").css("lineHeight",r)})}n.fn.ddslick=function(i){if(t[i])return t[i].apply(this,Array.prototype.slice.call(arguments,1));if(typeof i!="object"&&i)n.error("Method "+i+" does not exists.");else return t.init.apply(this,arguments)};var t={},f={data:[],keepJSONItemsOnTop:!1,width:260,height:null,background:"#eee",selectText:"",defaultSelectedIndex:null,truncateDescription:!0,imagePosition:"left",showSelectedHTML:!0,clickOffToClose:!0,onSelected:function(){}},e='<div class="dd-select"><input class="dd-selected-value" type="hidden" /><a class="dd-selected"><\/a><span class="dd-pointer dd-pointer-down"><\/span><\/div>',o='<ul class="dd-options"><\/ul>';t.init=function(t){var t=n.extend({},f,t);return this.each(function(){var u=n(this),v=u.data("ddslick"),y,c,h,f,s,l,a;if(!v){f=[],y=t.data,u.find("option").each(function(){var t=n(this),i=t.data();f.push({text:n.trim(t.text()),value:t.val(),selected:t.is(":selected"),description:i.description,imageSrc:i.imagesrc})}),t.keepJSONItemsOnTop?n.merge(t.data,f):t.data=n.merge(f,t.data),c=u,h=n('<div id="'+u.attr("id")+'"><\/div>'),u.replaceWith(h),u=h,u.addClass("dd-container").append(e).append(o),f=u.find(".dd-select"),s=u.find(".dd-options"),s.css({width:t.width}),f.css({width:t.width,background:t.background}),u.css({width:t.width}),t.height!=null&&s.css({height:t.height,overflow:"auto"}),n.each(t.data,function(n,i){i.selected&&(t.defaultSelectedIndex=n),s.append('<li><a class="dd-option">'+(i.value?' <input class="dd-option-value" type="hidden" value="'+i.value+'" />':"")+(i.imageSrc?' <img class="dd-option-image'+(t.imagePosition=="right"?" dd-image-right":"")+'" src="'+i.imageSrc+'" />':"")+(i.text?' <label class="dd-option-text">'+i.text+"<\/label>":"")+(i.description?' <small class="dd-option-description dd-desc">'+i.description+"<\/small>":"")+"<\/a><\/li>")}),l={settings:t,original:c,selectedIndex:-1,selectedItem:null,selectedData:null},u.data("ddslick",l),t.selectText.length>0&&t.defaultSelectedIndex==null?u.find(".dd-selected").html(t.selectText):(a=t.defaultSelectedIndex!=null&&t.defaultSelectedIndex>=0&&t.defaultSelectedIndex<t.data.length?t.defaultSelectedIndex:0,i(u,a));u.find(".dd-select").on("click.ddslick",function(){r(u)});u.find(".dd-option").on("click.ddslick",function(){i(u,n(this).closest("li").index())});if(t.clickOffToClose){s.addClass("dd-click-off-close");u.on("click.ddslick",function(n){n.stopPropagation()});n("body").on("click",function(){n(".dd-click-off-close").slideUp(50).siblings(".dd-select").find(".dd-pointer").removeClass("dd-pointer-up")})}}})},t.select=function(t){return this.each(function(){t.index!==null&&i(n(this),t.index)})},t.open=function(){return this.each(function(){var t=n(this),i=t.data("ddslick");i&&r(t)})},t.close=function(){return this.each(function(){var t=n(this),i=t.data("ddslick");i&&u(t)})},t.destroy=function(){return this.each(function(){var t=n(this),i=t.data("ddslick"),r;i&&(r=i.original,t.removeData("ddslick").unbind(".ddslick").replaceWith(r))})}})(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
14
  * Licensed under the MIT License (LICENSE.txt).
15
  *
17
  *
18
  * Requires: jQuery 1.2.2+
19
  */
20
+ (function(n){typeof define=="function"&&define.amd?define(["jquery"],n):typeof exports=="object"?module.exports=n:n(jQuery)})(function(n){function e(i){var r=i||window.event,y=h.call(arguments,1),o=0,e=0,f=0,l=0,a,v;if(i=n.event.fix(r),i.type="mousewheel","detail"in r&&(f=r.detail*-1),"wheelDelta"in r&&(f=r.wheelDelta),"wheelDeltaY"in r&&(f=r.wheelDeltaY),"wheelDeltaX"in r&&(e=r.wheelDeltaX*-1),"axis"in r&&r.axis===r.HORIZONTAL_AXIS&&(e=f*-1,f=0),o=f===0?e:f,"deltaY"in r&&(f=r.deltaY*-1,o=f),"deltaX"in r&&(e=r.deltaX,f===0&&(o=e*-1)),f!==0||e!==0)return r.deltaMode===1?(a=n.data(this,"mousewheel-line-height"),o*=a,f*=a,e*=a):r.deltaMode===2&&(v=n.data(this,"mousewheel-page-height"),o*=v,f*=v,e*=v),l=Math.max(Math.abs(f),Math.abs(e)),(!t||l<t)&&(t=l,s(r,l)&&(t/=40)),s(r,l)&&(o/=40,e/=40,f/=40),o=Math[o>=1?"floor":"ceil"](o/t),e=Math[e>=1?"floor":"ceil"](e/t),f=Math[f>=1?"floor":"ceil"](f/t),i.deltaX=e,i.deltaY=f,i.deltaFactor=t,i.deltaMode=0,y.unshift(i,o,e,f),u&&clearTimeout(u),u=setTimeout(c,200),(n.event.dispatch||n.event.handle).apply(this,y)}function c(){t=null}function s(n,t){return r.settings.adjustOldDeltas&&n.type==="mousewheel"&&t%120==0}var o=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],i="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],h=Array.prototype.slice,u,t,f,r;if(n.event.fixHooks)for(f=o.length;f;)n.event.fixHooks[o[--f]]=n.event.mouseHooks;r=n.event.special.mousewheel={version:"3.1.9",setup:function(){if(this.addEventListener)for(var t=i.length;t;)this.addEventListener(i[--t],e,!1);else this.onmousewheel=e;n.data(this,"mousewheel-line-height",r.getLineHeight(this)),n.data(this,"mousewheel-page-height",r.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var n=i.length;n;)this.removeEventListener(i[--n],e,!1);else this.onmousewheel=null},getLineHeight:function(t){return parseInt(n(t)["offsetParent"in n.fn?"offsetParent":"parent"]().css("fontSize"),10)},getPageHeight:function(t){return n(t).height()},settings:{adjustOldDeltas:!0}},n.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /*! Spectrum Colorpicker v1.3.2
22
  * License: MIT
23
  * Author: Brian Grinstead
24
  * https://github.com/bgrins/spectrum
25
  * Requires: jQuery
26
  */
27
+ (function(n,t,r){function h(n,t,i){for(var e=[],f,r,o,s,h,u=0;u<n.length;u++)f=n[u],f?(r=tinycolor(f),o=r.toHsl().l<.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light",o+=tinycolor.equals(t,f)?" sp-thumb-active":"",s=v?"background-color:"+r.toRgbString():"filter:"+r.toFilter(),e.push('<span title="'+r.toRgbString()+'" data-color="'+r.toRgbString()+'" class="'+o+'"><span class="sp-thumb-inner" style="'+s+';" /><\/span>')):(h="sp-clear-display",e.push('<span title="No Color Selected" data-color="" style="background-color:transparent;" class="'+h+'"><\/span>'));return"<div class='sp-cf "+i+"'>"+e.join("")+"<\/div>"}function b(){for(var n=0;n<u.length;n++)u[n]&&u[n].hide()}function k(n,i){var r=t.extend({},a,n);return r.callbacks={move:o(r.move,i),change:o(r.change,i),show:o(r.show,i),hide:o(r.hide,i),beforeShow:o(r.beforeShow,i)},r}function d(e,o){function nu(){var n,i,r;if(c.showPaletteOnly&&(c.showPalette=!0),c.palette)for(vi=c.palette.slice(0),ei=t.isArray(vi[0])?vi:[vi],yi={},n=0;n<ei.length;n++)for(i=0;i<ei[n].length;i++)r=tinycolor(ei[n][i]).toRgbString(),yi[r]=!0;l.toggleClass("sp-flat",ct),l.toggleClass("sp-input-disabled",!c.showInput),l.toggleClass("sp-alpha-enabled",c.showAlpha),l.toggleClass("sp-clear-enabled",at),l.toggleClass("sp-buttons-disabled",!c.showButtons),l.toggleClass("sp-palette-disabled",!c.showPalette),l.toggleClass("sp-palette-only",c.showPaletteOnly),l.toggleClass("sp-initial-disabled",!c.showInitial),l.addClass(c.className),ni()}function au(){function r(n){return n.data&&n.data.ignore?(vt(t(this).data("color")),dt()):(vt(t(this).data("color")),dt(),yt(!0),ht()),!1}var n,i;f&&l.find("*:not(input)").attr("unselectable","on"),nu(),ur&&a.after(bt).hide(),at||rr.hide(),ct?a.after(l).hide():(n=c.appendTo==="parent"?a.parent():t(c.appendTo),n.length!==1&&(n=t("body")),n.append(l)),tu(),si.bind("click.spectrum touchstart.spectrum",function(n){tr||uu(),n.stopPropagation(),t(n.target).is("input")||n.preventDefault()}),(a.is(":disabled")||c.disabled===!0)&&eu(),l.click(nt),et.change(hr),et.bind("paste",function(){setTimeout(hr,1)}),et.keydown(function(n){n.keyCode==13&&hr()}),dr.text(c.cancelText),dr.bind("click.spectrum",function(n){n.stopPropagation(),n.preventDefault(),ht("cancel")}),rr.attr("title",c.clearText),rr.bind("click.spectrum",function(n){n.stopPropagation(),n.preventDefault(),st=!0,dt(),ct&&yt(!0)}),gr.text(c.chooseText),gr.bind("click.spectrum",function(n){n.stopPropagation(),n.preventDefault(),pu()&&(yt(!0),ht())}),s(wr,function(n,t,i){it=n/nr,st=!1,i.shiftKey&&(it=Math.round(it*10)/10),dt()},or,sr),s(ir,function(n,t){ri=parseFloat(t/ai),st=!1,c.showAlpha||(it=1),dt()},or,sr),s(wi,function(n,t,i){var r,u;if(i.shiftKey){if(!ft){var f=ui*wt,e=ut-fi*ut,o=Math.abs(n-f)>Math.abs(t-e);ft=o?"x":"y"}}else ft=null;r=!ft||ft==="x",u=!ft||ft==="y",r&&(ui=parseFloat(n/wt)),u&&(fi=parseFloat((ut-t)/ut)),st=!1,c.showAlpha||(it=1),dt()},or,sr),hi?(vt(hi),gt(),ci=fr||tinycolor(hi).format,er(hi)):gt(),ct&&cr(),i=f?"mousedown.spectrum":"click.spectrum touchstart.spectrum",br.delegate(".sp-thumb-el",i,r),kr.delegate(".sp-thumb-el:nth-child(1)",i,{ignore:!0},r)}function tu(){if(pt&&n.localStorage){try{var i=n.localStorage[pt].split(",#");i.length>1&&(delete n.localStorage[pt],t.each(i,function(n,t){er(t)}))}catch(r){}try{rt=n.localStorage[pt].split(";")}catch(r){}}}function er(t){if(ou){var i=tinycolor(t).toRgbString();if(!yi[i]&&rt.indexOf(i)===-1)for(rt.push(i);rt.length>hu;)rt.shift();if(pt&&n.localStorage)try{n.localStorage[pt]=rt.join(";")}catch(r){}}}function vu(){var n=[],t;if(c.showPalette)for(i=0;i<rt.length;i++)t=tinycolor(rt[i]).toRgbString(),yi[t]||n.push(rt[i]);return n.reverse().slice(0,c.maxSelectionSize)}function iu(){var n=d(),i=t.map(ei,function(t,i){return h(t,n,"sp-palette-row sp-palette-row-"+i)});tu(),rt&&i.push(h(vu(),n,"sp-palette-row sp-palette-row-selection")),br.html(i.join(""))}function ru(){if(c.showInitial){var t=ot,n=d();kr.html(h([t,n],n,"sp-palette-row-initial"))}}function or(){(ut<=0||wt<=0||ai<=0)&&ni(),l.addClass(pr),ft=null,a.trigger("dragstart.spectrum",[d()])}function sr(){l.removeClass(pr),a.trigger("dragstop.spectrum",[d()])}function hr(){var n=et.val(),t;(n===null||n==="")&&at?(vt(null),yt(!0)):(t=tinycolor(n),t.ok?(vt(t),yt(!0)):et.addClass("sp-validation-error"))}function uu(){ii?ht():cr()}function cr(){var i=t.Event("beforeShow.spectrum");if(ii){ni();return}(a.trigger(i,[d()]),ti.beforeShow(d())===!1||i.isDefaultPrevented())||(b(),ii=!0,t(pi).bind("click.spectrum",ht),t(n).bind("resize.spectrum",ar),bt.addClass("sp-active"),l.removeClass("sp-hidden"),ni(),gt(),ot=d(),ru(),ti.show(ot),a.trigger("show.spectrum",[ot]))}function ht(i){if((!i||i.type!="click"||i.button!=2)&&ii&&!ct){ii=!1,t(pi).unbind("click.spectrum",ht),t(n).unbind("resize.spectrum",ar),bt.removeClass("sp-active"),l.addClass("sp-hidden");var r=!tinycolor.equals(d(),ot);r&&(lu&&i!=="cancel"?yt(!0):yu()),ti.hide(d()),a.trigger("hide.spectrum",[d()])}}function yu(){vt(ot,!0)}function vt(n,t){if(tinycolor.equals(n,d())){gt();return}var i,r;!n&&at?st=!0:(st=!1,i=tinycolor(n),r=i.toHsv(),ri=r.h%360/360,ui=r.s,fi=r.v,it=r.a),gt(),i&&i.ok&&!t&&(ci=fr||i.format)}function d(n){return(n=n||{},at&&st)?null:tinycolor.fromRatio({h:ri,s:ui,v:fi,a:Math.round(it*100)/100},{format:n.format||ci})}function pu(){return!et.hasClass("sp-validation-error")}function dt(){gt(),ti.move(d()),a.trigger("move.spectrum",[d()])}function gt(){var s,n,t,e,i,h,o,r,u;et.removeClass("sp-validation-error"),fu(),s=tinycolor.fromRatio({h:ri,s:1,v:1}),wi.css("background-color",s.toHexString()),n=ci,it<1&&!(it===0&&n==="name")&&(n==="hex"||n==="hex3"||n==="hex6"||n==="name")&&(n="rgb"),t=d({format:n}),e="",kt.removeClass("sp-clear-display"),kt.css("background-color","transparent"),!t&&at?kt.addClass("sp-clear-display"):(i=t.toHexString(),h=t.toRgbString(),v||t.alpha===1?kt.css("background-color",h):(kt.css("background-color","transparent"),kt.css("filter",t.toFilter())),c.showAlpha&&(o=t.toRgb(),o.a=0,r=tinycolor(o).toRgbString(),u="linear-gradient(left, "+r+", "+i+")",f?oi.css("filter",tinycolor(r).toFilter({gradientType:1},i)):(oi.css("background","-webkit-"+u),oi.css("background","-moz-"+u),oi.css("background","-ms-"+u),oi.css("background","linear-gradient(to right, "+r+", "+i+")"))),e=t.toString(n)),c.showInput&&et.val(e),c.showPalette&&iu(),ru()}function fu(){var u=ui,f=fi,n,t,i,r;at&&st?(di.hide(),ki.hide(),bi.hide()):(di.show(),ki.show(),bi.show(),n=u*wt,t=ut-f*ut,n=Math.max(-lt,Math.min(wt-lt,n-lt)),t=Math.max(-lt,Math.min(ut-lt,t-lt)),bi.css({top:t+"px",left:n+"px"}),i=it*nr,di.css({left:i-vr/2+"px"}),r=ri*ai,ki.css({top:r-yr+"px"}))}function yt(n){var t=d(),i="",r=!tinycolor.equals(t,ot);t&&(i=t.toString(ci),er(t)),gi&&a.val(i),ot=t,n&&r&&(ti.change(t),a.trigger("change",[t]))}function ni(){wt=wi.width(),ut=wi.height(),lt=bi.height(),su=ir.width(),ai=ir.height(),yr=ki.height(),nr=wr.width(),vr=di.width(),ct||(l.css("position","absolute"),l.offset(g(l,si))),fu(),c.showPalette&&iu(),a.trigger("reflow.spectrum")}function wu(){a.show(),si.unbind("click.spectrum touchstart.spectrum"),l.remove(),bt.remove(),u[li.id]=null}function bu(n,i){if(n===r)return t.extend({},c);if(i===r)return c[n];c[n]=i,nu()}function ku(){tr=!1,a.attr("disabled",!1),si.removeClass("sp-disabled")}function eu(){ht(),tr=!0,a.attr("disabled",!0),si.addClass("sp-disabled")}var c=k(o,e),ct=c.flat,ou=c.showSelectionPalette,pt=c.localStorageKey,lr=c.theme,ti=c.callbacks,ar=tt(ni,10),ii=!1,wt=0,ut=0,lt=0,ai=0,su=0,nr=0,vr=0,yr=0,ri=0,ui=0,fi=0,it=1,vi=[],ei=[],yi={},rt=c.selectionPalette.slice(0),hu=c.maxSelectionSize,pr="sp-dragging",ft=null,pi=e.ownerDocument,du=pi.body,a=t(e),tr=!1,l=t(w,pi).addClass(lr),wi=l.find(".sp-color"),bi=l.find(".sp-dragger"),ir=l.find(".sp-hue"),ki=l.find(".sp-slider"),oi=l.find(".sp-alpha-inner"),wr=l.find(".sp-alpha"),di=l.find(".sp-alpha-handle"),et=l.find(".sp-input"),br=l.find(".sp-palette"),kr=l.find(".sp-initial"),dr=l.find(".sp-cancel"),rr=l.find(".sp-clear"),gr=l.find(".sp-choose"),gi=a.is("input"),cu=gi&&y&&a.attr("type")==="color",ur=gi&&!ct,bt=ur?t(p).addClass(lr).addClass(c.className):t([]),si=ur?bt:a,kt=bt.find(".sp-preview-inner"),hi=c.color||gi&&a.val(),ot=!1,fr=c.preferredFormat,ci=fr,lu=!c.showButtons||c.clickoutFiresChange,st=!hi,at=c.allowEmpty&&!cu,li;return au(),li={show:cr,hide:ht,toggle:uu,reflow:ni,option:bu,enable:ku,disable:eu,set:function(n){vt(n),yt()},get:d,destroy:wu,container:l},li.id=u.push(li)-1,li}function g(n,i){var s=0,u=n.outerWidth(),f=n.outerHeight(),h=i.outerHeight(),e=n[0].ownerDocument,c=e.documentElement,o=c.clientWidth+t(e).scrollLeft(),l=c.clientHeight+t(e).scrollTop(),r=i.offset();return r.top+=h,r.left-=Math.min(r.left,r.left+u>o&&o>u?Math.abs(r.left+u-o):0),r.top-=Math.min(r.top,r.top+f>l&&l>f?Math.abs(f+h-s):s),r}function e(){}function nt(n){n.stopPropagation()}function o(n,t){var i=Array.prototype.slice,r=i.call(arguments,2);return function(){return n.apply(t,r.concat(i.call(arguments)))}}function s(i,r,u,e){function c(n){n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault(),n.returnValue=!1}function p(n){if(s){if(f&&document.documentMode<9&&!n.button)return w();var t=n.originalEvent.touches,u=t?t[0].pageX:n.pageX,e=t?t[0].pageY:n.pageY,o=Math.max(0,Math.min(u-l.left,v)),h=Math.max(0,Math.min(e-l.top,a));y&&c(n),r.apply(i,[o,h,n])}}function b(n){var r=n.which?n.which==3:n.button==2,f=n.originalEvent.touches;r||s||u.apply(i,arguments)!==!1&&(s=!0,a=t(i).height(),v=t(i).width(),l=t(i).offset(),t(h).bind(o),t(h.body).addClass("sp-dragging"),y||p(n),c(n))}function w(){s&&(t(h).unbind(o),t(h.body).removeClass("sp-dragging"),e.apply(i,arguments)),s=!1}r=r||function(){},u=u||function(){},e=e||function(){};var h=i.ownerDocument||document,s=!1,l={},a=0,v=0,y="ontouchstart"in n,o={};o.selectstart=c,o.dragstart=c,o["touchmove mousemove"]=p,o["touchend mouseup"]=w,t(i).bind("touchstart mousedown",b)}function tt(n,t,i){var r;return function(){var u=this,f=arguments,e=function(){r=null,n.apply(u,f)};i&&clearTimeout(r),(i||!r)&&(r=setTimeout(e,t))}}function c(){n.console&&(c=Function.prototype.bind?Function.prototype.bind.call(console.log,console):function(){Function.prototype.apply.call(console.log,console,arguments)},c.apply(this,arguments))}var a={beforeShow:e,move:e,change:e,show:e,hide:e,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!1,showInitial:!1,showPalette:!1,showPaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",clearText:"Clear Color Selection",preferredFormat:!1,className:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1},u=[],f=!!/msie/i.exec(n.navigator.userAgent),v=function(){function t(n,t){return!!~(""+n).indexOf(t)}var i=document.createElement("div"),n=i.style;return n.cssText="background-color:rgba(0,0,0,.5)",t(n.backgroundColor,"rgba")||t(n.backgroundColor,"hsla")}(),y=function(){var n=t("<input type='color' value='!' />")[0];return n.type==="color"&&n.value!=="!"}(),p="<div class='sp-replacer'><div class='sp-preview'><div class='sp-preview-inner'><\/div><\/div><div class='sp-dd'>&#9660;<\/div><\/div>",w=function(){var t="",n;if(f)for(n=1;n<=6;n++)t+="<div class='sp-"+n+"'><\/div>";return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'><\/div>","<\/div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'><\/div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'><\/div>","<\/div>","<\/div>","<\/div>","<div class='sp-clear sp-clear-display'>","<\/div>","<div class='sp-hue'>","<div class='sp-slider'><\/div>",t,"<\/div>","<\/div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'><\/div><\/div><\/div>","<\/div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false' />","<\/div>","<div class='sp-initial sp-thumb sp-cf'><\/div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'><\/a>","<button class='sp-choose'><\/button>","<\/div>","<\/div>","<\/div>"].join("")}(),l="spectrum.id";t.fn.spectrum=function(n){if(typeof n=="string"){var i=this,r=Array.prototype.slice.call(arguments,1);return this.each(function(){var f=u[t(this).data(l)],e;if(f){if(e=f[n],!e)throw new Error("Spectrum: no such method: '"+n+"'");n=="get"?i=f.get():n=="container"?i=f.container:n=="option"?i=f.option.apply(f,r):n=="destroy"?(f.destroy(),t(this).removeData(l)):e.apply(f,r)}}),i}return this.spectrum("destroy").each(function(){var i=t.extend({},n,t(this).data()),r=d(this,i);t(this).data(l,r.id)})},t.fn.spectrum.load=!0,t.fn.spectrum.loadOpts={},t.fn.spectrum.draggable=s,t.fn.spectrum.defaults=a,t.spectrum={},t.spectrum.localization={},t.spectrum.palettes={},t.fn.spectrum.processNativeColorInputs=function(){y||t("input[type=color]").spectrum({preferredFormat:"hex6"})},function(){function t(n,u){if(n=n?n:"",u=u||{},typeof n=="object"&&n.hasOwnProperty("_tc_id"))return n;var h=it(n),e=h.r,o=h.g,s=h.b,f=h.a,c=i(100*f)/100,l=u.format||h.format;return e<1&&(e=i(e)),o<1&&(o=i(o)),s<1&&(s=i(s)),{ok:h.ok,format:l,_tc_id:tt++,alpha:f,getAlpha:function(){return f},setAlpha:function(n){f=d(n),c=i(100*f)/100},toHsv:function(){var n=p(e,o,s);return{h:n.h*360,s:n.s,v:n.v,a:f}},toHsvString:function(){var n=p(e,o,s),t=i(n.h*360),r=i(n.s*100),u=i(n.v*100);return f==1?"hsv("+t+", "+r+"%, "+u+"%)":"hsva("+t+", "+r+"%, "+u+"%, "+c+")"},toHsl:function(){var n=y(e,o,s);return{h:n.h*360,s:n.s,l:n.l,a:f}},toHslString:function(){var n=y(e,o,s),t=i(n.h*360),r=i(n.s*100),u=i(n.l*100);return f==1?"hsl("+t+", "+r+"%, "+u+"%)":"hsla("+t+", "+r+"%, "+u+"%, "+c+")"},toHex:function(n){return w(e,o,s,n)},toHexString:function(n){return"#"+this.toHex(n)},toHex8:function(){return b(e,o,s,f)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:i(e),g:i(o),b:i(s),a:f}},toRgbString:function(){return f==1?"rgb("+i(e)+", "+i(o)+", "+i(s)+")":"rgba("+i(e)+", "+i(o)+", "+i(s)+", "+c+")"},toPercentageRgb:function(){return{r:i(r(e,255)*100)+"%",g:i(r(o,255)*100)+"%",b:i(r(s,255)*100)+"%",a:f}},toPercentageRgbString:function(){return f==1?"rgb("+i(r(e,255)*100)+"%, "+i(r(o,255)*100)+"%, "+i(r(s,255)*100)+"%)":"rgba("+i(r(e,255)*100)+"%, "+i(r(o,255)*100)+"%, "+i(r(s,255)*100)+"%, "+c+")"},toName:function(){return f===0?"transparent":k[w(e,o,s,!0)]||!1},toFilter:function(n){var i="#"+b(e,o,s,f),r=i,c=u&&u.gradientType?"GradientType = 1, ":"",h;return n&&(h=t(n),r=h.toHex8String()),"progid:DXImageTransform.Microsoft.gradient("+c+"startColorstr="+i+",endColorstr="+r+")"},toString:function(n){var i=!!n;n=n||this.format;var t=!1,r=!i&&f<1&&f>0,u=r&&(n==="hex"||n==="hex6"||n==="hex3"||n==="name");return(n==="rgb"&&(t=this.toRgbString()),n==="prgb"&&(t=this.toPercentageRgbString()),(n==="hex"||n==="hex6")&&(t=this.toHexString()),n==="hex3"&&(t=this.toHexString(!0)),n==="hex8"&&(t=this.toHex8String()),n==="name"&&(t=this.toName()),n==="hsl"&&(t=this.toHslString()),n==="hsv"&&(t=this.toHsvString()),u)?this.toRgbString():t||this.toHexString()}}}function it(n){var t={r:0,g:0,b:0},i=1,r=!1,u=!1;return typeof n=="string"&&(n=lt(n)),typeof n=="object"&&(n.hasOwnProperty("r")&&n.hasOwnProperty("g")&&n.hasOwnProperty("b")?(t=rt(n.r,n.g,n.b),r=!0,u=String(n.r).substr(-1)==="%"?"prgb":"rgb"):n.hasOwnProperty("h")&&n.hasOwnProperty("s")&&n.hasOwnProperty("v")?(n.s=c(n.s),n.v=c(n.v),t=ft(n.h,n.s,n.v),r=!0,u="hsv"):n.hasOwnProperty("h")&&n.hasOwnProperty("s")&&n.hasOwnProperty("l")&&(n.s=c(n.s),n.l=c(n.l),t=ut(n.h,n.s,n.l),r=!0,u="hsl"),n.hasOwnProperty("a")&&(i=n.a)),i=d(i),{ok:r,format:n.format||u,r:e(255,o(t.r,0)),g:e(255,o(t.g,0)),b:e(255,o(t.b,0)),a:i}}function rt(n,t,i){return{r:r(n,255)*255,g:r(t,255)*255,b:r(i,255)*255}}function y(n,t,i){var s;n=r(n,255),t=r(t,255),i=r(i,255);var u=o(n,t,i),h=e(n,t,i),f,c,l=(u+h)/2;if(u==h)f=c=0;else{s=u-h,c=l>.5?s/(2-u-h):s/(u+h);switch(u){case n:f=(t-i)/s+(t<i?6:0);break;case t:f=(i-n)/s+2;break;case i:f=(n-t)/s+4}f/=6}return{h:f,s:c,l:l}}function ut(n,t,i){function h(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n}var e,o,s,u,f;return n=r(n,360),t=r(t,100),i=r(i,100),t===0?e=o=s=i:(u=i<.5?i*(1+t):i+t-i*t,f=2*i-u,e=h(f,u,n+1/3),o=h(f,u,n),s=h(f,u,n-1/3)),{r:e*255,g:o*255,b:s*255}}function p(n,t,i){n=r(n,255),t=r(t,255),i=r(i,255);var u=o(n,t,i),h=e(n,t,i),f,c,l=u,s=u-h;if(c=u===0?0:s/u,u==h)f=0;else{switch(u){case n:f=(t-i)/s+(t<i?6:0);break;case t:f=(i-n)/s+2;break;case i:f=(n-t)/s+4}f/=6}return{h:f,s:c,v:l}}function ft(n,t,i){n=r(n,360)*6,t=r(t,100),i=r(i,100);var s=h.floor(n),c=n-s,u=i*(1-t),f=i*(1-c*t),e=i*(1-(1-c)*t),o=s%6,l=[i,f,u,u,e,i][o],a=[e,i,i,f,u,u][o],v=[u,u,e,i,i,f][o];return{r:l*255,g:a*255,b:v*255}}function w(n,t,r,u){var f=[s(i(n).toString(16)),s(i(t).toString(16)),s(i(r).toString(16))];return u&&f[0].charAt(0)==f[0].charAt(1)&&f[1].charAt(0)==f[1].charAt(1)&&f[2].charAt(0)==f[2].charAt(1)?f[0].charAt(0)+f[1].charAt(0)+f[2].charAt(0):f.join("")}function b(n,t,r,u){var f=[s(ht(u)),s(i(n).toString(16)),s(i(t).toString(16)),s(i(r).toString(16))];return f.join("")}function et(n){var i={},t;for(t in n)n.hasOwnProperty(t)&&(i[n[t]]=t);return i}function d(n){return n=parseFloat(n),(isNaN(n)||n<0||n>1)&&(n=1),n}function r(n,t){ot(n)&&(n="100%");var i=st(n);return(n=e(t,o(0,parseFloat(n))),i&&(n=parseInt(n*t,10)/100),h.abs(n-t)<1e-6)?1:n%t/parseFloat(t)}function a(n){return e(1,o(0,n))}function u(n){return parseInt(n,16)}function ot(n){return typeof n=="string"&&n.indexOf(".")!=-1&&parseFloat(n)===1}function st(n){return typeof n=="string"&&n.indexOf("%")!=-1}function s(n){return n.length==1?"0"+n:""+n}function c(n){return n<=1&&(n=n*100+"%"),n}function ht(n){return Math.round(parseFloat(n)*255).toString(16)}function ct(n){return u(n)/255}function lt(n){var i,t;if(n=n.replace(g,"").replace(nt,"").toLowerCase(),i=!1,l[n])n=l[n],i=!0;else if(n=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};return(t=f.rgb.exec(n))?{r:t[1],g:t[2],b:t[3]}:(t=f.rgba.exec(n))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=f.hsl.exec(n))?{h:t[1],s:t[2],l:t[3]}:(t=f.hsla.exec(n))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=f.hsv.exec(n))?{h:t[1],s:t[2],v:t[3]}:(t=f.hex8.exec(n))?{a:ct(t[1]),r:u(t[2]),g:u(t[3]),b:u(t[4]),format:i?"name":"hex8"}:(t=f.hex6.exec(n))?{r:u(t[1]),g:u(t[2]),b:u(t[3]),format:i?"name":"hex"}:(t=f.hex3.exec(n))?{r:u(t[1]+""+t[1]),g:u(t[2]+""+t[2]),b:u(t[3]+""+t[3]),format:i?"name":"hex"}:!1}var g=/^[\s,#]+/,nt=/\s+$/,tt=0,h=Math,i=h.round,e=h.min,o=h.max,v=h.random,l,k,f;t.fromRatio=function(n,i){var u,r;if(typeof n=="object"){u={};for(r in n)n.hasOwnProperty(r)&&(u[r]=r==="a"?n[r]:c(n[r]));n=u}return t(n,i)},t.equals=function(n,i){return!n||!i?!1:t(n).toRgbString()==t(i).toRgbString()},t.random=function(){return t.fromRatio({r:v(),g:v(),b:v()})},t.desaturate=function(n,i){i=i===0?0:i||10;var r=t(n).toHsl();return r.s-=i/100,r.s=a(r.s),t(r)},t.saturate=function(n,i){i=i===0?0:i||10;var r=t(n).toHsl();return r.s+=i/100,r.s=a(r.s),t(r)},t.greyscale=function(n){return t.desaturate(n,100)},t.lighten=function(n,i){i=i===0?0:i||10;var r=t(n).toHsl();return r.l+=i/100,r.l=a(r.l),t(r)},t.darken=function(n,i){i=i===0?0:i||10;var r=t(n).toHsl();return r.l-=i/100,r.l=a(r.l),t(r)},t.complement=function(n){var i=t(n).toHsl();return i.h=(i.h+180)%360,t(i)},t.triad=function(n){var i=t(n).toHsl(),r=i.h;return[t(n),t({h:(r+120)%360,s:i.s,l:i.l}),t({h:(r+240)%360,s:i.s,l:i.l})]},t.tetrad=function(n){var i=t(n).toHsl(),r=i.h;return[t(n),t({h:(r+90)%360,s:i.s,l:i.l}),t({h:(r+180)%360,s:i.s,l:i.l}),t({h:(r+270)%360,s:i.s,l:i.l})]},t.splitcomplement=function(n){var i=t(n).toHsl(),r=i.h;return[t(n),t({h:(r+72)%360,s:i.s,l:i.l}),t({h:(r+216)%360,s:i.s,l:i.l})]},t.analogous=function(n,i,r){i=i||6,r=r||30;var u=t(n).toHsl(),f=360/r,e=[t(n)];for(u.h=(u.h-(f*i>>1)+720)%360;--i;)u.h=(u.h+f)%360,e.push(t(u));return e},t.monochromatic=function(n,i){i=i||6;for(var r=t(n).toHsv(),e=r.h,o=r.s,u=r.v,f=[],s=1/i;i--;)f.push(t({h:e,s:o,v:u})),u=(u+s)%1;return f},t.readability=function(n,i){var r=t(n).toRgb(),u=t(i).toRgb(),f=(r.r*299+r.g*587+r.b*114)/1e3,e=(u.r*299+u.g*587+u.b*114)/1e3,o=Math.max(r.r,u.r)-Math.min(r.r,u.r)+Math.max(r.g,u.g)-Math.min(r.g,u.g)+Math.max(r.b,u.b)-Math.min(r.b,u.b);return{brightness:Math.abs(f-e),color:o}},t.readable=function(n,i){var r=t.readability(n,i);return r.brightness>125&&r.color>500},t.mostReadable=function(n,i){for(var h=null,o=0,u=!1,r=0;r<i.length;r++){var f=t.readability(n,i[r]),e=f.brightness>125&&f.color>500,s=3*(f.brightness/125)+f.color/500;(e&&!u||e&&u&&s>o||!e&&!u&&s>o)&&(u=e,o=s,h=t(i[r]))}return h},l=t.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},k=t.hexNames=et(l),f=function(){var n="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",t="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",i="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{rgb:new RegExp("rgb"+t),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+t),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+t),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}(),n.tinycolor=t}(),t(function(){t.fn.spectrum.load&&t.fn.spectrum.processNativeColorInputs()})})(window,jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /*!
29
  * @overview CodeMirror version 3.22
30
  * http://codemirror.net/
31
  */
32
+ window.CodeMirror=function(){"use strict";function n(t,i){var r,o,f,u,s;if(!(this instanceof n))return new n(t,i);this.options=i=i||{};for(r in gf)!i.hasOwnProperty(r)&&gf.hasOwnProperty(r)&&(i[r]=gf[r]);ke(i),o=typeof i.value=="string"?0:i.value.first,f=this.display=iv(t,o),f.wrapper.CodeMirror=this,sh(this),i.autofocus&&!ve&&d(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new bs},oh(this),i.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),u=i.value,typeof u=="string"&&(u=new w(i.value,i.mode)),e(this,wl)(this,u),st&&setTimeout(ut(ht,this,!0),20),gv(this);try{s=document.activeElement==f.input}catch(h){}s||i.autofocus&&!ve?setTimeout(ut(yo,this),20):po(this),e(this,function(){var n,t;for(n in ci)ci.propertyIsEnumerable(n)&&ci[n](this,i[n],is);for(t=0;t<ne.length;++t)ne[t](this)})()}function iv(n,t){var r={},u=r.input=i("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");return y?u.style.width="1000px":u.setAttribute("wrap","off"),cr&&(u.style.border="1px solid black"),u.setAttribute("autocorrect","off"),u.setAttribute("autocapitalize","off"),u.setAttribute("spellcheck","false"),r.inputDiv=i("div",[u],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),r.scrollbarH=i("div",[i("div",null,null,"height: 1px")],"CodeMirror-hscrollbar"),r.scrollbarV=i("div",[i("div",null,null,"width: 1px")],"CodeMirror-vscrollbar"),r.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler"),r.gutterFiller=i("div",null,"CodeMirror-gutter-filler"),r.lineDiv=i("div",null,"CodeMirror-code"),r.selectionDiv=i("div",null,null,"position: relative; z-index: 1"),r.cursor=i("div"," ","CodeMirror-cursor"),r.otherCursor=i("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"),r.measure=i("div",null,"CodeMirror-measure"),r.lineSpace=i("div",[r.measure,r.selectionDiv,r.lineDiv,r.cursor,r.otherCursor],null,"position: relative; outline: none"),r.mover=i("div",[i("div",[r.lineSpace],"CodeMirror-lines")],null,"position: relative"),r.sizer=i("div",[r.mover],"CodeMirror-sizer"),r.heightForcer=i("div",null,null,"position: absolute; height: "+ai+"px; width: 1px;"),r.gutters=i("div",null,"CodeMirror-gutters"),r.lineGutter=null,r.scroller=i("div",[r.sizer,r.heightForcer,r.gutters],"CodeMirror-scroll"),r.scroller.setAttribute("tabIndex","-1"),r.wrapper=i("div",[r.inputDiv,r.scrollbarH,r.scrollbarV,r.scrollbarFiller,r.gutterFiller,r.scroller],"CodeMirror"),yi&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),n.appendChild?n.appendChild(r.wrapper):n(r.wrapper),cr&&(u.style.width="0px"),y||(r.scroller.draggable=!0),ae?(r.inputDiv.style.height="1px",r.inputDiv.style.position="absolute"):yi&&(r.scrollbarH.style.minWidth=r.scrollbarV.style.minWidth="18px"),r.viewOffset=r.lastSizeC=0,r.showingFrom=r.showingTo=t,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.prevInput="",r.alignWidgets=!1,r.pollingFast=!1,r.poll=new bs,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null,r.measureLineCache=[],r.measureLineCachePos=0,r.inaccurateSelection=!1,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r}function pe(t){t.doc.mode=n.getMode(t.options,t.doc.modeOption),lr(t)}function lr(n){n.doc.iter(function(n){n.stateAfter&&(n.stateAfter=null),n.styles&&(n.styles=null)}),n.doc.frontier=n.doc.first,vr(n,100),n.state.modeGen++,n.curOp&&a(n)}function rv(n){n.options.lineWrapping?(n.display.wrapper.className+=" CodeMirror-wrap",n.display.sizer.style.minWidth=""):(n.display.wrapper.className=n.display.wrapper.className.replace(" CodeMirror-wrap",""),be(n)),we(n),a(n),bi(n),setTimeout(function(){de(n)},100)}function fh(n){var t=oi(n.display),i=n.options.lineWrapping,r=i&&Math.max(5,n.display.scroller.clientWidth/wh(n.display)-3);return function(u){return li(n.doc,u)?0:i?(Math.ceil(u.text.length/r)||1)*t:t}}function we(n){var t=n.doc,i=fh(n);t.iter(function(n){var t=i(n);t!=n.height&&et(n,t)})}function eh(n){var i=ct[n.options.keyMap],t=i.style;n.display.wrapper.className=n.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(t?" cm-keymap-"+t:"")}function oh(n){n.display.wrapper.className=n.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+n.options.theme.replace(/(^|\s)\s*/g," cm-s-"),bi(n)}function ar(n){sh(n),a(n),setTimeout(function(){no(n)},20)}function sh(n){var r=n.display.gutters,e=n.options.gutters,t,u,f;for(bu(r),t=0;t<e.length;++t)u=e[t],f=r.appendChild(i("div",null,"CodeMirror-gutter "+u)),u=="CodeMirror-linenumbers"&&(n.display.lineGutter=f,f.style.width=(n.display.lineNumWidth||1)+"px");r.style.display=t?"":"none"}function rf(n,t){var f,e,u,i;if(t.height==0)return 0;for(f=t.text.length,u=t;e=es(u);)i=e.find(),u=r(n,i.from.line),f+=i.from.ch-i.to.ch;for(u=t;e=te(u);)i=e.find(),f-=u.text.length-i.from.ch,u=r(n,i.to.line),f+=u.text.length-i.to.ch;return f}function be(n){var t=n.display,i=n.doc;t.maxLine=r(i,i.first),t.maxLineLength=rf(i,t.maxLine),t.maxLineChanged=!0,i.iter(function(n){var r=rf(i,n);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=n)})}function ke(n){var t=ot(n.gutters,"CodeMirror-linenumbers");t==-1&&n.lineNumbers?n.gutters=n.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!n.lineNumbers&&(n.gutters=n.gutters.slice(0),n.gutters.splice(t,1))}function de(n){var t=n.display,e=n.doc.height,r=e+lh(t);t.sizer.style.minHeight=t.heightForcer.style.top=r+"px",t.gutters.style.height=Math.max(r,t.scroller.clientHeight-ai)+"px";var f=Math.max(r,t.scroller.scrollHeight),i=t.scroller.scrollWidth>t.scroller.clientWidth+1,u=f>t.scroller.clientHeight+1;u?(t.scrollbarV.style.display="block",t.scrollbarV.style.bottom=i?gu(t.measure)+"px":"0",t.scrollbarV.firstChild.style.height=Math.max(0,f-t.scroller.clientHeight+t.scrollbarV.clientHeight)+"px"):(t.scrollbarV.style.display="",t.scrollbarV.firstChild.style.height="0"),i?(t.scrollbarH.style.display="block",t.scrollbarH.style.right=u?gu(t.measure)+"px":"0",t.scrollbarH.firstChild.style.width=t.scroller.scrollWidth-t.scroller.clientWidth+t.scrollbarH.clientWidth+"px"):(t.scrollbarH.style.display="",t.scrollbarH.firstChild.style.width="0"),i&&u?(t.scrollbarFiller.style.display="block",t.scrollbarFiller.style.height=t.scrollbarFiller.style.width=gu(t.measure)+"px"):t.scrollbarFiller.style.display="",i&&n.options.coverGutterNextToScrollbar&&n.options.fixedGutter?(t.gutterFiller.style.display="block",t.gutterFiller.style.height=gu(t.measure)+"px",t.gutterFiller.style.width=t.gutters.offsetWidth+"px"):t.gutterFiller.style.display="",da&&gu(t.measure)===0&&(t.scrollbarV.style.minWidth=t.scrollbarH.style.minHeight=ga?"18px":"12px",t.scrollbarV.style.pointerEvents=t.scrollbarH.style.pointerEvents="none")}function ge(n,t,i){var r=n.scroller.scrollTop,u=n.wrapper.clientHeight,f;return typeof i=="number"?r=i:i&&(r=i.top,u=i.bottom-i.top),r=Math.floor(r-ch(n)),f=Math.ceil(r+u),{from:cu(t,r),to:cu(t,f)}}function no(n){var t=n.display,i,r,u;if(t.alignWidgets||t.gutters.firstChild&&n.options.fixedGutter){var f=io(t)-t.scroller.scrollLeft+n.doc.scrollLeft,e=t.gutters.offsetWidth,o=f+"px";for(i=t.lineDiv.firstChild;i;i=i.nextSibling)if(i.alignable)for(r=0,u=i.alignable;r<u.length;++r)u[r].style.left=o;n.options.fixedGutter&&(t.gutters.style.left=f+e+"px")}}function uv(n){if(!n.options.lineNumbers)return!1;var u=n.doc,r=to(n.options,u.first+u.size-1),t=n.display;if(r.length!=t.lineNumChars){var f=t.measure.appendChild(i("div",[i("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),e=f.firstChild.offsetWidth,o=f.offsetWidth-e;return t.lineGutter.style.width="",t.lineNumInnerWidth=Math.max(e,t.lineGutter.offsetWidth-o),t.lineNumWidth=t.lineNumInnerWidth+o,t.lineNumChars=t.lineNumInnerWidth?r.length:-1,t.lineGutter.style.width=t.lineNumWidth+"px",!0}return!1}function to(n,t){return String(n.lineNumberFormatter(t+n.firstLineNumber))}function io(n){return c(n.scroller).left-c(n.sizer).left}function uf(n,t,i,r){for(var s=n.display.showingFrom,h=n.display.showingTo,f,u=ge(n.display,n.doc,i),o,e=!0;;e=!1){if(o=n.display.scroller.clientWidth,!fv(n,t,u,r))break;if(f=!0,t=[],uo(n),de(n),e&&n.options.lineWrapping&&o!=n.display.scroller.clientWidth){r=!0;continue}if(r=!1,i&&(i=Math.min(n.display.scroller.scrollHeight-n.display.scroller.clientHeight,typeof i=="number"?i:i.top)),u=ge(n.display,n.doc,i),u.from>=n.display.showingFrom&&u.to<=n.display.showingTo)break}return f&&(g(n,"update",n),(n.display.showingFrom!=s||n.display.showingTo!=h)&&g(n,"viewportChange",n,n.display.showingFrom,n.display.showingTo)),f}function fv(n,t,i,u){var f=n.display,o=n.doc,b,v,l,k,w,p,e,h,a,d;if(!f.wrapper.offsetWidth){f.showingFrom=f.showingTo=o.first,f.viewOffset=0;return}if(u||t.length!=0||!(i.from>f.showingFrom)||!(i.to<f.showingTo)){if(uv(n)&&(t=[{from:o.first,to:o.first+o.size}]),b=f.sizer.style.marginLeft=f.gutters.offsetWidth+"px",f.scrollbarH.style.left=n.options.fixedGutter?b:"0",v=Infinity,n.options.lineNumbers)for(e=0;e<t.length;++e)t[e].diff&&t[e].from<v&&(v=t[e].from);var y=o.first+o.size,c=Math.max(i.from-n.options.viewportMargin,o.first),s=Math.min(y,i.to+n.options.viewportMargin);if(f.showingFrom<c&&c-f.showingFrom<20&&(c=Math.max(o.first,f.showingFrom)),f.showingTo>s&&f.showingTo-s<20&&(s=Math.min(y,f.showingTo)),wi)for(c=tt(wt(o,r(o,c)));s<y&&li(o,r(o,s));)++s;if(l=[{from:Math.max(f.showingFrom,o.first),to:Math.min(f.showingTo,y)}],l=l[0].from>=l[0].to?[]:ov(l,t),wi)for(e=0;e<l.length;++e)for(h=l[e];k=te(r(o,h.to-1));)if(w=k.find().from.line,w>h.from)h.to=w;else{l.splice(e--,1);break}for(p=0,e=0;e<l.length;++e)h=l[e],h.from<c&&(h.from=c),h.to>s&&(h.to=s),h.from>=h.to?l.splice(e--,1):p+=h.to-h.from;if(!u&&p==s-c&&c==f.showingFrom&&s==f.showingTo){hh(n);return}l.sort(function(n,t){return n.from-t.from});try{a=document.activeElement}catch(g){}return p<(s-c)*.7&&(f.lineDiv.style.display="none"),hv(n,c,s,l,v),f.lineDiv.style.display="",a&&document.activeElement!=a&&a.offsetHeight&&a.focus(),d=c!=f.showingFrom||s!=f.showingTo||f.lastSizeC!=f.wrapper.clientHeight,d&&(f.lastSizeC=f.wrapper.clientHeight,vr(n,400)),f.showingFrom=c,f.showingTo=s,f.gutters.style.height="",ev(n),hh(n),!0}}function ev(n){for(var f=n.display,h=f.lineDiv.offsetTop,i,e,o,s,r,u,t=f.lineDiv.firstChild;t;t=t.nextSibling)if(t.lineObj&&(yi?(e=t.offsetTop+t.offsetHeight,i=e-h,h=e):(o=c(t),i=o.bottom-o.top),s=t.lineObj.height-i,i<2&&(i=oi(f)),(s>.001||s<-.001)&&(et(t.lineObj,i),r=t.lineObj.widgets,r)))for(u=0;u<r.length;++u)r[u].height=r[u].node.offsetHeight}function hh(n){var t=n.display.viewOffset=lu(n,r(n.doc,n.display.showingFrom));n.display.mover.style.top=t+"px"}function ov(n,t){for(var o,h,i,f=0,s=t.length||0;f<s;++f){var r=t[f],u=[],e=r.diff||0;for(o=0,h=n.length;o<h;++o)i=n[o],r.to<=i.from&&r.diff?u.push({from:i.from+e,to:i.to+e}):r.to<=i.from||r.from>=i.to?u.push(i):(r.from>i.from&&u.push({from:i.from,to:r.from}),r.to<i.to&&u.push({from:r.to+e,to:i.to+e}));n=u}return n}function sv(n){for(var i=n.display,u={},f={},t=i.gutters.firstChild,r=0;t;t=t.nextSibling,++r)u[n.options.gutters[r]]=t.offsetLeft,f[n.options.gutters[r]]=t.offsetWidth;return{fixedPos:io(i),gutterTotalWidth:i.gutters.offsetWidth,gutterLeft:u,gutterWidth:f,wrapperWidth:i.wrapper.clientWidth}}function hv(n,t,r,u,f){function c(t){var i=t.nextSibling;return y&&pi&&n.display.currentWheelTarget==t?(t.style.display="none",t.lineObj=null):t.parentNode.removeChild(t),i}var l=sv(n),a=n.display,v=n.options.lineNumbers,h,e,s,o;for(u.length||y&&n.display.currentWheelTarget||bu(a.lineDiv),h=a.lineDiv,e=h.firstChild,s=u.shift(),o=t,n.doc.iter(t,r,function(t){var p,y,r,w,d,g,a,b,k;if(s&&s.to==o&&(s=u.shift()),li(n.doc,t)){if(t.height!=0&&et(t,0),t.widgets&&e&&e.previousSibling)for(p=0;p<t.widgets.length;++p)y=t.widgets[p],y.showIfHidden&&(r=e.previousSibling,/pre/i.test(r.nodeName)&&(w=i("div",null,null,"position: relative"),r.parentNode.replaceChild(w,r),w.appendChild(r),r=w),d=r.appendChild(i("div",[y.node],"CodeMirror-linewidget")),y.handleMouseEvents||(d.ignoreEvents=!0),ro(y,d,r,l))}else if(s&&s.from<=o&&s.to>o){while(e.lineObj!=t)e=c(e);v&&f<=o&&e.lineNumber&&ha(e.lineNumber,to(n.options,o)),e=e.nextSibling}else{if(t.widgets)for(g=0,a=e;a&&g<20;++g,a=a.nextSibling)if(a.lineObj==t&&/div/i.test(a.nodeName)){b=a;break}if(k=cv(n,t,o,l,b),k!=b)h.insertBefore(k,e);else{while(e!=b)e=c(e);e=e.nextSibling}k.lineObj=t}++o});e;)e=c(e)}function cv(n,t,r,u,f){var w=hs(n,t),l=w.pre,c=t.gutterMarkers,ut=n.display,e,b=w.bgClass?w.bgClass+" "+(t.bgClass||""):t.bgClass,h,rt,a,p,v,d,s,nt,o,y;if(!n.options.lineNumbers&&!c&&!b&&!t.wrapClass&&!t.widgets)return l;if(f){f.alignable=null;var tt=!0,it=0,k=null;for(h=f.firstChild;h;h=rt)if(rt=h.nextSibling,/\bCodeMirror-linewidget\b/.test(h.className)){for(s=0;s<t.widgets.length;++s)if(o=t.widgets[s],o.node==h.firstChild){o.above||k||(k=h),ro(o,h,f,u),++it;break}if(s==t.widgets.length){tt=!1;break}}else f.removeChild(h);f.insertBefore(l,k),tt&&it==t.widgets.length&&(e=f,f.className=t.wrapClass||"")}if(e||(e=i("div",null,t.wrapClass,"position: relative"),e.appendChild(l)),b&&e.insertBefore(i("div",null,b+" CodeMirror-linebackground"),e.firstChild),(n.options.lineNumbers||c)&&(a=e.insertBefore(i("div",null,"CodeMirror-gutter-wrapper","position: absolute; left: "+(n.options.fixedGutter?u.fixedPos:-u.gutterTotalWidth)+"px"),l),n.options.fixedGutter&&(e.alignable||(e.alignable=[])).push(a),!n.options.lineNumbers||c&&c["CodeMirror-linenumbers"]||(e.lineNumber=a.appendChild(i("div",to(n.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+u.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+ut.lineNumInnerWidth+"px"))),c))for(p=0;p<n.options.gutters.length;++p)v=n.options.gutters[p],d=c.hasOwnProperty(v)&&c[v],d&&a.appendChild(i("div",[d],"CodeMirror-gutter-elt","left: "+u.gutterLeft[v]+"px; width: "+u.gutterWidth[v]+"px"));if(yi&&(e.style.zIndex=2),t.widgets&&e!=f)for(s=0,nt=t.widgets;s<nt.length;++s)o=nt[s],y=i("div",[o.node],"CodeMirror-linewidget"),o.handleMouseEvents||(y.ignoreEvents=!0),ro(o,y,e,u),o.above?e.insertBefore(y,n.options.lineNumbers&&t.height!=0?a:l):e.appendChild(y),g(o,"redraw");return e}function ro(n,t,i,r){if(n.noHScroll){(i.alignable||(i.alignable=[])).push(t);var u=r.wrapperWidth;t.style.left=r.fixedPos+"px",n.coverGutter||(u-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=u+"px"}n.coverGutter&&(t.style.zIndex=5,t.style.position="relative",n.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function uo(n){var t=n.display,i=s(n.doc.sel.from,n.doc.sel.to);if(i||n.options.showCursorWhenSelecting?lv(n):t.cursor.style.display=t.otherCursor.style.display="none",i?t.selectionDiv.style.display="none":av(n),n.options.moveInputWithCursor){var r=it(n,n.doc.sel.head,"div"),u=c(t.wrapper),f=c(t.lineDiv);t.inputDiv.style.top=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+f.top-u.top))+"px",t.inputDiv.style.left=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+f.left-u.left))+"px"}}function lv(n){var t=n.display,i=it(n,n.doc.sel.head,"div");t.cursor.style.left=i.left+"px",t.cursor.style.top=i.top+"px",t.cursor.style.height=Math.max(0,i.bottom-i.top)*n.options.cursorHeight+"px",t.cursor.style.display="",i.other?(t.otherCursor.style.display="",t.otherCursor.style.left=i.other.left+"px",t.otherCursor.style.top=i.other.top+"px",t.otherCursor.style.height=(i.other.bottom-i.other.top)*.85+"px"):t.otherCursor.style.display="none"}function av(n){function e(n,t,r,u){t<0&&(t=0),v.appendChild(i("div",null,"CodeMirror-selected","position: absolute; left: "+n+"px; top: "+t+"px; width: "+(r==null?p-n:r)+"px; height: "+(u-t)+"px"))}function l(i,u,f){function v(r,u){return so(n,t(i,r),"div",l,u)}var l=r(h,i),a=l.text.length,o,c;return op(lt(l),u||0,f==null?a:f,function(n,t,i){var r=v(n,"left"),h,l,y,w;n==t?(h=r,l=y=r.left):(h=v(t-1,"right"),i=="rtl"&&(w=r,r=h,h=w),l=r.left,y=h.right),u==null&&n==0&&(l=s),h.top-r.top>3&&(e(l,r.top,null,r.bottom),l=s,r.bottom<h.top&&e(l,r.bottom,null,h.top)),f==null&&t==a&&(y=p),(!o||r.top<o.top||r.top==o.top&&r.left<o.left)&&(o=r),(!c||h.bottom>c.bottom||h.bottom==c.bottom&&h.right>c.right)&&(c=h),l<s+1&&(l=s),e(l,h.top,y-l,h.bottom)}),{start:o,end:c}}var c=n.display,h=n.doc,u=n.doc.sel,v=document.createDocumentFragment(),y=pv(n.display),s=y.left,p=c.lineSpace.offsetWidth-y.right;if(u.from.line==u.to.line)l(u.from.line,u.from.ch,u.to.ch);else{var w=r(h,u.from.line),b=r(h,u.to.line),a=wt(h,w)==wt(h,b),f=l(u.from.line,u.from.ch,a?w.text.length:null).end,o=l(u.to.line,a?0:null,u.to.ch).start;a&&(f.top<o.top-2?(e(f.right,f.top,null,f.bottom),e(s,o.top,o.left,o.bottom)):e(f.right,f.top,o.left-f.right,f.bottom)),f.bottom<o.top&&e(s,f.bottom,null,o.top)}yt(c.selectionDiv,v),c.selectionDiv.style.display=""}function ff(n){var t,i;n.state.focused&&(t=n.display,clearInterval(t.blinker),i=!0,t.cursor.style.visibility=t.otherCursor.style.visibility="",n.options.cursorBlinkRate>0&&(t.blinker=setInterval(function(){t.cursor.style.visibility=t.otherCursor.style.visibility=(i=!i)?"":"hidden"},n.options.cursorBlinkRate)))}function vr(n,t){n.doc.mode.startState&&n.doc.frontier<n.display.showingTo&&n.state.highlight.set(t,ut(vv,n))}function vv(n){var t=n.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=n.display.showingTo)){var f=+new Date+n.options.workTime,r=fr(t.mode,yr(n,t.frontier)),i=[],u;t.iter(t.frontier,Math.min(t.first+t.size,n.display.showingTo+500),function(e){var o,h,s;if(t.frontier>=n.display.showingFrom){for(o=e.styles,e.styles=ol(n,e,r,!0),h=!o||o.length!=e.styles.length,s=0;!h&&s<o.length;++s)h=o[s]!=e.styles[s];h&&(u&&u.end==t.frontier?u.end++:i.push(u={start:t.frontier,end:t.frontier+1})),e.stateAfter=fr(t.mode,r)}else ss(n,e.text,r),e.stateAfter=t.frontier%5==0?fr(t.mode,r):null;return++t.frontier,+new Date>f?(vr(n,n.options.workDelay),!0):void 0}),i.length&&e(n,function(){for(var n=0;n<i.length;++n)a(this,i[n].start,i[n].end)})()}}function yv(n,t,i){for(var h,e,f=n.doc,c=i?-1:t-(n.doc.mode.innerMode?1e3:100),o,s,u=t;u>c;--u){if(u<=f.first)return f.first;if(o=r(f,u-1),o.stateAfter&&(!i||u<=f.frontier))return u;s=ii(o.text,null,n.options.tabSize),(e==null||h>s)&&(e=u-1,h=s)}return e}function yr(n,t,i){var f=n.doc,o=n.display,u,e;return f.mode.startState?(u=yv(n,t,i),e=u>f.first&&r(f,u-1).stateAfter,e=e?fr(f.mode,e):pc(f.mode),f.iter(u,t,function(i){ss(n,i.text,e);var r=u==t-1||u%5==0||u>=o.showingFrom&&u<o.showingTo;i.stateAfter=r?fr(f.mode,e):null,++u}),i&&(f.frontier=u),e):!0}function ch(n){return n.lineSpace.offsetTop}function lh(n){return n.mover.offsetHeight-n.lineSpace.offsetHeight}function pv(n){if(n.cachedPaddingH)return n.cachedPaddingH;var t=yt(n.measure,i("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle;return n.cachedPaddingH={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)}}function pr(n,t,i,r,u){var o=-1,s,e,f;if(r=r||eo(n,t),r.crude)return s=r.left+i*r.width,{left:s,right:s+r.width,top:r.top,bottom:r.bottom};for(e=i;;e+=o){if(f=r[e],f)break;o<0&&e==0&&(o=1)}return u=e>i?"left":e<i?"right":u,u=="left"&&f.leftSide?f=f.leftSide:u=="right"&&f.rightSide&&(f=f.rightSide),{left:e<i?f.right:f.left,right:e>i?f.left:f.right,top:f.top,bottom:f.bottom}}function fo(n,t){for(var u=n.display.measureLineCache,i,r=0;r<u.length;++r)if(i=u[r],i.text==t.text&&i.markedSpans==t.markedSpans&&n.display.scroller.clientWidth==i.width&&i.classes==t.textClass+"|"+t.wrapClass)return i}function wv(n,t){var i=fo(n,t);i&&(i.text=i.measure=i.markedSpans=null)}function eo(n,t){var r=fo(n,t);if(r)return r.measure;var u=ah(n,t),i=n.display.measureLineCache,f={text:t.text,width:n.display.scroller.clientWidth,markedSpans:t.markedSpans,measure:u,classes:t.textClass+"|"+t.wrapClass};return i.length==16?i[++n.display.measureLineCachePos%16]=f:i.push(f),u}function ah(n,t){function v(n){var i=n.top-s.top,r=n.bottom-s.top,t,u,e;for(r>rt&&(r=rt),i<0&&(i=0),t=f.length-2;t>=0;t-=2)if((u=f[t],e=f[t+1],!(u>r)&&!(e<i))&&(u<=i&&e>=r||i<=u&&r>=e||Math.min(r,e)-Math.max(i,u)>=r-i>>1)){f[t]=Math.min(i,u),f[t+1]=Math.max(r,e);break}return t<0&&(t=f.length,f.push(i,r)),{left:n.left-s.left,right:n.right-s.left,top:t,bottom:null}}function g(n){n.bottom=f[n.top+1],n.top=f[n.top]}var it,k,d,y,o,l,u,r;if(!n.options.lineWrapping&&t.text.length>=n.options.crudeMeasuringFrom)return bv(n,t);var a=n.display,p=fa(t.text.length),e=hs(n,t,p,!0).pre;if(st&&!yi&&!n.options.lineWrapping&&e.childNodes.length>100){var nt=document.createDocumentFragment(),tt=10,w=e.childNodes.length;for(u=0,it=Math.ceil(w/tt);u<it;++u){for(k=i("div",null,null,"display: inline-block"),d=0;d<tt&&w;++d)k.appendChild(e.firstChild),--w;nt.appendChild(k)}e.appendChild(nt)}yt(a.measure,e);var s=c(a.lineDiv),f=[],h=fa(t.text.length),rt=e.offsetHeight;for(b&&a.measure.first!=e&&yt(a.measure,e),u=0;u<p.length;++u)(r=p[u])&&(y=r,o=null,/\bCodeMirror-widget\b/.test(r.className)&&r.getClientRects&&(r.firstChild.nodeType==1&&(y=r.firstChild),l=y.getClientRects(),l.length>1&&(o=h[u]=v(l[0]),o.rightSide=v(l[l.length-1]))),o||(o=h[u]=v(c(y))),r.measureRight&&(o.right=c(r.measureRight).left-s.left),r.leftSide&&(o.leftSide=v(c(r.leftSide))));for(bu(n.display.measure),u=0;u<h.length;++u)(r=h[u])&&(g(r),r.leftSide&&g(r.leftSide),r.rightSide&&g(r.rightSide));return h}function bv(n,t){var i=new bt(t.text.slice(0,100),null);t.textClass&&(i.textClass=t.textClass);var u=ah(n,i),r=pr(n,i,0,u,"left"),f=pr(n,i,99,u,"right");return{crude:!0,top:r.top,left:r.left,bottom:r.bottom,width:(f.right-r.left)/100}}function kv(n,t){var e=!1,i,r,u,f,o;if(t.markedSpans)for(i=0;i<t.markedSpans;++i)r=t.markedSpans[i],r.collapsed&&(r.to==null||r.to==t.text.length)&&(e=!0);return(u=!e&&fo(n,t),u||t.text.length>=n.options.crudeMeasuringFrom)?pr(n,t,t.text.length,u&&u.measure,"right").right:(f=hs(n,t,null,!0).pre,o=f.appendChild(nf(n.display.measure)),yt(n.display.measure,f),c(o).right-c(n.display.lineDiv).left)}function bi(n){n.display.measureLineCache.length=n.display.measureLineCachePos=0,n.display.cachedCharWidth=n.display.cachedTextHeight=n.display.cachedPaddingH=null,n.options.lineWrapping||(n.display.maxLineChanged=!0),n.display.lineNumChars=null}function vh(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function yh(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function oo(n,t,i,r){var f,e,u,o,s;if(t.widgets)for(f=0;f<t.widgets.length;++f)t.widgets[f].above&&(e=ie(t.widgets[f]),i.top+=e,i.bottom+=e);return r=="line"?i:(r||(r="local"),u=lu(n,t),r=="local"?u+=ch(n.display):u-=n.display.viewOffset,(r=="page"||r=="window")&&(o=c(n.display.lineSpace),u+=o.top+(r=="window"?0:yh()),s=o.left+(r=="window"?0:vh()),i.left+=s,i.right+=s),i.top+=u,i.bottom+=u,i)}function ph(n,t,i){var r,u,f,e;return i=="div"?t:(r=t.left,u=t.top,i=="page"?(r-=vh(),u-=yh()):i!="local"&&i||(f=c(n.display.sizer),r+=f.left,u+=f.top),e=c(n.display.lineSpace),{left:r-e.left,top:u-e.top})}function so(n,t,i,u,f){return u||(u=r(n.doc,t.line)),oo(n,u,pr(n,u,t.ch,null,f),i)}function it(n,t,i,u,f){function s(t,r){var e=pr(n,u,t,f,r?"right":"left");return r?e.left=e.right:e.right=e.left,oo(n,u,e,i)}function c(n,t){var i=e[t],r=i.level%2;return(n==ds(i)&&t&&i.level<e[t-1].level?(i=e[--t],n=gs(i)-(i.level%2?0:1),r=!0):n==gs(i)&&t<e.length-1&&i.level<e[t+1].level&&(i=e[++t],n=ds(i)-i.level%2,r=!1),r&&n==i.to&&n>i.from)?s(n-1):s(n,r)}var e,o,l,h;return(u=u||r(n.doc,t.line),f||(f=eo(n,u)),e=lt(u),o=t.ch,!e)?s(o):(l=nh(e,o),h=c(o,l),tf!=null&&(h.other=c(o,tf)),h)}function ef(n,i,r,u){var f=new t(n,i);return f.xRel=u,r&&(f.outside=!0),f}function ho(n,t,i){var u=n.doc,f,o;if(i+=n.display.viewOffset,i<0)return ef(u.first,0,!0,-1);if(f=cu(u,i),o=u.first+u.size-1,f>o)return ef(u.first+u.size-1,r(u,o).text.length,!0,1);for(t<0&&(t=0);;){var c=r(u,f),e=dv(n,c,f,t,i),s=te(c),h=s&&s.find();if(s&&(e.ch>h.from.ch||e.ch==h.from.ch&&e.xRel>0))f=h.to.line;else return e}}function dv(n,i,r,u,f){function p(u){var f=it(n,t(r,u),"line",i,ut);return(h=!0,g>f.bottom)?f.left-nt:g<f.top?f.left+nt:(h=!1,f.left)}var g=f-lu(n,i),h=!1,nt=2*n.display.wrapper.clientWidth,ut=eo(n,i),tt=lt(i),w=i.text.length,e=he(i),o=ce(i),v=p(e),rt=h,l=p(o),b=h,c,k,a,s,d,y;if(u>l)return ef(r,o,b,1);for(;;){if(tt?o==e||o==ih(i,e,1):o-e<=1){for(c=u<v||u-v<=l-u?e:o,k=u-(c==e?v:l);se(i.text.charAt(c));)++c;return ef(r,c,c==e?rt:b,k<0?-1:k?1:0)}if(a=Math.ceil(w/2),s=e+a,tt)for(s=e,d=0;d<a;++d)s=ih(i,s,1);y=p(s),y>u?(o=s,l=y,(b=h)&&(l+=1e3),w=a):(e=s,v=y,rt=h,w-=a)}}function oi(n){var r,t;if(n.cachedTextHeight!=null)return n.cachedTextHeight;if(ei==null){for(ei=i("pre"),r=0;r<49;++r)ei.appendChild(document.createTextNode("x")),ei.appendChild(i("br"));ei.appendChild(document.createTextNode("x"))}return yt(n.measure,ei),t=ei.offsetHeight/50,t>3&&(n.cachedTextHeight=t),bu(n.measure),t||1}function wh(n){var r,u,t;return n.cachedCharWidth!=null?n.cachedCharWidth:(r=i("span","x"),u=i("pre",[r]),yt(n.measure,u),t=r.offsetWidth,t>2&&(n.cachedCharWidth=t),t||10)}function ki(n){n.curOp={changes:[],forceUpdate:!1,updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,cursorActivity:!1,updateMaxLine:!1,updateScrollPos:!1,id:++bh},yu++||(ti=[])}function di(n){var t=n.curOp,h=n.doc,i=n.display,v,a,f,y,e,p,w,o,s,c,r;if(n.curOp=null,t.updateMaxLine&&be(n),i.maxLineChanged&&!n.options.lineWrapping&&i.maxLine&&(v=kv(n,i.maxLine),i.sizer.style.minWidth=Math.max(0,v+3)+"px",i.maxLineChanged=!1,a=Math.max(0,i.sizer.offsetLeft+i.sizer.offsetWidth-i.scroller.clientWidth),a<h.scrollLeft&&!t.updateScrollPos&&gi(n,Math.min(i.scroller.scrollLeft,a),!0)),t.updateScrollPos?f=t.updateScrollPos:t.selectionChanged&&i.scroller.clientHeight&&(e=it(n,h.sel.head),f=wf(n,e.left,e.top,e.left,e.bottom)),(t.changes.length||t.forceUpdate||f&&f.scrollTop!=null)&&(y=uf(n,t.changes,f&&f.scrollTop,t.forceUpdate),n.display.scroller.offsetHeight&&(n.doc.scrollTop=n.display.scroller.scrollTop)),!y&&t.selectionChanged&&uo(n),t.updateScrollPos?(p=Math.max(0,Math.min(i.scroller.scrollHeight-i.scroller.clientHeight,f.scrollTop)),w=Math.max(0,Math.min(i.scroller.scrollWidth-i.scroller.clientWidth,f.scrollLeft)),i.scroller.scrollTop=i.scrollbarV.scrollTop=h.scrollTop=p,i.scroller.scrollLeft=i.scrollbarH.scrollLeft=h.scrollLeft=w,no(n),t.scrollToPos&&vc(n,u(n.doc,t.scrollToPos.from),u(n.doc,t.scrollToPos.to),t.scrollToPos.margin)):f&&oy(n),t.selectionChanged&&ff(n),n.state.focused&&t.updateInput&&ht(n,t.userSelChange),o=t.maybeHiddenMarkers,s=t.maybeUnhiddenMarkers,o)for(r=0;r<o.length;++r)o[r].lines.length||l(o[r],"hide");if(s)for(r=0;r<s.length;++r)s[r].lines.length&&l(s[r],"unhide");if(--yu||(c=ti,ti=null),t.textChanged&&l(n,"change",n,t.textChanged),t.cursorActivity&&l(n,"cursorActivity",n),c)for(r=0;r<c.length;++r)c[r]()}function e(n,t){return function(){var i=n||this,r=!i.curOp,u;r&&ki(i);try{u=t.apply(i,arguments)}finally{r&&di(i)}return u}}function wr(n){return function(){var t=this.cm&&!this.cm.curOp,i;t&&ki(this.cm);try{i=n.apply(this,arguments)}finally{t&&di(this.cm)}return i}}function co(n,t){var i=!n.curOp,r;i&&ki(n);try{r=t()}finally{i&&di(n)}return r}function a(n,t,i,r){t==null&&(t=n.doc.first),i==null&&(i=n.doc.first+n.doc.size),n.curOp.changes.push({from:t,to:i,diff:r})}function of(n){n.display.pollingFast||n.display.poll.set(n.options.pollInterval,function(){lo(n),n.state.focused&&of(n)})}function br(n){function i(){var r=lo(n);r||t?(n.display.pollingFast=!1,of(n)):(t=!0,n.display.poll.set(60,i))}var t=!1;n.display.pollingFast=!0,n.display.poll.set(20,i)}function lo(n){var e=n.display.input,h=n.display.prevInput,w=n.doc,u=w.sel,i,y,f,d,nt,p,a,v;if(!n.state.focused||ep(e)||sf(n)||n.options.disableInput||(n.state.pasteIncoming&&n.state.fakedLastChar&&(e.value=e.value.substring(0,e.value.length-1),n.state.fakedLastChar=!1),i=e.value,i==h&&s(u.from,u.to)))return!1;if(k&&!b&&n.display.inputHasSelection===i)return ht(n,!0),!1;for(y=!n.curOp,y&&ki(n),u.shift=!1,f=0,d=Math.min(h.length,i.length);f<d&&h.charCodeAt(f)==i.charCodeAt(f);)++f;var c=u.from,o=u.to,l=i.slice(f);if(f<h.length?c=t(c.line,c.ch-(h.length-f)):n.state.overwrite&&s(c,o)&&!n.state.pasteIncoming&&(o=t(o.line,Math.min(r(w,o.line).text.length,o.ch+l.length))),nt=n.curOp.updateInput,p={from:c,to:o,text:ri(l),origin:n.state.pasteIncoming?"paste":n.state.cutIncoming?"cut":"+input"},nr(n.doc,p,"end"),n.curOp.updateInput=nt,g(n,"inputRead",n,p),l&&!n.state.pasteIncoming&&n.options.electricChars&&n.options.smartIndent&&u.head.ch<100&&(a=n.getModeAt(u.head).electricChars,a))for(v=0;v<a.length;v++)if(l.indexOf(a.charAt(v))>-1){kf(n,u.head.line,"smart");break}return i.length>1e3||i.indexOf("\n")>-1?e.value=n.display.prevInput="":n.display.prevInput=i,y&&di(n),n.state.pasteIncoming=n.state.cutIncoming=!1,!0}function ht(n,t){var r,f,i=n.doc,u;s(i.sel.from,i.sel.to)?t&&(n.display.prevInput=n.display.input.value="",k&&!b&&(n.display.inputHasSelection=null)):(n.display.prevInput="",r=la&&(i.sel.to.line-i.sel.from.line>100||(f=n.getSelection()).length>1e3),u=r?"-":f||n.getSelection(),n.display.input.value=u,n.state.focused&&ra(n.display.input),k&&!b&&(n.display.inputHasSelection=u)),n.display.inaccurateSelection=r}function d(n){n.options.readOnly=="nocursor"||ve&&document.activeElement==n.display.input||n.display.input.focus()}function ao(n){n.state.focused||(d(n),yo(n))}function sf(n){return n.options.readOnly||n.doc.cantEdit}function gv(n){function u(){n.state.focused&&setTimeout(ut(d,n),0)}function f(){i==null&&(i=setTimeout(function(){i=null,t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=du=null,bi(n),co(n,ut(a,n))},100))}function s(){for(var n=t.wrapper.parentNode;n&&n!=document.body;n=n.parentNode);n?setTimeout(s,5e3):kt(window,"resize",f)}function h(t){at(n,t)||n.options.onDragEvent&&n.options.onDragEvent(n,au(t))||vu(t)}function c(i){t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,t.input.value=n.getSelection(),ra(t.input)),i.type=="cut"&&(n.state.cutIncoming=!0)}var t=n.display,i;o(t.scroller,"mousedown",e(n,ny)),st?o(t.scroller,"dblclick",e(n,function(t){var i,u;at(n,t)||(i=kr(n,t),!i||dh(n,t)||si(n.display,t))||(v(t),u=ts(r(n.doc,i.line).text,i),p(n.doc,u.from,u.to))})):o(t.scroller,"dblclick",function(t){at(n,t)||v(t)}),o(t.lineSpace,"selectstart",function(n){si(t,n)||v(n)}),ye||o(t.scroller,"contextmenu",function(t){ec(n,t)}),o(t.scroller,"scroll",function(){t.scroller.clientHeight&&(dr(n,t.scroller.scrollTop),gi(n,t.scroller.scrollLeft,!0),l(n,"scroll",n))}),o(t.scrollbarV,"scroll",function(){t.scroller.clientHeight&&dr(n,t.scrollbarV.scrollTop)}),o(t.scrollbarH,"scroll",function(){t.scroller.clientHeight&&gi(n,t.scrollbarH.scrollLeft)}),o(t.scroller,"mousewheel",function(t){gh(n,t)}),o(t.scroller,"DOMMouseScroll",function(t){gh(n,t)}),o(t.scrollbarH,"mousedown",u),o(t.scrollbarV,"mousedown",u),o(t.wrapper,"scroll",function(){t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),o(window,"resize",f),setTimeout(s,5e3),o(t.input,"keyup",e(n,rc)),o(t.input,"input",function(){k&&!b&&n.display.inputHasSelection&&(n.display.inputHasSelection=null),br(n)}),o(t.input,"keydown",e(n,uc)),o(t.input,"keypress",e(n,fc)),o(t.input,"focus",ut(yo,n)),o(t.input,"blur",ut(po,n)),n.options.dragDrop&&(o(t.scroller,"dragstart",function(t){ry(n,t)}),o(t.scroller,"dragenter",h),o(t.scroller,"dragover",h),o(t.scroller,"drop",e(n,iy))),o(t.scroller,"paste",function(i){si(t,i)||(d(n),br(n))}),o(t.input,"paste",function(){if(y&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var i=t.input.selectionStart,r=t.input.selectionEnd;t.input.value+="$",t.input.selectionStart=i,t.input.selectionEnd=r,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,br(n)}),o(t.input,"cut",c),o(t.input,"copy",c),ae&&o(t.sizer,"mouseup",function(){document.activeElement==t.input&&t.input.blur(),d(n)})}function si(n,t){for(var i=ps(t);i!=n.wrapper;i=i.parentNode)if(!i||i.ignoreEvents||i.parentNode==n.sizer&&i!=n.mover)return!0}function kr(n,t,i){var r=n.display,u,e,o,f;if(!i&&(u=ps(t),u==r.scrollbarH||u==r.scrollbarH.firstChild||u==r.scrollbarV||u==r.scrollbarV.firstChild||u==r.scrollbarFiller||u==r.gutterFiller))return null;f=c(r.lineSpace);try{e=t.clientX,o=t.clientY}catch(t){return null}return ho(n,e-f.left,o-f.top)}function ny(n){function wt(n){if(!s(yt,n)){if(yt=n,w=="single"){p(i.doc,u(a,f),n);return}if(tt=u(a,tt),ft=u(a,ft),w=="double"){var e=ts(r(a,n.line).text,n);h(n,tt)?p(i.doc,e.from,ft):p(i.doc,tt,e.to)}else w=="triple"&&(h(n,tt)?p(i.doc,ft,u(a,t(n.line,0))):p(i.doc,tt,u(a,t(n.line+1,0))))}}function ct(n){var f=++rt,t=kr(i,n,!0),r,u;t&&(s(t,ot)?(u=n.clientY<ht.top?-20:n.clientY>ht.bottom?20:0,u&&setTimeout(e(i,function(){rt==f&&(l.scroller.scrollTop+=u,ct(n))}),50)):(ao(i),ot=t,wt(t),r=ge(l,a),(t.line>=r.to||t.line<r.from)&&setTimeout(e(i,function(){rt==f&&ct(n)}),150)))}function pt(n){rt=Infinity,v(n),d(i),kt(document,"mousemove",lt),kt(document,"mouseup",vt)}var f,it,w,et,ot,nt,ht,rt,lt,vt;if(!at(this,n)){var i=this,l=i.display,a=i.doc,g=a.sel;if(g.shift=n.shiftKey,si(l,n)){y||(l.scroller.draggable=!1,setTimeout(function(){l.scroller.draggable=!0},100));return}if(!dh(i,n)){f=kr(i,n),window.focus();switch(ta(n)){case 3:ye&&ec.call(i,i,n);return;case 2:y&&(i.state.lastMiddleDown=+new Date),f&&p(i.doc,f),setTimeout(ut(d,i),20),v(n);return}if(!f){ps(n)==l.scroller&&v(n);return}if(setTimeout(ut(ao,i),0),it=+new Date,w="single",cf&&cf.time>it-400&&s(cf.pos,f)?(w="triple",v(n),setTimeout(ut(d,i),20),hy(i,f.line)):hf&&hf.time>it-400&&s(hf.pos,f)?(w="double",cf={time:it,pos:f},v(n),et=ts(r(a,f.line).text,f),p(i.doc,et.from,et.to)):hf={time:it,pos:f},ot=f,i.options.dragDrop&&ca&&!sf(i)&&!s(g.from,g.to)&&!h(f,g.from)&&!h(g.to,f)&&w=="single"){nt=e(i,function(t){y&&(l.scroller.draggable=!1),i.state.draggingText=!1,kt(document,"mouseup",nt),kt(l.scroller,"drop",nt),Math.abs(n.clientX-t.clientX)+Math.abs(n.clientY-t.clientY)<10&&(v(t),p(i.doc,f),d(i),st&&!b&&setTimeout(function(){document.body.focus(),d(i)},20))}),y&&(l.scroller.draggable=!0),i.state.draggingText=nt,l.scroller.dragDrop&&l.scroller.dragDrop(),o(document,"mouseup",nt),o(l.scroller,"drop",nt);return}v(n),w=="single"&&p(i.doc,u(a,f));var tt=g.from,ft=g.to,yt=f;ht=c(l.wrapper),rt=0,lt=e(i,function(n){(k&&!pa?n.buttons:ta(n))?ct(n):pt(n)}),vt=e(i,pt),o(document,"mousemove",lt),o(document,"mouseup",vt)}}}function kh(n,t,i,r,u){var s,e,o,h,f,l,a,y;try{s=t.clientX,e=t.clientY}catch(t){return!1}if(s>=Math.floor(c(n.display.gutters).right))return!1;if(r&&v(t),o=n.display,h=c(o.lineDiv),e>h.bottom||!vt(n,i))return ys(t);for(e-=h.top-o.viewOffset,f=0;f<n.options.gutters.length;++f)if(l=o.gutters.childNodes[f],l&&c(l).right>=s)return a=cu(n.doc,e),y=n.options.gutters[f],u(n,i,n,a,y,t),ys(t)}function ty(n,t){return vt(n,"gutterContextMenu")?kh(n,t,"gutterContextMenu",!1,l):!1}function dh(n,t){return kh(n,t,"gutterClick",!0,g)}function iy(n){var t=this,i,f,e,r,s,c;if(!at(t,n)&&!si(t.display,n)&&(!t.options.onDragEvent||!t.options.onDragEvent(t,au(n)))&&(v(n),k&&(vo=+new Date),i=kr(t,n,!0),f=n.dataTransfer.files,i&&!sf(t)))if(f&&f.length&&window.FileReader&&window.File){var o=f.length,r=Array(o),l=0,a=function(n,f){var e=new FileReader;e.onload=function(){r[f]=e.result,++l==o&&(i=u(t.doc,i),nr(t.doc,{from:i,to:i,text:ri(r.join("\n")),origin:"paste"},"around"))},e.readAsText(n)};for(e=0;e<o;++e)a(f[e],e)}else{if(t.state.draggingText&&!(h(i,t.doc.sel.from)||h(t.doc.sel.to,i))){t.state.draggingText(n),setTimeout(ut(d,t),20);return}try{r=n.dataTransfer.getData("Text"),r&&(s=t.doc.sel.from,c=t.doc.sel.to,pt(t.doc,i,i),t.state.draggingText&&dt(t.doc,"",s,c,"paste"),t.replaceSelection(r,null,"paste"),d(t))}catch(n){}}}function ry(n,t){var u,r;if(k&&(!n.state.draggingText||+new Date-vo<100)){vu(t);return}at(n,t)||si(n.display,t)||(u=n.getSelection(),t.dataTransfer.setData("Text",u),t.dataTransfer.setDragImage&&!le&&(r=i("img",null,null,"position: fixed; left: 0; top: 0;"),r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",ft&&(r.width=r.height=1,n.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),ft&&r.parentNode.removeChild(r)))}function dr(n,t){Math.abs(n.doc.scrollTop-t)<2||(n.doc.scrollTop=t,vi||uf(n,[],t),n.display.scroller.scrollTop!=t&&(n.display.scroller.scrollTop=t),n.display.scrollbarV.scrollTop!=t&&(n.display.scrollbarV.scrollTop=t),vi&&uf(n,[]),vr(n,100))}function gi(n,t,i){(i?t==n.doc.scrollLeft:Math.abs(n.doc.scrollLeft-t)<2)||(t=Math.min(t,n.display.scroller.scrollWidth-n.display.scroller.clientWidth),n.doc.scrollLeft=t,no(n),n.display.scroller.scrollLeft!=t&&(n.display.scroller.scrollLeft=t),n.display.scrollbarH.scrollLeft!=t&&(n.display.scrollbarH.scrollLeft=t))}function gh(n,t){var f=t.wheelDeltaX,u=t.wheelDeltaY,i,r,e;if(f==null&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(f=t.detail),u==null&&t.detail&&t.axis==t.VERTICAL_AXIS?u=t.detail:u==null&&(u=t.wheelDelta),i=n.display,r=i.scroller,f&&r.scrollWidth>r.clientWidth||u&&r.scrollHeight>r.clientHeight){if(u&&pi&&y)for(e=t.target;e!=r;e=e.parentNode)if(e.lineObj){n.display.currentWheelTarget=e;break}if(f&&!vi&&!ft&&rt!=null){u&&dr(n,Math.max(0,Math.min(r.scrollTop+u*rt,r.scrollHeight-r.clientHeight))),gi(n,Math.max(0,Math.min(r.scrollLeft+f*rt,r.scrollWidth-r.clientWidth))),v(t),i.wheelStartX=null;return}if(u&&rt!=null){var s=u*rt,o=n.doc.scrollTop,h=o+i.wrapper.clientHeight;s<0?o=Math.max(0,o+s-50):h=Math.min(n.doc.height,h+s+50),uf(n,[],{top:o,bottom:h})}gr<20&&(i.wheelStartX==null?(i.wheelStartX=r.scrollLeft,i.wheelStartY=r.scrollTop,i.wheelDX=f,i.wheelDY=u,setTimeout(function(){if(i.wheelStartX!=null){var n=r.scrollLeft-i.wheelStartX,t=r.scrollTop-i.wheelStartY,u=t&&i.wheelDY&&t/i.wheelDY||n&&i.wheelDX&&n/i.wheelDX;(i.wheelStartX=i.wheelStartY=null,u)&&(rt=(rt*gr+u)/(gr+1),++gr)}},200)):(i.wheelDX+=f,i.wheelDY+=u))}}function lf(n,t,i){if(typeof t=="string"&&(t=tu[t],!t))return!1;n.display.pollingFast&&lo(n)&&(n.display.pollingFast=!1);var r=n.doc,f=r.sel.shift,u=!1;try{sf(n)&&(n.state.suppressEdits=!0),i&&(r.sel.shift=!1),u=t(n)!=ws}finally{r.sel.shift=f,n.state.suppressEdits=!1}return u}function nc(n){var t=n.state.keyMaps.slice(0);return n.options.extraKeys&&t.push(n.options.extraKeys),t.push(n.options.keyMap),t}function ic(n,t){var e=us(n.options.keyMap),r=e.auto,i,u,f;return(clearTimeout(tc),r&&!wc(t)&&(tc=setTimeout(function(){us(n.options.keyMap)==e&&(n.options.keyMap=r.call?r.call(null,n):r,eh(n))},50)),i=bc(t,!0),u=!1,!i)?!1:(f=nc(n),u=t.shiftKey?iu("Shift-"+i,f,function(t){return lf(n,t,!0)})||iu(i,f,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return lf(n,t)}):iu(i,f,function(t){return lf(n,t)}),u&&(v(t),ff(n),b&&(t.oldKeyCode=t.keyCode,t.keyCode=0),g(n,"keyHandled",n,i,t)),u)}function uy(n,t,i){var r=iu("'"+i+"'",nc(n),function(t){return lf(n,t,!0)});return r&&(v(t),ff(n),g(n,"keyHandled",n,"'"+i+"'",t)),r}function rc(n){var t=this;at(t,n)||t.options.onKeyEvent&&t.options.onKeyEvent(t,au(n))||n.keyCode==16&&(t.doc.sel.shift=!1)}function uc(n){var t=this,i,r;(ao(t),at(t,n)||t.options.onKeyEvent&&t.options.onKeyEvent(t,au(n)))||(st&&n.keyCode==27&&(n.returnValue=!1),i=n.keyCode,t.doc.sel.shift=i==16||n.shiftKey,r=ic(t,n),ft&&(af=r?i:null,r||i!=88||la||!(pi?n.metaKey:n.ctrlKey)||t.replaceSelection("")))}function fc(n){var t=this,i,r,u;if(!at(t,n)&&(!t.options.onKeyEvent||!t.options.onKeyEvent(t,au(n)))){if(i=n.keyCode,r=n.charCode,ft&&i==af){af=null,v(n);return}(ft&&(!n.which||n.which<10)||ae)&&ic(t,n)||(u=String.fromCharCode(r==null?i:r),uy(t,n,u))||(k&&!b&&(t.display.inputHasSelection=null),br(t))}}function yo(n){n.options.readOnly!="nocursor"&&(n.state.focused||(l(n,"focus",n),n.state.focused=!0,n.display.wrapper.className.search(/\bCodeMirror-focused\b/)==-1&&(n.display.wrapper.className+=" CodeMirror-focused"),n.curOp||(ht(n,!0),y&&setTimeout(ut(ht,n,!0),0))),of(n),ff(n))}function po(n){n.state.focused&&(l(n,"blur",n),n.state.focused=!1,n.display.wrapper.className=n.display.wrapper.className.replace(" CodeMirror-focused","")),clearInterval(n.display.blinker),setTimeout(function(){n.state.focused||(n.doc.sel.shift=!1)},150)}function ec(n,t){function v(){if(i.input.selectionStart!=null){var n=i.input.value="​"+(s(r.from,r.to)?"":i.input.value);i.prevInput="​",i.input.selectionStart=1,i.input.selectionEnd=n.length}}function y(){if(i.inputDiv.style.position="relative",i.input.style.cssText=a,b&&(i.scrollbarV.scrollTop=i.scroller.scrollTop=c),of(n),i.input.selectionStart!=null){(!k||b)&&v(),clearTimeout(wo);var r=0,t=function(){i.prevInput=="​"&&i.input.selectionStart==0?e(n,tu.selectAll)(n):r++<10?wo=setTimeout(t,500):ht(n)};wo=setTimeout(t,200)}}var i,r,u,c,l,a,f;at(n,t,"contextmenu")||(i=n.display,r=n.doc.sel,si(i,t)||ty(n,t))||(u=kr(n,t),c=i.scroller.scrollTop,u&&!ft)&&(l=n.options.resetSelectionOnContextMenu,l&&(s(r.from,r.to)||h(u,r.from)||!h(u,r.to))&&e(n,pt)(n.doc,u,u),a=i.input.style.cssText,i.inputDiv.style.position="absolute",i.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: transparent; outline: none;border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);",d(n),ht(n,!0),s(r.from,r.to)&&(i.input.value=i.prevInput=" "),k&&!b&&v(),ye?(vu(t),f=function(){kt(window,"mouseup",f),setTimeout(y,20)},o(window,"mouseup",f)):setTimeout(y,50))}function oc(n,i,f){var e,s,o,c;return h(i.from,f)?(e=i.text.length-1-(i.to.line-i.from.line),f.line>i.to.line+e)?(s=f.line-e,o=n.first+n.size-1,s>o)?t(o,r(n,o).text.length):yf(f,r(n,s).text.length):f.line==i.to.line+e?yf(f,nt(i.text).length+(i.text.length==1?i.from.ch:0)+r(n,i.to.line).text.length-i.to.ch):(c=f.line-i.from.line,yf(f,i.text[c].length+(c?0:i.from.ch))):u(n,f)}function bo(n,i,r){var u,f;return r&&typeof r=="object"?{anchor:oc(n,i,r.anchor),head:oc(n,i,r.head)}:r=="start"?{anchor:i.from,head:i.from}:(u=vf(i),r=="around")?{anchor:i.from,head:u}:r=="end"?{anchor:u,head:u}:(f=function(n){if(h(n,i.from))return n;if(!h(i.to,n))return u;var f=n.line+i.text.length-(i.to.line-i.from.line)-1,r=n.ch;return n.line==i.to.line&&(r+=u.ch-i.to.ch),t(f,r)},{anchor:f(n.sel.anchor),head:f(n.sel.head)})}function sc(n,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return(i&&(r.update=function(t,i,r,f){t&&(this.from=u(n,t)),i&&(this.to=u(n,i)),r&&(this.text=r),f!==undefined&&(this.origin=f)}),l(n,"beforeChange",n,r),n.cm&&l(n.cm,"beforeChange",n.cm,r),r.canceled)?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function nr(n,t,i,r){var u,f;if(n.cm){if(!n.cm.curOp)return e(n.cm,nr)(n,t,i,r);if(n.cm.state.suppressEdits)return}if(!vt(n,"beforeChange")&&(!n.cm||!vt(n.cm,"beforeChange"))||(t=sc(n,t,!0),t))if(u=uh&&!r&&py(n,t.from,t.to),u){for(f=u.length-1;f>=1;--f)ko(n,{from:u[f].from,to:u[f].to,text:[""]});u.length&&ko(n,{from:u[0].from,to:u[0].to,text:t.text},i)}else ko(n,t,i)}function ko(n,t,i){var r,u;t.text.length==1&&t.text[0]==""&&s(t.from,t.to)||(r=bo(n,t,i),kl(n,t,r,n.cm?n.cm.curOp.id:NaN),nu(n,t,r,fs(n,t)),u=[],sr(n,function(n,i){i||ot(u,n.history)!=-1||(gl(n.history,t),u.push(n.history)),nu(n,t,null,fs(n,t))}))}function hc(n,t){var r,i,e,s,f,u,h,o;if((!n.cm||!n.cm.state.suppressEdits)&&(r=n.history,i=(t=="undo"?r.done:r.undone).pop(),i))for(e={changes:[],anchorBefore:i.anchorAfter,headBefore:i.headAfter,anchorAfter:i.anchorBefore,headAfter:i.headBefore,generation:r.generation},(t=="undo"?r.undone:r.done).push(e),r.generation=i.generation||++r.maxGeneration,s=vt(n,"beforeChange")||n.cm&&vt(n.cm,"beforeChange"),f=i.changes.length-1;f>=0;--f){if(u=i.changes[f],u.origin=t,s&&!sc(n,u,!1)){(t=="undo"?r.done:r.undone).length=0;return}e.changes.push(vs(n,u)),h=f?bo(n,u,null):{anchor:i.anchorBefore,head:i.headBefore},nu(n,u,h,gc(n,u)),o=[],sr(n,function(n,t){t||ot(o,n.history)!=-1||(gl(n.history,u),o.push(n.history)),nu(n,u,null,gc(n,u))})}}function cc(n,i){function r(n){return t(n.line+i,n.ch)}n.first+=i,n.cm&&a(n.cm,n.first,n.first,i),n.sel.head=r(n.sel.head),n.sel.anchor=r(n.sel.anchor),n.sel.from=r(n.sel.from),n.sel.to=r(n.sel.to)}function nu(n,i,u,f){var s,o;if(n.cm&&!n.cm.curOp)return e(n.cm,nu)(n,i,u,f);if(i.to.line<n.first){cc(n,i.text.length-1-(i.to.line-i.from.line));return}i.from.line>n.lastLine()||(i.from.line<n.first&&(s=i.text.length-1-(n.first-i.from.line),cc(n,s),i={from:t(n.first,0),to:t(i.to.line+s,i.to.ch),text:[nt(i.text)],origin:i.origin}),o=n.lastLine(),i.to.line>o&&(i={from:i.from,to:t(o,r(n,o).text.length),text:[i.text[0]],origin:i.origin}),i.removed=ls(n,i.from,i.to),u||(u=bo(n,i,null)),n.cm?fy(n.cm,i,f,u):cs(n,i,f,u))}function fy(n,t,i,u){var f=n.doc,o=n.display,e=t.from,c=t.to,l=!1,v=e.line,p,y,s;if(n.options.lineWrapping||(v=tt(wt(f,r(f,e.line))),f.iter(v,c.line+1,function(n){if(n==o.maxLine)return l=!0,!0})),h(f.sel.head,t.from)||h(t.to,f.sel.head)||(n.curOp.cursorActivity=!0),cs(f,t,i,u,fh(n)),n.options.lineWrapping||(f.iter(v,e.line+t.text.length,function(n){var t=rf(f,n);t>o.maxLineLength&&(o.maxLine=n,o.maxLineLength=t,o.maxLineChanged=!0,l=!1)}),l&&(n.curOp.updateMaxLine=!0)),f.frontier=Math.min(f.frontier,e.line),vr(n,400),p=t.text.length-(c.line-e.line)-1,a(n,e.line,c.line+1,p),vt(n,"change"))if(y={from:e,to:c,text:t.text,removed:t.removed,origin:t.origin},n.curOp.textChanged){for(s=n.curOp.textChanged;s.next;s=s.next);s.next=y}else n.curOp.textChanged=y}function dt(n,t,i,r,u){if(r||(r=i),h(r,i)){var f=r;r=i,i=f}typeof t=="string"&&(t=ri(t)),nr(n,{from:i,to:r,text:t,origin:u},null)}function t(n,i){if(!(this instanceof t))return new t(n,i);this.line=n,this.ch=i}function s(n,t){return n.line==t.line&&n.ch==t.ch}function h(n,t){return n.line<t.line||n.line==t.line&&n.ch<t.ch}function tr(n,t){return n.line-t.line||n.ch-t.ch}function hi(n){return t(n.line,n.ch)}function lc(n,t){return Math.max(n.first,Math.min(t,n.first+n.size-1))}function u(n,i){if(i.line<n.first)return t(n.first,0);var u=n.first+n.size-1;return i.line>u?t(u,r(n,u).text.length):yf(i,r(n,i.line).text.length)}function yf(n,i){var r=n.ch;return r==null||r>i?t(n.line,i):r<0?t(n.line,0):n}function ir(n,t){return t>=n.first&&t<n.first+n.size}function p(n,t,i,r){var u,f;n.sel.shift||n.sel.extend?(u=n.sel.anchor,i&&(f=h(t,u),f!=h(i,u)?(u=t,t=i):f!=h(t,i)&&(t=i)),pt(n,u,t,r)):pt(n,t,i||t,r),n.cm&&(n.cm.curOp.userSelChange=!0)}function ey(n,t,i){var r={anchor:t,head:i};return l(n,"beforeSelectionChange",n,r),n.cm&&l(n.cm,"beforeSelectionChange",n.cm,r),r.anchor=u(n,r.anchor),r.head=u(n,r.head),r}function pt(n,t,i,r,u){var e,f,o;((!u&&vt(n,"beforeSelectionChange")||n.cm&&vt(n.cm,"beforeSelectionChange"))&&(e=ey(n,t,i),i=e.head,t=e.anchor),f=n.sel,f.goalColumn=null,r==null&&(r=h(i,f.head)?-1:1),(u||!s(t,f.anchor))&&(t=pf(n,t,r,u!="push")),(u||!s(i,f.head))&&(i=pf(n,i,r,u!="push")),s(f.anchor,t)&&s(f.head,i))||(f.anchor=t,f.head=i,o=h(i,t),f.from=o?i:t,f.to=o?t:i,n.cm&&(n.cm.curOp.updateInput=n.cm.curOp.selectionChanged=n.cm.curOp.cursorActivity=!0),g(n,"cursorActivity",n))}function ac(n){pt(n.doc,n.doc.sel.from,n.doc.sel.to,null,"push")}function pf(n,i,f,e){var w=!1,h=i,p=f||1,v,y,c,a,o;n.cantEdit=!1;n:for(;;){if(v=r(n,h.line),v.markedSpans)for(y=0;y<v.markedSpans.length;++y)if(c=v.markedSpans[y],a=c.marker,(c.from==null||(a.inclusiveLeft?c.from<=h.ch:c.from<h.ch))&&(c.to==null||(a.inclusiveRight?c.to>=h.ch:c.to>h.ch))){if(e&&(l(a,"beforeCursorEnter"),a.explicitlyCleared))if(v.markedSpans){--y;continue}else break;if(!a.atomic)continue;if(o=a.find()[p<0?"from":"to"],s(o,h)&&(o.ch+=p,o.ch<0?o=o.line>n.first?u(n,t(o.line-1)):null:o.ch>v.text.length&&(o=o.line<n.first+n.size-1?t(o.line+1,0):null),!o)){if(w)return e?(n.cantEdit=!0,t(n.first,0)):pf(n,i,f,!0);w=!0,o=i,p=-p}h=o;continue n}return h}}function oy(n){var t=vc(n,n.doc.sel.head,null,n.options.cursorScrollMargin),u;if(n.state.focused){var f=n.display,e=c(f.sizer),r=null;t.top+e.top<0?r=!0:t.bottom+e.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1),r==null||nv||(u=i("div","​",null,"position: absolute; top: "+(t.top-f.viewOffset)+"px; height: "+(t.bottom-t.top+ai)+"px; left: "+t.left+"px; width: 2px;"),n.display.lineSpace.appendChild(u),u.scrollIntoView(r),n.display.lineSpace.removeChild(u))}}function vc(n,t,i,r){for(r==null&&(r=0);;){var o=!1,u=it(n,t),f=!i||i==t?u:it(n,i),e=wf(n,Math.min(u.left,f.left),Math.min(u.top,f.top)-r,Math.max(u.left,f.left),Math.max(u.bottom,f.bottom)+r),s=n.doc.scrollTop,h=n.doc.scrollLeft;if(e.scrollTop!=null&&(dr(n,e.scrollTop),Math.abs(n.doc.scrollTop-s)>1&&(o=!0)),e.scrollLeft!=null&&(gi(n,e.scrollLeft),Math.abs(n.doc.scrollLeft-h)>1&&(o=!0)),!o)return u}}function sy(n,t,i,r,u){var f=wf(n,t,i,r,u);f.scrollTop!=null&&dr(n,f.scrollTop),f.scrollLeft!=null&&gi(n,f.scrollLeft)}function wf(n,t,i,r,u){var f=n.display,v=oi(n.display),h,c,l,o,a;i<0&&(i=0);var y=f.scroller.clientHeight-ai,s=f.scroller.scrollTop,e={},p=n.doc.height+lh(f),w=i<v,b=u>p-v;return i<s?e.scrollTop=w?0:i:u>s+y&&(h=Math.min(i,(b?p:u)-y),h!=s&&(e.scrollTop=h)),c=f.scroller.clientWidth-ai,l=f.scroller.scrollLeft,t+=f.gutters.offsetWidth,r+=f.gutters.offsetWidth,o=f.gutters.offsetWidth,a=t<o+10,t<l+o||a?(a&&(t=0),e.scrollLeft=Math.max(0,t-10-o)):r>c+l-3&&(e.scrollLeft=r+10-c),e}function bf(n,t,i){n.curOp.updateScrollPos={scrollLeft:t==null?n.doc.scrollLeft:t,scrollTop:i==null?n.doc.scrollTop:i}}function go(n,t,i){var r=n.curOp.updateScrollPos||(n.curOp.updateScrollPos={scrollLeft:n.doc.scrollLeft,scrollTop:n.doc.scrollTop}),u=n.display.scroller;r.scrollTop=Math.max(0,Math.min(u.scrollHeight-u.clientHeight,r.scrollTop+i)),r.scrollLeft=Math.max(0,Math.min(u.scrollWidth-u.clientWidth,r.scrollLeft+t))}function kf(n,i,u,f){var h=n.doc,p,s,e,c,a,y;u==null&&(u="add"),u=="smart"&&(n.doc.mode.indent?p=yr(n,i):u="prev");var l=n.options.tabSize,o=r(h,i),v=ii(o.text,null,l);if(o.stateAfter&&(o.stateAfter=null),s=o.text.match(/^\s*/)[0],f||/\S/.test(o.text)){if(u=="smart"&&(e=n.doc.mode.indent(p,o.text.slice(s.length),o.text),e==ws)){if(!f)return;u="prev"}}else e=0,u="not";if(u=="prev"?e=i>h.first?ii(r(h,i-1).text,null,l):0:u=="add"?e=v+n.options.indentUnit:u=="subtract"?e=v-n.options.indentUnit:typeof u=="number"&&(e=v+u),e=Math.max(0,e),c="",a=0,n.options.indentWithTabs)for(y=Math.floor(e/l);y;--y)a+=l,c+="\t";a<e&&(c+=ia(e-a)),c!=s?dt(n.doc,c,t(i,0),t(i,s.length),"+input"):h.sel.head.line==i&&h.sel.head.ch<s.length&&pt(h,t(i,s.length),t(i,s.length),1),o.stateAfter=null}function df(n,t,i){var u=t,f=t,e=n.doc;if(typeof t=="number"?f=r(e,lc(e,t)):u=tt(t),u==null)return null;if(i(f,u))a(n,u,u+1);else return null;return f}function ns(n,i,u,f,e){function d(){var t=a+u;return t<n.first||t>=n.first+n.size?w=!1:(a=t,h=r(n,t))}function c(n){var t=(e?ih:va)(h,o,u,!0);if(t==null)if(!n&&d())o=e?(u<0?ce:he)(h):u<0?h.text.length:0;else return w=!1;else o=t;return!0}var a=i.line,o=i.ch,k=u,h=r(n,a),w=!0,v,y,l,p,s,b;if(f=="char")c();else if(f=="column")c(!0);else if(f=="word"||f=="group")for(v=null,y=f=="group",l=!0;;l=!1){if(u<0&&!c(!l))break;if(p=h.text.charAt(o)||"\n",s=wu(p)?"w":y&&p=="\n"?"n":!y||/\s/.test(p)?null:"p",!y||l||s||(s="s"),v&&v!=s){u<0&&(u=1,c());break}if(s&&(v=s),u>0&&!c(!l))break}return b=pf(n,t(a,o),k,!0),w||(b.hitSide=!0),b}function yc(n,t,i,r){var o=n.doc,s=t.left,u,e,f;for(r=="page"?(e=Math.min(n.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=t.top+i*(e-(i<0?1.5:.5)*oi(n.display))):r=="line"&&(u=i>0?t.bottom+3:t.top-3);;){if(f=ho(n,s,u),!f.outside)break;if(i<0?u<=0:u>=o.height){f.hitSide=!0;break}u+=i*5}return f}function ts(n,i){var r=i.ch,u=i.ch,f,e;if(n){for((i.xRel<0||u==n.length)&&r?--r:++u,f=n.charAt(r),e=wu(f)?wu:/\s/.test(f)?function(n){return/\s/.test(n)}:function(n){return!/\s/.test(n)&&!wu(n)};r>0&&e(n.charAt(r-1));)--r;while(u<n.length&&e(n.charAt(u)))++u}return{from:t(i.line,r),to:t(i.line,u)}}function hy(n,i){p(n.doc,t(i,0),u(n.doc,t(i+1,0)))}function f(t,i,r,u){n.defaults[t]=i,r&&(ci[t]=u?function(n,t,i){i!=is&&r(n,t,i)}:r)}function fr(n,t){var r,u,i;if(t===!0)return t;if(n.copyState)return n.copyState(t);r={};for(u in t)i=t[u],i instanceof Array&&(i=i.concat([])),r[u]=i;return r}function pc(n,t,i){return n.startState?n.startState(t,i):!0}function us(n){return typeof n=="string"?ct[n]:n}function iu(n,t,i){function u(t){var f,r,e,s,o;if(t=us(t),f=t[n],f===!1)return"stop";if(f!=null&&i(f))return!0;if(t.nofallthrough)return"stop";if(r=t.fallthrough,r==null)return!1;if(Object.prototype.toString.call(r)!="[object Array]")return u(r);for(e=0,s=r.length;e<s;++e)if(o=u(r[e]),o)return o;return!1}for(var f,r=0;r<t.length;++r)if(f=u(t[r]),f)return f!="stop"}function wc(n){var t=ui[n.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function bc(n,t){if(ft&&n.keyCode==34&&n.char)return!1;var i=ui[n.keyCode];return i==null||n.altGraphKey?!1:(n.altKey&&(i="Alt-"+i),(rh?n.metaKey:n.ctrlKey)&&(i="Ctrl-"+i),(rh?n.ctrlKey:n.metaKey)&&(i="Cmd-"+i),!t&&n.shiftKey&&(i="Shift-"+i),i)}function ru(n,t){this.pos=this.start=0,this.string=n,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0}function ni(n,t){this.lines=[],this.type=t,this.doc=n}function uu(n,t,r,u,f){var c,v,l,y;if(u&&u.shared)return cy(n,t,r,u,f);if(n.cm&&!n.cm.curOp)return e(n.cm,uu)(n,t,r,u,f);if(c=new ni(n,f),u&&oe(u,c),h(r,t)||s(t,r)&&c.clearWhenEmpty!==!1)return c;if(c.replacedWith&&(c.collapsed=!0,c.replacedWith=i("span",[c.replacedWith],"CodeMirror-widget"),u.handleMouseEvents||(c.replacedWith.ignoreEvents=!0)),c.collapsed){if(il(n,t.line,t,r,c)||t.line!=r.line&&il(n,r.line,t,r,c))throw new Error("Inserting collapsed marker partially overlapping an existing one");wi=!0}return c.addToHistory&&kl(n,{from:t,to:r,origin:"markText"},{head:n.sel.head,anchor:n.sel.anchor},NaN),v=t.line,l=n.cm,n.iter(v,r.line+1,function(i){l&&c.collapsed&&!l.options.lineWrapping&&wt(n,i)==l.display.maxLine&&(y=!0);var u={from:null,to:null,marker:c};v==t.line&&(u.from=t.ch),v==r.line&&(u.to=r.ch),c.collapsed&&v!=t.line&&et(i,0),ay(i,u),++v}),c.collapsed&&n.iter(t.line,r.line+1,function(t){li(n,t)&&et(t,0)}),c.clearOnEnter&&o(c,"beforeCursorEnter",function(){c.clear()}),c.readOnly&&(uh=!0,(n.history.done.length||n.history.undone.length)&&n.clearHistory()),c.collapsed&&(c.id=++kc,c.atomic=!0),l&&(y&&(l.curOp.updateMaxLine=!0),(c.className||c.title||c.startStyle||c.endStyle||c.collapsed)&&a(l,t.line,r.line+1),c.atomic&&ac(l)),c}function fu(n,t){this.markers=n,this.primary=t;for(var i=0,r=this;i<n.length;++i)n[i].parent=this,o(n[i],"clear",function(){r.clear()})}function cy(n,t,i,r,f){r=oe(r),r.shared=!1;var e=[uu(n,t,i,r,f)],o=e[0],s=r.replacedWith;return sr(n,function(n){s&&(r.replacedWith=s.cloneNode(!0)),e.push(uu(n,u(n,t),u(n,i),r,f));for(var h=0;h<n.linked.length;++h)if(n.linked[h].isParent)return;o=nt(e)}),new fu(e,o)}function eu(n,t){var i,r;if(n)for(i=0;i<n.length;++i)if(r=n[i],r.marker==t)return r}function ly(n,t){for(var r,i=0;i<n.length;++i)n[i]!=t&&(r||(r=[])).push(n[i]);return r}function ay(n,t){n.markedSpans=n.markedSpans?n.markedSpans.concat([t]):[t],t.marker.attachLine(n)}function vy(n,t,i){var u,e,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t);!s&&(r.from!=t||f.type!="bookmark"||i&&r.marker.insertLeft)||(o=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t),(e||(e=[])).push({from:r.from,to:o?null:r.to,marker:f}))}return e}function yy(n,t,i){var u,e,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t);(s||r.from==t&&f.type=="bookmark"&&(!i||r.marker.insertLeft))&&(o=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t),(e||(e=[])).push({from:o?null:r.from-t,to:r.to==null?null:r.to-t,marker:f}))}return e}function fs(n,t){var p=ir(n,t.from.line)&&r(n,t.from.line).markedSpans,w=ir(n,t.to.line)&&r(n,t.to.line).markedSpans,f,o,l,v,y,i;if(!p&&!w)return null;var a=t.from.ch,k=t.to.ch,b=s(t.from,t.to),u=vy(p,a,b),e=yy(w,k,b),h=t.text.length==1,c=nt(t.text).length+(h?a:0);if(u)for(i=0;i<u.length;++i)f=u[i],f.to==null&&(o=eu(e,f.marker),o?h&&(f.to=o.to==null?null:o.to+c):f.to=a);if(e)for(i=0;i<e.length;++i)f=e[i],f.to!=null&&(f.to+=c),f.from==null?(o=eu(u,f.marker),o||(f.from=c,h&&(u||(u=[])).push(f))):(f.from+=c,h&&(u||(u=[])).push(f));if(u&&(u=dc(u)),e&&e!=u&&(e=dc(e)),l=[u],!h){if(v=t.text.length-2,v>0&&u)for(i=0;i<u.length;++i)u[i].to==null&&(y||(y=[])).push({from:null,to:null,marker:u[i].marker});for(i=0;i<v;++i)l.push(y);l.push(e)}return l}function dc(n){for(var i,t=0;t<n.length;++t)i=n[t],i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&n.splice(t--,1);return n.length?n:null}function gc(n,t){var i=rp(n,t),s=fs(n,t),r,f,u,e,h,o;if(!i)return s;if(!s)return i;for(r=0;r<i.length;++r)if(f=i[r],u=s[r],f&&u)n:for(e=0;e<u.length;++e){for(h=u[e],o=0;o<f.length;++o)if(f[o].marker==h.marker)continue n;f.push(h)}else u&&(i[r]=u);return i}function py(n,t,i){var f=null,e,l,a,r,o,u,c;if(n.iter(t.line,i.line+1,function(n){var t,i;if(n.markedSpans)for(t=0;t<n.markedSpans.length;++t)i=n.markedSpans[t].marker,i.readOnly&&(!f||ot(f,i)==-1)&&(f||(f=[])).push(i)}),!f)return null;for(e=[{from:t,to:i}],l=0;l<f.length;++l)for(a=f[l],r=a.find(),o=0;o<e.length;++o)(u=e[o],h(u.to,r.from)||h(r.to,u.from))||(c=[o,1],(h(u.from,r.from)||!a.inclusiveLeft&&s(u.from,r.from))&&c.push({from:u.from,to:r.from}),(h(r.to,u.to)||!a.inclusiveRight&&s(u.to,r.to))&&c.push({from:r.to,to:u.to}),e.splice.apply(e,c),o+=c.length-1);return e}function er(n){return n.inclusiveLeft?-1:0}function or(n){return n.inclusiveRight?1:0}function nl(n,t){var r=n.lines.length-t.lines.length,i;if(r!=0)return r;var u=n.find(),f=t.find(),e=tr(u.from,f.from)||er(n)-er(t);return e?-e:(i=tr(u.to,f.to)||or(n)-or(t),i)?i:t.id-n.id}function tl(n,t){var f=wi&&n.markedSpans,r,i,u;if(f)for(u=0;u<f.length;++u)i=f[u],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||nl(r,i.marker)<0)&&(r=i.marker);return r}function es(n){return tl(n,!0)}function te(n){return tl(n,!1)}function il(n,t,i,u,f){var a=r(n,t),c=wi&&a.markedSpans,o,e;if(c)for(o=0;o<c.length;++o)if(e=c[o],e.marker.collapsed){var s=e.marker.find(!0),h=tr(s.from,i)||er(e.marker)-er(f),l=tr(s.to,u)||or(e.marker)-or(f);if((!(h>=0)||!(l<=0))&&(!(h<=0)||!(l>=0))&&(h<=0&&(tr(s.to,i)||or(e.marker)-er(f))>0||h>=0&&(tr(s.from,u)||er(e.marker)-or(f))<0))return!0}}function wt(n,t){for(var i;i=es(t);)t=r(n,i.find().from.line);return t}function li(n,t){var u=wi&&t.markedSpans,i,r;if(u)for(r=0;r<u.length;++r)if(i=u[r],i.marker.collapsed){if(i.from==null)return!0;if(!i.marker.replacedWith&&i.from==0&&i.marker.inclusiveLeft&&os(n,t,i))return!0}}function os(n,t,i){var o,e,u,f;if(i.to==null)return o=i.marker.find().to,e=r(n,o.line),os(n,e,eu(e.markedSpans,i.marker));if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(f=0;f<t.markedSpans.length;++f)if(u=t.markedSpans[f],u.marker.collapsed&&!u.marker.replacedWith&&u.from==i.to&&(u.to==null||u.to!=i.from)&&(u.marker.inclusiveLeft||i.marker.inclusiveRight)&&os(n,t,u))return!0}function rl(n){var i=n.markedSpans,t;if(i){for(t=0;t<i.length;++t)i[t].marker.detachLine(n);n.markedSpans=null}}function ul(n,t){if(t){for(var i=0;i<t.length;++i)t[i].marker.attachLine(n);n.markedSpans=t}}function fl(n){return function(){var t=!this.cm.curOp,i;t&&ki(this.cm);try{i=n.apply(this,arguments)}finally{t&&di(this.cm)}return i}}function ie(n){return n.height!=null?n.height:(n.node.parentNode&&n.node.parentNode.nodeType==1||yt(n.cm.display.measure,i("div",[n.node],null,"position: relative")),n.height=n.node.offsetHeight)}function wy(n,t,i,r){var u=new ou(n,i,r);return u.noHScroll&&(n.display.alignWidgets=!0),df(n,t,function(t){var i=t.widgets||(t.widgets=[]),r;return u.insertAt==null?i.push(u):i.splice(Math.min(i.length-1,Math.max(0,u.insertAt)),0,u),u.line=t,(!li(n.doc,t)||u.showIfHidden)&&(r=lu(n,t)<n.doc.scrollTop,et(t,t.height+ie(u)),r&&go(n,0,u.height),n.curOp.forceUpdate=!0),!0}),u}function by(n,t,i,r){n.text=t,n.stateAfter&&(n.stateAfter=null),n.styles&&(n.styles=null),n.order!=null&&(n.order=null),rl(n),ul(n,i);var u=r?r(n):1;u!=n.height&&et(n,u)}function ky(n){n.parent=null,rl(n)}function el(t,i,r,u,f,e){var c=r.flattenSpans,a,v;c==null&&(c=t.options.flattenSpans);var h=0,l=null,o=new ru(i,t.options.tabSize),s;for(i==""&&r.blankLine&&r.blankLine(u);!o.eol();)o.pos>t.options.maxHighlightLength?(c=!1,e&&ss(t,i,u,o.pos),o.pos=i.length,s=null):s=r.token(o,u),t.options.addModeClass&&(a=n.innerMode(r,u).mode.name,a&&(s="m-"+(s?a+" "+s:a))),c&&l==s||(h<o.start&&f(o.start,l),h=o.start,l=s),o.start=o.pos;while(h<o.pos)v=Math.min(o.pos,h+5e4),f(v,l),h=v}function ol(n,t,i,r){var u=[n.state.modeGen],e;for(el(n,t.text,n.doc.mode,i,function(n,t){u.push(n,t)},r),e=0;e<n.state.overlays.length;++e){var o=n.state.overlays[e],f=1,s=0;el(n,t.text,o.mode,!0,function(n,t){for(var i=f,r,e;s<n;)r=u[f],r>n&&u.splice(f,1,n,u[f+1],r),f+=2,s=Math.min(n,r);if(t)if(o.opaque)u.splice(i,f-i,n,t),f=i+2;else for(;i<f;i+=2)e=u[i+1],u[i+1]=e?e+" "+t:t})}return u}function sl(n,t){return t.styles&&t.styles[0]==n.state.modeGen||(t.styles=ol(n,t,t.stateAfter=yr(n,tt(t)))),t.styles}function ss(n,t,i,r){var f=n.doc.mode,u=new ru(t,n.options.tabSize);for(u.start=u.pos=r||0,t==""&&f.blankLine&&f.blankLine(i);!u.eol()&&u.pos<=n.options.maxHighlightLength;)f.token(u,i),u.start=u.pos}function ll(n,t){var i,r,u;if(!n)return null;for(;;){if(i=n.match(/(?:^|\s+)line-(background-)?(\S+)/),!i)break;n=n.slice(0,i.index)+n.slice(i.index+i[0].length),r=i[1]?"bgClass":"textClass",t[r]==null?t[r]=i[2]:new RegExp("(?:^|s)"+i[2]+"(?:$|s)").test(t[r])||(t[r]+=" "+i[2])}return/^\s*$/.test(n)?null:(u=t.cm.options.addModeClass?cl:hl,u[n]||(u[n]=n.replace(/\S+/g,"cm-$&")))}function hs(n,t,u,f){for(var b,o=t,d=!0,e,a,s,h,v,p,c,w;b=es(o);)o=r(n.doc,b.find().from.line);e={pre:i("pre"),col:0,pos:0,measure:null,measuredSomething:!1,cm:n,copyWidgets:f};do o.text&&(d=!1),e.measure=o==t&&u,e.pos=0,e.addToken=e.measure?gy:al,(k||y)&&n.getOption("lineWrapping")&&(e.addToken=np(e.addToken)),a=tp(o,e,sl(n,o)),u&&o==t&&!e.measuredSomething&&(u[0]=e.pre.appendChild(nf(n.display.measure)),e.measuredSomething=!0),a&&(o=r(n.doc,a.to.line));while(a);return!u||e.measuredSomething||u[0]||(u[0]=e.pre.appendChild(d?i("span"," "):nf(n.display.measure))),e.pre.firstChild||li(n.doc,t)||e.pre.appendChild(document.createTextNode(" ")),u&&k&&(s=lt(o))&&(h=s.length-1,s[h].from==s[h].to&&--h,v=s[h],p=s[h-1],v.from+1==v.to&&p&&v.level<p.level&&(c=u[e.pos-1],c&&c.parentNode.insertBefore(c.measureRight=nf(n.display.measure),c.nextSibling))),w=e.textClass?e.textClass+" "+(t.textClass||""):t.textClass,w&&(e.pre.className=w),l(n,"renderLine",n,t,e.pre),e}function dy(n){var t=i("span","•","cm-invalidchar");return t.title="\\u"+n.charCodeAt(0).toString(16),t}function al(n,t,r,u,f,e){var a,o,s,h,l,y,p,v,c;if(t){if(a=n.cm.options.specialChars,a.test(t))for(o=document.createDocumentFragment(),s=0;;){if(a.lastIndex=s,h=a.exec(t),l=h?h.index-s:t.length-s,l&&(o.appendChild(document.createTextNode(t.slice(s,s+l))),n.col+=l),!h)break;s+=l+1,h[0]=="\t"?(y=n.cm.options.tabSize,p=y-n.col%y,o.appendChild(i("span",ia(p),"cm-tab")),n.col+=p):(c=n.cm.options.specialCharPlaceholder(h[0]),o.appendChild(c),n.col+=1)}else n.col+=t.length,o=document.createTextNode(t);if(r||u||f||n.measure)return v=r||"",u&&(v+=u),f&&(v+=f),c=i("span",[o],v),e&&(c.title=e),n.pre.appendChild(c);n.pre.appendChild(o)}}function gy(n,t,r,u,f){for(var l=n.cm.options.lineWrapping,a,o,s,h,c,e=0;e<t.length;++e){for(a=e==0,o=e+1;o<t.length&&se(t.charAt(o));)++o;s=t.slice(e,o),e=o-1,e&&l&&ku(t,e)&&n.pre.appendChild(i("wbr")),h=n.measure[n.pos],c=n.measure[n.pos]=al(n,s,r,a&&u,e==t.length-1&&f),h&&(c.leftSide=h.leftSide||h),st&&l&&s==" "&&e&&!/\s/.test(t.charAt(e-1))&&e<t.length-1&&!/\s/.test(t.charAt(e+1))&&(c.style.whiteSpace="normal"),n.pos+=s.length}t.length&&(n.measuredSomething=!0)}function np(n){function t(n){for(var i=" ",t=0;t<n.length-2;++t)i+=t%2?" ":" ";return i+" "}return function(i,r,u,f,e,o){return n(i,r.replace(/ {3,}/g,t),u,f,e,o)}}function vl(n,t,i,r){var u=!r&&i.replacedWith,f;if(u&&(n.copyWidgets&&(u=u.cloneNode(!0)),n.pre.appendChild(u),n.measure)){if(t)n.measure[n.pos]=u;else if(f=nf(n.cm.display.measure),i.type!="bookmark"||i.insertLeft){if(n.measure[n.pos])return;n.measure[n.pos]=n.pre.insertBefore(f,u)}else n.measure[n.pos]=n.pre.appendChild(f);n.measuredSomething=!0}n.pos+=t}function tp(n,t,i){var d=n.markedSpans,g=n.text,v=0,h,a,u,e,s,l,k,it;if(!d){for(h=1;h<i.length;h+=2)t.addToken(t,g.slice(v,v=i[h]),ll(i[h+1],t));return}for(var nt=g.length,r=0,h=1,c="",tt,o=0,y,p,w,b,f;;){if(o==r){for(y=p=w=b="",f=null,o=Infinity,a=[],s=0;s<d.length;++s)u=d[s],e=u.marker,u.from<=r&&(u.to==null||u.to>r)?(u.to!=null&&o>u.to&&(o=u.to,p=""),e.className&&(y+=" "+e.className),e.startStyle&&u.from==r&&(w+=" "+e.startStyle),e.endStyle&&u.to==o&&(p+=" "+e.endStyle),e.title&&!b&&(b=e.title),e.collapsed&&(!f||nl(f.marker,e)<0)&&(f=u)):u.from>r&&o>u.from&&(o=u.from),e.type=="bookmark"&&u.from==r&&e.replacedWith&&a.push(e);if(f&&(f.from||0)==r&&(vl(t,(f.to==null?nt:f.to)-r,f.marker,f.from==null),f.to==null))return f.marker.find();if(!f&&a.length)for(s=0;s<a.length;++s)vl(t,0,a[s])}if(r>=nt)break;for(l=Math.min(nt,o);;){if(c){if(k=r+c.length,f||(it=k>l?c.slice(0,l-r):c,t.addToken(t,it,tt?tt+y:y,w,r+it.length==o?p:"",b)),k>=l){c=c.slice(l-r),r=l;break}r=k,w=""}c=g.slice(v,v=i[h++]),tt=ll(i[h++],t)}}}function cs(n,t,i,u,f){function l(n){return i?i[n]:null}function v(n,i,r){by(n,i,r,f),g(n,"change",n,t)}var o=t.from,a=t.to,s=t.text,h=r(n,o.line),y=r(n,a.line),b=nt(s),k=l(s.length-1),p=a.line-o.line;if(o.ch==0&&a.ch==0&&b==""&&(!n.cm||n.cm.options.wholeLineUpdateBefore)){for(var e=0,w=s.length-1,c=[];e<w;++e)c.push(new bt(s[e],l(e),f));v(y,y.text,k),p&&n.remove(o.line,p),c.length&&n.insert(o.line,c)}else if(h==y)if(s.length==1)v(h,h.text.slice(0,o.ch)+b+h.text.slice(a.ch),k);else{for(var c=[],e=1,w=s.length-1;e<w;++e)c.push(new bt(s[e],l(e),f));c.push(new bt(b+h.text.slice(a.ch),k,f)),v(h,h.text.slice(0,o.ch)+s[0],l(0)),n.insert(o.line+1,c)}else if(s.length==1)v(h,h.text.slice(0,o.ch)+s[0]+y.text.slice(a.ch),l(0)),n.remove(o.line+1,p);else{v(h,h.text.slice(0,o.ch)+s[0],l(0)),v(y,b+y.text.slice(a.ch),k);for(var e=1,w=s.length-1,c=[];e<w;++e)c.push(new bt(s[e],l(e),f));p>1&&n.remove(o.line+1,p-1),n.insert(o.line+1,c)}g(n,"change",n,t),pt(n,u.anchor,u.head,null,!0)}function re(n){this.lines=n,this.parent=null;for(var t=0,r=n.length,i=0;t<r;++t)n[t].parent=this,i+=n[t].height;this.height=i}function su(n){var r,u,t,f,i;for(this.children=n,r=0,u=0,t=0,f=n.length;t<f;++t)i=n[t],r+=i.chunkSize(),u+=i.height,i.parent=this;this.size=r,this.height=u,this.parent=null}function sr(n,t,i){function r(n,u,f){var o,e,s;if(n.linked)for(o=0;o<n.linked.length;++o)(e=n.linked[o],e.doc!=u)&&(s=f&&e.sharedHist,!i||s)&&(t(e.doc,s),r(e.doc,n,s))}r(n,null,!0)}function wl(n,t){if(t.cm)throw new Error("This document is already in use.");n.doc=t,t.cm=n,we(n),pe(n),n.options.lineWrapping||be(n),n.options.mode=t.modeOption,a(n)}function r(n,t){var i,r,u;for(t-=n.first;!n.lines;)for(i=0;;++i){if(r=n.children[i],u=r.chunkSize(),t<u){n=r;break}t-=u}return n.lines[t]}function ls(n,t,i){var u=[],r=t.line;return n.iter(t.line,i.line+1,function(n){var f=n.text;r==i.line&&(f=f.slice(0,i.ch)),r==t.line&&(f=f.slice(t.ch)),u.push(f),++r}),u}function as(n,t,i){var r=[];return n.iter(t,i,function(n){r.push(n.text)}),r}function et(n,t){for(var r=t-n.height,i=n;i;i=i.parent)i.height+=r}function tt(n){var i,u,t,r;if(n.parent==null)return null;for(i=n.parent,u=ot(i.lines,n),t=i.parent;t;i=t,t=t.parent)for(r=0;;++r){if(t.children[r]==i)break;u+=t.children[r].chunkSize()}return u+i.first}function cu(n,t){var f=n.first,u,e,i,r,s,o;n:do{for(i=0,r=n.children.length;i<r;++i){if(u=n.children[i],e=u.height,t<e){n=u;continue n}t-=e,f+=u.chunkSize()}return f}while(!n.lines);for(i=0,r=n.lines.length;i<r;++i){if(s=n.lines[i],o=s.height,t<o)break;t-=o}return f+i}function lu(n,t){var f,r,e,u,i,o;for(t=wt(n.doc,t),f=0,r=t.parent,i=0;i<r.lines.length;++i)if(e=r.lines[i],e==t)break;else f+=e.height;for(u=r.parent;u;r=u,u=r.parent)for(i=0;i<u.children.length;++i)if(o=u.children[i],o==r)break;else f+=o.height;return f}function lt(n){var t=n.order;return t==null&&(t=n.order=ya(n.text)),t}function ue(n){return{done:[],undone:[],undoDepth:Infinity,lastTime:0,lastOp:null,lastOrigin:null,generation:n||1,maxGeneration:n||1}}function bl(n,t,i,r){var u=t["spans_"+n.id],f=0;n.iter(Math.max(n.first,i),Math.min(n.first+n.size,r),function(i){i.markedSpans&&((u||(u=t["spans_"+n.id]={}))[f]=i.markedSpans),++f})}function vs(n,t){var r={line:t.from.line,ch:t.from.ch},i={from:r,to:vf(t),text:ls(n,t.from,t.to)};return bl(n,i,t.from.line,t.to.line+1),sr(n,function(n){bl(n,i,t.from.line,t.to.line+1)},!0),i}function kl(n,t,i,r){var u=n.history,o,f,e;if(u.undone.length=0,o=+new Date,f=nt(u.done),f&&(u.lastOp==r||u.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.cm&&u.lastTime>o-n.cm.options.historyEventDelay||t.origin.charAt(0)=="*")))e=nt(f.changes),s(t.from,t.to)&&s(t.from,e.to)?e.to=vf(t):f.changes.push(vs(n,t)),f.anchorAfter=i.anchor,f.headAfter=i.head;else for(f={changes:[vs(n,t)],generation:u.generation,anchorBefore:n.sel.anchor,headBefore:n.sel.head,anchorAfter:i.anchor,headAfter:i.head},u.done.push(f);u.done.length>u.undoDepth;)u.done.shift();u.generation=++u.maxGeneration,u.lastTime=o,u.lastOp=r,u.lastOrigin=t.origin,e||l(n,"historyAdded")}function ip(n){if(!n)return null;for(var i=0,t;i<n.length;++i)n[i].marker.explicitlyCleared?t||(t=n.slice(0,i)):t&&t.push(n[i]);return t?t.length?t:null:n}function rp(n,t){var u=t["spans_"+n.id],i,r;if(!u)return null;for(i=0,r=[];i<t.text.length;++i)r.push(ip(u[i]));return r}function fe(n,t){for(var e,i,c,u,f=0,o=[];f<n.length;++f){var r=n[f],h=r.changes,s=[];for(o.push({changes:s,anchorBefore:r.anchorBefore,headBefore:r.headBefore,anchorAfter:r.anchorAfter,headAfter:r.headAfter}),e=0;e<h.length;++e)if(i=h[e],s.push({from:i.from,to:i.to,text:i.text}),t)for(u in i)(c=u.match(/^spans_(\d+)$/))&&ot(t,Number(c[1]))>-1&&(nt(s)[u]=i[u],delete i[u])}return o}function ee(n,t,i,r){i<n.line?n.line+=r:t<n.line&&(n.line=t,n.ch=0)}function dl(n,t,i,r){for(var u,s,o,f,e=0;e<n.length;++e){for(u=n[e],s=!0,o=0;o<u.changes.length;++o)if(f=u.changes[o],u.copied||(f.from=hi(f.from),f.to=hi(f.to)),i<f.from.line)f.from.line+=r,f.to.line+=r;else if(t<=f.to.line){s=!1;break}u.copied||(u.anchorBefore=hi(u.anchorBefore),u.headBefore=hi(u.headBefore),u.anchorAfter=hi(u.anchorAfter),u.readAfter=hi(u.headAfter),u.copied=!0),s?(ee(u.anchorBefore),ee(u.headBefore),ee(u.anchorAfter),ee(u.headAfter)):(n.splice(0,e+1),e=0)}}function gl(n,t){var i=t.from.line,r=t.to.line,u=t.text.length-(r-i)-1;dl(n.done,i,r,u),dl(n.undone,i,r,u)}function up(){vu(this)}function au(n){return n.stop||(n.stop=up),n}function v(n){n.preventDefault?n.preventDefault():n.returnValue=!1}function na(n){n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}function ys(n){return n.defaultPrevented!=null?n.defaultPrevented:n.returnValue==!1}function vu(n){v(n),na(n)}function ps(n){return n.target||n.srcElement}function ta(n){var t=n.which;return t==null&&(n.button&1?t=1:n.button&2?t=3:n.button&4&&(t=2)),pi&&n.ctrlKey&&t==1&&(t=3),t}function o(n,t,i){if(n.addEventListener)n.addEventListener(t,i,!1);else if(n.attachEvent)n.attachEvent("on"+t,i);else{var r=n._handlers||(n._handlers={}),u=r[t]||(r[t]=[]);u.push(i)}}function kt(n,t,i){var r,u;if(n.removeEventListener)n.removeEventListener(t,i,!1);else if(n.detachEvent)n.detachEvent("on"+t,i);else{if(r=n._handlers&&n._handlers[t],!r)return;for(u=0;u<r.length;++u)if(r[u]==i){r.splice(u,1);break}}}function l(n,t){var r=n._handlers&&n._handlers[t],u,i;if(r)for(u=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,u)}function g(n,t){function f(n){return function(){n.apply(null,u)}}var r=n._handlers&&n._handlers[t],u,i;if(r)for(u=Array.prototype.slice.call(arguments,2),ti||(++yu,ti=[],setTimeout(fp,0)),i=0;i<r.length;++i)ti.push(f(r[i]))}function at(n,t,i){return l(n,i||t.type,n,t),ys(t)||t.codemirrorIgnore}function fp(){var t,n;for(--yu,t=ti,ti=null,n=0;n<t.length;++n)t[n]()}function vt(n,t){var i=n._handlers&&n._handlers[t];return i&&i.length>0}function hr(n){n.prototype.on=function(n,t){o(this,n,t)},n.prototype.off=function(n,t){kt(this,n,t)}}function bs(){this.id=null}function ii(n,t,i,r,u){t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length));for(var e=r||0,f=u||0;e<t;++e)n.charAt(e)=="\t"?f+=i-f%i:++f;return f}function ia(n){while(pu.length<=n)pu.push(nt(pu)+" ");return pu[n]}function nt(n){return n[n.length-1]}function ra(n){if(cr)n.selectionStart=0,n.selectionEnd=n.value.length;else try{n.select()}catch(t){}}function ot(n,t){if(n.indexOf)return n.indexOf(t);for(var i=0,r=n.length;i<r;++i)if(n[i]==t)return i;return-1}function ua(n,t){function i(){}i.prototype=n;var r=new i;return t&&oe(t,r),r}function oe(n,t){t||(t={});for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);return t}function fa(n){for(var t=[],i=0;i<n;++i)t.push(undefined);return t}function ut(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t)}}function wu(n){return/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||ea.test(n))}function oa(n){for(var t in n)if(n.hasOwnProperty(t)&&n[t])return!1;return!0}function se(n){return n.charCodeAt(0)>=768&&sa.test(n)}function i(n,t,i,r){var u=document.createElement(n),f;if(i&&(u.className=i),r&&(u.style.cssText=r),typeof t=="string")ha(u,t);else if(t)for(f=0;f<t.length;++f)u.appendChild(t[f]);return u}function bu(n){for(var t=n.childNodes.length;t>0;--t)n.removeChild(n.firstChild);return n}function yt(n,t){return bu(n).appendChild(t)}function ha(n,t){b?(n.innerHTML="",n.appendChild(document.createTextNode(t))):n.textContent=t}function c(n){return n.getBoundingClientRect()}function ku(){return!1}function gu(n){if(du!=null)return du;var t=i("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return yt(n,t),t.offsetWidth&&(du=t.offsetHeight-t.clientHeight),du||0}function nf(n){if(ks==null){var t=i("span","​");yt(n,i("span",[t,document.createTextNode("x")])),n.firstChild.offsetHeight!=0&&(ks=t.offsetWidth<=1&&t.offsetHeight>2&&!yi)}return ks?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function op(n,t,i,r){var e,f,u;if(!n)return r(t,i,"ltr");for(e=!1,f=0;f<n.length;++f)u=n[f],(u.from<i&&u.to>t||t==i&&u.to==t)&&(r(Math.max(u.from,t),Math.min(u.to,i),u.level==1?"rtl":"ltr"),e=!0);e||r(t,i,"ltr")}function ds(n){return n.level%2?n.to:n.from}function gs(n){return n.level%2?n.from:n.to}function he(n){var t=lt(n);return t?ds(t[0]):0}function ce(n){var t=lt(n);return t?gs(nt(t)):n.text.length}function aa(n,i){var e=r(n.doc,i),u=wt(n.doc,e),f,o;return u!=e&&(i=tt(u)),f=lt(u),o=f?f[0].level%2?ce(u):he(u):0,t(i,o)}function sp(n,i){for(var e,u,f,o;e=te(u=r(n.doc,i));)i=e.find().to.line;return f=lt(u),o=f?f[0].level%2?he(u):ce(u):u.text.length,t(i,o)}function hp(n,t,i){var r=n[0].level;return t==r?!0:i==r?!1:t<i}function nh(n,t){var r,u,i;for(tf=null,r=0;r<n.length;++r){if(i=n[r],i.from<t&&i.to>t)return r;if(i.from==t||i.to==t)if(u==null)u=r;else return hp(n,i.level,n[u].level)?(i.from!=i.to&&(tf=u),r):(i.from!=i.to&&(tf=r),u)}return u}function th(n,t,i,r){if(!r)return t+i;do t+=i;while(t>0&&se(n.text.charAt(t)));return t}function ih(n,t,i,r){var e=lt(n);if(!e)return va(n,t,i,r);for(var o=nh(e,t),u=e[o],f=th(n,t,u.level%2?-i:i,r);;){if(f>u.from&&f<u.to)return f;if(f==u.from||f==u.to)return nh(e,f)==o?f:(u=e[o+=i],i>0==u.level%2?u.to:u.from);if(u=e[o+=i],!u)return null;f=i>0==u.level%2?th(n,u.to,-1,r):th(n,u.from,1,r)}}function va(n,t,i,r){var u=t+i;if(r)while(u>0&&se(n.text.charAt(u)))u+=i;return u<0||u>n.text.length?null:u}var vi=/gecko\/\d/i.test(navigator.userAgent),st=/MSIE \d/.test(navigator.userAgent),yi=st&&(document.documentMode==null||document.documentMode<8),b=st&&(document.documentMode==null||document.documentMode<9),pa=st&&(document.documentMode==null||document.documentMode<10),wa=/Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent),k=st||wa,y=/WebKit\//.test(navigator.userAgent),ba=y&&/Qt\/\d+\.\d+/.test(navigator.userAgent),ka=/Chrome\//.test(navigator.userAgent),ft=/Opera\//.test(navigator.userAgent),le=/Apple Computer/.test(navigator.vendor),ae=/KHTML\//.test(navigator.userAgent),da=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),ga=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),nv=/PhantomJS/.test(navigator.userAgent),cr=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),ve=cr||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),pi=cr||/Mac/.test(navigator.platform),tv=/win/i.test(navigator.platform),fi=ft&&navigator.userAgent.match(/Version\/(\d*\.\d*)/),ei,bh,hf,cf,vo,gr,rt,tc,af,wo,vf,ci,gf,is,rs,rr,ur,ne,gt,tu,ct,kc,ou,bt,hl,cl,yl,w,pl,hu,ti,yu,ai,ws,pu,ea,sa,ca,du,ks,ri,tf,ya;fi&&(fi=Number(fi[1])),fi&&fi>=15&&(ft=!1,y=!0);var rh=pi&&(ba||ft&&(fi==null||fi<12.11)),ye=vi||k&&!b,uh=!1,wi=!1;bh=0,vo=0,gr=0,rt=null,k?rt=-.53:vi?rt=15:ka?rt=-.7:le&&(rt=-1/3),af=null,vf=n.changeEnd=function(n){return n.text?t(n.from.line+n.text.length-1,nt(n.text).length+(n.text.length==1?n.from.ch:0)):n.to},n.Pos=t,n.prototype={constructor:n,focus:function(){window.focus(),d(this),br(this)},setOption:function(n,t){var i=this.options,r=i[n];(i[n]!=t||n=="mode")&&(i[n]=t,ci.hasOwnProperty(n)&&e(this,ci[n])(this,t,r))},getOption:function(n){return this.options[n]},getDoc:function(){return this.doc},addKeyMap:function(n,t){this.state.keyMaps[t?"push":"unshift"](n)},removeKeyMap:function(n){for(var i=this.state.keyMaps,t=0;t<i.length;++t)if(i[t]==n||typeof i[t]!="string"&&i[t].name==n)return i.splice(t,1),!0},addOverlay:e(null,function(t,i){var r=t.token?t:n.getMode(this.options,t);if(r.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:r,modeSpec:t,opaque:i&&i.opaque}),this.state.modeGen++,a(this)}),removeOverlay:e(null,function(n){for(var i=this.state.overlays,r,t=0;t<i.length;++t)if(r=i[t].modeSpec,r==n||typeof n=="string"&&r.name==n){i.splice(t,1),this.state.modeGen++,a(this);return}}),indentLine:e(null,function(n,t,i){typeof t!="string"&&typeof t!="number"&&(t=t==null?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ir(this.doc,n)&&kf(this,n,t,i)}),indentSelection:e(null,function(n){var t=this.doc.sel,r,i;if(s(t.from,t.to))return kf(this,t.from.line,n,!0);for(r=t.to.line-(t.to.ch?0:1),i=t.from.line;i<=r;++i)kf(this,i,n)}),getTokenAt:function(n,t){var e=this.doc,f;n=u(e,n);for(var o=yr(this,n.line,t),s=this.doc.mode,h=r(e,n.line),i=new ru(h.text,this.options.tabSize);i.pos<n.ch&&!i.eol();)i.start=i.pos,f=s.token(i,o);return{start:i.start,end:i.pos,string:i.current(),className:f||null,type:f||null,state:o}},getTokenTypeAt:function(n){var t;n=u(this.doc,n);var i=sl(this,r(this.doc,n.line)),e=0,o=(i.length-1)/2,f=n.ch;if(f==0)return i[2];for(;;)if(t=e+o>>1,(t?i[t*2-1]:0)>=f)o=t;else if(i[t*2+1]<f)e=t+1;else return i[t*2+2]},getModeAt:function(t){var i=this.doc.mode;return i.innerMode?n.innerMode(i,this.getTokenAt(t).state).mode:i},getHelper:function(n,t){return this.getHelpers(n,t)[0]},getHelpers:function(n,t){var f=[],r,i,o,u,e;if(!gt.hasOwnProperty(t))return gt;if(r=gt[t],i=this.getModeAt(n),typeof i[t]=="string")r[i[t]]&&f.push(r[i[t]]);else if(i[t])for(u=0;u<i[t].length;u++)o=r[i[t][u]],o&&f.push(o);else i.helperType&&r[i.helperType]?f.push(r[i.helperType]):r[i.name]&&f.push(r[i.name]);for(u=0;u<r._global.length;u++)e=r._global[u],e.pred(i,this)&&ot(f,e.val)==-1&&f.push(e.val);return f},getStateAfter:function(n,t){var i=this.doc;return n=lc(i,n==null?i.first+i.size-1:n),yr(this,n+1,t)},cursorCoords:function(n,t){var r,i=this.doc.sel;return r=n==null?i.head:typeof n=="object"?u(this.doc,n):n?i.from:i.to,it(this,r,t||"page")},charCoords:function(n,t){return so(this,u(this.doc,n),t||"page")},coordsChar:function(n,t){return n=ph(this,n,t||"page"),ho(this,n.left,n.top)},lineAtHeight:function(n,t){return n=ph(this,{top:n,left:0},t||"page").top,cu(this.doc,n+this.display.viewOffset)},heightAtLine:function(n,t){var i=!1,u=this.doc.first+this.doc.size-1,f;return n<this.doc.first?n=this.doc.first:n>u&&(n=u,i=!0),f=r(this.doc,n),oo(this,r(this.doc,n),{top:0,left:0},t||"page").top+(i?f.height:0)},defaultTextHeight:function(){return oi(this.display)},defaultCharWidth:function(){return wh(this.display)},setGutterMarker:e(null,function(n,t,i){return df(this,n,function(n){var r=n.gutterMarkers||(n.gutterMarkers={});return r[t]=i,!i&&oa(r)&&(n.gutterMarkers=null),!0})}),clearGutter:e(null,function(n){var i=this,r=i.doc,t=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[n]&&(r.gutterMarkers[n]=null,a(i,t,t+1),oa(r.gutterMarkers)&&(r.gutterMarkers=null)),++t})}),addLineClass:e(null,function(n,t,i){return df(this,n,function(n){var r=t=="text"?"textClass":t=="background"?"bgClass":"wrapClass";if(n[r]){if(new RegExp("(?:^|\\s)"+i+"(?:$|\\s)").test(n[r]))return!1;n[r]+=" "+i}else n[r]=i;return!0})}),removeLineClass:e(null,function(n,t,i){return df(this,n,function(n){var f=t=="text"?"textClass":t=="background"?"bgClass":"wrapClass",u=n[f],r,e;if(u)if(i==null)n[f]=null;else{if(r=u.match(new RegExp("(?:^|\\s+)"+i+"(?:$|\\s+)")),!r)return!1;e=r.index+r[0].length,n[f]=u.slice(0,r.index)+(!r.index||e==u.length?"":" ")+u.slice(e)||null}else return!1;return!0})}),addLineWidget:e(null,function(n,t,i){return wy(this,n,t,i)}),removeLineWidget:function(n){n.clear()},lineInfo:function(n){var t;if(typeof n=="number"){if(!ir(this.doc,n)||(t=n,n=r(this.doc,n),!n))return null}else if(t=tt(n),t==null)return null;return{line:t,handle:n,text:n.text,gutterMarkers:n.gutterMarkers,textClass:n.textClass,bgClass:n.bgClass,wrapClass:n.wrapClass,widgets:n.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(n,t,i,r,f){var s=this.display,o,e,h,c;n=it(this,u(this.doc,n)),o=n.bottom,e=n.left,t.style.position="absolute",s.sizer.appendChild(t),r=="over"?o=n.top:(r=="above"||r=="near")&&(h=Math.max(s.wrapper.clientHeight,this.doc.height),c=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth),(r=="above"||n.bottom+t.offsetHeight>h)&&n.top>t.offsetHeight?o=n.top-t.offsetHeight:n.bottom+t.offsetHeight<=h&&(o=n.bottom),e+t.offsetWidth>c&&(e=c-t.offsetWidth)),t.style.top=o+"px",t.style.left=t.style.right="",f=="right"?(e=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(f=="left"?e=0:f=="middle"&&(e=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=e+"px"),i&&sy(this,e,o,e+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:e(null,uc),triggerOnKeyPress:e(null,fc),triggerOnKeyUp:e(null,rc),execCommand:function(n){if(tu.hasOwnProperty(n))return tu[n](this)},findPosH:function(n,t,i,r){var o=1,e,f;for(t<0&&(o=-1,t=-t),e=0,f=u(this.doc,n);e<t;++e)if(f=ns(this.doc,f,o,i,r),f.hitSide)break;return f},moveH:e(null,function(n,t){var i=this.doc.sel,r;r=i.shift||i.extend||s(i.from,i.to)?ns(this.doc,i.head,n,t,this.options.rtlMoveVisually):n<0?i.from:i.to,p(this.doc,r,r,n)}),deleteH:e(null,function(n,t){var i=this.doc.sel;s(i.from,i.to)?dt(this.doc,"",i.from,ns(this.doc,i.head,n,t,!1),"+delete"):dt(this.doc,"",i.from,i.to,"+delete"),this.curOp.userSelChange=!0}),findPosV:function(n,t,i,r){var h=1,o=r,s,f,e;for(t<0&&(h=-1,t=-t),s=0,f=u(this.doc,n);s<t;++s)if(e=it(this,f,"div"),o==null?o=e.left:e.left=o,f=yc(this,e,h,i),f.hitSide)break;return f},moveV:e(null,function(n,t){var i=this.doc.sel,r,f,u;i.shift||i.extend||s(i.from,i.to)?(u=it(this,i.head,"div"),i.goalColumn!=null&&(u.left=i.goalColumn),r=yc(this,u,n,t),t=="page"&&go(this,0,so(this,r,"div").top-u.top),f=u.left):r=n<0?i.from:i.to,p(this.doc,r,r,n),f!=null&&(i.goalColumn=f)}),toggleOverwrite:function(n){(n==null||n!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite",""),l(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return document.activeElement==this.display.input},scrollTo:e(null,function(n,t){bf(this,n,t)}),getScrollInfo:function(){var n=this.display.scroller,t=ai;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight-t,width:n.scrollWidth-t,clientHeight:n.clientHeight-t,clientWidth:n.clientWidth-t}},scrollIntoView:e(null,function(n,i){var r,u;n==null?n={from:this.doc.sel.head,to:null}:typeof n=="number"?n={from:t(n,0),to:null}:n.from==null&&(n={from:n,to:null}),n.to||(n.to=n.from),i||(i=0),r=n,n.from.line!=null&&(this.curOp.scrollToPos={from:n.from,to:n.to,margin:i},r={from:it(this,n.from),to:it(this,n.to)}),u=wf(this,Math.min(r.from.left,r.to.left),Math.min(r.from.top,r.to.top)-i,Math.max(r.from.right,r.to.right),Math.max(r.from.bottom,r.to.bottom)+i),bf(this,u.scrollLeft,u.scrollTop)}),setSize:e(null,function(n,t){function i(n){return typeof n=="number"||/^\d+$/.test(String(n))?n+"px":n}n!=null&&(this.display.wrapper.style.width=i(n)),t!=null&&(this.display.wrapper.style.height=i(t)),this.options.lineWrapping&&(this.display.measureLineCache.length=this.display.measureLineCachePos=0),this.curOp.forceUpdate=!0,l(this,"refresh",this)}),operation:function(n){return co(this,n)},refresh:e(null,function(){var n=this.display.cachedTextHeight;bi(this),bf(this,this.doc.scrollLeft,this.doc.scrollTop),a(this),(n==null||Math.abs(n-oi(this.display))>.5)&&we(this),l(this,"refresh",this)}),swapDoc:e(null,function(n){var t=this.doc;return t.cm=null,wl(this,n),bi(this),ht(this,!0),bf(this,n.scrollLeft,n.scrollTop),g(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},hr(n),ci=n.optionHandlers={},gf=n.defaults={},is=n.Init={toString:function(){return"CodeMirror.Init"}},f("value","",function(n,t){n.setValue(t)},!0),f("mode",null,function(n,t){n.doc.modeOption=t,pe(n)},!0),f("indentUnit",2,pe,!0),f("indentWithTabs",!1),f("smartIndent",!0),f("tabSize",4,function(n){lr(n),bi(n),a(n)},!0),f("specialChars",/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g,function(n,t){n.options.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n.refresh()},!0),f("specialCharPlaceholder",dy,function(n){n.refresh()},!0),f("electricChars",!0),f("rtlMoveVisually",!tv),f("wholeLineUpdateBefore",!0),f("theme","default",function(n){oh(n),ar(n)},!0),f("keyMap","default",eh),f("extraKeys",null),f("onKeyEvent",null),f("onDragEvent",null),f("lineWrapping",!1,rv,!0),f("gutters",[],function(n){ke(n.options),ar(n)},!0),f("fixedGutter",!0,function(n,t){n.display.gutters.style.left=t?io(n.display)+"px":"0",n.refresh()},!0),f("coverGutterNextToScrollbar",!1,de,!0),f("lineNumbers",!1,function(n){ke(n.options),ar(n)},!0),f("firstLineNumber",1,ar,!0),f("lineNumberFormatter",function(n){return n},ar,!0),f("showCursorWhenSelecting",!1,uo,!0),f("resetSelectionOnContextMenu",!0),f("readOnly",!1,function(n,t){t=="nocursor"?(po(n),n.display.input.blur(),n.display.disabled=!0):(n.display.disabled=!1,t||ht(n,!0))}),f("disableInput",!1,function(n,t){t||ht(n,!0)},!0),f("dragDrop",!0),f("cursorBlinkRate",530),f("cursorScrollMargin",0),f("cursorHeight",1),f("workTime",100),f("workDelay",100),f("flattenSpans",!0,lr,!0),f("addModeClass",!1,lr,!0),f("pollInterval",100),f("undoDepth",40,function(n,t){n.doc.history.undoDepth=t}),f("historyEventDelay",500),f("viewportMargin",10,function(n){n.refresh()},!0),f("maxHighlightLength",1e4,lr,!0),f("crudeMeasuringFrom",1e4),f("moveInputWithCursor",!0,function(n,t){t||(n.display.inputDiv.style.top=n.display.inputDiv.style.left=0)}),f("tabindex",null,function(n,t){n.display.input.tabIndex=t||""}),f("autofocus",null),rs=n.modes={},rr=n.mimeModes={},n.defineMode=function(t,i){if(n.defaults.mode||t=="null"||(n.defaults.mode=t),arguments.length>2){i.dependencies=[];for(var r=2;r<arguments.length;++r)i.dependencies.push(arguments[r])}rs[t]=i},n.defineMIME=function(n,t){rr[n]=t},n.resolveMode=function(t){if(typeof t=="string"&&rr.hasOwnProperty(t))t=rr[t];else if(t&&typeof t.name=="string"&&rr.hasOwnProperty(t.name)){var i=rr[t.name];typeof i=="string"&&(i={name:i}),t=ua(i,t),t.name=i.name}else if(typeof t=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return n.resolveMode("application/xml");return typeof t=="string"?{name:t}:t||{name:"null"}},n.getMode=function(t,i){var i=n.resolveMode(i),e=rs[i.name],u,f,r;if(!e)return n.getMode(t,"text/plain");if(u=e(t,i),ur.hasOwnProperty(i.name)){f=ur[i.name];for(r in f)f.hasOwnProperty(r)&&(u.hasOwnProperty(r)&&(u["_"+r]=u[r]),u[r]=f[r])}if(u.name=i.name,i.helperType&&(u.helperType=i.helperType),i.modeProps)for(r in i.modeProps)u[r]=i.modeProps[r];return u},n.defineMode("null",function(){return{token:function(n){n.skipToEnd()}}}),n.defineMIME("text/plain","null"),ur=n.modeExtensions={},n.extendMode=function(n,t){var i=ur.hasOwnProperty(n)?ur[n]:ur[n]={};oe(t,i)},n.defineExtension=function(t,i){n.prototype[t]=i},n.defineDocExtension=function(n,t){w.prototype[n]=t},n.defineOption=f,ne=[],n.defineInitHook=function(n){ne.push(n)},gt=n.helpers={},n.registerHelper=function(t,i,r){gt.hasOwnProperty(t)||(gt[t]=n[t]={_global:[]}),gt[t][i]=r},n.registerGlobalHelper=function(t,i,r,u){n.registerHelper(t,i,u),gt[t]._global.push({pred:r,val:u})},n.isWordChar=wu,n.copyState=fr,n.startState=pc,n.innerMode=function(n,t){while(n.innerMode){var i=n.innerMode(t);if(!i||i.mode==n)break;t=i.state,n=i.mode}return i||{mode:n,state:t}},tu=n.commands={selectAll:function(n){n.setSelection(t(n.firstLine(),0),t(n.lastLine()))},killLine:function(n){var i=n.getCursor(!0),r=n.getCursor(!1),u=!s(i,r);u||n.getLine(i.line).length!=i.ch?n.replaceRange("",i,u?r:t(i.line),"+delete"):n.replaceRange("",i,t(i.line+1,0),"+delete")},deleteLine:function(n){var i=n.getCursor().line;n.replaceRange("",t(i,0),t(i+1,0),"+delete")},delLineLeft:function(n){var i=n.getCursor();n.replaceRange("",t(i.line,0),i,"+delete")},undo:function(n){n.undo()},redo:function(n){n.redo()},goDocStart:function(n){n.extendSelection(t(n.firstLine(),0))},goDocEnd:function(n){n.extendSelection(t(n.lastLine()))},goLineStart:function(n){n.extendSelection(aa(n,n.getCursor().line))},goLineStartSmart:function(n){var i=n.getCursor(),r=aa(n,i.line),f=n.getLineHandle(r.line),e=lt(f),u,o;e&&e[0].level!=0?n.extendSelection(r):(u=Math.max(0,f.text.search(/\S/)),o=i.line==r.line&&i.ch<=u&&i.ch,n.extendSelection(t(r.line,o?0:u)))},goLineEnd:function(n){n.extendSelection(sp(n,n.getCursor().line))},goLineRight:function(n){var t=n.charCoords(n.getCursor(),"div").top+5;n.extendSelection(n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:t},"div"))},goLineLeft:function(n){var t=n.charCoords(n.getCursor(),"div").top+5;n.extendSelection(n.coordsChar({left:0,top:t},"div"))},goLineUp:function(n){n.moveV(-1,"line")},goLineDown:function(n){n.moveV(1,"line")},goPageUp:function(n){n.moveV(-1,"page")},goPageDown:function(n){n.moveV(1,"page")},goCharLeft:function(n){n.moveH(-1,"char")},goCharRight:function(n){n.moveH(1,"char")},goColumnLeft:function(n){n.moveH(-1,"column")},goColumnRight:function(n){n.moveH(1,"column")},goWordLeft:function(n){n.moveH(-1,"word")},goGroupRight:function(n){n.moveH(1,"group")},goGroupLeft:function(n){n.moveH(-1,"group")},goWordRight:function(n){n.moveH(1,"word")},delCharBefore:function(n){n.deleteH(-1,"char")},delCharAfter:function(n){n.deleteH(1,"char")},delWordBefore:function(n){n.deleteH(-1,"word")},delWordAfter:function(n){n.deleteH(1,"word")},delGroupBefore:function(n){n.deleteH(-1,"group")},delGroupAfter:function(n){n.deleteH(1,"group")},indentAuto:function(n){n.indentSelection("smart")},indentMore:function(n){n.indentSelection("add")},indentLess:function(n){n.indentSelection("subtract")},insertTab:function(n){n.replaceSelection("\t","end","+input")},defaultTab:function(n){n.somethingSelected()?n.indentSelection("add"):n.replaceSelection("\t","end","+input")},transposeChars:function(n){var i=n.getCursor(),r=n.getLine(i.line);i.ch>0&&i.ch<r.length-1&&n.replaceRange(r.charAt(i.ch)+r.charAt(i.ch-1),t(i.line,i.ch-1),t(i.line,i.ch+1))},newlineAndIndent:function(n){e(n,function(){n.replaceSelection("\n","end","+input"),n.indentLine(n.getCursor().line,null,!0)})()},toggleOverwrite:function(n){n.toggleOverwrite()}},ct=n.keyMap={},ct.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"},ct.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","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",fallthrough:"basic"},ct.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","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":"delLineLeft",fallthrough:["basic","emacsy"]},ct["default"]=pi?ct.macDefault:ct.pcDefault,ct.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"},n.lookupKey=iu,n.isModifierKey=wc,n.keyName=bc,n.fromTextArea=function(t,i){function f(){t.value=r.getValue()}var e,u,s,h,r;if(i||(i={}),i.value=t.value,!i.tabindex&&t.tabindex&&(i.tabindex=t.tabindex),!i.placeholder&&t.placeholder&&(i.placeholder=t.placeholder),i.autofocus==null){e=document.body;try{e=document.activeElement}catch(c){}i.autofocus=e==t||t.getAttribute("autofocus")!=null&&e==document.body}if(t.form&&(o(t.form,"submit",f),!i.leaveSubmitMethodAlone)){u=t.form,s=u.submit;try{h=u.submit=function(){f(),u.submit=s,u.submit(),u.submit=h}}catch(c){}}return t.style.display="none",r=n(function(n){t.parentNode.insertBefore(n,t.nextSibling)},i),r.save=f,r.getTextArea=function(){return t},r.toTextArea=function(){f(),t.parentNode.removeChild(r.getWrapperElement()),t.style.display="",t.form&&(kt(t.form,"submit",f),typeof t.form.submit=="function"&&(t.form.submit=s))},r},ru.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(n){var t=this.string.charAt(this.pos),i;return i=typeof n=="string"?t==n:t&&(n.test?n.test(t):n(t)),i?(++this.pos,t):void 0},eatWhile:function(n){for(var t=this.pos;this.eat(n););return this.pos>t},eatSpace:function(){for(var n=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>n},skipToEnd:function(){this.pos=this.string.length},skipTo:function(n){var t=this.string.indexOf(n,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(n){this.pos-=n},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ii(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ii(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return ii(this.string,null,this.tabSize)-(this.lineStart?ii(this.string,this.lineStart,this.tabSize):0)},match:function(n,t,i){var u,f,r;if(typeof n=="string"){if(u=function(n){return i?n.toLowerCase():n},f=this.string.substr(this.pos,n.length),u(f)==u(n))return t!==!1&&(this.pos+=n.length),!0}else return(r=this.string.slice(this.pos).match(n),r&&r.index>0)?null:(r&&t!==!1&&(this.pos+=r[0].length),r)},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(n,t){this.lineStart+=n;try{return t()}finally{this.lineStart-=n}}},n.StringStream=ru,n.TextMarker=ni,hr(ni),ni.prototype.clear=function(){var n,e,r,u,o,i,f,t,s,h;if(!this.explicitlyCleared){for(n=this.doc.cm,e=n&&!n.curOp,e&&ki(n),vt(this,"clear")&&(r=this.find(),r&&g(this,"clear",r.from,r.to)),u=null,o=null,t=0;t<this.lines.length;++t)i=this.lines[t],f=eu(i.markedSpans,this),f.to!=null&&(o=tt(i)),i.markedSpans=ly(i.markedSpans,f),f.from!=null?u=tt(i):this.collapsed&&!li(this.doc,i)&&n&&et(i,oi(n.display));if(n&&this.collapsed&&!n.options.lineWrapping)for(t=0;t<this.lines.length;++t)s=wt(n.doc,this.lines[t]),h=rf(n.doc,s),h>n.display.maxLineLength&&(n.display.maxLine=s,n.display.maxLineLength=h,n.display.maxLineChanged=!0);u!=null&&n&&a(n,u,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,n&&ac(n)),e&&di(n)}},ni.prototype.find=function(n){for(var r,o,f,i,e,u=0;u<this.lines.length;++u)f=this.lines[u],i=eu(f.markedSpans,this),(i.from!=null||i.to!=null)&&(e=tt(f),i.from!=null&&(r=t(e,i.from)),i.to!=null&&(o=t(e,i.to)));return this.type=="bookmark"&&!n?r:r&&{from:r,to:o}},ni.prototype.changed=function(){var i=this.find(),n=this.doc.cm,u,t;if(i&&n&&(this.type!="bookmark"&&(i=i.from),u=r(this.doc,i.line),wv(n,u),i.line>=n.display.showingFrom&&i.line<n.display.showingTo)){for(t=n.display.lineDiv.firstChild;t;t=t.nextSibling)if(t.lineObj==u){t.offsetHeight!=u.height&&et(u,t.offsetHeight);break}co(n,function(){n.curOp.selectionChanged=n.curOp.forceUpdate=n.curOp.updateMaxLine=!0})}},ni.prototype.attachLine=function(n){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&ot(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(n)},ni.prototype.detachLine=function(n){if(this.lines.splice(ot(this.lines,n),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},kc=0,n.SharedTextMarker=fu,hr(fu),fu.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var n=0;n<this.markers.length;++n)this.markers[n].clear();g(this,"clear")}},fu.prototype.find=function(){return this.primary.find()},ou=n.LineWidget=function(n,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.cm=n,this.node=t},hr(ou),ou.prototype.clear=fl(function(){var n=this.line.widgets,i=tt(this.line),t,r;if(i!=null&&n){for(t=0;t<n.length;++t)n[t]==this&&n.splice(t--,1);n.length||(this.line.widgets=null),r=lu(this.cm,this.line)<this.cm.doc.scrollTop,et(this.line,Math.max(0,this.line.height-ie(this))),r&&go(this.cm,0,-this.height),a(this.cm,i,i+1)}}),ou.prototype.changed=fl(function(){var i=this.height,n,t;(this.height=null,n=ie(this)-i,n)&&(et(this.line,this.line.height+n),t=tt(this.line),a(this.cm,t,t+1))}),bt=n.Line=function(n,t,i){this.text=n,ul(this,t),this.height=i?i(this):1},hr(bt),bt.prototype.lineNo=function(){return tt(this)},hl={},cl={},re.prototype={chunkSize:function(){return this.lines.length},removeInner:function(n,t){for(var r,i=n,u=n+t;i<u;++i)r=this.lines[i],this.height-=r.height,ky(r),g(r,"delete");this.lines.splice(n,t)},collapse:function(n){n.splice.apply(n,[n.length,0].concat(this.lines))},insertInner:function(n,t,i){this.height+=i,this.lines=this.lines.slice(0,n).concat(t).concat(this.lines.slice(n));for(var r=0,u=t.length;r<u;++r)t[r].parent=this},iterN:function(n,t,i){for(var r=n+t;n<r;++n)if(i(this.lines[n]))return!0}},su.prototype={chunkSize:function(){return this.size},removeInner:function(n,t){var r,i,u,f,o,e;for(this.size-=t,r=0;r<this.children.length;++r)if(i=this.children[r],u=i.chunkSize(),n<u){if(f=Math.min(t,u-n),o=i.height,i.removeInner(n,f),this.height-=o-i.height,u==f&&(this.children.splice(r--,1),i.parent=null),(t-=f)==0)break;n=0}else n-=u;this.size-t<25&&(e=[],this.collapse(e),this.children=[new re(e)],this.children[0].parent=this)},collapse:function(n){for(var t=0,i=this.children.length;t<i;++t)this.children[t].collapse(n)},insertInner:function(n,t,i){var u,o,r,e,s,f;for(this.size+=t.length,this.height+=i,u=0,o=this.children.length;u<o;++u){if(r=this.children[u],e=r.chunkSize(),n<=e){if(r.insertInner(n,t,i),r.lines&&r.lines.length>50){while(r.lines.length>50)s=r.lines.splice(r.lines.length-25,25),f=new re(s),r.height-=f.height,this.children.splice(u+1,0,f),f.parent=this;this.maybeSpill()}break}n-=e}},maybeSpill:function(){var n,r,t,i,u;if(!(this.children.length<=10)){n=this;do r=n.children.splice(n.children.length-5,5),t=new su(r),n.parent?(n.size-=t.size,n.height-=t.height,u=ot(n.parent.children,n),n.parent.children.splice(u+1,0,t)):(i=new su(n.children),i.parent=n,n.children=[i,t],n=i),t.parent=n.parent;while(n.children.length>10);n.parent.maybeSpill()}},iterN:function(n,t,i){for(var f,u,e,r=0,o=this.children.length;r<o;++r)if(f=this.children[r],u=f.chunkSize(),n<u){if(e=Math.min(t,u-n),f.iterN(n,e,i))return!0;if((t-=e)==0)break;n=0}else n-=u}},yl=0,w=n.Doc=function(n,i,r){if(!(this instanceof w))return new w(n,i,r);r==null&&(r=0),su.call(this,[new re([new bt("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.history=ue(),this.cleanGeneration=1,this.frontier=r;var u=t(r,0);this.sel={from:u,to:u,head:u,anchor:u,shift:!1,extend:!1,goalColumn:null},this.id=++yl,this.modeOption=i,typeof n=="string"&&(n=ri(n)),cs(this,{from:u,to:u,text:n},null,{head:u,anchor:u})},w.prototype=ua(su.prototype,{constructor:w,iter:function(n,t,i){i?this.iterN(n-this.first,t-n,i):this.iterN(this.first,this.first+this.size,n)},insert:function(n,t){for(var r=0,i=0,u=t.length;i<u;++i)r+=t[i].height;this.insertInner(n-this.first,t,r)},remove:function(n,t){this.removeInner(n-this.first,t)},getValue:function(n){var t=as(this,this.first,this.first+this.size);return n===!1?t:t.join(n||"\n")},setValue:function(n){var i=t(this.first,0),u=this.first+this.size-1;nr(this,{from:i,to:t(u,r(this,u).text.length),text:ri(n),origin:"setValue"},{head:i,anchor:i},!0)},replaceRange:function(n,t,i,r){t=u(this,t),i=i?u(this,i):t,dt(this,n,t,i,r)},getRange:function(n,t,i){var r=ls(this,u(this,n),u(this,t));return i===!1?r:r.join(i||"\n")},getLine:function(n){var t=this.getLineHandle(n);return t&&t.text},setLine:function(n,i){ir(this,n)&&dt(this,i,t(n,0),u(this,t(n)))},removeLine:function(n){n?dt(this,"",u(this,t(n-1)),u(this,t(n))):dt(this,"",t(0,0),u(this,t(1,0)))},getLineHandle:function(n){if(ir(this,n))return r(this,n)},getLineNumber:function(n){return tt(n)},getLineHandleVisualStart:function(n){return typeof n=="number"&&(n=r(this,n)),wt(this,n)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(n){return u(this,n)},getCursor:function(n){var t=this.sel,i;return i=n==null||n=="head"?t.head:n=="anchor"?t.anchor:n=="end"||n===!1?t.to:t.from,hi(i)},somethingSelected:function(){return!s(this.sel.head,this.sel.anchor)},setCursor:wr(function(n,i,r){var f=u(this,typeof n=="number"?t(n,i||0):n);r?p(this,f):pt(this,f,f)}),setSelection:wr(function(n,t,i){pt(this,u(this,n),u(this,t||n),i)}),extendSelection:wr(function(n,t,i){p(this,u(this,n),t&&u(this,t),i)}),getSelection:function(n){return this.getRange(this.sel.from,this.sel.to,n)},replaceSelection:function(n,t,i){nr(this,{from:this.sel.from,to:this.sel.to,text:ri(n),origin:i},t||"around")},undo:wr(function(){hc(this,"undo")}),redo:wr(function(){hc(this,"redo")}),setExtending:function(n){this.sel.extend=n},historySize:function(){var n=this.history;return{undo:n.done.length,redo:n.undone.length}},clearHistory:function(){this.history=ue(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(n){return n&&(this.history.lastOp=this.history.lastOrigin=null),this.history.generation},isClean:function(n){return this.history.generation==(n||this.cleanGeneration)},getHistory:function(){return{done:fe(this.history.done),undone:fe(this.history.undone)}},setHistory:function(n){var t=this.history=ue(this.history.maxGeneration);t.done=n.done.slice(0),t.undone=n.undone.slice(0)},markText:function(n,t,i){return uu(this,u(this,n),u(this,t),i,"range")},setBookmark:function(n,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1};return n=u(this,n),uu(this,n,n,i,"bookmark")},findMarksAt:function(n){var e,i,f,t;if(n=u(this,n),e=[],i=r(this,n.line).markedSpans,i)for(f=0;f<i.length;++f)t=i[f],(t.from==null||t.from<=n.ch)&&(t.to==null||t.to>=n.ch)&&e.push(t.marker.parent||t.marker);return e},findMarks:function(n,t){n=u(this,n),t=u(this,t);var r=[],i=n.line;return this.iter(n.line,t.line+1,function(u){var o=u.markedSpans,e,f;if(o)for(e=0;e<o.length;e++)f=o[e],i==n.line&&n.ch>f.to||f.from==null&&i!=n.line||i==t.line&&f.from>t.ch||r.push(f.marker.parent||f.marker);++i}),r},getAllMarks:function(){var n=[];return this.iter(function(t){var r=t.markedSpans,i;if(r)for(i=0;i<r.length;++i)r[i].from!=null&&n.push(r[i].marker)}),n},posFromIndex:function(n){var i,r=this.first;return this.iter(function(t){var u=t.text.length+1;if(u>n)return i=n,!0;n-=u,++r}),u(this,t(r,i))},indexFromPos:function(n){n=u(this,n);var t=n.ch;return n.line<this.first||n.ch<0?0:(this.iter(this.first,n.line,function(n){t+=n.text.length+1}),t)},copy:function(n){var t=new w(as(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn},n&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(n){var t,r,i;return n||(n={}),t=this.first,r=this.first+this.size,n.from!=null&&n.from>t&&(t=n.from),n.to!=null&&n.to<r&&(r=n.to),i=new w(as(this,t,r),n.mode||this.modeOption,t),n.sharedHist&&(i.history=this.history),(this.linked||(this.linked=[])).push({doc:i,sharedHist:n.sharedHist}),i.linked=[{doc:this,isParent:!0,sharedHist:n.sharedHist}],i},unlinkDoc:function(t){var i,u,r;if(t instanceof n&&(t=t.doc),this.linked)for(i=0;i<this.linked.length;++i)if(u=this.linked[i],u.doc==t){this.linked.splice(i,1),t.unlinkDoc(this);break}t.history==this.history&&(r=[t.id],sr(t,function(n){r.push(n.id)},!0),t.history=ue(),t.history.done=fe(this.history.done,r),t.history.undone=fe(this.history.undone,r))},iterLinkedDocs:function(n){sr(this,n)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),w.prototype.eachLine=w.prototype.iter,pl="iter insert remove copy getEditor".split(" ");for(hu in w.prototype)w.prototype.hasOwnProperty(hu)&&ot(pl,hu)<0&&(n.prototype[hu]=function(n){return function(){return n.apply(this.doc,arguments)}}(w.prototype[hu]));hr(w),n.e_stop=vu,n.e_preventDefault=v,n.e_stopPropagation=na,yu=0,n.on=o,n.off=kt,n.signal=l,ai=30,ws=n.Pass={toString:function(){return"CodeMirror.Pass"}},bs.prototype={set:function(n,t){clearTimeout(this.id),this.id=setTimeout(t,n)}},n.countColumn=ii,pu=[""],ea=/[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,sa=/[\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]/,n.replaceGetRect=function(n){c=n},ca=function(){if(b)return!1;var n=i("div");return"draggable"in n||"dragDrop"in n}(),vi?ku=function(n,t){return n.charCodeAt(t-1)==36&&n.charCodeAt(t)==39}:le&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?ku=function(n,t){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(n.slice(t-1,t+1))}:y&&/Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent)?ku=function(n,t){var i=n.charCodeAt(t-1);return i>=8208&&i<=8212}:y&&(ku=function(n,t){if(t>1&&n.charCodeAt(t-1)==45){if(/\w/.test(n.charAt(t-2))&&/[^\-?\.]/.test(n.charAt(t)))return!0;if(t>2&&/[\d\.,]/.test(n.charAt(t-2))&&/[\d\.,]/.test(n.charAt(t)))return!1}return/[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|\u2026[\w~`@#$%\^&*(_=+{[><]/.test(n.slice(t-1,t+1))}),ri="\n\nb".split(/\n/).length!=3?function(n){for(var i=0,f=[],e=n.length,t,r,u;i<=e;)t=n.indexOf("\n",i),t==-1&&(t=n.length),r=n.slice(i,n.charAt(t-1)=="\r"?t-1:t),u=r.indexOf("\r"),u!=-1?(f.push(r.slice(0,u)),i+=u+1):(f.push(r),i=t+1);return f}:function(n){return n.split(/\r\n?|\n/)},n.splitLines=ri;var ep=window.getSelection?function(n){try{return n.selectionStart!=n.selectionEnd}catch(t){return!1}}:function(n){try{var t=n.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=n?!1:t.compareEndPoints("StartToEnd",t)!=0},la=function(){var n=i("div");return"oncopy"in n?!0:(n.setAttribute("oncopy","return;"),typeof n.oncopy=="function")}(),ui={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"};return n.keyNames=ui,function(){for(var n=0;n<10;n++)ui[n+48]=ui[n+96]=String(n);for(n=65;n<=90;n++)ui[n]=String.fromCharCode(n);for(n=1;n<=12;n++)ui[n+111]=ui[n+63235]="F"+n}(),ya=function(){function o(n){return n<=255?f.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1791?e.charAt(n-1536):1792<=n&&n<=2220?"r":"L"}var f="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",e="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",s=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,t=/[stwN]/,i=/[LRr]/,r=/[Lb1n]/,u=/[1n]/,n="L";return function(f){var a,h,p,d,w,c,v,y,k,e,tt,b,g,l,it;if(!s.test(f))return!1;for(a=f.length,h=[],e=0;e<a;++e)h.push(c=o(f.charCodeAt(e)));for(e=0,p=n;e<a;++e)c=h[e],c=="m"?h[e]=p:p=c;for(e=0,w=n;e<a;++e)c=h[e],c=="1"&&w=="r"?h[e]="n":i.test(c)&&(w=c,c=="r"&&(h[e]="R"));for(e=1,p=h[0];e<a-1;++e)c=h[e],c=="+"&&p=="1"&&h[e+1]=="1"?h[e]="1":c==","&&p==h[e+1]&&(p=="1"||p=="n")&&(h[e]=p),p=c;for(e=0;e<a;++e)if(c=h[e],c==",")h[e]="N";else if(c=="%"){for(v=e+1;v<a&&h[v]=="%";++v);for(d=e&&h[e-1]=="!"||v<a&&h[v]=="1"?"1":"N",l=e;l<v;++l)h[l]=d;e=v-1}for(e=0,w=n;e<a;++e)c=h[e],w=="L"&&c=="1"?h[e]="L":i.test(c)&&(w=c);for(e=0;e<a;++e)if(t.test(h[e])){for(v=e+1;v<a&&t.test(h[v]);++v);var rt=(e?h[e-1]:n)=="L",ut=(v<a?h[v]:n)=="L",d=rt||ut?"L":"R";for(l=e;l<v;++l)h[l]=d;e=v-1}for(y=[],e=0;e<a;)if(r.test(h[e])){for(tt=e,++e;e<a&&r.test(h[e]);++e);y.push({from:tt,to:e,level:0})}else{for(b=e,g=y.length,++e;e<a&&h[e]!="L";++e);for(l=b;l<e;)if(u.test(h[l])){for(b<l&&y.splice(g,0,{from:b,to:l,level:1}),it=l,++l;l<e&&u.test(h[l]);++l);y.splice(g,0,{from:it,to:l,level:2}),b=l}else++l;b<e&&y.splice(g,0,{from:b,to:e,level:1})}return y[0].level==1&&(k=f.match(/^\s+/))&&(y[0].from=k[0].length,y.unshift({from:0,to:k[0].length,level:0})),nt(y).level==1&&(k=f.match(/\s+$/))&&(nt(y).to-=k[0].length,y.push({from:a-k[0].length,to:a,level:0})),y[0].level!=nt(y).level&&y.push({from:a,to:a,level:y[0].level}),y}}(),n.version="3.22.0",n}(),CodeMirror.defineMode("css",function(n,t){"use strict";function u(n,t){return c=t,n}function tt(n,t){var i=n.next(),r;if(a[i]&&(r=a[i](n,t),r!==!1))return r;if(i=="@")return n.eatWhile(/[\w\\\-]/),u("def",n.current());if(i=="="||(i=="~"||i=="|")&&n.eat("="))return u(null,"compare");if(i=='"'||i=="'")return t.tokenize=v(i),t.tokenize(n,t);if(i=="#")return n.eatWhile(/[\w\\\-]/),u("atom","hash");if(i=="!")return n.match(/^\s*\w*/),u("keyword","important");if(/\d/.test(i)||i=="."&&n.eat(/\d/))return n.eatWhile(/[\w.%]/),u("number","unit");if(i==="-"){if(/[\d.]/.test(n.peek()))return n.eatWhile(/[\w.%]/),u("number","unit");if(n.match(/^[^-]+-/))return u("meta","meta")}else return/[,+>*\/]/.test(i)?u(null,"select-op"):i=="."&&n.match(/^-?[_a-z][_a-z0-9-]*/i)?u("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(i)?u(null,i):i=="u"&&n.match("rl(")?(n.backUp(1),t.tokenize=it,u("property","word")):/[\w\\\-]/.test(i)?(n.eatWhile(/[\w\\\-]/),u("property","word")):u(null,null)}function v(n){return function(t,i){for(var r=!1,f;(f=t.next())!=null;){if(f==n&&!r){n==")"&&t.backUp(1);break}r=!r&&f=="\\"}return f!=n&&(r||n==")")||(i.tokenize=null),u("string","string")}}function it(n,t){return n.next(),t.tokenize=n.match(/\s*[\"\']/,!1)?null:v(")"),u(null,"(")}function y(n,t,i){this.type=n,this.indent=t,this.prev=i}function f(n,t,i){return n.context=new y(i,t.indentation()+l,n.context),i}function e(n){return n.context=n.context.prev,n.context.type}function h(n,t,i){return r[i.context.type](n,t,i)}function o(n,t,i,r){for(var u=r||1;u>0;u--)i.context=i.context.prev;return h(n,t,i)}function p(n){var t=n.current().toLowerCase();i=g.hasOwnProperty(t)?"atom":d.hasOwnProperty(t)?"keyword":"variable"}var r;t.propertyKeywords||(t=CodeMirror.resolveMode("text/css"));var l=n.indentUnit,a=t.tokenHooks,w=t.mediaTypes||{},b=t.mediaFeatures||{},k=t.propertyKeywords||{},d=t.colorKeywords||{},g=t.valueKeywords||{},nt=t.fontProperties||{},s=t.allowNested,c,i;return r={},r.top=function(n,t,r){if(n=="{")return f(r,t,"block");if(n=="}"&&r.context.prev)return e(r);if(n=="@media")return f(r,t,"media");if(n=="@font-face")return"font_face_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(n))return"keyframes";if(n&&n.charAt(0)=="@")return f(r,t,"at");if(n=="hash")i="builtin";else if(n=="word")i="tag";else{if(n=="variable-definition")return"maybeprop";if(n=="interpolation")return f(r,t,"interpolation");if(n==":")return"pseudo";if(s&&n=="(")return f(r,t,"params")}return r.context.type},r.block=function(n,t,u){return n=="word"?k.hasOwnProperty(t.current().toLowerCase())?(i="property","maybeprop"):s?(i=t.match(/^\s*:/,!1)?"property":"tag","block"):(i+=" error","maybeprop"):n=="meta"?"block":s||n!="hash"&&n!="qualifier"?r.top(n,t,u):(i="error","block")},r.maybeprop=function(n,t,i){return n==":"?f(i,t,"prop"):h(n,t,i)},r.prop=function(n,t,r){if(n==";")return e(r);if(n=="{"&&s)return f(r,t,"propBlock");if(n=="}"||n=="{")return o(n,t,r);if(n=="(")return f(r,t,"parens");if(n!="hash"||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t.current())){if(n=="word")p(t);else if(n=="interpolation")return f(r,t,"interpolation")}else i+=" error";return"prop"},r.propBlock=function(n,t,r){return n=="}"?e(r):n=="word"?(i="property","maybeprop"):r.context.type},r.parens=function(n,t,i){return n=="{"||n=="}"?o(n,t,i):n==")"?e(i):"parens"},r.pseudo=function(n,t,r){return n=="word"?(i="variable-3",r.context.type):h(n,t,r)},r.media=function(n,t,r){if(n=="(")return f(r,t,"media_parens");if(n=="}")return o(n,t,r);if(n=="{")return e(r)&&f(r,t,s?"block":"top");if(n=="word"){var u=t.current().toLowerCase();i=u=="only"||u=="not"||u=="and"?"keyword":w.hasOwnProperty(u)?"attribute":b.hasOwnProperty(u)?"property":"error"}return r.context.type},r.media_parens=function(n,t,i){return n==")"?e(i):n=="{"||n=="}"?o(n,t,i,2):r.media(n,t,i)},r.font_face_before=function(n,t,i){return n=="{"?f(i,t,"font_face"):h(n,t,i)},r.font_face=function(n,t,r){return n=="}"?e(r):n=="word"?(i=nt.hasOwnProperty(t.current().toLowerCase())?"property":"error","maybeprop"):"font_face"},r.keyframes=function(n,t,r){return n=="word"?(i="variable","keyframes"):n=="{"?f(r,t,"top"):h(n,t,r)},r.at=function(n,t,r){return n==";"?e(r):n=="{"||n=="}"?o(n,t,r):(n=="word"?i="tag":n=="hash"&&(i="builtin"),"at")},r.interpolation=function(n,t,r){return n=="}"?e(r):n=="{"||n==";"?o(n,t,r):(n!="variable"&&(i="error"),"interpolation")},r.params=function(n,t,i){return n==")"?e(i):n=="{"||n=="}"?o(n,t,i):(n=="word"&&p(t),"params")},{startState:function(n){return{tokenize:null,state:"top",context:new y("top",n||0,null)}},token:function(n,t){if(!t.tokenize&&n.eatSpace())return null;var u=(t.tokenize||tt)(n,t);return u&&typeof u=="object"&&(c=u[1],u=u[0]),i=u,t.state=r[t.state](c,n,t),i},indent:function(n,t){var i=n.context,r=t&&t.charAt(0),u=i.indent;return i.type=="prop"&&r=="}"&&(i=i.prev),i.prev&&(r=="}"&&(i.type=="block"||i.type=="top"||i.type=="interpolation"||i.type=="font_face")||r==")"&&(i.type=="parens"||i.type=="params"||i.type=="media_parens")||r=="{"&&(i.type=="at"||i.type=="media"))&&(u=i.indent-l,i=i.prev),u},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}}),function(){function n(n){for(var i={},t=0;t<n.length;++t)i[n[t]]=!0;return i}function t(n,t){for(var r=!1,i;(i=n.next())!=null;){if(r&&i=="/"){t.tokenize=null;break}r=i=="*"}return["comment","comment"]}function v(n,t){return n.skipTo("-->")?(n.match("-->"),t.tokenize=null):n.skipToEnd(),["comment","comment"]}var s=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],i=n(s),h=["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"],r=n(h),c=["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","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-inside","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","zoom","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-profile","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","kerning","text-anchor","writing-mode"],u=n(c),l=["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","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"],f=n(l),a=["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","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","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","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","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","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","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","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-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","keep-all","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","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","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","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","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","single","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","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","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","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small"],e=n(a),o=n(["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]),y=s.concat(h).concat(c).concat(l).concat(a);CodeMirror.registerHelper("hintWords","css",y),CodeMirror.defineMIME("text/css",{mediaTypes:i,mediaFeatures:r,propertyKeywords:u,colorKeywords:f,valueKeywords:e,fontProperties:o,tokenHooks:{"<":function(n,t){return n.match("!--")?(t.tokenize=v,v(n,t)):!1},"/":function(n,i){return n.eat("*")?(i.tokenize=t,t(n,i)):!1}},name:"css"}),CodeMirror.defineMIME("text/x-scss",{mediaTypes:i,mediaFeatures:r,propertyKeywords:u,colorKeywords:f,valueKeywords:e,fontProperties:o,allowNested:!0,tokenHooks:{"/":function(n,i){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(i.tokenize=t,t(n,i)):["operator","operator"]},":":function(n){return n.match(/\s*{/)?[null,"{"]:!1},$:function(n){return(n.match(/^[\w-]+/),n.match(/^\s*:/,!1))?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(n){return n.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),CodeMirror.defineMIME("text/x-less",{mediaTypes:i,mediaFeatures:r,propertyKeywords:u,colorKeywords:f,valueKeywords:e,fontProperties:o,allowNested:!0,tokenHooks:{"/":function(n,i){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(i.tokenize=t,t(n,i)):["operator","operator"]},"@":function(n){return n.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(n.eatWhile(/[\w\\\-]/),n.match(/^\s*:/,!1))?["variable-2","variable-definition"]:["variable-2","variable"]},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})}(),function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";n.defineMode("javascript",function(t,i){function yi(n){for(var r=!1,t,i=!1;(t=n.next())!=null;){if(!r){if(t=="/"&&!i)return;t=="["?i=!0:i&&t=="]"&&(i=!1)}r=!r&&t=="\\"}}function c(n,t,i){return tt=n,ut=i,t}function p(n,t){var i=n.next(),r,u;return i=='"'||i=="'"?(t.tokenize=pi(i),t.tokenize(n,t)):i=="."&&n.match(/^\d+(?:[eE][+\-]?\d+)?/)?c("number","number"):i=="."&&n.match("..")?c("spread","meta"):/[\[\]{}\(\),;\:\.]/.test(i)?c(i):i=="="&&n.eat(">")?c("=>","operator"):i=="0"&&n.eat(/x/i)?(n.eatWhile(/[\da-f]/i),c("number","number")):/\d/.test(i)?(n.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),c("number","number")):i=="/"?n.eat("*")?(t.tokenize=ft,ft(n,t)):n.eat("/")?(n.skipToEnd(),c("comment","comment")):t.lastType=="operator"||t.lastType=="keyword c"||t.lastType=="sof"||/^[\[{}\(,;:]$/.test(t.lastType)?(yi(n),n.eatWhile(/[gimy]/),c("regexp","string-2")):(n.eatWhile(ht),c("operator","operator",n.current())):i=="`"?(t.tokenize=ct,ct(n,t)):i=="#"?(n.skipToEnd(),c("error","error")):ht.test(i)?(n.eatWhile(ht),c("operator","operator",n.current())):(n.eatWhile(/[\w\$_]/),r=n.current(),u=ti.propertyIsEnumerable(r)&&ti[r],u&&t.lastType!="."?c(u.type,u.style,r):c("variable","variable",r))}function pi(n){return function(t,i){var r=!1,u;if(rt&&t.peek()=="@"&&t.match(vi))return i.tokenize=p,c("jsonld-keyword","meta");while((u=t.next())!=null){if(u==n&&!r)break;r=!r&&u=="\\"}return r||(i.tokenize=p),c("string","string")}}function ft(n,t){for(var r=!1,i;i=n.next();){if(i=="/"&&r){t.tokenize=p;break}r=i=="*"}return c("comment","comment")}function ct(n,t){for(var r=!1,i;(i=n.next())!=null;){if(!r&&(i=="`"||i=="$"&&n.eat("{"))){t.tokenize=p;break}r=!r&&i=="\\"}return c("quasi","string-2",n.current())}function lt(n,t){var e,r,f,i,o,u;if(t.fatArrowAt&&(t.fatArrowAt=null),e=n.string.indexOf("=>",n.start),!(e<0)){for(r=0,f=!1,i=e-1;i>=0;--i)if(o=n.string.charAt(i),u=wi.indexOf(o),u>=0&&u<3){if(!r){++i;break}if(--r==0)break}else if(u>=3&&u<6)++r;else if(/[$\w]/.test(o))f=!0;else if(f&&!r){++i;break}f&&!r&&(t.fatArrowAt=i)}}function ri(n,t,i,r,u,f){this.indented=n,this.column=t,this.type=i,this.prev=u,this.info=f,r!=null&&(this.align=r)}function bi(n,t){for(var r,i=n.localVars;i;i=i.next)if(i.name==t)return!0;for(r=n.context;r;r=r.prev)for(i=r.vars;i;i=i.next)if(i.name==t)return!0}function ki(n,t,i,r,f){var e=n.cc,o;for(u.state=n,u.stream=f,u.marked=null,u.cc=e,n.lexical.hasOwnProperty("align")||(n.lexical.align=!0);;)if(o=e.length?e.pop():y?h:l,o(i,r)){while(e.length&&e[e.length-1].lex)e.pop()();return u.marked?u.marked:i=="variable"&&bi(n,r)?"variable-2":t}}function f(){for(var n=arguments.length-1;n>=0;n--)u.cc.push(arguments[n])}function r(){return f.apply(null,arguments),!0}function w(n){function r(t){for(var i=t;i;i=i.next)if(i.name==n)return!0;return!1}var t=u.state;if(t.context){if(u.marked="def",r(t.localVars))return;t.localVars={name:n,next:t.localVars}}else{if(r(t.globalVars))return;i.globalVars&&(t.globalVars={name:n,next:t.globalVars})}}function b(){u.state.context={prev:u.state.context,vars:u.state.localVars},u.state.localVars=di}function k(){u.state.localVars=u.state.context.vars,u.state.context=u.state.context.prev}function o(n,t){var i=function(){var i=u.state,r=i.indented;i.lexical.type=="stat"&&(r=i.lexical.indented),i.lexical=new ri(r,u.stream.column(),n,null,i.lexical,t)};return i.lex=!0,i}function e(){var n=u.state;n.lexical.prev&&(n.lexical.type==")"&&(n.indented=n.lexical.indented),n.lexical=n.lexical.prev)}function s(n){function t(i){return i==n?r():n==";"?f():r(t)}return t}function l(n,t){return n=="var"?r(o("vardef",t.length),wt,s(";"),e):n=="keyword a"?r(o("form"),h,l,e):n=="keyword b"?r(o("form"),l,e):n=="{"?r(o("}"),pt,e):n==";"?r():n=="if"?r(o("form"),h,l,e,hi):n=="function"?r(nt):n=="for"?r(o("form"),ci,l,e):n=="variable"?r(o("stat"),ir):n=="switch"?r(o("form"),h,o("}","switch"),s("{"),pt,e,e):n=="case"?r(h,s(":")):n=="default"?r(s(":")):n=="catch"?r(o("form"),b,s("("),kt,s(")"),l,e,k):n=="module"?r(o("form"),b,vr,k,e):n=="class"?r(o("form"),cr,ar,e):n=="export"?r(o("form"),yr,e):n=="import"?r(o("form"),pr,e):f(o("stat"),h,s(";"),e)}function h(n){return ui(n,!1)}function a(n){return ui(n,!0)}function ui(n,t){var c,i;if(u.state.fatArrowAt==u.stream.start){if(c=t?ei:fi,n=="(")return r(b,o(")"),it(g,")"),e,s("=>"),c,k);if(n=="variable")return f(b,g,s("=>"),c,k)}return(i=t?vt:et,ii.hasOwnProperty(n))?r(i):n=="function"?r(nt,i):n=="keyword c"?r(t?gi:at):n=="("?r(o(")"),at,st,s(")"),e,i):n=="operator"||n=="spread"?r(t?a:h):n=="["?r(o("]"),wr,e,i):n=="{"?d(oi,"}",null,i):r()}function at(n){return n.match(/[;\}\)\],]/)?f():f(h)}function gi(n){return n.match(/[;\}\)\],]/)?f():f(a)}function et(n,t){return n==","?r(h):vt(n,t,!1)}function vt(n,t,i){var f=i==!1?et:vt,c=i==!1?h:a;return t=="=>"?r(b,i?ei:fi,k):n=="operator"?/\+\+|--/.test(t)?r(f):t=="?"?r(h,s(":"),c):r(c):n=="quasi"?(u.cc.push(f),nr(t)):n==";"?void 0:n=="("?d(a,")","call",f):n=="."?r(rr,f):n=="["?r(o("]"),at,s("]"),e,f):void 0}function nr(n){return n.slice(n.length-2)!="${"?r():r(h,tr)}function tr(n){if(n=="}")return u.marked="string-2",u.state.tokenize=ct,r()}function fi(n){return(lt(u.stream,u.state),n=="{")?f(l):f(h)}function ei(n){return(lt(u.stream,u.state),n=="{")?f(l):f(a)}function ir(n){return n==":"?r(e,l):f(et,s(";"),e)}function rr(n){if(n=="variable")return u.marked="property",r()}function oi(n,t){if(n=="variable"){if(u.marked="property",t=="get"||t=="set")return r(ur)}else if(n=="number"||n=="string")u.marked=rt?"property":n+" property";else if(n=="[")return r(h,s("]"),yt);if(ii.hasOwnProperty(n))return r(yt)}function ur(n){return n!="variable"?f(yt):(u.marked="property",r(nt))}function yt(n){return n==":"?r(a):n=="("?f(nt):void 0}function it(n,t){function i(f){if(f==","){var e=u.state.lexical;return e.info=="call"&&(e.pos=(e.pos||0)+1),r(n,i)}return f==t?r():r(s(t))}return function(u){return u==t?r():f(n,i)}}function d(n,t,i){for(var f=3;f<arguments.length;f++)u.cc.push(arguments[f]);return r(o(t,i),it(n,t),e)}function pt(n){return n=="}"?r():f(l,pt)}function si(n){if(ni&&n==":")return r(fr)}function fr(n){if(n=="variable")return u.marked="variable-3",r()}function wt(){return f(g,si,bt,or)}function g(n,t){return n=="variable"?(w(t),r()):n=="["?d(g,"]"):n=="{"?d(er,"}"):void 0}function er(n,t){return n=="variable"&&!u.stream.match(/^\s*:/,!1)?(w(t),r(bt)):(n=="variable"&&(u.marked="property"),r(s(":"),g,bt))}function bt(n,t){if(t=="=")return r(a)}function or(n){if(n==",")return r(wt)}function hi(n,t){if(n=="keyword b"&&t=="else")return r(o("form"),l,e)}function ci(n){if(n=="(")return r(o(")"),sr,s(")"),e)}function sr(n){return n=="var"?r(wt,s(";"),ot):n==";"?r(ot):n=="variable"?r(hr):f(h,s(";"),ot)}function hr(n,t){return t=="in"||t=="of"?(u.marked="keyword",r(h)):r(et,ot)}function ot(n,t){return n==";"?r(li):t=="in"||t=="of"?(u.marked="keyword",r(h)):f(h,s(";"),li)}function li(n){n!=")"&&r(h)}function nt(n,t){return t=="*"?(u.marked="keyword",r(nt)):n=="variable"?(w(t),r(nt)):n=="("?r(b,o(")"),it(kt,")"),e,l,k):void 0}function kt(n){return n=="spread"?r(kt):f(g,si)}function cr(n,t){if(n=="variable")return w(t),r(lr)}function lr(n,t){if(t=="extends")return r(h)}function ar(n){if(n=="{")return d(oi,"}")}function vr(n,t){return n=="string"?r(l):n=="variable"?(w(t),r(dt)):void 0}function yr(n,t){return t=="*"?(u.marked="keyword",r(dt,s(";"))):t=="default"?(u.marked="keyword",r(h,s(";"))):f(l)}function pr(n){return n=="string"?r():f(ai,dt)}function ai(n,t){return n=="{"?d(ai,"}"):(n=="variable"&&w(t),r())}function dt(n,t){if(t=="from")return u.marked="keyword",r(h)}function wr(n){return n=="]"?r():f(a,br)}function br(n){return n=="for"?f(st,s("]")):n==","?r(it(a,"]")):f(it(a,"]"))}function st(n){return n=="for"?r(ci,st):n=="if"?r(h,st):void 0}var v=t.indentUnit,gt=i.statementIndent,rt=i.jsonld,y=i.json||rt,ni=i.typescript,ti=function(){function n(n){return{type:n,style:"keyword"}}var s=n("keyword a"),u=n("keyword b"),t=n("keyword c"),f=n("operator"),i={type:"atom",style:"atom"},h={"if":n("if"),"while":s,"with":s,"else":u,"do":u,"try":u,"finally":u,"return":t,"break":t,"continue":t,"new":t,"delete":t,"throw":t,"debugger":t,"var":n("var"),"const":n("var"),"let":n("var"),"function":n("function"),"catch":n("catch"),"for":n("for"),"switch":n("switch"),"case":n("case"),"default":n("default"),"in":f,"typeof":f,"instanceof":f,"true":i,"false":i,"null":i,undefined:i,NaN:i,Infinity:i,"this":n("this"),module:n("module"),"class":n("class"),"super":n("atom"),"yield":t,"export":n("export"),"import":n("import"),"extends":t},r,e,o;if(ni){r={type:"variable",style:"variable-3"},e={"interface":n("interface"),"extends":n("extends"),constructor:n("constructor"),"public":n("public"),"private":n("private"),"protected":n("protected"),"static":n("static"),string:r,number:r,bool:r,any:r};for(o in e)h[o]=e[o]}return h}(),ht=/[+\-*&%=<>!?|~^]/,vi=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,tt,ut,wi="([{}])",ii={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},u={state:null,column:null,marked:null,cc:null},di={name:"this",next:{name:"arguments"}};return e.lex=!0,{startState:function(n){var t={tokenize:p,lastType:"sof",cc:[],lexical:new ri((n||0)-v,0,"block",!1),localVars:i.localVars,context:i.localVars&&{vars:i.localVars},indented:0};return i.globalVars&&typeof i.globalVars=="object"&&(t.globalVars=i.globalVars),t},token:function(n,t){if(n.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=n.indentation(),lt(n,t)),t.tokenize!=ft&&n.eatSpace())return null;var i=t.tokenize(n,t);return tt=="comment"?i:(t.lastType=tt=="operator"&&(ut=="++"||ut=="--")?"incdec":tt,ki(t,i,tt,ut,n))},indent:function(t,r){var o,u,s,c,f,h;if(t.tokenize==ft)return n.Pass;if(t.tokenize!=p)return 0;for(o=r&&r.charAt(0),u=t.lexical,s=t.cc.length-1;s>=0;--s)if(c=t.cc[s],c==e)u=u.prev;else if(c!=hi)break;return u.type=="stat"&&o=="}"&&(u=u.prev),gt&&u.type==")"&&u.prev.type=="stat"&&(u=u.prev),f=u.type,h=o==f,f=="vardef"?u.indented+(t.lastType=="operator"||t.lastType==","?u.info+1:0):f=="form"&&o=="{"?u.indented:f=="form"?u.indented+v:f=="stat"?u.indented+(t.lastType=="operator"||t.lastType==","?gt||v:0):u.info!="switch"||h||i.doubleIndentSwitch==!1?u.align?u.column+(h?0:1):u.indented+(h?0:v):u.indented+(/^(?:case|default)\b/.test(r)?v:2*v)},electricChars:":{}",blockCommentStart:y?null:"/*",blockCommentEnd:y?null:"*/",lineComment:y?null:"//",fold:"brace",helperType:y?"json":"javascript",jsonldMode:rt,jsonMode:y}}),n.defineMIME("text/javascript","javascript"),n.defineMIME("text/ecmascript","javascript"),n.defineMIME("application/javascript","javascript"),n.defineMIME("application/ecmascript","javascript"),n.defineMIME("application/json",{name:"javascript",json:!0}),n.defineMIME("application/x-json",{name:"javascript",json:!0}),n.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),n.defineMIME("text/typescript",{name:"javascript",typescript:!0}),n.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(){function t(n){return n.toString().split(".")[1]}var n=Ember.RSVP.Promise;Ember.OfflineAdapter=Ember.Adapter.extend({find:function(t,i){var r=this._getItem(t.constructor,i);return new n(function(n,u){r?(t.load(i,r),n(t)):u(t)})},findAll:function(i,r){var u=this,f=this.applicationData;return new n(function(n){var e=f.meta[t(i)+"!ids"],s=[],o,h;if(e)for(e=e.split(","),o=0,h=e.length;o<h;o++)s.push(u._getItem(i,e[o]));r.load(i,s),n(r)})},createRecord:function(i){var u=this,r=i.constructor,f=this.applicationData;return new n(function(n){var e=f.meta[t(r)+"!nextId"]||"1",o;i.set(r.primaryKey,e),o=i.toJSON(),u._setItem(r,e,o),u._updateIds(r,e),f.meta[t(r)+"!nextId"]=parseInt(e,10)+1,i.load(e,o),i.didCreateRecord(),n(i)})},saveRecord:function(t){var r=this,i=t.constructor;return new n(function(n){r._setItem(i,t.get(i.primaryKey),t.toJSON()),t.didSaveRecord(),n(t)})},deleteRecord:function(t){var r=this,i=t.constructor;return new n(function(n){r._deleteItem(i,t.get(i.primaryKey)),t.didDeleteRecord(),n(t)})},_getItem:function(n,t){var i=this.applicationData[n][t];return i&&JSON.parse(i)},_setItem:function(n,t,i){this.applicationData[n]||(this.applicationData[n]={}),this.applicationData[n][t]=JSON.stringify(i)},_deleteItem:function(n,i){var f,r,u,e;for(delete this.applicationData[n][i],f=t(n)+"!ids",r=this.applicationData.meta[f].split(","),u=0,e=r.length;u<e;u++)if(r[u]===""+i){r.splice(u,1);break}this.applicationData.meta[f]=r.join(",")},_updateIds:function(n,i){i=String(i);var r=t(n)+"!ids",u=this.applicationData.meta[r];u?this.applicationData.meta[r]+=","+i:this.applicationData.meta[r]=i}})}();
33
+ /*!
34
+ Copyright Vassilis Petroulias [DRDigit]
35
+ Licensed under the Apache License, Version 2.0 (the "License");
36
+ you may not use this file except in compliance with the License.
37
+ You may obtain a copy of the License at
38
+ http://www.apache.org/licenses/LICENSE-2.0
39
+ Unless required by applicable law or agreed to in writing, software
40
+ distributed under the License is distributed on an "AS IS" BASIS,
41
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ See the License for the specific language governing permissions and
43
+ limitations under the License.
44
+ */
45
+ var B64={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",lookup:null,ie:/MSIE /.test(navigator.userAgent),ieo:/MSIE [67]/.test(navigator.userAgent),encode:function(n){var r=B64.toUtf8(n),i=-1,o=r.length,f,e,t=[,,,],u;if(B64.ie){for(u=[];++i<o;)f=r[i+1],e=r[i+2],t[0]=r[i]>>2,t[1]=(r[i]&3)<<4|r[++i]>>4,isNaN(f)?t[2]=t[3]=64:(t[2]=(r[i]&15)<<2|r[++i]>>6,t[3]=isNaN(e)?64:r[i]&63),u.push(B64.alphabet[t[0]],B64.alphabet[t[1]],B64.alphabet[t[2]],B64.alphabet[t[3]]);return u.join("")}for(u="";++i<o;)f=r[i+1],e=r[i+2],t[0]=r[i]>>2,t[1]=(r[i]&3)<<4|r[++i]>>4,isNaN(f)?t[2]=t[3]=64:(t[2]=(r[i]&15)<<2|r[++i]>>6,t[3]=isNaN(e)?64:r[i]&63),u+=B64.alphabet[t[0]]+B64.alphabet[t[1]]+B64.alphabet[t[2]]+B64.alphabet[t[3]];return u},decode:function(n){var i=B64.fromUtf8(n),t=0,r=i.length;if(B64.ieo){for(result=[];t<r;)i[t]<128?result.push(String.fromCharCode(i[t++])):i[t]>191&&i[t]<224?result.push(String.fromCharCode((i[t++]&31)<<6|i[t++]&63)):result.push(String.fromCharCode((i[t++]&15)<<12|(i[t++]&63)<<6|i[t++]&63));return result.join("")}for(result="";t<r;)result+=i[t]<128?String.fromCharCode(i[t++]):i[t]>191&&i[t]<224?String.fromCharCode((i[t++]&31)<<6|i[t++]&63):String.fromCharCode((i[t++]&15)<<12|(i[t++]&63)<<6|i[t++]&63);return result},toUtf8:function(n){var r=-1,u=n.length,t,i=[];if(/^[\x00-\x7f]*$/.test(n))while(++r<u)i.push(n.charCodeAt(r));else while(++r<u)t=n.charCodeAt(r),t<128?i.push(t):t<2048?i.push(t>>6|192,t&63|128):i.push(t>>12|224,t>>6&63|128,t&63|128);return i},fromUtf8:function(n){var i=-1,r,u=[],t=[,,,];if(!B64.lookup){for(r=B64.alphabet.length,B64.lookup={};++i<r;)B64.lookup[B64.alphabet[i]]=i;i=-1}for(r=n.length;i<r;){if(t[0]=B64.lookup[n.charAt(++i)],t[1]=B64.lookup[n.charAt(++i)],u.push(t[0]<<2|t[1]>>4),t[2]=B64.lookup[n.charAt(++i)],t[2]==64)break;if(u.push((t[1]&15)<<4|t[2]>>2),t[3]=B64.lookup[n.charAt(++i)],t[3]==64)break;u.push((t[2]&3)<<6|t[3])}return u}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/init/define.php CHANGED
@@ -5,7 +5,7 @@ if ( ! defined('ABSPATH') ) {
5
  die();
6
  }
7
 
8
- define( 'MSWP_AVERTA_VERSION' , '1.0.5' );
9
 
10
  define( 'MSWP_SLUG' , 'master-slider' );
11
  define( 'MSWP_TEXT_DOMAIN' , 'masterslider' );
5
  die();
6
  }
7
 
8
+ define( 'MSWP_AVERTA_VERSION' , '1.0.10' );
9
 
10
  define( 'MSWP_SLUG' , 'master-slider' );
11
  define( 'MSWP_TEXT_DOMAIN' , 'masterslider' );
master-slider.php CHANGED
@@ -11,13 +11,13 @@
11
  * Plugin Name: Master Slider
12
  * Plugin URI: https://wordpress.org/plugins/master-slider/
13
  * Description: Master Slider is the most advanced responsive HTML5 WordPress slider plugin with touch swipe navigation that works smoothly on devices too.
14
- * Version: 1.0.5
15
  * Author: averta
16
  * Author URI: http://averta.net
17
  * Text Domain: master-slider
18
  * License URI: license.txt
19
  * Domain Path: /languages
20
- * Tested up to: 3.9.1
21
  */
22
 
23
  // If this file is called directly, abort.
11
  * Plugin Name: Master Slider
12
  * Plugin URI: https://wordpress.org/plugins/master-slider/
13
  * Description: Master Slider is the most advanced responsive HTML5 WordPress slider plugin with touch swipe navigation that works smoothly on devices too.
14
+ * Version: 1.0.10
15
  * Author: averta
16
  * Author URI: http://averta.net
17
  * Text Domain: master-slider
18
  * License URI: license.txt
19
  * Domain Path: /languages
20
+ * Tested up to: 3.9.2
21
  */
22
 
23
  // If this file is called directly, abort.
public/includes/class-msp-frontend-assets.php CHANGED
@@ -65,6 +65,10 @@ class MSP_Frontend_Assets {
65
  $this->assets_dir . '/js/masterslider.min.js' ,
66
  array( 'jquery', 'jquery-easing' ), $this->version, true );
67
 
 
 
 
 
68
 
69
  // Print JS Object //////////////////////////////////////////////////////////////////
70
 
65
  $this->assets_dir . '/js/masterslider.min.js' ,
66
  array( 'jquery', 'jquery-easing' ), $this->version, true );
67
 
68
+ // always load assets by default if 'allways_load_ms_assets' option was enabled
69
+ if( 'on' == msp_get_setting( 'allways_load_ms_assets' , 'msp_advanced' ) ) {
70
+ wp_enqueue_script( 'masterslider-core' );
71
+ }
72
 
73
  // Print JS Object //////////////////////////////////////////////////////////////////
74
 
uninstall.php CHANGED
@@ -16,7 +16,7 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
16
  exit( 'No Naughty Business Please !' );
17
  }
18
 
19
- // To uninstall the plugin completely you need to define MS_UNINSTALL_PLUGIN constant
20
  // before deleting it from plugins page
21
  if ( defined( 'MS_UNINSTALL_PLUGIN' ) ) {
22
 
16
  exit( 'No Naughty Business Please !' );
17
  }
18
 
19
+ // To uninstall the plugin completely you need to define MS_UNINSTALL_PLUGIN constant in wp-config.php file
20
  // before deleting it from plugins page
21
  if ( defined( 'MS_UNINSTALL_PLUGIN' ) ) {
22