Unlimited Elements For Elementor (Free Widgets, Addons, Templates) - Version 1.4.81

Version Description

Download this release

Release Info

Developer unitecms
Plugin Icon 128x128 Unlimited Elements For Elementor (Free Widgets, Addons, Templates)
Version 1.4.81
Comparing to
See all releases

Code changes from version 1.4.79 to 1.4.81

Files changed (68) hide show
  1. assets_libraries/filters/ue_filters.js +1133 -45
  2. assets_libraries/owl-carousel-new/assets/owl.carousel.css +186 -0
  3. assets_libraries/owl-carousel-new/owl.carousel.js +3448 -0
  4. assets_libraries/owl-carousel-new/owl.carousel.min.js +7 -0
  5. css/unitecreator_styles.css +4 -0
  6. images/no_image_placeholder.jpg +0 -0
  7. inc_php/framework/font_manager.class.php +42 -5
  8. inc_php/framework/functions.class.php +42 -1
  9. inc_php/framework/settings.class.php +5 -1
  10. inc_php/unitecreator_actions.class.php +7 -26
  11. inc_php/unitecreator_addon.class.php +8 -4
  12. inc_php/unitecreator_addons.class.php +3 -5
  13. inc_php/unitecreator_dialog_param.class.php +127 -12
  14. inc_php/unitecreator_filters_process.class.php +532 -150
  15. inc_php/unitecreator_globals.class.php +4 -0
  16. inc_php/unitecreator_helper.class.php +3 -0
  17. inc_php/unitecreator_helperhtml.class.php +7 -1
  18. inc_php/unitecreator_library.class.php +5 -3
  19. inc_php/unitecreator_output.class.php +87 -54
  20. inc_php/unitecreator_params_processor.class.php +89 -15
  21. inc_php/unitecreator_settings.class.php +14 -2
  22. inc_php/unitecreator_template_engine.class.php +41 -8
  23. inc_php/unitecreator_variables_output.class.php +23 -0
  24. includes.php +1 -1
  25. js/codemirror/old/codemirror.css +0 -323
  26. js/codemirror/old/codemirror.js +0 -8658
  27. js/codemirror/old/codemirror.min.js +0 -5
  28. js/settings.js +15 -0
  29. js/unitecreator_params_panel.js +11 -1
  30. provider/core/plugins/unlimited_elements/copy_paste.class.php +2 -7
  31. provider/core/plugins/unlimited_elements/dialog_param_elementor.class.php +37 -1
  32. provider/core/plugins/unlimited_elements/elementor/assets/template_library_admin.js +11 -2
  33. provider/core/plugins/unlimited_elements/elementor/assets/uc_editor_admin.css +11 -2
  34. provider/core/plugins/unlimited_elements/elementor/assets/uc_editor_admin.js +59 -2
  35. provider/core/plugins/unlimited_elements/elementor/assets/uc_editor_admin_temp.js +0 -78
  36. provider/core/plugins/unlimited_elements/elementor/assets/uc_front_admin.js +94 -2
  37. provider/core/plugins/unlimited_elements/elementor/elementor_controls.class.php +156 -0
  38. provider/core/plugins/unlimited_elements/elementor/elementor_dynamic_visibility.class.php +109 -45
  39. provider/core/plugins/unlimited_elements/elementor/elementor_integrate.class.php +28 -34
  40. provider/core/plugins/unlimited_elements/elementor/elementor_layout_exporter.class.php +3 -1
  41. provider/core/plugins/unlimited_elements/elementor/elementor_widget.class.php +145 -58
  42. provider/core/plugins/unlimited_elements/elementor/images/new2.svg +0 -15
  43. provider/core/plugins/unlimited_elements/elementor/images/widget-icon.svg +28 -0
  44. provider/core/plugins/unlimited_elements/elementor/pagination.class.php +46 -7
  45. provider/core/plugins/unlimited_elements/globals.class.php +1 -1
  46. provider/core/plugins/unlimited_elements/helper_provider_core.class.php +181 -9
  47. provider/core/plugins/unlimited_elements/plugin.php +1 -1
  48. provider/core/plugins/unlimited_elements/settings/general_settings_el.xml +0 -17
  49. provider/freemius/assets/img/unlimited-elements-for-elementor.png +0 -0
  50. provider/functions_wordpress.class.php +92 -4
  51. provider/provider_dialog_param.class.php +1 -0
  52. provider/provider_functions.class.php +11 -0
  53. provider/provider_helper.class.php +30 -0
  54. provider/provider_library.class.php +5 -2
  55. provider/provider_params_processor.class.php +181 -143
  56. provider/provider_settings.class.php +13 -4
  57. provider/woocommerce_integrate.class.php +54 -1
  58. readme.txt +283 -248
  59. release_log.txt +33 -0
  60. settings/addon_fields.xml +1 -0
  61. settings/library.xml +11 -2
  62. temp/index.html +0 -0
  63. unlimited_elements.php +4 -4
  64. views/objects/addon_view.class.php +14 -1
  65. views/objects/addon_view_childparams.class.php +38 -6
  66. views/test_settings.php +5 -3
  67. views/troubleshooting-api-access.php +0 -101
  68. views/troubleshooting-connectivity.php +22 -8
assets_libraries/filters/ue_filters.js CHANGED
@@ -1,12 +1,30 @@
1
 
2
- function UEListingFilters(){
 
 
 
3
 
4
- var g_objFilters, g_objListing, g_listingData, g_urlBase;
5
-
6
  var g_types = {
7
  CHECKBOX:"checkbox"
8
  };
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /**
12
  * console log some string
@@ -15,6 +33,44 @@ function UEListingFilters(){
15
  console.log(str);
16
  }
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * get object property
20
  */
@@ -36,6 +92,167 @@ function UEListingFilters(){
36
  return(val);
37
  }
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  /**
41
  * get filter type
@@ -163,6 +380,77 @@ function UEListingFilters(){
163
  return(objSelected);
164
  }
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
  /**
168
  * get filters data array
@@ -317,90 +605,890 @@ function UEListingFilters(){
317
  return(url);
318
  }
319
 
320
-
 
321
  /**
322
- * on filters change - refresh the page with the new query
323
  */
324
- function onFiltersChange(){
325
 
326
- var query = buildUrlQuery();
327
 
328
- var url = getRedirectUrl(query);
 
329
 
330
- if(!url)
331
- throw new error("onFiltersChange error - empty redirect url");
 
 
 
332
 
333
- location.href = url;
334
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  }
336
 
337
 
338
  /**
339
- * init events
340
  */
341
- function initEvents(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
 
343
- var objCheckboxes = g_objFilters.filter("input[type=checkbox]");
 
344
 
345
- objCheckboxes.on("click", onFiltersChange);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
 
347
  }
348
 
349
 
350
  /**
351
- * init
352
  */
353
- function init(){
354
 
355
- g_objFilters = jQuery(".uc-listing-filter");
 
356
 
357
- if(g_objFilters.length == 0){
 
 
 
 
 
 
 
358
  return(false);
359
  }
360
 
361
- //init the listing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
 
363
- g_objListing = jQuery(".uc-filterable-listing");
364
 
365
- if(g_objListing.length == 0){
366
- trace("fitlers not loaded, no listing available on page");
 
367
  return(false);
368
- }
369
 
370
- //get first listing
371
- if(g_objListing.length > 1)
372
- g_objListing = jQuery(g_objListing[0]);
 
 
 
 
 
373
 
374
- g_listingData = g_objListing.data("ucfilters");
375
- if(!g_listingData)
376
- g_listingData = {};
 
 
 
 
 
377
 
378
- g_urlBase = getVal(g_listingData, "urlbase");
379
 
380
- if(!g_urlBase){
381
- trace("ue filters error - base url not inited");
382
  return(false);
383
- }
384
 
385
- trace("filters are active!");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
 
387
- clearFilters(true);
388
 
389
- initEvents();
390
 
391
  }
392
 
393
 
394
  /**
395
- * init the class
396
  */
397
- function construct(){
398
 
399
- if(!jQuery){
400
- trace("Filters not loaded, jQuery not loaded");
401
  return(false);
402
- }
403
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  jQuery("document").ready(init);
405
 
406
  }
@@ -408,5 +1496,5 @@ function UEListingFilters(){
408
  construct();
409
  }
410
 
411
- new UEListingFilters();
412
 
1
 
2
+ function UEDynamicFilters(){
3
+
4
+ var g_objFilters, g_objGrid, g_filtersData, g_urlBase;
5
+ var g_urlAjax, g_lastGridAjaxCall, g_cache = {};
6
 
 
 
7
  var g_types = {
8
  CHECKBOX:"checkbox"
9
  };
10
 
11
+ var g_vars = {
12
+ CLASS_DIV_DEBUG:"uc-div-ajax-debug",
13
+ CLASS_GRID:"uc-filterable-grid",
14
+ DEBUG_AJAX_OPTIONS: false,
15
+ CLASS_PREDICTIVE_CACHE:"uc-predictive-cache-next",
16
+ cachePredictiveKeys:{},
17
+ handleTrashold:null
18
+ };
19
+
20
+ var g_options = {
21
+ is_cache_enabled:true,
22
+ is_predictive_cache_enabled:false,
23
+ ajax_reload: false,
24
+ widget_name: null,
25
+ predictive_trashold_time: 3000
26
+ };
27
+
28
 
29
  /**
30
  * console log some string
33
  console.log(str);
34
  }
35
 
36
+ function ________GENERAL_______________(){}
37
+
38
+
39
+ /**
40
+ * run function with trashold
41
+ */
42
+ function runWithTrashold(func, time){
43
+
44
+ if(!time)
45
+ var time = g_options.predictive_trashold_time;
46
+
47
+ if(g_vars.handle)
48
+ clearTimeout(g_vars.handleTrashold);
49
+
50
+ g_vars.handleTrashold = setTimeout(func, g_options.predictive_trashold_time);
51
+
52
+ };
53
+
54
+
55
+ /**
56
+ * add url param
57
+ */
58
+ function addUrlParam(url, param, value){
59
+
60
+ if(url.indexOf("?") == -1)
61
+ url += "?";
62
+ else
63
+ url += "&";
64
+
65
+ if(typeof value == "undefined")
66
+ url += param;
67
+ else
68
+ url += param + "=" + value;
69
+
70
+ return(url);
71
+ }
72
+
73
+
74
  /**
75
  * get object property
76
  */
92
  return(val);
93
  }
94
 
95
+ /**
96
+ * turn string value ("true", "false") to string
97
+ */
98
+ function strToBool(str){
99
+
100
+ switch(typeof str){
101
+ case "boolean":
102
+ return(str);
103
+ break;
104
+ case "undefined":
105
+ return(false);
106
+ break;
107
+ case "number":
108
+ if(str == 0)
109
+ return(false);
110
+ else
111
+ return(true);
112
+ break;
113
+ case "string":
114
+ str = str.toLowerCase();
115
+
116
+ if(str == "true" || str == "1")
117
+ return(true);
118
+ else
119
+ return(false);
120
+
121
+ break;
122
+ }
123
+
124
+ return(false);
125
+ };
126
+
127
+ /**
128
+ * get closest grid to some object
129
+ */
130
+ function getClosestGrid(objSource){
131
+
132
+ //in case there is only one grid - return it
133
+ if(g_objGrid)
134
+ return(g_objGrid);
135
+
136
+ //in case there are nothing:
137
+ var objGrids = jQuery("."+ g_vars.CLASS_GRID);
138
+
139
+ if(objGrids.length == 0)
140
+ return(null);
141
+
142
+ //get from current section
143
+ var objSection = objSource.parents("section");
144
+
145
+ var objGrid = objSection.find("."+ g_vars.CLASS_GRID);
146
+
147
+ if(objGrid.length == 1)
148
+ return(objGrid);
149
+
150
+ var objPrevSection = objSection;
151
+ var objNextSection = objSection;
152
+
153
+ //get from previous section
154
+ do{
155
+ objPrevSection = objPrevSection.prev();
156
+ objNextSection = objNextSection.next();
157
+
158
+ objGrid = objPrevSection.find("."+ g_vars.CLASS_GRID);
159
+ if(objGrid.length == 1)
160
+ return(objGrid);
161
+
162
+ objGrid = objNextSection.find("."+ g_vars.CLASS_GRID);
163
+ if(objGrid.length == 1)
164
+ return(objGrid);
165
+
166
+ }while(objNextSection.length != 0 && objNextSection != 0);
167
+
168
+ //return first grid in the list
169
+
170
+ var objFirstGrid = jQuery(objGrids[0]);
171
+ return(objFirstGrid);
172
+ }
173
+
174
+
175
+ /**
176
+ * add filter object to grid
177
+ */
178
+ function bindFilterToGrid(objGrid, objFilter){
179
+
180
+ var arrFilters = objGrid.data("filters");
181
+
182
+ if(!arrFilters)
183
+ arrFilters = [];
184
+
185
+ arrFilters.push(objFilter);
186
+
187
+ objGrid.data("filters", arrFilters);
188
+
189
+ }
190
+
191
+ /**
192
+ *
193
+ * get element widget id from parent wrapper
194
+ */
195
+ function getElementWidgetID(objElement){
196
+
197
+ if(!objElement || objElement.length == 0)
198
+ throw new Error("Element not found");
199
+
200
+ //get widget id
201
+
202
+ var objWidget = objElement.parents(".elementor-widget");
203
+
204
+ if(objWidget.langth == 0)
205
+ throw new Error("Element parent not found");
206
+
207
+ var widgetID = objWidget.data("id");
208
+
209
+ if(!widgetID)
210
+ throw new Error("widget id not found");
211
+
212
+ return(widgetID);
213
+ }
214
+
215
+
216
+ /**
217
+ * get element layout data
218
+ */
219
+ function getElementLayoutData(objElement){
220
+
221
+ if(!objElement || objElement.length == 0)
222
+ throw new Error("Element not found");
223
+
224
+ //get widget id
225
+
226
+ var objWidget = objElement.parents(".elementor-widget");
227
+
228
+ if(objWidget.langth == 0)
229
+ throw new Error("Element parent not found");
230
+
231
+ var widgetID = objWidget.data("id");
232
+
233
+ if(!widgetID)
234
+ throw new Error("widget id not found");
235
+
236
+ //get layout id
237
+ var objLayout = objWidget.parents(".elementor");
238
+
239
+ if(objLayout.length == 0)
240
+ throw new Error("layout not found");
241
+
242
+ var layoutID = objLayout.data("elementor-id");
243
+
244
+ var output = {};
245
+
246
+ output["widgetid"] = widgetID;
247
+ output["layoutid"] = layoutID;
248
+
249
+ return(output);
250
+ }
251
+
252
+
253
+
254
+ function ________FILTERS_______________(){}
255
+
256
 
257
  /**
258
  * get filter type
380
  return(objSelected);
381
  }
382
 
383
+ function ________PAGINATION_FILTER______(){}
384
+
385
+ /**
386
+ * check if the filter is pagination
387
+ */
388
+ function isPaginationFilter(objFilter){
389
+
390
+ if(objFilter.hasClass("uc-filter-pagination"))
391
+ return(true);
392
+
393
+ return(false);
394
+ }
395
+
396
+ /**
397
+ * get pagination selected url or null if is current
398
+ */
399
+ function getPaginationSelectedUrl(objPagination, isPredictive){
400
+
401
+ if(isPredictive == true){
402
+
403
+ var objCurrentLink = objPagination.find("a."+g_vars.CLASS_PREDICTIVE_CACHE);
404
+
405
+ if(objCurrentLink.length == 0)
406
+ return(null);
407
+ }
408
+ else
409
+ var objCurrentLink = objPagination.find("a.current");
410
+
411
+ if(objCurrentLink.length == 0)
412
+ return(null);
413
+
414
+ var url = objCurrentLink.attr("href");
415
+
416
+ if(!url)
417
+ return(null);
418
+
419
+ return(url);
420
+ }
421
+
422
+
423
+
424
+ /**
425
+ * on ajax pagination click
426
+ */
427
+ function onAjaxPaginationLinkClick(event){
428
+
429
+ var objLink = jQuery(this);
430
+
431
+ var objPagination = objLink.parents(".uc-filter-pagination");
432
+
433
+ var objLinkCurrent = objPagination.find(".current");
434
+
435
+ objLinkCurrent.removeClass("current");
436
+
437
+ objLink.addClass("current");
438
+
439
+ var objGrid = objPagination.data("grid");
440
+
441
+ if(!objGrid || objGrid.length == 0)
442
+ throw new Error("Grid not found!");
443
+
444
+ //run the ajax, prevent default
445
+ refreshAjaxGrid(objGrid);
446
+
447
+ event.preventDefault();
448
+ return(false);
449
+ }
450
+
451
+
452
+ function ________DATA_______________(){}
453
+
454
 
455
  /**
456
  * get filters data array
605
  return(url);
606
  }
607
 
608
+ function ________AJAX_CACHE_________(){}
609
+
610
  /**
611
+ * get ajax url
612
  */
613
+ function getAjaxCacheKeyFromUrl(ajaxUrl){
614
 
615
+ var key = ajaxUrl;
616
 
617
+ key = key.replace(g_urlAjax, "");
618
+ key = key.replace(g_urlBase, "");
619
 
620
+ //replace special signs
621
+ key = replaceAll(key, "/","");
622
+ key = replaceAll(key, "?","_");
623
+ key = replaceAll(key, "&","_");
624
+ key = replaceAll(key, "=","_");
625
 
626
+ return(key);
627
+ }
628
+
629
+ /**
630
+ * get ajax cache key
631
+ */
632
+ function getAjaxCacheKey(ajaxUrl, action, objData){
633
+
634
+ if(g_options.is_cache_enabled == false)
635
+ return(false);
636
+
637
+ //cache only by url meanwhile
638
+
639
+ if(jQuery.isEmptyObject(objData) == false)
640
+ return(false);
641
+
642
+ if(action)
643
+ return(false);
644
+
645
+ var cacheKey = getAjaxCacheKeyFromUrl(ajaxUrl);
646
+
647
+ if(!cacheKey)
648
+ return(false);
649
+
650
+ return(cacheKey);
651
  }
652
 
653
 
654
  /**
655
+ * cache ajax response
656
  */
657
+ function cacheAjaxResponse(ajaxUrl, action, objData, response){
658
+
659
+ var cacheKey = getAjaxCacheKey(ajaxUrl, action, objData);
660
+
661
+ if(!cacheKey)
662
+ return(false);
663
+
664
+ //some precoutions for overload
665
+ if(g_cache.length > 100)
666
+ return(false);
667
+
668
+ g_cache[cacheKey] = response;
669
+
670
+ }
671
+
672
+
673
+ function ________PREDICTIVE_______________(){}
674
+
675
+ /**
676
+ * get predictive url
677
+ */
678
+ function setPredictiveCache_pagination(objPagination){
679
 
680
+ if(g_options.is_predictive_cache_enabled == false)
681
+ return(false);
682
 
683
+ //check if already on the page
684
+ var objPredictive = jQuery("." + g_vars.CLASS_PREDICTIVE_CACHE);
685
+
686
+ if(objPredictive.length != 0)
687
+ return(false);
688
+
689
+ var objLinks = objPagination.find("a:not("+g_vars.CLASS_PREDICTIVE_CACHE+")");
690
+
691
+ if(objLinks.length == 0)
692
+ return(null);
693
+
694
+ var paginationID = objPagination.attr("id");
695
+
696
+ var urlNextLink = null;
697
+
698
+ jQuery.each(objLinks, function(index, link){
699
+
700
+ var objLink = jQuery(link);
701
+
702
+ if(objLink.hasClass("current"))
703
+ return(true);
704
+
705
+ var linkID = paginationID + "_" + objLink.index();
706
+
707
+ if(g_vars.cachePredictiveKeys.hasOwnProperty(linkID))
708
+ return(true);
709
+
710
+ //set next predictive
711
+
712
+ objLink.addClass(g_vars.CLASS_PREDICTIVE_CACHE);
713
+
714
+ //remember predictive item
715
+ g_vars.cachePredictiveKeys[linkID] = true;
716
+
717
+ //set only once
718
+ return(false);
719
+ });
720
 
721
  }
722
 
723
 
724
  /**
725
+ * check the predictive request
726
  */
727
+ function checkPredictiveRequest(){
728
 
729
+ if(g_options.is_predictive_cache_enabled == false)
730
+ return(false);
731
 
732
+ //check if already on the page
733
+ var objPredictive = jQuery("." + g_vars.CLASS_PREDICTIVE_CACHE);
734
+
735
+ if(objPredictive.length == 0)
736
+ return(false);
737
+
738
+ if(objPredictive.length > 1){
739
+ objPredictive.removeClass(g_vars.CLASS_PREDICTIVE_CACHE);
740
  return(false);
741
  }
742
 
743
+ //run with delay
744
+
745
+ runWithTrashold(function(){
746
+
747
+ if(objPredictive.length == 0)
748
+ return(false);
749
+
750
+ objPredictive.trigger("predictive");
751
+
752
+ });
753
+
754
+
755
+ }
756
+
757
+ /**
758
+ * on predictive link click
759
+ */
760
+ function onAjaxPaginationPredictive(){
761
+
762
+ var objLink = jQuery(this);
763
 
764
+ var objPagination = objLink.parents(".uc-filter-pagination");
765
 
766
+ var objGrid = objPagination.data("grid");
767
+
768
+ if(!objGrid || objGrid.length == 0)
769
  return(false);
 
770
 
771
+ var ajaxOptions = getGridAjaxOptions([objPagination], objGrid, true);
772
+
773
+ if(!ajaxOptions)
774
+ return(false);
775
+
776
+ var ajaxUrl = ajaxOptions["ajax_url"];
777
+
778
+ removePredictiveItem();
779
 
780
+ ajaxRequest(ajaxUrl);
781
+ }
782
+
783
+
784
+ /**
785
+ * remove predicfive from all
786
+ */
787
+ function removePredictiveItem(){
788
 
789
+ var objPredictive = jQuery("."+g_vars.CLASS_PREDICTIVE_CACHE);
790
 
791
+ if(objPredictive.length == 0)
 
792
  return(false);
 
793
 
794
+ objPredictive.removeClass(g_vars.CLASS_PREDICTIVE_CACHE);
795
+
796
+ }
797
+
798
+
799
+ function ________AJAX_RESPONSE_______________(){}
800
+
801
+ /**
802
+ * replace the grid debug
803
+ */
804
+ function operateAjax_setHtmlDebug(response, objGrid){
805
+
806
+ //replace the debug
807
+ var htmlDebug = getVal(response, "html_debug");
808
+
809
+ if(!htmlDebug)
810
+ return(false);
811
+
812
+ var gridParent = objGrid.parent();
813
+
814
+ var objDebug = objGrid.siblings(".uc-debug-query-wrapper");
815
+
816
+ if(objDebug.length == 0)
817
+ return(false);
818
+
819
+ objDebug.replaceWith(htmlDebug);
820
+ }
821
+
822
+
823
+ /**
824
+ * set html grid from ajax response
825
+ */
826
+ function operateAjax_setHtmlGrid(response, objGrid){
827
+
828
+ if(objGrid.length == 0)
829
+ return(false);
830
+
831
+ objItemsWrapper = getGridItemsWrapper(objGrid);
832
+
833
+ var htmlItems = getVal(response, "html_items");
834
 
835
+ objItemsWrapper.html(htmlItems);
836
 
837
+ operateAjax_setHtmlDebug(response, objGrid);
838
 
839
  }
840
 
841
 
842
  /**
843
+ * replace filters html
844
  */
845
+ function operateAjax_setHtmlWidgets(response, objFilters){
846
 
847
+ if(!objFilters)
 
848
  return(false);
849
+
850
+ if(objFilters.length == 0)
851
+ return(false);
852
+
853
+ var objHtmlWidgets = getVal(response, "html_widgets");
854
+
855
+ if(!objHtmlWidgets)
856
+ return(false);
857
+
858
+ if(objHtmlWidgets.length == 0)
859
+ return(false);
860
+
861
+ jQuery.each(objFilters, function(index, objFilter){
862
+
863
+ var widgetID = getElementWidgetID(objFilter);
864
+
865
+ if(!widgetID)
866
+ return(true);
867
+
868
+ var html = getVal(objHtmlWidgets, widgetID);
869
+
870
+ var objHtml = jQuery(html);
871
+
872
+ var htmlInner = objHtml.html();
873
+
874
+ objFilter.html(htmlInner);
875
+ });
876
+
877
+ }
878
+
879
+ /**
880
+ * scroll to grid top
881
+ */
882
+ function scrollToGridTop(objGrid){
883
+
884
+ var gapTop = 150;
885
+
886
+ var gridOffset = objGrid.offset().top;
887
+
888
+ var gridTop = gridOffset - gapTop;
889
+
890
+ if(gridTop < 0)
891
+ gridTop = 0;
892
+
893
+ //check if the grid top is visible
894
+
895
+ var currentPos = jQuery(window).scrollTop();
896
+
897
+ if(currentPos <= gridOffset)
898
+ return(false);
899
+
900
+ window.scrollTo({ top: gridTop, behavior: 'smooth' });
901
+
902
+ }
903
+
904
+
905
+ /**
906
+ * operate the response
907
+ */
908
+ function operateAjaxRefreshResponse(response, objGrid, objFilters){
909
+
910
+ operateAjax_setHtmlGrid(response, objGrid);
911
+
912
+ operateAjax_setHtmlWidgets(response, objFilters);
913
+
914
+ objGrid.trigger("uc_ajax_refreshed");
915
+
916
+ setTimeout(function(){
917
+
918
+ scrollToGridTop(objGrid);
919
+
920
+ },200);
921
+
922
+ }
923
+
924
+
925
+ /**
926
+ * replace all occurances
927
+ */
928
+ function replaceAll(text, from, to){
929
+
930
+ return text.split(from).join(to);
931
+ };
932
+
933
+
934
+
935
+
936
+ /**
937
+ * get response from ajax cache
938
+ */
939
+ function getResponseFromAjaxCache(ajaxUrl, action, objData){
940
+
941
+ var cacheKey = getAjaxCacheKey(ajaxUrl, action, objData);
942
+
943
+ if(!cacheKey)
944
+ return(false);
945
+
946
+ var response = getVal(g_cache, cacheKey);
947
+
948
+ return(response);
949
+ }
950
+
951
+
952
+ function ________AJAX_______________(){}
953
+
954
+ /**
955
+ * show ajax error, should be something visible
956
+ */
957
+ function showAjaxError(message){
958
+
959
+ alert(message);
960
+
961
+ }
962
+
963
+ /**
964
+ * get the debug object
965
+ */
966
+ function getDebugObject(){
967
+
968
+ var objGrid = g_lastGridAjaxCall;
969
+
970
+ if(!objGrid)
971
+ return(null);
972
+
973
+ var objDebug = objGrid.find("."+g_vars.CLASS_DIV_DEBUG);
974
+
975
+ if(objDebug.length)
976
+ return(objDebug);
977
+
978
+ //insert if not exists
979
+
980
+ objGrid.after("<div class='"+g_vars.CLASS_DIV_DEBUG+"' style='padding:10px;display:none;background-color:#D8FCC6'></div>");
981
+
982
+ var objDebug = jQuery("body").find("."+g_vars.CLASS_DIV_DEBUG);
983
+
984
+ return(objDebug);
985
+ }
986
+
987
+
988
+ /**
989
+ * show ajax debug
990
+ */
991
+ function showAjaxDebug(str){
992
+
993
+ str = jQuery.trim(str);
994
+
995
+ if(!str || str.length == 0)
996
+ return(false);
997
+
998
+ var objStr = jQuery(str);
999
+
1000
+ if(objStr.find("header").length || objStr.find("body").length){
1001
+ str = "Wrong ajax response!";
1002
+ }
1003
+
1004
+ var objDebug = getDebugObject();
1005
+
1006
+ if(!objDebug || objDebug.length == 0){
1007
+
1008
+ alert(str);
1009
+
1010
+ throw new Error("debug not found");
1011
+ }
1012
+
1013
+ objDebug.show();
1014
+ objDebug.html(str);
1015
+
1016
+ }
1017
+
1018
+
1019
+ /**
1020
+ * small ajax request
1021
+ */
1022
+ function ajaxRequest(ajaxUrl, action, objData, onSuccess){
1023
+
1024
+ if(!objData)
1025
+ var objData = {};
1026
+
1027
+ if(typeof objData != "object")
1028
+ throw new Error("wrong ajax param");
1029
+
1030
+ //check response from cache
1031
+ var responseFromCache = getResponseFromAjaxCache(ajaxUrl, action, objData);
1032
+
1033
+ if(responseFromCache){
1034
+
1035
+ //simulate ajax request
1036
+ setTimeout(function(){
1037
+ onSuccess(responseFromCache);
1038
+ }, 300);
1039
+
1040
+ return(false);
1041
+ }
1042
+
1043
+ var ajaxData = {};
1044
+ ajaxData["action"] = "unlimitedelements_ajax_action";
1045
+ ajaxData["client_action"] = action;
1046
+
1047
+ var ajaxtype = "get";
1048
+
1049
+ if(objData){
1050
+ ajaxData["data"] = objData;
1051
+ ajaxtype = "post";
1052
+ }
1053
+
1054
+ var ajaxOptions = {
1055
+ type:ajaxtype,
1056
+ url:ajaxUrl,
1057
+ success:function(response){
1058
+
1059
+ if(!response){
1060
+ showAjaxError("Empty ajax response!");
1061
+ return(false);
1062
+ }
1063
+
1064
+ if(typeof response != "object"){
1065
+
1066
+ try{
1067
+
1068
+ response = jQuery.parseJSON(response);
1069
+
1070
+ }catch(e){
1071
+
1072
+ showAjaxDebug(response);
1073
+
1074
+ showAjaxError("Ajax Error!!! not ajax response");
1075
+ return(false);
1076
+ }
1077
+ }
1078
+
1079
+ if(response == -1){
1080
+ showAjaxError("ajax error!!!");
1081
+ return(false);
1082
+ }
1083
+
1084
+ if(response == 0){
1085
+ showAjaxError("ajax error, action: <b>"+action+"</b> not found");
1086
+ return(false);
1087
+ }
1088
+
1089
+ if(response.success == undefined){
1090
+ showAjaxError("The 'success' param is a must!");
1091
+ return(false);
1092
+ }
1093
+
1094
+
1095
+ if(response.success == false){
1096
+ showAjaxError(response.message);
1097
+ return(false);
1098
+ }
1099
+
1100
+ cacheAjaxResponse(ajaxUrl, action, objData, response);
1101
+
1102
+ if(typeof onSuccess == "function"){
1103
+
1104
+ onSuccess(response);
1105
+ }
1106
+
1107
+ },
1108
+ error:function(jqXHR, textStatus, errorThrown){
1109
+
1110
+ switch(textStatus){
1111
+ case "parsererror":
1112
+ case "error":
1113
+
1114
+ //showAjaxError("parse error");
1115
+
1116
+ showAjaxDebug(jqXHR.responseText);
1117
+
1118
+ break;
1119
+ }
1120
+ }
1121
+ }
1122
+
1123
+ if(ajaxtype == "post"){
1124
+ ajaxOptions.dataType = 'json';
1125
+ ajaxOptions.data = ajaxData
1126
+ }
1127
+
1128
+ jQuery.ajax(ajaxOptions);
1129
+
1130
+ }
1131
+
1132
+
1133
+
1134
+ /**
1135
+ * get grid items wrapper
1136
+ */
1137
+ function getGridItemsWrapper(objGrid){
1138
+
1139
+ if(objGrid.hasClass("uc-items-wrapper"))
1140
+ return(objGrid);
1141
+
1142
+ var objItemsWrapper = objGrid.find(".uc-items-wrapper");
1143
+
1144
+ if(objItemsWrapper.length == 0)
1145
+ throw new Error("Missing items wrapper - with class: uc-items-wrapper");
1146
+
1147
+ return(objItemsWrapper);
1148
+ }
1149
+
1150
+
1151
+ /**
1152
+ * set ajax loader
1153
+ */
1154
+ function showAjaxLoader(objElement){
1155
+
1156
+ objElement.addClass("uc-ajax-loading");
1157
+ }
1158
+
1159
+ /**
1160
+ * hide ajax loader
1161
+ */
1162
+ function hideAjaxLoader(objElement){
1163
+
1164
+ objElement.removeClass("uc-ajax-loading");
1165
+ }
1166
+
1167
+
1168
+ /**
1169
+ * show multiple ajax loader
1170
+ */
1171
+ function showMultipleAjaxLoaders(objElements, isShow){
1172
+
1173
+ if(!objElements)
1174
+ return(false);
1175
+
1176
+ if(objElements.length == 0)
1177
+ return(false);
1178
+
1179
+ jQuery.each(objElements,function(index, objElement){
1180
+
1181
+ if(isShow == true)
1182
+ showAjaxLoader(objElement);
1183
+ else
1184
+ hideAjaxLoader(objElement);
1185
+ });
1186
+
1187
+ }
1188
+
1189
+
1190
+
1191
+
1192
+ /**
1193
+ * refresh ajax grid
1194
+ */
1195
+ function refreshAjaxGrid(objGrid){
1196
+
1197
+ removePredictiveItem();
1198
+
1199
+ //get all grid filters
1200
+ var objFilters = objGrid.data("filters");
1201
+
1202
+ if(!objFilters)
1203
+ return(false);
1204
+
1205
+ if(objFilters.length == 0)
1206
+ return(false);
1207
+
1208
+ var objAjaxOptions = getGridAjaxOptions(objFilters, objGrid);
1209
+
1210
+ if(!objAjaxOptions)
1211
+ return(false);
1212
+
1213
+ var ajaxUrl = objAjaxOptions["ajax_url"];
1214
+
1215
+ if(g_vars.DEBUG_AJAX_OPTIONS == true){
1216
+
1217
+ trace("DEBUG AJAX OPTIONS");
1218
+ trace(objAjaxOptions);
1219
+ return(false);
1220
+ }
1221
+
1222
+ //do the ajax call
1223
+ showAjaxLoader(objGrid);
1224
+ showMultipleAjaxLoaders(objFilters, true);
1225
+
1226
+ g_lastGridAjaxCall = objGrid;
1227
+
1228
+ ajaxRequest(ajaxUrl,null,null, function(response){
1229
+
1230
+ hideAjaxLoader(objGrid);
1231
+ showMultipleAjaxLoaders(objFilters, false);
1232
+
1233
+ operateAjaxRefreshResponse(response, objGrid, objFilters);
1234
+
1235
+ });
1236
+ }
1237
+
1238
+
1239
+ function ________RUN_______________(){}
1240
+
1241
+ /**
1242
+ * on filters change - refresh the page with the new query
1243
+ */
1244
+ function onFiltersChange(objGrid){
1245
+
1246
+ var query = buildUrlQuery();
1247
+
1248
+ var url = getRedirectUrl(query);
1249
+
1250
+ if(!url)
1251
+ throw new error("onFiltersChange error - empty redirect url");
1252
+
1253
+ location.href = url;
1254
+ }
1255
+
1256
+
1257
+ /**
1258
+ * get grid ajax options
1259
+ */
1260
+ function getGridAjaxOptions(objFilters, objGrid, isPredictive){
1261
+
1262
+ if(!objFilters)
1263
+ return(false);
1264
+
1265
+ var urlAjax = g_urlBase;
1266
+
1267
+ var strRefreshIDs = "";
1268
+
1269
+ //get ajax options
1270
+ jQuery.each(objFilters, function(index, objFilter){
1271
+
1272
+ var isPagination = isPaginationFilter(objFilter);
1273
+
1274
+ if(isPagination == true){
1275
+ var urlPagination = getPaginationSelectedUrl(objFilter, isPredictive);
1276
+
1277
+ if(isPredictive == true && !urlPagination)
1278
+ urlAjax = null;
1279
+
1280
+ if(urlPagination)
1281
+ urlAjax = urlPagination;
1282
+ }
1283
+
1284
+ //add widget id of the filter to refresh
1285
+
1286
+ var filterWidgetID = getElementWidgetID(objFilter);
1287
+
1288
+ if(strRefreshIDs)
1289
+ strRefreshIDs += ",";
1290
+
1291
+ strRefreshIDs += filterWidgetID
1292
+ });
1293
+
1294
+ if(urlAjax == null)
1295
+ return(null);
1296
+
1297
+ var dataLayout = getElementLayoutData(objGrid);
1298
+
1299
+ var widgetID = dataLayout["widgetid"];
1300
+ var layoutID = dataLayout["layoutid"];
1301
+
1302
+ var urlAddition = "ucfrontajaxaction=getfiltersdata&layoutid="+layoutID+"&elid="+widgetID;
1303
+
1304
+ urlAjax = addUrlParam(urlAjax, urlAddition);
1305
+
1306
+ //add refresh ids
1307
+ if(strRefreshIDs)
1308
+ urlAjax += "&addelids="+strRefreshIDs;
1309
+
1310
+ var output = {};
1311
+ output["ajax_url"] = urlAjax;
1312
+
1313
+ return(output);
1314
+ }
1315
+
1316
+
1317
+
1318
+ function ________INIT_______________(){}
1319
+
1320
+
1321
+
1322
+ /**
1323
+ * init events
1324
+ */
1325
+ function initEvents(){
1326
+
1327
+ var objCheckboxes = g_objFilters.filter("input[type=checkbox]");
1328
+
1329
+ objCheckboxes.on("click", onFiltersChange);
1330
+
1331
+ }
1332
+
1333
+
1334
+ /**
1335
+ * init listing object
1336
+ */
1337
+ function initGridObject(){
1338
+
1339
+ //init the listing
1340
+ g_objGrid = jQuery("."+ g_vars.CLASS_GRID);
1341
+
1342
+ if(g_objGrid.length == 0){
1343
+ g_objGrid = null;
1344
+ return(false);
1345
+ }
1346
+
1347
+ //set only available grid
1348
+ if(g_objGrid.length > 1){
1349
+ g_objGrid = null;
1350
+ }
1351
+
1352
+ }
1353
+
1354
+
1355
+ /**
1356
+ * init grid filters
1357
+ */
1358
+ function initGridFilters(){
1359
+
1360
+ //init the filters objects
1361
+ g_objFilters = jQuery(".uc-grid-filter");
1362
+
1363
+ if(g_objFilters.length == 0){
1364
+ return(false);
1365
+ }
1366
+
1367
+ }
1368
+
1369
+
1370
+ /**
1371
+ * init the globals
1372
+ */
1373
+ function initGlobals(){
1374
+
1375
+ if(typeof g_strFiltersData != "undefined"){
1376
+ g_filtersData = JSON.parse(g_strFiltersData);
1377
+ }
1378
+
1379
+ if(jQuery.isEmptyObject(g_filtersData)){
1380
+
1381
+ trace("filters error - filters data not found");
1382
+ return(false);
1383
+ }
1384
+
1385
+ g_urlBase = getVal(g_filtersData, "urlbase");
1386
+ g_urlAjax = getVal(g_filtersData, "urlajax");
1387
+
1388
+ if(!g_urlBase){
1389
+ trace("ue filters error - base url not inited");
1390
+ return(false);
1391
+ }
1392
+
1393
+ if(!g_urlAjax){
1394
+ trace("ue filters error - ajax url not inited");
1395
+ return(false);
1396
+ }
1397
+
1398
+ return(true);
1399
+ }
1400
+
1401
+
1402
+
1403
+ /**
1404
+ * init pagination filter
1405
+ */
1406
+ function initPaginationFilter(objPagination){
1407
+
1408
+ var objGrid = getClosestGrid(objPagination);
1409
+
1410
+ if(!objGrid)
1411
+ return(null);
1412
+
1413
+ var isAjax = objGrid.data("ajax");
1414
+
1415
+ if(isAjax == false)
1416
+ return(false);
1417
+
1418
+ //bind grid to pagination
1419
+ objPagination.data("grid", objGrid);
1420
+
1421
+ //bind pagination to grid
1422
+ bindFilterToGrid(objGrid, objPagination);
1423
+
1424
+ }
1425
+
1426
+
1427
+ /**
1428
+ * init pagination filter
1429
+ */
1430
+ function initPaginationFilters(){
1431
+
1432
+ var objPaginations = jQuery(".uc-filter-pagination");
1433
+
1434
+ if(objPaginations.length == 0)
1435
+ return(false);
1436
+
1437
+ jQuery.each(objPaginations, function(index, pagination){
1438
+
1439
+ var objPagination = jQuery(pagination);
1440
+
1441
+ initPaginationFilter(objPagination);
1442
+
1443
+ });
1444
+
1445
+ //init the events
1446
+ var objParent = objPaginations.parents(".elementor");
1447
+
1448
+ if(g_options.is_predictive_cache_enabled == true)
1449
+ objParent.on("predictive",".uc-filter-pagination a", onAjaxPaginationPredictive);
1450
+
1451
+ objParent.on("click",".uc-filter-pagination a", onAjaxPaginationLinkClick);
1452
+
1453
+ }
1454
+
1455
+
1456
+
1457
+ /**
1458
+ * init
1459
+ */
1460
+ function init(){
1461
+
1462
+ var success = initGlobals();
1463
+
1464
+ if(success == false)
1465
+ return(false);
1466
+
1467
+ //init the grid object
1468
+ initGridObject();
1469
+
1470
+ //initGridFilters();
1471
+
1472
+ initPaginationFilters();
1473
+
1474
+ checkPredictiveRequest();
1475
+
1476
+ //clearFilters(true);
1477
+ //initEvents();
1478
+
1479
+ }
1480
+
1481
+
1482
+ /**
1483
+ * init the class
1484
+ */
1485
+ function construct(){
1486
+
1487
+ if(!jQuery){
1488
+ trace("Filters not loaded, jQuery not loaded");
1489
+ return(false);
1490
+ }
1491
+
1492
  jQuery("document").ready(init);
1493
 
1494
  }
1496
  construct();
1497
  }
1498
 
1499
+ new UEDynamicFilters();
1500
 
assets_libraries/owl-carousel-new/assets/owl.carousel.css ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Owl Carousel v2.3.4
3
+ * Copyright 2013-2018 David Deutsch
4
+ * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
5
+ */
6
+ /*
7
+ * Owl Carousel - Core
8
+ */
9
+ .owl-carousel {
10
+ display: none;
11
+ width: 100%;
12
+ -webkit-tap-highlight-color: transparent;
13
+ /* position relative and z-index fix webkit rendering fonts issue */
14
+ position: relative;
15
+ z-index: 1; }
16
+ .owl-carousel .owl-stage {
17
+ position: relative;
18
+ -ms-touch-action: pan-Y;
19
+ touch-action: manipulation;
20
+ -moz-backface-visibility: hidden;
21
+ /* fix firefox animation glitch */ }
22
+ .owl-carousel .owl-stage:after {
23
+ content: ".";
24
+ display: block;
25
+ clear: both;
26
+ visibility: hidden;
27
+ line-height: 0;
28
+ height: 0; }
29
+ .owl-carousel .owl-stage-outer {
30
+ position: relative;
31
+ overflow: hidden;
32
+ /* fix for flashing background */
33
+ -webkit-transform: translate3d(0px, 0px, 0px); }
34
+ .owl-carousel .owl-wrapper,
35
+ .owl-carousel .owl-item {
36
+ -webkit-backface-visibility: hidden;
37
+ -moz-backface-visibility: hidden;
38
+ -ms-backface-visibility: hidden;
39
+ -webkit-transform: translate3d(0, 0, 0);
40
+ -moz-transform: translate3d(0, 0, 0);
41
+ -ms-transform: translate3d(0, 0, 0); }
42
+ .owl-carousel .owl-item {
43
+ position: relative;
44
+ min-height: 1px;
45
+ float: left;
46
+ -webkit-backface-visibility: hidden;
47
+ -webkit-tap-highlight-color: transparent;
48
+ -webkit-touch-callout: none; }
49
+ .owl-carousel .owl-item img {
50
+ display: block;
51
+ width: 100%; }
52
+ .owl-carousel .owl-nav.disabled,
53
+ .owl-carousel .owl-dots.disabled {
54
+ display: none; }
55
+ .owl-carousel .owl-nav .owl-prev,
56
+ .owl-carousel .owl-nav .owl-next,
57
+ .owl-carousel .owl-dot {
58
+ cursor: pointer;
59
+ -webkit-user-select: none;
60
+ -khtml-user-select: none;
61
+ -moz-user-select: none;
62
+ -ms-user-select: none;
63
+ user-select: none; }
64
+ .owl-carousel .owl-nav button.owl-prev,
65
+ .owl-carousel .owl-nav button.owl-next,
66
+ .owl-carousel button.owl-dot {
67
+ background: none;
68
+ color: inherit;
69
+ border: none;
70
+ padding: 0 !important;
71
+ font: inherit; }
72
+ .owl-carousel.owl-loaded {
73
+ display: block; }
74
+ .owl-carousel.owl-loading {
75
+ opacity: 0;
76
+ display: block; }
77
+ .owl-carousel.owl-hidden {
78
+ opacity: 0; }
79
+ .owl-carousel.owl-refresh .owl-item {
80
+ visibility: hidden; }
81
+ .owl-carousel.owl-drag .owl-item {
82
+ -ms-touch-action: pan-y;
83
+ touch-action: pan-y;
84
+ -webkit-user-select: none;
85
+ -moz-user-select: none;
86
+ -ms-user-select: none;
87
+ user-select: none; }
88
+ .owl-carousel.owl-grab {
89
+ cursor: move;
90
+ cursor: grab; }
91
+ .owl-carousel.owl-rtl {
92
+ direction: rtl; }
93
+ .owl-carousel.owl-rtl .owl-item {
94
+ float: right; }
95
+
96
+ /* No Js */
97
+ .no-js .owl-carousel {
98
+ display: block; }
99
+
100
+ /*
101
+ * Owl Carousel - Animate Plugin
102
+ */
103
+ .owl-carousel .animated {
104
+ animation-duration: 1000ms;
105
+ animation-fill-mode: both; }
106
+
107
+ .owl-carousel .owl-animated-in {
108
+ z-index: 0; }
109
+
110
+ .owl-carousel .owl-animated-out {
111
+ z-index: 1; }
112
+
113
+ .owl-carousel .fadeOut {
114
+ animation-name: fadeOut; }
115
+
116
+ @keyframes fadeOut {
117
+ 0% {
118
+ opacity: 1; }
119
+ 100% {
120
+ opacity: 0; } }
121
+
122
+ /*
123
+ * Owl Carousel - Auto Height Plugin
124
+ */
125
+ .owl-height {
126
+ transition: height 500ms ease-in-out; }
127
+
128
+ /*
129
+ * Owl Carousel - Lazy Load Plugin
130
+ */
131
+ .owl-carousel .owl-item {
132
+ /**
133
+ This is introduced due to a bug in IE11 where lazy loading combined with autoheight plugin causes a wrong
134
+ calculation of the height of the owl-item that breaks page layouts
135
+ */ }
136
+ .owl-carousel .owl-item .owl-lazy {
137
+ opacity: 0;
138
+ transition: opacity 400ms ease; }
139
+ .owl-carousel .owl-item .owl-lazy[src^=""], .owl-carousel .owl-item .owl-lazy:not([src]) {
140
+ max-height: 0; }
141
+ .owl-carousel .owl-item img.owl-lazy {
142
+ transform-style: preserve-3d; }
143
+
144
+ /*
145
+ * Owl Carousel - Video Plugin
146
+ */
147
+ .owl-carousel .owl-video-wrapper {
148
+ position: relative;
149
+ height: 100%;
150
+ background: #000; }
151
+
152
+ .owl-carousel .owl-video-play-icon {
153
+ position: absolute;
154
+ height: 80px;
155
+ width: 80px;
156
+ left: 50%;
157
+ top: 50%;
158
+ margin-left: -40px;
159
+ margin-top: -40px;
160
+ background: url("owl.video.play.png") no-repeat;
161
+ cursor: pointer;
162
+ z-index: 1;
163
+ -webkit-backface-visibility: hidden;
164
+ transition: transform 100ms ease; }
165
+
166
+ .owl-carousel .owl-video-play-icon:hover {
167
+ -ms-transform: scale(1.3, 1.3);
168
+ transform: scale(1.3, 1.3); }
169
+
170
+ .owl-carousel .owl-video-playing .owl-video-tn,
171
+ .owl-carousel .owl-video-playing .owl-video-play-icon {
172
+ display: none; }
173
+
174
+ .owl-carousel .owl-video-tn {
175
+ opacity: 0;
176
+ height: 100%;
177
+ background-position: center center;
178
+ background-repeat: no-repeat;
179
+ background-size: contain;
180
+ transition: opacity 400ms ease; }
181
+
182
+ .owl-carousel .owl-video-frame {
183
+ position: relative;
184
+ z-index: 1;
185
+ height: 100%;
186
+ width: 100%; }
assets_libraries/owl-carousel-new/owl.carousel.js ADDED
@@ -0,0 +1,3448 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Owl Carousel v2.3.4
3
+ * Copyright 2013-2018 David Deutsch
4
+ * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
5
+ */
6
+ /**
7
+ * Owl carousel
8
+ * @version 2.3.4
9
+ * @author Bartosz Wojciechowski
10
+ * @author David Deutsch
11
+ * @license The MIT License (MIT)
12
+ * @todo Lazy Load Icon
13
+ * @todo prevent animationend bubling
14
+ * @todo itemsScaleUp
15
+ * @todo Test Zepto
16
+ * @todo stagePadding calculate wrong active classes
17
+ */
18
+ ;(function($, window, document, undefined) {
19
+
20
+ /**
21
+ * Creates a carousel.
22
+ * @class The Owl Carousel.
23
+ * @public
24
+ * @param {HTMLElement|jQuery} element - The element to create the carousel for.
25
+ * @param {Object} [options] - The options
26
+ */
27
+ function Owl(element, options) {
28
+
29
+ /**
30
+ * Current settings for the carousel.
31
+ * @public
32
+ */
33
+ this.settings = null;
34
+
35
+ /**
36
+ * Current options set by the caller including defaults.
37
+ * @public
38
+ */
39
+ this.options = $.extend({}, Owl.Defaults, options);
40
+
41
+ /**
42
+ * Plugin element.
43
+ * @public
44
+ */
45
+ this.$element = $(element);
46
+
47
+ /**
48
+ * Proxied event handlers.
49
+ * @protected
50
+ */
51
+ this._handlers = {};
52
+
53
+ /**
54
+ * References to the running plugins of this carousel.
55
+ * @protected
56
+ */
57
+ this._plugins = {};
58
+
59
+ /**
60
+ * Currently suppressed events to prevent them from being retriggered.
61
+ * @protected
62
+ */
63
+ this._supress = {};
64
+
65
+ /**
66
+ * Absolute current position.
67
+ * @protected
68
+ */
69
+ this._current = null;
70
+
71
+ /**
72
+ * Animation speed in milliseconds.
73
+ * @protected
74
+ */
75
+ this._speed = null;
76
+
77
+ /**
78
+ * Coordinates of all items in pixel.
79
+ * @todo The name of this member is missleading.
80
+ * @protected
81
+ */
82
+ this._coordinates = [];
83
+
84
+ /**
85
+ * Current breakpoint.
86
+ * @todo Real media queries would be nice.
87
+ * @protected
88
+ */
89
+ this._breakpoint = null;
90
+
91
+ /**
92
+ * Current width of the plugin element.
93
+ */
94
+ this._width = null;
95
+
96
+ /**
97
+ * All real items.
98
+ * @protected
99
+ */
100
+ this._items = [];
101
+
102
+ /**
103
+ * All cloned items.
104
+ * @protected
105
+ */
106
+ this._clones = [];
107
+
108
+ /**
109
+ * Merge values of all items.
110
+ * @todo Maybe this could be part of a plugin.
111
+ * @protected
112
+ */
113
+ this._mergers = [];
114
+
115
+ /**
116
+ * Widths of all items.
117
+ */
118
+ this._widths = [];
119
+
120
+ /**
121
+ * Invalidated parts within the update process.
122
+ * @protected
123
+ */
124
+ this._invalidated = {};
125
+
126
+ /**
127
+ * Ordered list of workers for the update process.
128
+ * @protected
129
+ */
130
+ this._pipe = [];
131
+
132
+ /**
133
+ * Current state information for the drag operation.
134
+ * @todo #261
135
+ * @protected
136
+ */
137
+ this._drag = {
138
+ time: null,
139
+ target: null,
140
+ pointer: null,
141
+ stage: {
142
+ start: null,
143
+ current: null
144
+ },
145
+ direction: null
146
+ };
147
+
148
+ /**
149
+ * Current state information and their tags.
150
+ * @type {Object}
151
+ * @protected
152
+ */
153
+ this._states = {
154
+ current: {},
155
+ tags: {
156
+ 'initializing': [ 'busy' ],
157
+ 'animating': [ 'busy' ],
158
+ 'dragging': [ 'interacting' ]
159
+ }
160
+ };
161
+
162
+ $.each([ 'onResize', 'onThrottledResize' ], $.proxy(function(i, handler) {
163
+ this._handlers[handler] = $.proxy(this[handler], this);
164
+ }, this));
165
+
166
+ $.each(Owl.Plugins, $.proxy(function(key, plugin) {
167
+ this._plugins[key.charAt(0).toLowerCase() + key.slice(1)]
168
+ = new plugin(this);
169
+ }, this));
170
+
171
+ $.each(Owl.Workers, $.proxy(function(priority, worker) {
172
+ this._pipe.push({
173
+ 'filter': worker.filter,
174
+ 'run': $.proxy(worker.run, this)
175
+ });
176
+ }, this));
177
+
178
+ this.setup();
179
+ this.initialize();
180
+ }
181
+
182
+ /**
183
+ * Default options for the carousel.
184
+ * @public
185
+ */
186
+ Owl.Defaults = {
187
+ items: 3,
188
+ loop: false,
189
+ center: false,
190
+ rewind: false,
191
+ checkVisibility: true,
192
+
193
+ mouseDrag: true,
194
+ touchDrag: true,
195
+ pullDrag: true,
196
+ freeDrag: false,
197
+
198
+ margin: 0,
199
+ stagePadding: 0,
200
+
201
+ merge: false,
202
+ mergeFit: true,
203
+ autoWidth: false,
204
+
205
+ startPosition: 0,
206
+ rtl: false,
207
+
208
+ smartSpeed: 250,
209
+ fluidSpeed: false,
210
+ dragEndSpeed: false,
211
+
212
+ responsive: {},
213
+ responsiveRefreshRate: 200,
214
+ responsiveBaseElement: window,
215
+
216
+ fallbackEasing: 'swing',
217
+ slideTransition: '',
218
+
219
+ info: false,
220
+
221
+ nestedItemSelector: false,
222
+ itemElement: 'div',
223
+ stageElement: 'div',
224
+
225
+ refreshClass: 'owl-refresh',
226
+ loadedClass: 'owl-loaded',
227
+ loadingClass: 'owl-loading',
228
+ rtlClass: 'owl-rtl',
229
+ responsiveClass: 'owl-responsive',
230
+ dragClass: 'owl-drag',
231
+ itemClass: 'owl-item',
232
+ stageClass: 'owl-stage',
233
+ stageOuterClass: 'owl-stage-outer',
234
+ grabClass: 'owl-grab'
235
+ };
236
+
237
+ /**
238
+ * Enumeration for width.
239
+ * @public
240
+ * @readonly
241
+ * @enum {String}
242
+ */
243
+ Owl.Width = {
244
+ Default: 'default',
245
+ Inner: 'inner',
246
+ Outer: 'outer'
247
+ };
248
+
249
+ /**
250
+ * Enumeration for types.
251
+ * @public
252
+ * @readonly
253
+ * @enum {String}
254
+ */
255
+ Owl.Type = {
256
+ Event: 'event',
257
+ State: 'state'
258
+ };
259
+
260
+ /**
261
+ * Contains all registered plugins.
262
+ * @public
263
+ */
264
+ Owl.Plugins = {};
265
+
266
+ /**
267
+ * List of workers involved in the update process.
268
+ */
269
+ Owl.Workers = [ {
270
+ filter: [ 'width', 'settings' ],
271
+ run: function() {
272
+ this._width = this.$element.width();
273
+ }
274
+ }, {
275
+ filter: [ 'width', 'items', 'settings' ],
276
+ run: function(cache) {
277
+ cache.current = this._items && this._items[this.relative(this._current)];
278
+ }
279
+ }, {
280
+ filter: [ 'items', 'settings' ],
281
+ run: function() {
282
+ this.$stage.children('.cloned').remove();
283
+ }
284
+ }, {
285
+ filter: [ 'width', 'items', 'settings' ],
286
+ run: function(cache) {
287
+ var margin = this.settings.margin || '',
288
+ grid = !this.settings.autoWidth,
289
+ rtl = this.settings.rtl,
290
+ css = {
291
+ 'width': 'auto',
292
+ 'margin-left': rtl ? margin : '',
293
+ 'margin-right': rtl ? '' : margin
294
+ };
295
+
296
+ !grid && this.$stage.children().css(css);
297
+
298
+ cache.css = css;
299
+ }
300
+ }, {
301
+ filter: [ 'width', 'items', 'settings' ],
302
+ run: function(cache) {
303
+ var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin,
304
+ merge = null,
305
+ iterator = this._items.length,
306
+ grid = !this.settings.autoWidth,
307
+ widths = [];
308
+
309
+ cache.items = {
310
+ merge: false,
311
+ width: width
312
+ };
313
+
314
+ while (iterator--) {
315
+ merge = this._mergers[iterator];
316
+ merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge;
317
+
318
+ cache.items.merge = merge > 1 || cache.items.merge;
319
+
320
+ widths[iterator] = !grid ? this._items[iterator].width() : width * merge;
321
+ }
322
+
323
+ this._widths = widths;
324
+ }
325
+ }, {
326
+ filter: [ 'items', 'settings' ],
327
+ run: function() {
328
+ var clones = [],
329
+ items = this._items,
330
+ settings = this.settings,
331
+ // TODO: Should be computed from number of min width items in stage
332
+ view = Math.max(settings.items * 2, 4),
333
+ size = Math.ceil(items.length / 2) * 2,
334
+ repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0,
335
+ append = '',
336
+ prepend = '';
337
+
338
+ repeat /= 2;
339
+
340
+ while (repeat > 0) {
341
+ // Switch to only using appended clones
342
+ clones.push(this.normalize(clones.length / 2, true));
343
+ append = append + items[clones[clones.length - 1]][0].outerHTML;
344
+ clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true));
345
+ prepend = items[clones[clones.length - 1]][0].outerHTML + prepend;
346
+ repeat -= 1;
347
+ }
348
+
349
+ this._clones = clones;
350
+
351
+ $(append).addClass('cloned').appendTo(this.$stage);
352
+ $(prepend).addClass('cloned').prependTo(this.$stage);
353
+ }
354
+ }, {
355
+ filter: [ 'width', 'items', 'settings' ],
356
+ run: function() {
357
+ var rtl = this.settings.rtl ? 1 : -1,
358
+ size = this._clones.length + this._items.length,
359
+ iterator = -1,
360
+ previous = 0,
361
+ current = 0,
362
+ coordinates = [];
363
+
364
+ while (++iterator < size) {
365
+ previous = coordinates[iterator - 1] || 0;
366
+ current = this._widths[this.relative(iterator)] + this.settings.margin;
367
+ coordinates.push(previous + current * rtl);
368
+ }
369
+
370
+ this._coordinates = coordinates;
371
+ }
372
+ }, {
373
+ filter: [ 'width', 'items', 'settings' ],
374
+ run: function() {
375
+ var padding = this.settings.stagePadding,
376
+ coordinates = this._coordinates,
377
+ css = {
378
+ 'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2,
379
+ 'padding-left': padding || '',
380
+ 'padding-right': padding || ''
381
+ };
382
+
383
+ this.$stage.css(css);
384
+ }
385
+ }, {
386
+ filter: [ 'width', 'items', 'settings' ],
387
+ run: function(cache) {
388
+ var iterator = this._coordinates.length,
389
+ grid = !this.settings.autoWidth,
390
+ items = this.$stage.children();
391
+
392
+ if (grid && cache.items.merge) {
393
+ while (iterator--) {
394
+ cache.css.width = this._widths[this.relative(iterator)];
395
+ items.eq(iterator).css(cache.css);
396
+ }
397
+ } else if (grid) {
398
+ cache.css.width = cache.items.width;
399
+ items.css(cache.css);
400
+ }
401
+ }
402
+ }, {
403
+ filter: [ 'items' ],
404
+ run: function() {
405
+ this._coordinates.length < 1 && this.$stage.removeAttr('style');
406
+ }
407
+ }, {
408
+ filter: [ 'width', 'items', 'settings' ],
409
+ run: function(cache) {
410
+ cache.current = cache.current ? this.$stage.children().index(cache.current) : 0;
411
+ cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current));
412
+ this.reset(cache.current);
413
+ }
414
+ }, {
415
+ filter: [ 'position' ],
416
+ run: function() {
417
+ this.animate(this.coordinates(this._current));
418
+ }
419
+ }, {
420
+ filter: [ 'width', 'position', 'items', 'settings' ],
421
+ run: function() {
422
+ var rtl = this.settings.rtl ? 1 : -1,
423
+ padding = this.settings.stagePadding * 2,
424
+ begin = this.coordinates(this.current()) + padding,
425
+ end = begin + this.width() * rtl,
426
+ inner, outer, matches = [], i, n;
427
+
428
+ for (i = 0, n = this._coordinates.length; i < n; i++) {
429
+ inner = this._coordinates[i - 1] || 0;
430
+ outer = Math.abs(this._coordinates[i]) + padding * rtl;
431
+
432
+ if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end)))
433
+ || (this.op(outer, '<', begin) && this.op(outer, '>', end))) {
434
+ matches.push(i);
435
+ }
436
+ }
437
+
438
+ this.$stage.children('.active').removeClass('active');
439
+ this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active');
440
+
441
+ this.$stage.children('.center').removeClass('center');
442
+ if (this.settings.center) {
443
+ this.$stage.children().eq(this.current()).addClass('center');
444
+ }
445
+ }
446
+ } ];
447
+
448
+ /**
449
+ * Create the stage DOM element
450
+ */
451
+ Owl.prototype.initializeStage = function() {
452
+ this.$stage = this.$element.find('.' + this.settings.stageClass);
453
+
454
+ // if the stage is already in the DOM, grab it and skip stage initialization
455
+ if (this.$stage.length) {
456
+ return;
457
+ }
458
+
459
+ this.$element.addClass(this.options.loadingClass);
460
+
461
+ // create stage
462
+ this.$stage = $('<' + this.settings.stageElement + '>', {
463
+ "class": this.settings.stageClass
464
+ }).wrap( $( '<div/>', {
465
+ "class": this.settings.stageOuterClass
466
+ }));
467
+
468
+ // append stage
469
+ this.$element.append(this.$stage.parent());
470
+ };
471
+
472
+ /**
473
+ * Create item DOM elements
474
+ */
475
+ Owl.prototype.initializeItems = function() {
476
+ var $items = this.$element.find('.owl-item');
477
+
478
+ // if the items are already in the DOM, grab them and skip item initialization
479
+ if ($items.length) {
480
+ this._items = $items.get().map(function(item) {
481
+ return $(item);
482
+ });
483
+
484
+ this._mergers = this._items.map(function() {
485
+ return 1;
486
+ });
487
+
488
+ this.refresh();
489
+
490
+ return;
491
+ }
492
+
493
+ // append content
494
+ this.replace(this.$element.children().not(this.$stage.parent()));
495
+
496
+ // check visibility
497
+ if (this.isVisible()) {
498
+ // update view
499
+ this.refresh();
500
+ } else {
501
+ // invalidate width
502
+ this.invalidate('width');
503
+ }
504
+
505
+ this.$element
506
+ .removeClass(this.options.loadingClass)
507
+ .addClass(this.options.loadedClass);
508
+ };
509
+
510
+ /**
511
+ * Initializes the carousel.
512
+ * @protected
513
+ */
514
+ Owl.prototype.initialize = function() {
515
+ this.enter('initializing');
516
+ this.trigger('initialize');
517
+
518
+ this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl);
519
+
520
+ if (this.settings.autoWidth && !this.is('pre-loading')) {
521
+ var imgs, nestedSelector, width;
522
+ imgs = this.$element.find('img');
523
+ nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined;
524
+ width = this.$element.children(nestedSelector).width();
525
+
526
+ if (imgs.length && width <= 0) {
527
+ this.preloadAutoWidthImages(imgs);
528
+ }
529
+ }
530
+
531
+ this.initializeStage();
532
+ this.initializeItems();
533
+
534
+ // register event handlers
535
+ this.registerEventHandlers();
536
+
537
+ this.leave('initializing');
538
+ this.trigger('initialized');
539
+ };
540
+
541
+ /**
542
+ * @returns {Boolean} visibility of $element
543
+ * if you know the carousel will always be visible you can set `checkVisibility` to `false` to
544
+ * prevent the expensive browser layout forced reflow the $element.is(':visible') does
545
+ */
546
+ Owl.prototype.isVisible = function() {
547
+ return this.settings.checkVisibility
548
+ ? this.$element.is(':visible')
549
+ : true;
550
+ };
551
+
552
+ /**
553
+ * Setups the current settings.
554
+ * @todo Remove responsive classes. Why should adaptive designs be brought into IE8?
555
+ * @todo Support for media queries by using `matchMedia` would be nice.
556
+ * @public
557
+ */
558
+ Owl.prototype.setup = function() {
559
+ var viewport = this.viewport(),
560
+ overwrites = this.options.responsive,
561
+ match = -1,
562
+ settings = null;
563
+
564
+ if (!overwrites) {
565
+ settings = $.extend({}, this.options);
566
+ } else {
567
+ $.each(overwrites, function(breakpoint) {
568
+ if (breakpoint <= viewport && breakpoint > match) {
569
+ match = Number(breakpoint);
570
+ }
571
+ });
572
+
573
+ settings = $.extend({}, this.options, overwrites[match]);
574
+ if (typeof settings.stagePadding === 'function') {
575
+ settings.stagePadding = settings.stagePadding();
576
+ }
577
+ delete settings.responsive;
578
+
579
+ // responsive class
580
+ if (settings.responsiveClass) {
581
+ this.$element.attr('class',
582
+ this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match)
583
+ );
584
+ }
585
+ }
586
+
587
+ this.trigger('change', { property: { name: 'settings', value: settings } });
588
+ this._breakpoint = match;
589
+ this.settings = settings;
590
+ this.invalidate('settings');
591
+ this.trigger('changed', { property: { name: 'settings', value: this.settings } });
592
+ };
593
+
594
+ /**
595
+ * Updates option logic if necessery.
596
+ * @protected
597
+ */
598
+ Owl.prototype.optionsLogic = function() {
599
+ if (this.settings.autoWidth) {
600
+ this.settings.stagePadding = false;
601
+ this.settings.merge = false;
602
+ }
603
+ };
604
+
605
+ /**
606
+ * Prepares an item before add.
607
+ * @todo Rename event parameter `content` to `item`.
608
+ * @protected
609
+ * @returns {jQuery|HTMLElement} - The item container.
610
+ */
611
+ Owl.prototype.prepare = function(item) {
612
+ var event = this.trigger('prepare', { content: item });
613
+
614
+ if (!event.data) {
615
+ event.data = $('<' + this.settings.itemElement + '/>')
616
+ .addClass(this.options.itemClass).append(item)
617
+ }
618
+
619
+ this.trigger('prepared', { content: event.data });
620
+
621
+ return event.data;
622
+ };
623
+
624
+ /**
625
+ * Updates the view.
626
+ * @public
627
+ */
628
+ Owl.prototype.update = function() {
629
+ var i = 0,
630
+ n = this._pipe.length,
631
+ filter = $.proxy(function(p) { return this[p] }, this._invalidated),
632
+ cache = {};
633
+
634
+ while (i < n) {
635
+ if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) {
636
+ this._pipe[i].run(cache);
637
+ }
638
+ i++;
639
+ }
640
+
641
+ this._invalidated = {};
642
+
643
+ !this.is('valid') && this.enter('valid');
644
+ };
645
+
646
+ /**
647
+ * Gets the width of the view.
648
+ * @public
649
+ * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return.
650
+ * @returns {Number} - The width of the view in pixel.
651
+ */
652
+ Owl.prototype.width = function(dimension) {
653
+ dimension = dimension || Owl.Width.Default;
654
+ switch (dimension) {
655
+ case Owl.Width.Inner:
656
+ case Owl.Width.Outer:
657
+ return this._width;
658
+ default:
659
+ return this._width - this.settings.stagePadding * 2 + this.settings.margin;
660
+ }
661
+ };
662
+
663
+ /**
664
+ * Refreshes the carousel primarily for adaptive purposes.
665
+ * @public
666
+ */
667
+ Owl.prototype.refresh = function() {
668
+ this.enter('refreshing');
669
+ this.trigger('refresh');
670
+
671
+ this.setup();
672
+
673
+ this.optionsLogic();
674
+
675
+ this.$element.addClass(this.options.refreshClass);
676
+
677
+ this.update();
678
+
679
+ this.$element.removeClass(this.options.refreshClass);
680
+
681
+ this.leave('refreshing');
682
+ this.trigger('refreshed');
683
+ };
684
+
685
+ /**
686
+ * Checks window `resize` event.
687
+ * @protected
688
+ */
689
+ Owl.prototype.onThrottledResize = function() {
690
+ window.clearTimeout(this.resizeTimer);
691
+ this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate);
692
+ };
693
+
694
+ /**
695
+ * Checks window `resize` event.
696
+ * @protected
697
+ */
698
+ Owl.prototype.onResize = function() {
699
+ if (!this._items.length) {
700
+ return false;
701
+ }
702
+
703
+ if (this._width === this.$element.width()) {
704
+ return false;
705
+ }
706
+
707
+ if (!this.isVisible()) {
708
+ return false;
709
+ }
710
+
711
+ this.enter('resizing');
712
+
713
+ if (this.trigger('resize').isDefaultPrevented()) {
714
+ this.leave('resizing');
715
+ return false;
716
+ }
717
+
718
+ this.invalidate('width');
719
+
720
+ this.refresh();
721
+
722
+ this.leave('resizing');
723
+ this.trigger('resized');
724
+ };
725
+
726
+ /**
727
+ * Registers event handlers.
728
+ * @todo Check `msPointerEnabled`
729
+ * @todo #261
730
+ * @protected
731
+ */
732
+ Owl.prototype.registerEventHandlers = function() {
733
+ if ($.support.transition) {
734
+ this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this));
735
+ }
736
+
737
+ if (this.settings.responsive !== false) {
738
+ this.on(window, 'resize', this._handlers.onThrottledResize);
739
+ }
740
+
741
+ if (this.settings.mouseDrag) {
742
+ this.$element.addClass(this.options.dragClass);
743
+ this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this));
744
+ this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false });
745
+ }
746
+
747
+ if (this.settings.touchDrag){
748
+ this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this));
749
+ this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this));
750
+ }
751
+ };
752
+
753
+ /**
754
+ * Handles `touchstart` and `mousedown` events.
755
+ * @todo Horizontal swipe threshold as option
756
+ * @todo #261
757
+ * @protected
758
+ * @param {Event} event - The event arguments.
759
+ */
760
+ Owl.prototype.onDragStart = function(event) {
761
+ var stage = null;
762
+
763
+ if (event.which === 3) {
764
+ return;
765
+ }
766
+
767
+ if ($.support.transform) {
768
+ stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(',');
769
+ stage = {
770
+ x: stage[stage.length === 16 ? 12 : 4],
771
+ y: stage[stage.length === 16 ? 13 : 5]
772
+ };
773
+ } else {
774
+ stage = this.$stage.position();
775
+ stage = {
776
+ x: this.settings.rtl ?
777
+ stage.left + this.$stage.width() - this.width() + this.settings.margin :
778
+ stage.left,
779
+ y: stage.top
780
+ };
781
+ }
782
+
783
+ if (this.is('animating')) {
784
+ $.support.transform ? this.animate(stage.x) : this.$stage.stop()
785
+ this.invalidate('position');
786
+ }
787
+
788
+ this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown');
789
+
790
+ this.speed(0);
791
+
792
+ this._drag.time = new Date().getTime();
793
+ this._drag.target = $(event.target);
794
+ this._drag.stage.start = stage;
795
+ this._drag.stage.current = stage;
796
+ this._drag.pointer = this.pointer(event);
797
+
798
+ $(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this));
799
+
800
+ $(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) {
801
+ var delta = this.difference(this._drag.pointer, this.pointer(event));
802
+
803
+ $(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this));
804
+
805
+ if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) {
806
+ return;
807
+ }
808
+
809
+ event.preventDefault();
810
+
811
+ this.enter('dragging');
812
+ this.trigger('drag');
813
+ }, this));
814
+ };
815
+
816
+ /**
817
+ * Handles the `touchmove` and `mousemove` events.
818
+ * @todo #261
819
+ * @protected
820
+ * @param {Event} event - The event arguments.
821
+ */
822
+ Owl.prototype.onDragMove = function(event) {
823
+ var minimum = null,
824
+ maximum = null,
825
+ pull = null,
826
+ delta = this.difference(this._drag.pointer, this.pointer(event)),
827
+ stage = this.difference(this._drag.stage.start, delta);
828
+
829
+ if (!this.is('dragging')) {
830
+ return;
831
+ }
832
+
833
+ event.preventDefault();
834
+
835
+ if (this.settings.loop) {
836
+ minimum = this.coordinates(this.minimum());
837
+ maximum = this.coordinates(this.maximum() + 1) - minimum;
838
+ stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum;
839
+ } else {
840
+ minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum());
841
+ maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum());
842
+ pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0;
843
+ stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull);
844
+ }
845
+
846
+ this._drag.stage.current = stage;
847
+
848
+ this.animate(stage.x);
849
+ };
850
+
851
+ /**
852
+ * Handles the `touchend` and `mouseup` events.
853
+ * @todo #261
854
+ * @todo Threshold for click event
855
+ * @protected
856
+ * @param {Event} event - The event arguments.
857
+ */
858
+ Owl.prototype.onDragEnd = function(event) {
859
+ var delta = this.difference(this._drag.pointer, this.pointer(event)),
860
+ stage = this._drag.stage.current,
861
+ direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right';
862
+
863
+ $(document).off('.owl.core');
864
+
865
+ this.$element.removeClass(this.options.grabClass);
866
+
867
+ if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) {
868
+ this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed);
869
+ this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction));
870
+ this.invalidate('position');
871
+ this.update();
872
+
873
+ this._drag.direction = direction;
874
+
875
+ if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) {
876
+ this._drag.target.one('click.owl.core', function() { return false; });
877
+ }
878
+ }
879
+
880
+ if (!this.is('dragging')) {
881
+ return;
882
+ }
883
+
884
+ this.leave('dragging');
885
+ this.trigger('dragged');
886
+ };
887
+
888
+ /**
889
+ * Gets absolute position of the closest item for a coordinate.
890
+ * @todo Setting `freeDrag` makes `closest` not reusable. See #165.
891
+ * @protected
892
+ * @param {Number} coordinate - The coordinate in pixel.
893
+ * @param {String} direction - The direction to check for the closest item. Ether `left` or `right`.
894
+ * @return {Number} - The absolute position of the closest item.
895
+ */
896
+ Owl.prototype.closest = function(coordinate, direction) {
897
+ var position = -1,
898
+ pull = 30,
899
+ width = this.width(),
900
+ coordinates = this.coordinates();
901
+
902
+ if (!this.settings.freeDrag) {
903
+ // check closest item
904
+ $.each(coordinates, $.proxy(function(index, value) {
905
+ // on a left pull, check on current index
906
+ if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) {
907
+ position = index;
908
+ // on a right pull, check on previous index
909
+ // to do so, subtract width from value and set position = index + 1
910
+ } else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) {
911
+ position = index + 1;
912
+ } else if (this.op(coordinate, '<', value)
913
+ && this.op(coordinate, '>', coordinates[index + 1] !== undefined ? coordinates[index + 1] : value - width)) {
914
+ position = direction === 'left' ? index + 1 : index;
915
+ }
916
+ return position === -1;
917
+ }, this));
918
+ }
919
+
920
+ if (!this.settings.loop) {
921
+ // non loop boundries
922
+ if (this.op(coordinate, '>', coordinates[this.minimum()])) {
923
+ position = coordinate = this.minimum();
924
+ } else if (this.op(coordinate, '<', coordinates[this.maximum()])) {
925
+ position = coordinate = this.maximum();
926
+ }
927
+ }
928
+
929
+ return position;
930
+ };
931
+
932
+ /**
933
+ * Animates the stage.
934
+ * @todo #270
935
+ * @public
936
+ * @param {Number} coordinate - The coordinate in pixels.
937
+ */
938
+ Owl.prototype.animate = function(coordinate) {
939
+ var animate = this.speed() > 0;
940
+
941
+ this.is('animating') && this.onTransitionEnd();
942
+
943
+ if (animate) {
944
+ this.enter('animating');
945
+ this.trigger('translate');
946
+ }
947
+
948
+ if ($.support.transform3d && $.support.transition) {
949
+ this.$stage.css({
950
+ transform: 'translate3d(' + coordinate + 'px,0px,0px)',
951
+ transition: (this.speed() / 1000) + 's' + (
952
+ this.settings.slideTransition ? ' ' + this.settings.slideTransition : ''
953
+ )
954
+ });
955
+ } else if (animate) {
956
+ this.$stage.animate({
957
+ left: coordinate + 'px'
958
+ }, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this));
959
+ } else {
960
+ this.$stage.css({
961
+ left: coordinate + 'px'
962
+ });
963
+ }
964
+ };
965
+
966
+ /**
967
+ * Checks whether the carousel is in a specific state or not.
968
+ * @param {String} state - The state to check.
969
+ * @returns {Boolean} - The flag which indicates if the carousel is busy.
970
+ */
971
+ Owl.prototype.is = function(state) {
972
+ return this._states.current[state] && this._states.current[state] > 0;
973
+ };
974
+
975
+ /**
976
+ * Sets the absolute position of the current item.
977
+ * @public
978
+ * @param {Number} [position] - The new absolute position or nothing to leave it unchanged.
979
+ * @returns {Number} - The absolute position of the current item.
980
+ */
981
+ Owl.prototype.current = function(position) {
982
+ if (position === undefined) {
983
+ return this._current;
984
+ }
985
+
986
+ if (this._items.length === 0) {
987
+ return undefined;
988
+ }
989
+
990
+ position = this.normalize(position);
991
+
992
+ if (this._current !== position) {
993
+ var event = this.trigger('change', { property: { name: 'position', value: position } });
994
+
995
+ if (event.data !== undefined) {
996
+ position = this.normalize(event.data);
997
+ }
998
+
999
+ this._current = position;
1000
+
1001
+ this.invalidate('position');
1002
+
1003
+ this.trigger('changed', { property: { name: 'position', value: this._current } });
1004
+ }
1005
+
1006
+ return this._current;
1007
+ };
1008
+
1009
+ /**
1010
+ * Invalidates the given part of the update routine.
1011
+ * @param {String} [part] - The part to invalidate.
1012
+ * @returns {Array.<String>} - The invalidated parts.
1013
+ */
1014
+ Owl.prototype.invalidate = function(part) {
1015
+ if ($.type(part) === 'string') {
1016
+ this._invalidated[part] = true;
1017
+ this.is('valid') && this.leave('valid');
1018
+ }
1019
+ return $.map(this._invalidated, function(v, i) { return i });
1020
+ };
1021
+
1022
+ /**
1023
+ * Resets the absolute position of the current item.
1024
+ * @public
1025
+ * @param {Number} position - The absolute position of the new item.
1026
+ */
1027
+ Owl.prototype.reset = function(position) {
1028
+ position = this.normalize(position);
1029
+
1030
+ if (position === undefined) {
1031
+ return;
1032
+ }
1033
+
1034
+ this._speed = 0;
1035
+ this._current = position;
1036
+
1037
+ this.suppress([ 'translate', 'translated' ]);
1038
+
1039
+ this.animate(this.coordinates(position));
1040
+
1041
+ this.release([ 'translate', 'translated' ]);
1042
+ };
1043
+
1044
+ /**
1045
+ * Normalizes an absolute or a relative position of an item.
1046
+ * @public
1047
+ * @param {Number} position - The absolute or relative position to normalize.
1048
+ * @param {Boolean} [relative=false] - Whether the given position is relative or not.
1049
+ * @returns {Number} - The normalized position.
1050
+ */
1051
+ Owl.prototype.normalize = function(position, relative) {
1052
+ var n = this._items.length,
1053
+ m = relative ? 0 : this._clones.length;
1054
+
1055
+ if (!this.isNumeric(position) || n < 1) {
1056
+ position = undefined;
1057
+ } else if (position < 0 || position >= n + m) {
1058
+ position = ((position - m / 2) % n + n) % n + m / 2;
1059
+ }
1060
+
1061
+ return position;
1062
+ };
1063
+
1064
+ /**
1065
+ * Converts an absolute position of an item into a relative one.
1066
+ * @public
1067
+ * @param {Number} position - The absolute position to convert.
1068
+ * @returns {Number} - The converted position.
1069
+ */
1070
+ Owl.prototype.relative = function(position) {
1071
+ position -= this._clones.length / 2;
1072
+ return this.normalize(position, true);
1073
+ };
1074
+
1075
+ /**
1076
+ * Gets the maximum position for the current item.
1077
+ * @public
1078
+ * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1079
+ * @returns {Number}
1080
+ */
1081
+ Owl.prototype.maximum = function(relative) {
1082
+ var settings = this.settings,
1083
+ maximum = this._coordinates.length,
1084
+ iterator,
1085
+ reciprocalItemsWidth,
1086
+ elementWidth;
1087
+
1088
+ if (settings.loop) {
1089
+ maximum = this._clones.length / 2 + this._items.length - 1;
1090
+ } else if (settings.autoWidth || settings.merge) {
1091
+ iterator = this._items.length;
1092
+ if (iterator) {
1093
+ reciprocalItemsWidth = this._items[--iterator].width();
1094
+ elementWidth = this.$element.width();
1095
+ while (iterator--) {
1096
+ reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin;
1097
+ if (reciprocalItemsWidth > elementWidth) {
1098
+ break;
1099
+ }
1100
+ }
1101
+ }
1102
+ maximum = iterator + 1;
1103
+ } else if (settings.center) {
1104
+ maximum = this._items.length - 1;
1105
+ } else {
1106
+ maximum = this._items.length - settings.items;
1107
+ }
1108
+
1109
+ if (relative) {
1110
+ maximum -= this._clones.length / 2;
1111
+ }
1112
+
1113
+ return Math.max(maximum, 0);
1114
+ };
1115
+
1116
+ /**
1117
+ * Gets the minimum position for the current item.
1118
+ * @public
1119
+ * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1120
+ * @returns {Number}
1121
+ */
1122
+ Owl.prototype.minimum = function(relative) {
1123
+ return relative ? 0 : this._clones.length / 2;
1124
+ };
1125
+
1126
+ /**
1127
+ * Gets an item at the specified relative position.
1128
+ * @public
1129
+ * @param {Number} [position] - The relative position of the item.
1130
+ * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1131
+ */
1132
+ Owl.prototype.items = function(position) {
1133
+ if (position === undefined) {
1134
+ return this._items.slice();
1135
+ }
1136
+
1137
+ position = this.normalize(position, true);
1138
+ return this._items[position];
1139
+ };
1140
+
1141
+ /**
1142
+ * Gets an item at the specified relative position.
1143
+ * @public
1144
+ * @param {Number} [position] - The relative position of the item.
1145
+ * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1146
+ */
1147
+ Owl.prototype.mergers = function(position) {
1148
+ if (position === undefined) {
1149
+ return this._mergers.slice();
1150
+ }
1151
+
1152
+ position = this.normalize(position, true);
1153
+ return this._mergers[position];
1154
+ };
1155
+
1156
+ /**
1157
+ * Gets the absolute positions of clones for an item.
1158
+ * @public
1159
+ * @param {Number} [position] - The relative position of the item.
1160
+ * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given.
1161
+ */
1162
+ Owl.prototype.clones = function(position) {
1163
+ var odd = this._clones.length / 2,
1164
+ even = odd + this._items.length,
1165
+ map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 };
1166
+
1167
+ if (position === undefined) {
1168
+ return $.map(this._clones, function(v, i) { return map(i) });
1169
+ }
1170
+
1171
+ return $.map(this._clones, function(v, i) { return v === position ? map(i) : null });
1172
+ };
1173
+
1174
+ /**
1175
+ * Sets the current animation speed.
1176
+ * @public
1177
+ * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged.
1178
+ * @returns {Number} - The current animation speed in milliseconds.
1179
+ */
1180
+ Owl.prototype.speed = function(speed) {
1181
+ if (speed !== undefined) {
1182
+ this._speed = speed;
1183
+ }
1184
+
1185
+ return this._speed;
1186
+ };
1187
+
1188
+ /**
1189
+ * Gets the coordinate of an item.
1190
+ * @todo The name of this method is missleanding.
1191
+ * @public
1192
+ * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`.
1193
+ * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates.
1194
+ */
1195
+ Owl.prototype.coordinates = function(position) {
1196
+ var multiplier = 1,
1197
+ newPosition = position - 1,
1198
+ coordinate;
1199
+
1200
+ if (position === undefined) {
1201
+ return $.map(this._coordinates, $.proxy(function(coordinate, index) {
1202
+ return this.coordinates(index);
1203
+ }, this));
1204
+ }
1205
+
1206
+ if (this.settings.center) {
1207
+ if (this.settings.rtl) {
1208
+ multiplier = -1;
1209
+ newPosition = position + 1;
1210
+ }
1211
+
1212
+ coordinate = this._coordinates[position];
1213
+ coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier;
1214
+ } else {
1215
+ coordinate = this._coordinates[newPosition] || 0;
1216
+ }
1217
+
1218
+ coordinate = Math.ceil(coordinate);
1219
+
1220
+ return coordinate;
1221
+ };
1222
+
1223
+ /**
1224
+ * Calculates the speed for a translation.
1225
+ * @protected
1226
+ * @param {Number} from - The absolute position of the start item.
1227
+ * @param {Number} to - The absolute position of the target item.
1228
+ * @param {Number} [factor=undefined] - The time factor in milliseconds.
1229
+ * @returns {Number} - The time in milliseconds for the translation.
1230
+ */
1231
+ Owl.prototype.duration = function(from, to, factor) {
1232
+ if (factor === 0) {
1233
+ return 0;
1234
+ }
1235
+
1236
+ return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed));
1237
+ };
1238
+
1239
+ /**
1240
+ * Slides to the specified item.
1241
+ * @public
1242
+ * @param {Number} position - The position of the item.
1243
+ * @param {Number} [speed] - The time in milliseconds for the transition.
1244
+ */
1245
+ Owl.prototype.to = function(position, speed) {
1246
+ var current = this.current(),
1247
+ revert = null,
1248
+ distance = position - this.relative(current),
1249
+ direction = (distance > 0) - (distance < 0),
1250
+ items = this._items.length,
1251
+ minimum = this.minimum(),
1252
+ maximum = this.maximum();
1253
+
1254
+ if (this.settings.loop) {
1255
+ if (!this.settings.rewind && Math.abs(distance) > items / 2) {
1256
+ distance += direction * -1 * items;
1257
+ }
1258
+
1259
+ position = current + distance;
1260
+ revert = ((position - minimum) % items + items) % items + minimum;
1261
+
1262
+ if (revert !== position && revert - distance <= maximum && revert - distance > 0) {
1263
+ current = revert - distance;
1264
+ position = revert;
1265
+ this.reset(current);
1266
+ }
1267
+ } else if (this.settings.rewind) {
1268
+ maximum += 1;
1269
+ position = (position % maximum + maximum) % maximum;
1270
+ } else {
1271
+ position = Math.max(minimum, Math.min(maximum, position));
1272
+ }
1273
+
1274
+ this.speed(this.duration(current, position, speed));
1275
+ this.current(position);
1276
+
1277
+ if (this.isVisible()) {
1278
+ this.update();
1279
+ }
1280
+ };
1281
+
1282
+ /**
1283
+ * Slides to the next item.
1284
+ * @public
1285
+ * @param {Number} [speed] - The time in milliseconds for the transition.
1286
+ */
1287
+ Owl.prototype.next = function(speed) {
1288
+ speed = speed || false;
1289
+ this.to(this.relative(this.current()) + 1, speed);
1290
+ };
1291
+
1292
+ /**
1293
+ * Slides to the previous item.
1294
+ * @public
1295
+ * @param {Number} [speed] - The time in milliseconds for the transition.
1296
+ */
1297
+ Owl.prototype.prev = function(speed) {
1298
+ speed = speed || false;
1299
+ this.to(this.relative(this.current()) - 1, speed);
1300
+ };
1301
+
1302
+ /**
1303
+ * Handles the end of an animation.
1304
+ * @protected
1305
+ * @param {Event} event - The event arguments.
1306
+ */
1307
+ Owl.prototype.onTransitionEnd = function(event) {
1308
+
1309
+ // if css2 animation then event object is undefined
1310
+ if (event !== undefined) {
1311
+ event.stopPropagation();
1312
+
1313
+ // Catch only owl-stage transitionEnd event
1314
+ if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) {
1315
+ return false;
1316
+ }
1317
+ }
1318
+
1319
+ this.leave('animating');
1320
+ this.trigger('translated');
1321
+ };
1322
+
1323
+ /**
1324
+ * Gets viewport width.
1325
+ * @protected
1326
+ * @return {Number} - The width in pixel.
1327
+ */
1328
+ Owl.prototype.viewport = function() {
1329
+ var width;
1330
+ if (this.options.responsiveBaseElement !== window) {
1331
+ width = $(this.options.responsiveBaseElement).width();
1332
+ } else if (window.innerWidth) {
1333
+ width = window.innerWidth;
1334
+ } else if (document.documentElement && document.documentElement.clientWidth) {
1335
+ width = document.documentElement.clientWidth;
1336
+ } else {
1337
+ console.warn('Can not detect viewport width.');
1338
+ }
1339
+ return width;
1340
+ };
1341
+
1342
+ /**
1343
+ * Replaces the current content.
1344
+ * @public
1345
+ * @param {HTMLElement|jQuery|String} content - The new content.
1346
+ */
1347
+ Owl.prototype.replace = function(content) {
1348
+ this.$stage.empty();
1349
+ this._items = [];
1350
+
1351
+ if (content) {
1352
+ content = (content instanceof jQuery) ? content : $(content);
1353
+ }
1354
+
1355
+ if (this.settings.nestedItemSelector) {
1356
+ content = content.find('.' + this.settings.nestedItemSelector);
1357
+ }
1358
+
1359
+ content.filter(function() {
1360
+ return this.nodeType === 1;
1361
+ }).each($.proxy(function(index, item) {
1362
+ item = this.prepare(item);
1363
+ this.$stage.append(item);
1364
+ this._items.push(item);
1365
+ this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1366
+ }, this));
1367
+
1368
+ this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0);
1369
+
1370
+ this.invalidate('items');
1371
+ };
1372
+
1373
+ /**
1374
+ * Adds an item.
1375
+ * @todo Use `item` instead of `content` for the event arguments.
1376
+ * @public
1377
+ * @param {HTMLElement|jQuery|String} content - The item content to add.
1378
+ * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end.
1379
+ */
1380
+ Owl.prototype.add = function(content, position) {
1381
+ var current = this.relative(this._current);
1382
+
1383
+ position = position === undefined ? this._items.length : this.normalize(position, true);
1384
+ content = content instanceof jQuery ? content : $(content);
1385
+
1386
+ this.trigger('add', { content: content, position: position });
1387
+
1388
+ content = this.prepare(content);
1389
+
1390
+ if (this._items.length === 0 || position === this._items.length) {
1391
+ this._items.length === 0 && this.$stage.append(content);
1392
+ this._items.length !== 0 && this._items[position - 1].after(content);
1393
+ this._items.push(content);
1394
+ this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1395
+ } else {
1396
+ this._items[position].before(content);
1397
+ this._items.splice(position, 0, content);
1398
+ this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1399
+ }
1400
+
1401
+ this._items[current] && this.reset(this._items[current].index());
1402
+
1403
+ this.invalidate('items');
1404
+
1405
+ this.trigger('added', { content: content, position: position });
1406
+ };
1407
+
1408
+ /**
1409
+ * Removes an item by its position.
1410
+ * @todo Use `item` instead of `content` for the event arguments.
1411
+ * @public
1412
+ * @param {Number} position - The relative position of the item to remove.
1413
+ */
1414
+ Owl.prototype.remove = function(position) {
1415
+ position = this.normalize(position, true);
1416
+
1417
+ if (position === undefined) {
1418
+ return;
1419
+ }
1420
+
1421
+ this.trigger('remove', { content: this._items[position], position: position });
1422
+
1423
+ this._items[position].remove();
1424
+ this._items.splice(position, 1);
1425
+ this._mergers.splice(position, 1);
1426
+
1427
+ this.invalidate('items');
1428
+
1429
+ this.trigger('removed', { content: null, position: position });
1430
+ };
1431
+
1432
+ /**
1433
+ * Preloads images with auto width.
1434
+ * @todo Replace by a more generic approach
1435
+ * @protected
1436
+ */
1437
+ Owl.prototype.preloadAutoWidthImages = function(images) {
1438
+ images.each($.proxy(function(i, element) {
1439
+ this.enter('pre-loading');
1440
+ element = $(element);
1441
+ $(new Image()).one('load', $.proxy(function(e) {
1442
+ element.attr('src', e.target.src);
1443
+ element.css('opacity', 1);
1444
+ this.leave('pre-loading');
1445
+ !this.is('pre-loading') && !this.is('initializing') && this.refresh();
1446
+ }, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina'));
1447
+ }, this));
1448
+ };
1449
+
1450
+ /**
1451
+ * Destroys the carousel.
1452
+ * @public
1453
+ */
1454
+ Owl.prototype.destroy = function() {
1455
+
1456
+ this.$element.off('.owl.core');
1457
+ this.$stage.off('.owl.core');
1458
+ $(document).off('.owl.core');
1459
+
1460
+ if (this.settings.responsive !== false) {
1461
+ window.clearTimeout(this.resizeTimer);
1462
+ this.off(window, 'resize', this._handlers.onThrottledResize);
1463
+ }
1464
+
1465
+ for (var i in this._plugins) {
1466
+ this._plugins[i].destroy();
1467
+ }
1468
+
1469
+ this.$stage.children('.cloned').remove();
1470
+
1471
+ this.$stage.unwrap();
1472
+ this.$stage.children().contents().unwrap();
1473
+ this.$stage.children().unwrap();
1474
+ this.$stage.remove();
1475
+ this.$element
1476
+ .removeClass(this.options.refreshClass)
1477
+ .removeClass(this.options.loadingClass)
1478
+ .removeClass(this.options.loadedClass)
1479
+ .removeClass(this.options.rtlClass)
1480
+ .removeClass(this.options.dragClass)
1481
+ .removeClass(this.options.grabClass)
1482
+ .attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), ''))
1483
+ .removeData('owl.carousel');
1484
+ };
1485
+
1486
+ /**
1487
+ * Operators to calculate right-to-left and left-to-right.
1488
+ * @protected
1489
+ * @param {Number} [a] - The left side operand.
1490
+ * @param {String} [o] - The operator.
1491
+ * @param {Number} [b] - The right side operand.
1492
+ */
1493
+ Owl.prototype.op = function(a, o, b) {
1494
+ var rtl = this.settings.rtl;
1495
+ switch (o) {
1496
+ case '<':
1497
+ return rtl ? a > b : a < b;
1498
+ case '>':
1499
+ return rtl ? a < b : a > b;
1500
+ case '>=':
1501
+ return rtl ? a <= b : a >= b;
1502
+ case '<=':
1503
+ return rtl ? a >= b : a <= b;
1504
+ default:
1505
+ break;
1506
+ }
1507
+ };
1508
+
1509
+ /**
1510
+ * Attaches to an internal event.
1511
+ * @protected
1512
+ * @param {HTMLElement} element - The event source.
1513
+ * @param {String} event - The event name.
1514
+ * @param {Function} listener - The event handler to attach.
1515
+ * @param {Boolean} capture - Wether the event should be handled at the capturing phase or not.
1516
+ */
1517
+ Owl.prototype.on = function(element, event, listener, capture) {
1518
+ if (element.addEventListener) {
1519
+ element.addEventListener(event, listener, capture);
1520
+ } else if (element.attachEvent) {
1521
+ element.attachEvent('on' + event, listener);
1522
+ }
1523
+ };
1524
+
1525
+ /**
1526
+ * Detaches from an internal event.
1527
+ * @protected
1528
+ * @param {HTMLElement} element - The event source.
1529
+ * @param {String} event - The event name.
1530
+ * @param {Function} listener - The attached event handler to detach.
1531
+ * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not.
1532
+ */
1533
+ Owl.prototype.off = function(element, event, listener, capture) {
1534
+ if (element.removeEventListener) {
1535
+ element.removeEventListener(event, listener, capture);
1536
+ } else if (element.detachEvent) {
1537
+ element.detachEvent('on' + event, listener);
1538
+ }
1539
+ };
1540
+
1541
+ /**
1542
+ * Triggers a public event.
1543
+ * @todo Remove `status`, `relatedTarget` should be used instead.
1544
+ * @protected
1545
+ * @param {String} name - The event name.
1546
+ * @param {*} [data=null] - The event data.
1547
+ * @param {String} [namespace=carousel] - The event namespace.
1548
+ * @param {String} [state] - The state which is associated with the event.
1549
+ * @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not.
1550
+ * @returns {Event} - The event arguments.
1551
+ */
1552
+ Owl.prototype.trigger = function(name, data, namespace, state, enter) {
1553
+ var status = {
1554
+ item: { count: this._items.length, index: this.current() }
1555
+ }, handler = $.camelCase(
1556
+ $.grep([ 'on', name, namespace ], function(v) { return v })
1557
+ .join('-').toLowerCase()
1558
+ ), event = $.Event(
1559
+ [ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(),
1560
+ $.extend({ relatedTarget: this }, status, data)
1561
+ );
1562
+
1563
+ if (!this._supress[name]) {
1564
+ $.each(this._plugins, function(name, plugin) {
1565
+ if (plugin.onTrigger) {
1566
+ plugin.onTrigger(event);
1567
+ }
1568
+ });
1569
+
1570
+ this.register({ type: Owl.Type.Event, name: name });
1571
+ this.$element.trigger(event);
1572
+
1573
+ if (this.settings && typeof this.settings[handler] === 'function') {
1574
+ this.settings[handler].call(this, event);
1575
+ }
1576
+ }
1577
+
1578
+ return event;
1579
+ };
1580
+
1581
+ /**
1582
+ * Enters a state.
1583
+ * @param name - The state name.
1584
+ */
1585
+ Owl.prototype.enter = function(name) {
1586
+ $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
1587
+ if (this._states.current[name] === undefined) {
1588
+ this._states.current[name] = 0;
1589
+ }
1590
+
1591
+ this._states.current[name]++;
1592
+ }, this));
1593
+ };
1594
+
1595
+ /**
1596
+ * Leaves a state.
1597
+ * @param name - The state name.
1598
+ */
1599
+ Owl.prototype.leave = function(name) {
1600
+ $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
1601
+ this._states.current[name]--;
1602
+ }, this));
1603
+ };
1604
+
1605
+ /**
1606
+ * Registers an event or state.
1607
+ * @public
1608
+ * @param {Object} object - The event or state to register.
1609
+ */
1610
+ Owl.prototype.register = function(object) {
1611
+ if (object.type === Owl.Type.Event) {
1612
+ if (!$.event.special[object.name]) {
1613
+ $.event.special[object.name] = {};
1614
+ }
1615
+
1616
+ if (!$.event.special[object.name].owl) {
1617
+ var _default = $.event.special[object.name]._default;
1618
+ $.event.special[object.name]._default = function(e) {
1619
+ if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) {
1620
+ return _default.apply(this, arguments);
1621
+ }
1622
+ return e.namespace && e.namespace.indexOf('owl') > -1;
1623
+ };
1624
+ $.event.special[object.name].owl = true;
1625
+ }
1626
+ } else if (object.type === Owl.Type.State) {
1627
+ if (!this._states.tags[object.name]) {
1628
+ this._states.tags[object.name] = object.tags;
1629
+ } else {
1630
+ this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags);
1631
+ }
1632
+
1633
+ this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) {
1634
+ return $.inArray(tag, this._states.tags[object.name]) === i;
1635
+ }, this));
1636
+ }
1637
+ };
1638
+
1639
+ /**
1640
+ * Suppresses events.
1641
+ * @protected
1642
+ * @param {Array.<String>} events - The events to suppress.
1643
+ */
1644
+ Owl.prototype.suppress = function(events) {
1645
+ $.each(events, $.proxy(function(index, event) {
1646
+ this._supress[event] = true;
1647
+ }, this));
1648
+ };
1649
+
1650
+ /**
1651
+ * Releases suppressed events.
1652
+ * @protected
1653
+ * @param {Array.<String>} events - The events to release.
1654
+ */
1655
+ Owl.prototype.release = function(events) {
1656
+ $.each(events, $.proxy(function(index, event) {
1657
+ delete this._supress[event];
1658
+ }, this));
1659
+ };
1660
+
1661
+ /**
1662
+ * Gets unified pointer coordinates from event.
1663
+ * @todo #261
1664
+ * @protected
1665
+ * @param {Event} - The `mousedown` or `touchstart` event.
1666
+ * @returns {Object} - Contains `x` and `y` coordinates of current pointer position.
1667
+ */
1668
+ Owl.prototype.pointer = function(event) {
1669
+ var result = { x: null, y: null };
1670
+
1671
+ event = event.originalEvent || event || window.event;
1672
+
1673
+ event = event.touches && event.touches.length ?
1674
+ event.touches[0] : event.changedTouches && event.changedTouches.length ?
1675
+ event.changedTouches[0] : event;
1676
+
1677
+ if (event.pageX) {
1678
+ result.x = event.pageX;
1679
+ result.y = event.pageY;
1680
+ } else {
1681
+ result.x = event.clientX;
1682
+ result.y = event.clientY;
1683
+ }
1684
+
1685
+ return result;
1686
+ };
1687
+
1688
+ /**
1689
+ * Determines if the input is a Number or something that can be coerced to a Number
1690
+ * @protected
1691
+ * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested
1692
+ * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number
1693
+ */
1694
+ Owl.prototype.isNumeric = function(number) {
1695
+ return !isNaN(parseFloat(number));
1696
+ };
1697
+
1698
+ /**
1699
+ * Gets the difference of two vectors.
1700
+ * @todo #261
1701
+ * @protected
1702
+ * @param {Object} - The first vector.
1703
+ * @param {Object} - The second vector.
1704
+ * @returns {Object} - The difference.
1705
+ */
1706
+ Owl.prototype.difference = function(first, second) {
1707
+ return {
1708
+ x: first.x - second.x,
1709
+ y: first.y - second.y
1710
+ };
1711
+ };
1712
+
1713
+ /**
1714
+ * The jQuery Plugin for the Owl Carousel
1715
+ * @todo Navigation plugin `next` and `prev`
1716
+ * @public
1717
+ */
1718
+ $.fn.owlCarousel = function(option) {
1719
+ var args = Array.prototype.slice.call(arguments, 1);
1720
+
1721
+ return this.each(function() {
1722
+ var $this = $(this),
1723
+ data = $this.data('owl.carousel');
1724
+
1725
+ if (!data) {
1726
+ data = new Owl(this, typeof option == 'object' && option);
1727
+ $this.data('owl.carousel', data);
1728
+
1729
+ $.each([
1730
+ 'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove'
1731
+ ], function(i, event) {
1732
+ data.register({ type: Owl.Type.Event, name: event });
1733
+ data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) {
1734
+ if (e.namespace && e.relatedTarget !== this) {
1735
+ this.suppress([ event ]);
1736
+ data[event].apply(this, [].slice.call(arguments, 1));
1737
+ this.release([ event ]);
1738
+ }
1739
+ }, data));
1740
+ });
1741
+ }
1742
+
1743
+ if (typeof option == 'string' && option.charAt(0) !== '_') {
1744
+ data[option].apply(data, args);
1745
+ }
1746
+ });
1747
+ };
1748
+
1749
+ /**
1750
+ * The constructor for the jQuery Plugin
1751
+ * @public
1752
+ */
1753
+ $.fn.owlCarousel.Constructor = Owl;
1754
+
1755
+ })(window.Zepto || window.jQuery, window, document);
1756
+
1757
+ /**
1758
+ * AutoRefresh Plugin
1759
+ * @version 2.3.4
1760
+ * @author Artus Kolanowski
1761
+ * @author David Deutsch
1762
+ * @license The MIT License (MIT)
1763
+ */
1764
+ ;(function($, window, document, undefined) {
1765
+
1766
+ /**
1767
+ * Creates the auto refresh plugin.
1768
+ * @class The Auto Refresh Plugin
1769
+ * @param {Owl} carousel - The Owl Carousel
1770
+ */
1771
+ var AutoRefresh = function(carousel) {
1772
+ /**
1773
+ * Reference to the core.
1774
+ * @protected
1775
+ * @type {Owl}
1776
+ */
1777
+ this._core = carousel;
1778
+
1779
+ /**
1780
+ * Refresh interval.
1781
+ * @protected
1782
+ * @type {number}
1783
+ */
1784
+ this._interval = null;
1785
+
1786
+ /**
1787
+ * Whether the element is currently visible or not.
1788
+ * @protected
1789
+ * @type {Boolean}
1790
+ */
1791
+ this._visible = null;
1792
+
1793
+ /**
1794
+ * All event handlers.
1795
+ * @protected
1796
+ * @type {Object}
1797
+ */
1798
+ this._handlers = {
1799
+ 'initialized.owl.carousel': $.proxy(function(e) {
1800
+ if (e.namespace && this._core.settings.autoRefresh) {
1801
+ this.watch();
1802
+ }
1803
+ }, this)
1804
+ };
1805
+
1806
+ // set default options
1807
+ this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options);
1808
+
1809
+ // register event handlers
1810
+ this._core.$element.on(this._handlers);
1811
+ };
1812
+
1813
+ /**
1814
+ * Default options.
1815
+ * @public
1816
+ */
1817
+ AutoRefresh.Defaults = {
1818
+ autoRefresh: true,
1819
+ autoRefreshInterval: 500
1820
+ };
1821
+
1822
+ /**
1823
+ * Watches the element.
1824
+ */
1825
+ AutoRefresh.prototype.watch = function() {
1826
+ if (this._interval) {
1827
+ return;
1828
+ }
1829
+
1830
+ this._visible = this._core.isVisible();
1831
+ this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval);
1832
+ };
1833
+
1834
+ /**
1835
+ * Refreshes the element.
1836
+ */
1837
+ AutoRefresh.prototype.refresh = function() {
1838
+ if (this._core.isVisible() === this._visible) {
1839
+ return;
1840
+ }
1841
+
1842
+ this._visible = !this._visible;
1843
+
1844
+ this._core.$element.toggleClass('owl-hidden', !this._visible);
1845
+
1846
+ this._visible && (this._core.invalidate('width') && this._core.refresh());
1847
+ };
1848
+
1849
+ /**
1850
+ * Destroys the plugin.
1851
+ */
1852
+ AutoRefresh.prototype.destroy = function() {
1853
+ var handler, property;
1854
+
1855
+ window.clearInterval(this._interval);
1856
+
1857
+ for (handler in this._handlers) {
1858
+ this._core.$element.off(handler, this._handlers[handler]);
1859
+ }
1860
+ for (property in Object.getOwnPropertyNames(this)) {
1861
+ typeof this[property] != 'function' && (this[property] = null);
1862
+ }
1863
+ };
1864
+
1865
+ $.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh;
1866
+
1867
+ })(window.Zepto || window.jQuery, window, document);
1868
+
1869
+ /**
1870
+ * Lazy Plugin
1871
+ * @version 2.3.4
1872
+ * @author Bartosz Wojciechowski
1873
+ * @author David Deutsch
1874
+ * @license The MIT License (MIT)
1875
+ */
1876
+ ;(function($, window, document, undefined) {
1877
+
1878
+ /**
1879
+ * Creates the lazy plugin.
1880
+ * @class The Lazy Plugin
1881
+ * @param {Owl} carousel - The Owl Carousel
1882
+ */
1883
+ var Lazy = function(carousel) {
1884
+
1885
+ /**
1886
+ * Reference to the core.
1887
+ * @protected
1888
+ * @type {Owl}
1889
+ */
1890
+ this._core = carousel;
1891
+
1892
+ /**
1893
+ * Already loaded items.
1894
+ * @protected
1895
+ * @type {Array.<jQuery>}
1896
+ */
1897
+ this._loaded = [];
1898
+
1899
+ /**
1900
+ * Event handlers.
1901
+ * @protected
1902
+ * @type {Object}
1903
+ */
1904
+ this._handlers = {
1905
+ 'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) {
1906
+ if (!e.namespace) {
1907
+ return;
1908
+ }
1909
+
1910
+ if (!this._core.settings || !this._core.settings.lazyLoad) {
1911
+ return;
1912
+ }
1913
+
1914
+ if ((e.property && e.property.name == 'position') || e.type == 'initialized') {
1915
+ var settings = this._core.settings,
1916
+ n = (settings.center && Math.ceil(settings.items / 2) || settings.items),
1917
+ i = ((settings.center && n * -1) || 0),
1918
+ position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i,
1919
+ clones = this._core.clones().length,
1920
+ load = $.proxy(function(i, v) { this.load(v) }, this);
1921
+ //TODO: Need documentation for this new option
1922
+ if (settings.lazyLoadEager > 0) {
1923
+ n += settings.lazyLoadEager;
1924
+ // If the carousel is looping also preload images that are to the "left"
1925
+ if (settings.loop) {
1926
+ position -= settings.lazyLoadEager;
1927
+ n++;
1928
+ }
1929
+ }
1930
+
1931
+ while (i++ < n) {
1932
+ this.load(clones / 2 + this._core.relative(position));
1933
+ clones && $.each(this._core.clones(this._core.relative(position)), load);
1934
+ position++;
1935
+ }
1936
+ }
1937
+ }, this)
1938
+ };
1939
+
1940
+ // set the default options
1941
+ this._core.options = $.extend({}, Lazy.Defaults, this._core.options);
1942
+
1943
+ // register event handler
1944
+ this._core.$element.on(this._handlers);
1945
+ };
1946
+
1947
+ /**
1948
+ * Default options.
1949
+ * @public
1950
+ */
1951
+ Lazy.Defaults = {
1952
+ lazyLoad: false,
1953
+ lazyLoadEager: 0
1954
+ };
1955
+
1956
+ /**
1957
+ * Loads all resources of an item at the specified position.
1958
+ * @param {Number} position - The absolute position of the item.
1959
+ * @protected
1960
+ */
1961
+ Lazy.prototype.load = function(position) {
1962
+ var $item = this._core.$stage.children().eq(position),
1963
+ $elements = $item && $item.find('.owl-lazy');
1964
+
1965
+ if (!$elements || $.inArray($item.get(0), this._loaded) > -1) {
1966
+ return;
1967
+ }
1968
+
1969
+ $elements.each($.proxy(function(index, element) {
1970
+ var $element = $(element), image,
1971
+ url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src') || $element.attr('data-srcset');
1972
+
1973
+ this._core.trigger('load', { element: $element, url: url }, 'lazy');
1974
+
1975
+ if ($element.is('img')) {
1976
+ $element.one('load.owl.lazy', $.proxy(function() {
1977
+ $element.css('opacity', 1);
1978
+ this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1979
+ }, this)).attr('src', url);
1980
+ } else if ($element.is('source')) {
1981
+ $element.one('load.owl.lazy', $.proxy(function() {
1982
+ this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1983
+ }, this)).attr('srcset', url);
1984
+ } else {
1985
+ image = new Image();
1986
+ image.onload = $.proxy(function() {
1987
+ $element.css({
1988
+ 'background-image': 'url("' + url + '")',
1989
+ 'opacity': '1'
1990
+ });
1991
+ this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1992
+ }, this);
1993
+ image.src = url;
1994
+ }
1995
+ }, this));
1996
+
1997
+ this._loaded.push($item.get(0));
1998
+ };
1999
+
2000
+ /**
2001
+ * Destroys the plugin.
2002
+ * @public
2003
+ */
2004
+ Lazy.prototype.destroy = function() {
2005
+ var handler, property;
2006
+
2007
+ for (handler in this.handlers) {
2008
+ this._core.$element.off(handler, this.handlers[handler]);
2009
+ }
2010
+ for (property in Object.getOwnPropertyNames(this)) {
2011
+ typeof this[property] != 'function' && (this[property] = null);
2012
+ }
2013
+ };
2014
+
2015
+ $.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy;
2016
+
2017
+ })(window.Zepto || window.jQuery, window, document);
2018
+
2019
+ /**
2020
+ * AutoHeight Plugin
2021
+ * @version 2.3.4
2022
+ * @author Bartosz Wojciechowski
2023
+ * @author David Deutsch
2024
+ * @license The MIT License (MIT)
2025
+ */
2026
+ ;(function($, window, document, undefined) {
2027
+
2028
+ /**
2029
+ * Creates the auto height plugin.
2030
+ * @class The Auto Height Plugin
2031
+ * @param {Owl} carousel - The Owl Carousel
2032
+ */
2033
+ var AutoHeight = function(carousel) {
2034
+ /**
2035
+ * Reference to the core.
2036
+ * @protected
2037
+ * @type {Owl}
2038
+ */
2039
+ this._core = carousel;
2040
+
2041
+ this._previousHeight = null;
2042
+
2043
+ /**
2044
+ * All event handlers.
2045
+ * @protected
2046
+ * @type {Object}
2047
+ */
2048
+ this._handlers = {
2049
+ 'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) {
2050
+ if (e.namespace && this._core.settings.autoHeight) {
2051
+ this.update();
2052
+ }
2053
+ }, this),
2054
+ 'changed.owl.carousel': $.proxy(function(e) {
2055
+ if (e.namespace && this._core.settings.autoHeight && e.property.name === 'position'){
2056
+ this.update();
2057
+ }
2058
+ }, this),
2059
+ 'loaded.owl.lazy': $.proxy(function(e) {
2060
+ if (e.namespace && this._core.settings.autoHeight
2061
+ && e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) {
2062
+ this.update();
2063
+ }
2064
+ }, this)
2065
+ };
2066
+
2067
+ // set default options
2068
+ this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options);
2069
+
2070
+ // register event handlers
2071
+ this._core.$element.on(this._handlers);
2072
+ this._intervalId = null;
2073
+ var refThis = this;
2074
+
2075
+ // These changes have been taken from a PR by gavrochelegnou proposed in #1575
2076
+ // and have been made compatible with the latest jQuery version
2077
+ $(window).on('load', function() {
2078
+ if (refThis._core.settings.autoHeight) {
2079
+ refThis.update();
2080
+ }
2081
+ });
2082
+
2083
+ // Autoresize the height of the carousel when window is resized
2084
+ // When carousel has images, the height is dependent on the width
2085
+ // and should also change on resize
2086
+ $(window).resize(function() {
2087
+ if (refThis._core.settings.autoHeight) {
2088
+ if (refThis._intervalId != null) {
2089
+ clearTimeout(refThis._intervalId);
2090
+ }
2091
+
2092
+ refThis._intervalId = setTimeout(function() {
2093
+ refThis.update();
2094
+ }, 250);
2095
+ }
2096
+ });
2097
+
2098
+ };
2099
+
2100
+ /**
2101
+ * Default options.
2102
+ * @public
2103
+ */
2104
+ AutoHeight.Defaults = {
2105
+ autoHeight: false,
2106
+ autoHeightClass: 'owl-height'
2107
+ };
2108
+
2109
+ /**
2110
+ * Updates the view.
2111
+ */
2112
+ AutoHeight.prototype.update = function() {
2113
+ var start = this._core._current,
2114
+ end = start + this._core.settings.items,
2115
+ lazyLoadEnabled = this._core.settings.lazyLoad,
2116
+ visible = this._core.$stage.children().toArray().slice(start, end),
2117
+ heights = [],
2118
+ maxheight = 0;
2119
+
2120
+ $.each(visible, function(index, item) {
2121
+ heights.push($(item).height());
2122
+ });
2123
+
2124
+ maxheight = Math.max.apply(null, heights);
2125
+
2126
+ if (maxheight <= 1 && lazyLoadEnabled && this._previousHeight) {
2127
+ maxheight = this._previousHeight;
2128
+ }
2129
+
2130
+ this._previousHeight = maxheight;
2131
+
2132
+ this._core.$stage.parent()
2133
+ .height(maxheight)
2134
+ .addClass(this._core.settings.autoHeightClass);
2135
+ };
2136
+
2137
+ AutoHeight.prototype.destroy = function() {
2138
+ var handler, property;
2139
+
2140
+ for (handler in this._handlers) {
2141
+ this._core.$element.off(handler, this._handlers[handler]);
2142
+ }
2143
+ for (property in Object.getOwnPropertyNames(this)) {
2144
+ typeof this[property] !== 'function' && (this[property] = null);
2145
+ }
2146
+ };
2147
+
2148
+ $.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight;
2149
+
2150
+ })(window.Zepto || window.jQuery, window, document);
2151
+
2152
+ /**
2153
+ * Video Plugin
2154
+ * @version 2.3.4
2155
+ * @author Bartosz Wojciechowski
2156
+ * @author David Deutsch
2157
+ * @license The MIT License (MIT)
2158
+ */
2159
+ ;(function($, window, document, undefined) {
2160
+
2161
+ /**
2162
+ * Creates the video plugin.
2163
+ * @class The Video Plugin
2164
+ * @param {Owl} carousel - The Owl Carousel
2165
+ */
2166
+ var Video = function(carousel) {
2167
+ /**
2168
+ * Reference to the core.
2169
+ * @protected
2170
+ * @type {Owl}
2171
+ */
2172
+ this._core = carousel;
2173
+
2174
+ /**
2175
+ * Cache all video URLs.
2176
+ * @protected
2177
+ * @type {Object}
2178
+ */
2179
+ this._videos = {};
2180
+
2181
+ /**
2182
+ * Current playing item.
2183
+ * @protected
2184
+ * @type {jQuery}
2185
+ */
2186
+ this._playing = null;
2187
+
2188
+ /**
2189
+ * All event handlers.
2190
+ * @todo The cloned content removale is too late
2191
+ * @protected
2192
+ * @type {Object}
2193
+ */
2194
+ this._handlers = {
2195
+ 'initialized.owl.carousel': $.proxy(function(e) {
2196
+ if (e.namespace) {
2197
+ this._core.register({ type: 'state', name: 'playing', tags: [ 'interacting' ] });
2198
+ }
2199
+ }, this),
2200
+ 'resize.owl.carousel': $.proxy(function(e) {
2201
+ if (e.namespace && this._core.settings.video && this.isInFullScreen()) {
2202
+ e.preventDefault();
2203
+ }
2204
+ }, this),
2205
+ 'refreshed.owl.carousel': $.proxy(function(e) {
2206
+ if (e.namespace && this._core.is('resizing')) {
2207
+ this._core.$stage.find('.cloned .owl-video-frame').remove();
2208
+ }
2209
+ }, this),
2210
+ 'changed.owl.carousel': $.proxy(function(e) {
2211
+ if (e.namespace && e.property.name === 'position' && this._playing) {
2212
+ this.stop();
2213
+ }
2214
+ }, this),
2215
+ 'prepared.owl.carousel': $.proxy(function(e) {
2216
+ if (!e.namespace) {
2217
+ return;
2218
+ }
2219
+
2220
+ var $element = $(e.content).find('.owl-video');
2221
+
2222
+ if ($element.length) {
2223
+ $element.css('display', 'none');
2224
+ this.fetch($element, $(e.content));
2225
+ }
2226
+ }, this)
2227
+ };
2228
+
2229
+ // set default options
2230
+ this._core.options = $.extend({}, Video.Defaults, this._core.options);
2231
+
2232
+ // register event handlers
2233
+ this._core.$element.on(this._handlers);
2234
+
2235
+ this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) {
2236
+ this.play(e);
2237
+ }, this));
2238
+ };
2239
+
2240
+ /**
2241
+ * Default options.
2242
+ * @public
2243
+ */
2244
+ Video.Defaults = {
2245
+ video: false,
2246
+ videoHeight: false,
2247
+ videoWidth: false
2248
+ };
2249
+
2250
+ /**
2251
+ * Gets the video ID and the type (YouTube/Vimeo/vzaar only).
2252
+ * @protected
2253
+ * @param {jQuery} target - The target containing the video data.
2254
+ * @param {jQuery} item - The item containing the video.
2255
+ */
2256
+ Video.prototype.fetch = function(target, item) {
2257
+ var type = (function() {
2258
+ if (target.attr('data-vimeo-id')) {
2259
+ return 'vimeo';
2260
+ } else if (target.attr('data-vzaar-id')) {
2261
+ return 'vzaar'
2262
+ } else {
2263
+ return 'youtube';
2264
+ }
2265
+ })(),
2266
+ id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'),
2267
+ width = target.attr('data-width') || this._core.settings.videoWidth,
2268
+ height = target.attr('data-height') || this._core.settings.videoHeight,
2269
+ url = target.attr('href');
2270
+
2271
+ if (url) {
2272
+
2273
+ /*
2274
+ Parses the id's out of the following urls (and probably more):
2275
+ https://www.youtube.com/watch?v=:id
2276
+ https://youtu.be/:id
2277
+ https://vimeo.com/:id
2278
+ https://vimeo.com/channels/:channel/:id
2279
+ https://vimeo.com/groups/:group/videos/:id
2280
+ https://app.vzaar.com/videos/:id
2281
+
2282
+ Visual example: https://regexper.com/#(http%3A%7Chttps%3A%7C)%5C%2F%5C%2F(player.%7Cwww.%7Capp.)%3F(vimeo%5C.com%7Cyoutu(be%5C.com%7C%5C.be%7Cbe%5C.googleapis%5C.com)%7Cvzaar%5C.com)%5C%2F(video%5C%2F%7Cvideos%5C%2F%7Cembed%5C%2F%7Cchannels%5C%2F.%2B%5C%2F%7Cgroups%5C%2F.%2B%5C%2F%7Cwatch%5C%3Fv%3D%7Cv%5C%2F)%3F(%5BA-Za-z0-9._%25-%5D*)(%5C%26%5CS%2B)%3F
2283
+ */
2284
+
2285
+ id = url.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/);
2286
+
2287
+ if (id[3].indexOf('youtu') > -1) {
2288
+ type = 'youtube';
2289
+ } else if (id[3].indexOf('vimeo') > -1) {
2290
+ type = 'vimeo';
2291
+ } else if (id[3].indexOf('vzaar') > -1) {
2292
+ type = 'vzaar';
2293
+ } else {
2294
+ throw new Error('Video URL not supported.');
2295
+ }
2296
+ id = id[6];
2297
+ } else {
2298
+ throw new Error('Missing video URL.');
2299
+ }
2300
+
2301
+ this._videos[url] = {
2302
+ type: type,
2303
+ id: id,
2304
+ width: width,
2305
+ height: height
2306
+ };
2307
+
2308
+ item.attr('data-video', url);
2309
+
2310
+ this.thumbnail(target, this._videos[url]);
2311
+ };
2312
+
2313
+ /**
2314
+ * Creates video thumbnail.
2315
+ * @protected
2316
+ * @param {jQuery} target - The target containing the video data.
2317
+ * @param {Object} info - The video info object.
2318
+ * @see `fetch`
2319
+ */
2320
+ Video.prototype.thumbnail = function(target, video) {
2321
+ var tnLink,
2322
+ icon,
2323
+ path,
2324
+ dimensions = video.width && video.height ? 'width:' + video.width + 'px;height:' + video.height + 'px;' : '',
2325
+ customTn = target.find('img'),
2326
+ srcType = 'src',
2327
+ lazyClass = '',
2328
+ settings = this._core.settings,
2329
+ create = function(path) {
2330
+ icon = '<div class="owl-video-play-icon"></div>';
2331
+
2332
+ if (settings.lazyLoad) {
2333
+ tnLink = $('<div/>',{
2334
+ "class": 'owl-video-tn ' + lazyClass,
2335
+ "srcType": path
2336
+ });
2337
+ } else {
2338
+ tnLink = $( '<div/>', {
2339
+ "class": "owl-video-tn",
2340
+ "style": 'opacity:1;background-image:url(' + path + ')'
2341
+ });
2342
+ }
2343
+ target.after(tnLink);
2344
+ target.after(icon);
2345
+ };
2346
+
2347
+ // wrap video content into owl-video-wrapper div
2348
+ target.wrap( $( '<div/>', {
2349
+ "class": "owl-video-wrapper",
2350
+ "style": dimensions
2351
+ }));
2352
+
2353
+ if (this._core.settings.lazyLoad) {
2354
+ srcType = 'data-src';
2355
+ lazyClass = 'owl-lazy';
2356
+ }
2357
+
2358
+ // custom thumbnail
2359
+ if (customTn.length) {
2360
+ create(customTn.attr(srcType));
2361
+ customTn.remove();
2362
+ return false;
2363
+ }
2364
+
2365
+ if (video.type === 'youtube') {
2366
+ path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg";
2367
+ create(path);
2368
+ } else if (video.type === 'vimeo') {
2369
+ $.ajax({
2370
+ type: 'GET',
2371
+ url: '//vimeo.com/api/v2/video/' + video.id + '.json',
2372
+ jsonp: 'callback',
2373
+ dataType: 'jsonp',
2374
+ success: function(data) {
2375
+ path = data[0].thumbnail_large;
2376
+ create(path);
2377
+ }
2378
+ });
2379
+ } else if (video.type === 'vzaar') {
2380
+ $.ajax({
2381
+ type: 'GET',
2382
+ url: '//vzaar.com/api/videos/' + video.id + '.json',
2383
+ jsonp: 'callback',
2384
+ dataType: 'jsonp',
2385
+ success: function(data) {
2386
+ path = data.framegrab_url;
2387
+ create(path);
2388
+ }
2389
+ });
2390
+ }
2391
+ };
2392
+
2393
+ /**
2394
+ * Stops the current video.
2395
+ * @public
2396
+ */
2397
+ Video.prototype.stop = function() {
2398
+ this._core.trigger('stop', null, 'video');
2399
+ this._playing.find('.owl-video-frame').remove();
2400
+ this._playing.removeClass('owl-video-playing');
2401
+ this._playing = null;
2402
+ this._core.leave('playing');
2403
+ this._core.trigger('stopped', null, 'video');
2404
+ };
2405
+
2406
+ /**
2407
+ * Starts the current video.
2408
+ * @public
2409
+ * @param {Event} event - The event arguments.
2410
+ */
2411
+ Video.prototype.play = function(event) {
2412
+ var target = $(event.target),
2413
+ item = target.closest('.' + this._core.settings.itemClass),
2414
+ video = this._videos[item.attr('data-video')],
2415
+ width = video.width || '100%',
2416
+ height = video.height || this._core.$stage.height(),
2417
+ html,
2418
+ iframe;
2419
+
2420
+ if (this._playing) {
2421
+ return;
2422
+ }
2423
+
2424
+ this._core.enter('playing');
2425
+ this._core.trigger('play', null, 'video');
2426
+
2427
+ item = this._core.items(this._core.relative(item.index()));
2428
+
2429
+ this._core.reset(item.index());
2430
+
2431
+ html = $( '<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>' );
2432
+ html.attr( 'height', height );
2433
+ html.attr( 'width', width );
2434
+ if (video.type === 'youtube') {
2435
+ html.attr( 'src', '//www.youtube.com/embed/' + video.id + '?autoplay=1&rel=0&v=' + video.id );
2436
+ } else if (video.type === 'vimeo') {
2437
+ html.attr( 'src', '//player.vimeo.com/video/' + video.id + '?autoplay=1' );
2438
+ } else if (video.type === 'vzaar') {
2439
+ html.attr( 'src', '//view.vzaar.com/' + video.id + '/player?autoplay=true' );
2440
+ }
2441
+
2442
+ iframe = $(html).wrap( '<div class="owl-video-frame" />' ).insertAfter(item.find('.owl-video'));
2443
+
2444
+ this._playing = item.addClass('owl-video-playing');
2445
+ };
2446
+
2447
+ /**
2448
+ * Checks whether an video is currently in full screen mode or not.
2449
+ * @todo Bad style because looks like a readonly method but changes members.
2450
+ * @protected
2451
+ * @returns {Boolean}
2452
+ */
2453
+ Video.prototype.isInFullScreen = function() {
2454
+ var element = document.fullscreenElement || document.mozFullScreenElement ||
2455
+ document.webkitFullscreenElement;
2456
+
2457
+ return element && $(element).parent().hasClass('owl-video-frame');
2458
+ };
2459
+
2460
+ /**
2461
+ * Destroys the plugin.
2462
+ */
2463
+ Video.prototype.destroy = function() {
2464
+ var handler, property;
2465
+
2466
+ this._core.$element.off('click.owl.video');
2467
+
2468
+ for (handler in this._handlers) {
2469
+ this._core.$element.off(handler, this._handlers[handler]);
2470
+ }
2471
+ for (property in Object.getOwnPropertyNames(this)) {
2472
+ typeof this[property] != 'function' && (this[property] = null);
2473
+ }
2474
+ };
2475
+
2476
+ $.fn.owlCarousel.Constructor.Plugins.Video = Video;
2477
+
2478
+ })(window.Zepto || window.jQuery, window, document);
2479
+
2480
+ /**
2481
+ * Animate Plugin
2482
+ * @version 2.3.4
2483
+ * @author Bartosz Wojciechowski
2484
+ * @author David Deutsch
2485
+ * @license The MIT License (MIT)
2486
+ */
2487
+ ;(function($, window, document, undefined) {
2488
+
2489
+ /**
2490
+ * Creates the animate plugin.
2491
+ * @class The Navigation Plugin
2492
+ * @param {Owl} scope - The Owl Carousel
2493
+ */
2494
+ var Animate = function(scope) {
2495
+ this.core = scope;
2496
+ this.core.options = $.extend({}, Animate.Defaults, this.core.options);
2497
+ this.swapping = true;
2498
+ this.previous = undefined;
2499
+ this.next = undefined;
2500
+
2501
+ this.handlers = {
2502
+ 'change.owl.carousel': $.proxy(function(e) {
2503
+ if (e.namespace && e.property.name == 'position') {
2504
+ this.previous = this.core.current();
2505
+ this.next = e.property.value;
2506
+ }
2507
+ }, this),
2508
+ 'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) {
2509
+ if (e.namespace) {
2510
+ this.swapping = e.type == 'translated';
2511
+ }
2512
+ }, this),
2513
+ 'translate.owl.carousel': $.proxy(function(e) {
2514
+ if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) {
2515
+ this.swap();
2516
+ }
2517
+ }, this)
2518
+ };
2519
+
2520
+ this.core.$element.on(this.handlers);
2521
+ };
2522
+
2523
+ /**
2524
+ * Default options.
2525
+ * @public
2526
+ */
2527
+ Animate.Defaults = {
2528
+ animateOut: false,
2529
+ animateIn: false
2530
+ };
2531
+
2532
+ /**
2533
+ * Toggles the animation classes whenever an translations starts.
2534
+ * @protected
2535
+ * @returns {Boolean|undefined}
2536
+ */
2537
+ Animate.prototype.swap = function() {
2538
+
2539
+ if (this.core.settings.items !== 1) {
2540
+ return;
2541
+ }
2542
+
2543
+ if (!$.support.animation || !$.support.transition) {
2544
+ return;
2545
+ }
2546
+
2547
+ this.core.speed(0);
2548
+
2549
+ var left,
2550
+ clear = $.proxy(this.clear, this),
2551
+ previous = this.core.$stage.children().eq(this.previous),
2552
+ next = this.core.$stage.children().eq(this.next),
2553
+ incoming = this.core.settings.animateIn,
2554
+ outgoing = this.core.settings.animateOut;
2555
+
2556
+ if (this.core.current() === this.previous) {
2557
+ return;
2558
+ }
2559
+
2560
+ if (outgoing) {
2561
+ left = this.core.coordinates(this.previous) - this.core.coordinates(this.next);
2562
+ previous.one($.support.animation.end, clear)
2563
+ .css( { 'left': left + 'px' } )
2564
+ .addClass('animated owl-animated-out')
2565
+ .addClass(outgoing);
2566
+ }
2567
+
2568
+ if (incoming) {
2569
+ next.one($.support.animation.end, clear)
2570
+ .addClass('animated owl-animated-in')
2571
+ .addClass(incoming);
2572
+ }
2573
+ };
2574
+
2575
+ Animate.prototype.clear = function(e) {
2576
+ $(e.target).css( { 'left': '' } )
2577
+ .removeClass('animated owl-animated-out owl-animated-in')
2578
+ .removeClass(this.core.settings.animateIn)
2579
+ .removeClass(this.core.settings.animateOut);
2580
+ this.core.onTransitionEnd();
2581
+ };
2582
+
2583
+ /**
2584
+ * Destroys the plugin.
2585
+ * @public
2586
+ */
2587
+ Animate.prototype.destroy = function() {
2588
+ var handler, property;
2589
+
2590
+ for (handler in this.handlers) {
2591
+ this.core.$element.off(handler, this.handlers[handler]);
2592
+ }
2593
+ for (property in Object.getOwnPropertyNames(this)) {
2594
+ typeof this[property] != 'function' && (this[property] = null);
2595
+ }
2596
+ };
2597
+
2598
+ $.fn.owlCarousel.Constructor.Plugins.Animate = Animate;
2599
+
2600
+ })(window.Zepto || window.jQuery, window, document);
2601
+
2602
+ /**
2603
+ * Autoplay Plugin
2604
+ * @version 2.3.4
2605
+ * @author Bartosz Wojciechowski
2606
+ * @author Artus Kolanowski
2607
+ * @author David Deutsch
2608
+ * @author Tom De Caluwé
2609
+ * @license The MIT License (MIT)
2610
+ */
2611
+ ;(function($, window, document, undefined) {
2612
+
2613
+ /**
2614
+ * Creates the autoplay plugin.
2615
+ * @class The Autoplay Plugin
2616
+ * @param {Owl} scope - The Owl Carousel
2617
+ */
2618
+ var Autoplay = function(carousel) {
2619
+ /**
2620
+ * Reference to the core.
2621
+ * @protected
2622
+ * @type {Owl}
2623
+ */
2624
+ this._core = carousel;
2625
+
2626
+ /**
2627
+ * The autoplay timeout id.
2628
+ * @type {Number}
2629
+ */
2630
+ this._call = null;
2631
+
2632
+ /**
2633
+ * Depending on the state of the plugin, this variable contains either
2634
+ * the start time of the timer or the current timer value if it's
2635
+ * paused. Since we start in a paused state we initialize the timer
2636
+ * value.
2637
+ * @type {Number}
2638
+ */
2639
+ this._time = 0;
2640
+
2641
+ /**
2642
+ * Stores the timeout currently used.
2643
+ * @type {Number}
2644
+ */
2645
+ this._timeout = 0;
2646
+
2647
+ /**
2648
+ * Indicates whenever the autoplay is paused.
2649
+ * @type {Boolean}
2650
+ */
2651
+ this._paused = true;
2652
+
2653
+ /**
2654
+ * All event handlers.
2655
+ * @protected
2656
+ * @type {Object}
2657
+ */
2658
+ this._handlers = {
2659
+ 'changed.owl.carousel': $.proxy(function(e) {
2660
+ if (e.namespace && e.property.name === 'settings') {
2661
+ if (this._core.settings.autoplay) {
2662
+ this.play();
2663
+ } else {
2664
+ this.stop();
2665
+ }
2666
+ } else if (e.namespace && e.property.name === 'position' && this._paused) {
2667
+ // Reset the timer. This code is triggered when the position
2668
+ // of the carousel was changed through user interaction.
2669
+ this._time = 0;
2670
+ }
2671
+ }, this),
2672
+ 'initialized.owl.carousel': $.proxy(function(e) {
2673
+ if (e.namespace && this._core.settings.autoplay) {
2674
+ this.play();
2675
+ }
2676
+ }, this),
2677
+ 'play.owl.autoplay': $.proxy(function(e, t, s) {
2678
+ if (e.namespace) {
2679
+ this.play(t, s);
2680
+ }
2681
+ }, this),
2682
+ 'stop.owl.autoplay': $.proxy(function(e) {
2683
+ if (e.namespace) {
2684
+ this.stop();
2685
+ }
2686
+ }, this),
2687
+ 'mouseover.owl.autoplay': $.proxy(function() {
2688
+ if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
2689
+ this.pause();
2690
+ }
2691
+ }, this),
2692
+ 'mouseleave.owl.autoplay': $.proxy(function() {
2693
+ if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
2694
+ this.play();
2695
+ }
2696
+ }, this),
2697
+ 'touchstart.owl.core': $.proxy(function() {
2698
+ if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
2699
+ this.pause();
2700
+ }
2701
+ }, this),
2702
+ 'touchend.owl.core': $.proxy(function() {
2703
+ if (this._core.settings.autoplayHoverPause) {
2704
+ this.play();
2705
+ }
2706
+ }, this)
2707
+ };
2708
+
2709
+ // register event handlers
2710
+ this._core.$element.on(this._handlers);
2711
+
2712
+ // set default options
2713
+ this._core.options = $.extend({}, Autoplay.Defaults, this._core.options);
2714
+ };
2715
+
2716
+ /**
2717
+ * Default options.
2718
+ * @public
2719
+ */
2720
+ Autoplay.Defaults = {
2721
+ autoplay: false,
2722
+ autoplayTimeout: 5000,
2723
+ autoplayHoverPause: false,
2724
+ autoplaySpeed: false
2725
+ };
2726
+
2727
+ /**
2728
+ * Transition to the next slide and set a timeout for the next transition.
2729
+ * @private
2730
+ * @param {Number} [speed] - The animation speed for the animations.
2731
+ */
2732
+ Autoplay.prototype._next = function(speed) {
2733
+ this._call = window.setTimeout(
2734
+ $.proxy(this._next, this, speed),
2735
+ this._timeout * (Math.round(this.read() / this._timeout) + 1) - this.read()
2736
+ );
2737
+
2738
+ if (this._core.is('interacting') || document.hidden) {
2739
+ return;
2740
+ }
2741
+ this._core.next(speed || this._core.settings.autoplaySpeed);
2742
+ }
2743
+
2744
+ /**
2745
+ * Reads the current timer value when the timer is playing.
2746
+ * @public
2747
+ */
2748
+ Autoplay.prototype.read = function() {
2749
+ return new Date().getTime() - this._time;
2750
+ };
2751
+
2752
+ /**
2753
+ * Starts the autoplay.
2754
+ * @public
2755
+ * @param {Number} [timeout] - The interval before the next animation starts.
2756
+ * @param {Number} [speed] - The animation speed for the animations.
2757
+ */
2758
+ Autoplay.prototype.play = function(timeout, speed) {
2759
+ var elapsed;
2760
+
2761
+ if (!this._core.is('rotating')) {
2762
+ this._core.enter('rotating');
2763
+ }
2764
+
2765
+ timeout = timeout || this._core.settings.autoplayTimeout;
2766
+
2767
+ // Calculate the elapsed time since the last transition. If the carousel
2768
+ // wasn't playing this calculation will yield zero.
2769
+ elapsed = Math.min(this._time % (this._timeout || timeout), timeout);
2770
+
2771
+ if (this._paused) {
2772
+ // Start the clock.
2773
+ this._time = this.read();
2774
+ this._paused = false;
2775
+ } else {
2776
+ // Clear the active timeout to allow replacement.
2777
+ window.clearTimeout(this._call);
2778
+ }
2779
+
2780
+ // Adjust the origin of the timer to match the new timeout value.
2781
+ this._time += this.read() % timeout - elapsed;
2782
+
2783
+ this._timeout = timeout;
2784
+ this._call = window.setTimeout($.proxy(this._next, this, speed), timeout - elapsed);
2785
+ };
2786
+
2787
+ /**
2788
+ * Stops the autoplay.
2789
+ * @public
2790
+ */
2791
+ Autoplay.prototype.stop = function() {
2792
+ if (this._core.is('rotating')) {
2793
+ // Reset the clock.
2794
+ this._time = 0;
2795
+ this._paused = true;
2796
+
2797
+ window.clearTimeout(this._call);
2798
+ this._core.leave('rotating');
2799
+ }
2800
+ };
2801
+
2802
+ /**
2803
+ * Pauses the autoplay.
2804
+ * @public
2805
+ */
2806
+ Autoplay.prototype.pause = function() {
2807
+ if (this._core.is('rotating') && !this._paused) {
2808
+ // Pause the clock.
2809
+ this._time = this.read();
2810
+ this._paused = true;
2811
+
2812
+ window.clearTimeout(this._call);
2813
+ }
2814
+ };
2815
+
2816
+ /**
2817
+ * Destroys the plugin.
2818
+ */
2819
+ Autoplay.prototype.destroy = function() {
2820
+ var handler, property;
2821
+
2822
+ this.stop();
2823
+
2824
+ for (handler in this._handlers) {
2825
+ this._core.$element.off(handler, this._handlers[handler]);
2826
+ }
2827
+ for (property in Object.getOwnPropertyNames(this)) {
2828
+ typeof this[property] != 'function' && (this[property] = null);
2829
+ }
2830
+ };
2831
+
2832
+ $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay;
2833
+
2834
+ })(window.Zepto || window.jQuery, window, document);
2835
+
2836
+ /**
2837
+ * Navigation Plugin
2838
+ * @version 2.3.4
2839
+ * @author Artus Kolanowski
2840
+ * @author David Deutsch
2841
+ * @license The MIT License (MIT)
2842
+ */
2843
+ ;(function($, window, document, undefined) {
2844
+ 'use strict';
2845
+
2846
+ /**
2847
+ * Creates the navigation plugin.
2848
+ * @class The Navigation Plugin
2849
+ * @param {Owl} carousel - The Owl Carousel.
2850
+ */
2851
+ var Navigation = function(carousel) {
2852
+ /**
2853
+ * Reference to the core.
2854
+ * @protected
2855
+ * @type {Owl}
2856
+ */
2857
+ this._core = carousel;
2858
+
2859
+ /**
2860
+ * Indicates whether the plugin is initialized or not.
2861
+ * @protected
2862
+ * @type {Boolean}
2863
+ */
2864
+ this._initialized = false;
2865
+
2866
+ /**
2867
+ * The current paging indexes.
2868
+ * @protected
2869
+ * @type {Array}
2870
+ */
2871
+ this._pages = [];
2872
+
2873
+ /**
2874
+ * All DOM elements of the user interface.
2875
+ * @protected
2876
+ * @type {Object}
2877
+ */
2878
+ this._controls = {};
2879
+
2880
+ /**
2881
+ * Markup for an indicator.
2882
+ * @protected
2883
+ * @type {Array.<String>}
2884
+ */
2885
+ this._templates = [];
2886
+
2887
+ /**
2888
+ * The carousel element.
2889
+ * @type {jQuery}
2890
+ */
2891
+ this.$element = this._core.$element;
2892
+
2893
+ /**
2894
+ * Overridden methods of the carousel.
2895
+ * @protected
2896
+ * @type {Object}
2897
+ */
2898
+ this._overrides = {
2899
+ next: this._core.next,
2900
+ prev: this._core.prev,
2901
+ to: this._core.to
2902
+ };
2903
+
2904
+ /**
2905
+ * All event handlers.
2906
+ * @protected
2907
+ * @type {Object}
2908
+ */
2909
+ this._handlers = {
2910
+ 'prepared.owl.carousel': $.proxy(function(e) {
2911
+ if (e.namespace && this._core.settings.dotsData) {
2912
+ this._templates.push('<div class="' + this._core.settings.dotClass + '">' +
2913
+ $(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>');
2914
+ }
2915
+ }, this),
2916
+ 'added.owl.carousel': $.proxy(function(e) {
2917
+ if (e.namespace && this._core.settings.dotsData) {
2918
+ this._templates.splice(e.position, 0, this._templates.pop());
2919
+ }
2920
+ }, this),
2921
+ 'remove.owl.carousel': $.proxy(function(e) {
2922
+ if (e.namespace && this._core.settings.dotsData) {
2923
+ this._templates.splice(e.position, 1);
2924
+ }
2925
+ }, this),
2926
+ 'changed.owl.carousel': $.proxy(function(e) {
2927
+ if (e.namespace && e.property.name == 'position') {
2928
+ this.draw();
2929
+ }
2930
+ }, this),
2931
+ 'initialized.owl.carousel': $.proxy(function(e) {
2932
+ if (e.namespace && !this._initialized) {
2933
+ this._core.trigger('initialize', null, 'navigation');
2934
+ this.initialize();
2935
+ this.update();
2936
+ this.draw();
2937
+ this._initialized = true;
2938
+ this._core.trigger('initialized', null, 'navigation');
2939
+ }
2940
+ }, this),
2941
+ 'refreshed.owl.carousel': $.proxy(function(e) {
2942
+ if (e.namespace && this._initialized) {
2943
+ this._core.trigger('refresh', null, 'navigation');
2944
+ this.update();
2945
+ this.draw();
2946
+ this._core.trigger('refreshed', null, 'navigation');
2947
+ }
2948
+ }, this)
2949
+ };
2950
+
2951
+ // set default options
2952
+ this._core.options = $.extend({}, Navigation.Defaults, this._core.options);
2953
+
2954
+ // register event handlers
2955
+ this.$element.on(this._handlers);
2956
+ };
2957
+
2958
+ /**
2959
+ * Default options.
2960
+ * @public
2961
+ * @todo Rename `slideBy` to `navBy`
2962
+ */
2963
+ Navigation.Defaults = {
2964
+ nav: false,
2965
+ navText: [
2966
+ '<span aria-label="' + 'Previous' + '">&#x2039;</span>',
2967
+ '<span aria-label="' + 'Next' + '">&#x203a;</span>'
2968
+ ],
2969
+ navSpeed: false,
2970
+ navElement: 'button type="button" role="presentation"',
2971
+ navContainer: false,
2972
+ navContainerClass: 'owl-nav',
2973
+ navClass: [
2974
+ 'owl-prev',
2975
+ 'owl-next'
2976
+ ],
2977
+ slideBy: 1,
2978
+ dotClass: 'owl-dot',
2979
+ dotsClass: 'owl-dots',
2980
+ dots: true,
2981
+ dotsEach: false,
2982
+ dotsData: false,
2983
+ dotsSpeed: false,
2984
+ dotsContainer: false
2985
+ };
2986
+
2987
+ /**
2988
+ * Initializes the layout of the plugin and extends the carousel.
2989
+ * @protected
2990
+ */
2991
+ Navigation.prototype.initialize = function() {
2992
+ var override,
2993
+ settings = this._core.settings;
2994
+
2995
+ // create DOM structure for relative navigation
2996
+ this._controls.$relative = (settings.navContainer ? $(settings.navContainer)
2997
+ : $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled');
2998
+
2999
+ this._controls.$previous = $('<' + settings.navElement + '>')
3000
+ .addClass(settings.navClass[0])
3001
+ .html(settings.navText[0])
3002
+ .prependTo(this._controls.$relative)
3003
+ .on('click', $.proxy(function(e) {
3004
+ this.prev(settings.navSpeed);
3005
+ }, this));
3006
+ this._controls.$next = $('<' + settings.navElement + '>')
3007
+ .addClass(settings.navClass[1])
3008
+ .html(settings.navText[1])
3009
+ .appendTo(this._controls.$relative)
3010
+ .on('click', $.proxy(function(e) {
3011
+ this.next(settings.navSpeed);
3012
+ }, this));
3013
+
3014
+ // create DOM structure for absolute navigation
3015
+ if (!settings.dotsData) {
3016
+ this._templates = [ $('<button role="button">')
3017
+ .addClass(settings.dotClass)
3018
+ .append($('<span>'))
3019
+ .prop('outerHTML') ];
3020
+ }
3021
+
3022
+ this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer)
3023
+ : $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled');
3024
+
3025
+ this._controls.$absolute.on('click', 'button', $.proxy(function(e) {
3026
+ var index = $(e.target).parent().is(this._controls.$absolute)
3027
+ ? $(e.target).index() : $(e.target).parent().index();
3028
+
3029
+ e.preventDefault();
3030
+
3031
+ this.to(index, settings.dotsSpeed);
3032
+ }, this));
3033
+
3034
+ /*$el.on('focusin', function() {
3035
+ $(document).off(".carousel");
3036
+
3037
+ $(document).on('keydown.carousel', function(e) {
3038
+ if(e.keyCode == 37) {
3039
+ $el.trigger('prev.owl')
3040
+ }
3041
+ if(e.keyCode == 39) {
3042
+ $el.trigger('next.owl')
3043
+ }
3044
+ });
3045
+ });*/
3046
+
3047
+ // override public methods of the carousel
3048
+ for (override in this._overrides) {
3049
+ this._core[override] = $.proxy(this[override], this);
3050
+ }
3051
+ };
3052
+
3053
+ /**
3054
+ * Destroys the plugin.
3055
+ * @protected
3056
+ */
3057
+ Navigation.prototype.destroy = function() {
3058
+ var handler, control, property, override, settings;
3059
+ settings = this._core.settings;
3060
+
3061
+ for (handler in this._handlers) {
3062
+ this.$element.off(handler, this._handlers[handler]);
3063
+ }
3064
+ for (control in this._controls) {
3065
+ if (control === '$relative' && settings.navContainer) {
3066
+ this._controls[control].html('');
3067
+ } else {
3068
+ this._controls[control].remove();
3069
+ }
3070
+ }
3071
+ for (override in this.overides) {
3072
+ this._core[override] = this._overrides[override];
3073
+ }
3074
+ for (property in Object.getOwnPropertyNames(this)) {
3075
+ typeof this[property] != 'function' && (this[property] = null);
3076
+ }
3077
+ };
3078
+
3079
+ /**
3080
+ * Updates the internal state.
3081
+ * @protected
3082
+ */
3083
+ Navigation.prototype.update = function() {
3084
+ var i, j, k,
3085
+ lower = this._core.clones().length / 2,
3086
+ upper = lower + this._core.items().length,
3087
+ maximum = this._core.maximum(true),
3088
+ settings = this._core.settings,
3089
+ size = settings.center || settings.autoWidth || settings.dotsData
3090
+ ? 1 : settings.dotsEach || settings.items;
3091
+
3092
+ if (settings.slideBy !== 'page') {
3093
+ settings.slideBy = Math.min(settings.slideBy, settings.items);
3094
+ }
3095
+
3096
+ if (settings.dots || settings.slideBy == 'page') {
3097
+ this._pages = [];
3098
+
3099
+ for (i = lower, j = 0, k = 0; i < upper; i++) {
3100
+ if (j >= size || j === 0) {
3101
+ this._pages.push({
3102
+ start: Math.min(maximum, i - lower),
3103
+ end: i - lower + size - 1
3104
+ });
3105
+ if (Math.min(maximum, i - lower) === maximum) {
3106
+ break;
3107
+ }
3108
+ j = 0, ++k;
3109
+ }
3110
+ j += this._core.mergers(this._core.relative(i));
3111
+ }
3112
+ }
3113
+ };
3114
+
3115
+ /**
3116
+ * Draws the user interface.
3117
+ * @todo The option `dotsData` wont work.
3118
+ * @protected
3119
+ */
3120
+ Navigation.prototype.draw = function() {
3121
+ var difference,
3122
+ settings = this._core.settings,
3123
+ disabled = this._core.items().length <= settings.items,
3124
+ index = this._core.relative(this._core.current()),
3125
+ loop = settings.loop || settings.rewind;
3126
+
3127
+ this._controls.$relative.toggleClass('disabled', !settings.nav || disabled);
3128
+
3129
+ if (settings.nav) {
3130
+ this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true));
3131
+ this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true));
3132
+ }
3133
+
3134
+ this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled);
3135
+
3136
+ if (settings.dots) {
3137
+ difference = this._pages.length - this._controls.$absolute.children().length;
3138
+
3139
+ if (settings.dotsData && difference !== 0) {
3140
+ this._controls.$absolute.html(this._templates.join(''));
3141
+ } else if (difference > 0) {
3142
+ this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0]));
3143
+ } else if (difference < 0) {
3144
+ this._controls.$absolute.children().slice(difference).remove();
3145
+ }
3146
+
3147
+ this._controls.$absolute.find('.active').removeClass('active');
3148
+ this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active');
3149
+ }
3150
+ };
3151
+
3152
+ /**
3153
+ * Extends event data.
3154
+ * @protected
3155
+ * @param {Event} event - The event object which gets thrown.
3156
+ */
3157
+ Navigation.prototype.onTrigger = function(event) {
3158
+ var settings = this._core.settings;
3159
+
3160
+ event.page = {
3161
+ index: $.inArray(this.current(), this._pages),
3162
+ count: this._pages.length,
3163
+ size: settings && (settings.center || settings.autoWidth || settings.dotsData
3164
+ ? 1 : settings.dotsEach || settings.items)
3165
+ };
3166
+ };
3167
+
3168
+ /**
3169
+ * Gets the current page position of the carousel.
3170
+ * @protected
3171
+ * @returns {Number}
3172
+ */
3173
+ Navigation.prototype.current = function() {
3174
+ var current = this._core.relative(this._core.current());
3175
+ return $.grep(this._pages, $.proxy(function(page, index) {
3176
+ return page.start <= current && page.end >= current;
3177
+ }, this)).pop();
3178
+ };
3179
+
3180
+ /**
3181
+ * Gets the current succesor/predecessor position.
3182
+ * @protected
3183
+ * @returns {Number}
3184
+ */
3185
+ Navigation.prototype.getPosition = function(successor) {
3186
+ var position, length,
3187
+ settings = this._core.settings;
3188
+
3189
+ if (settings.slideBy == 'page') {
3190
+ position = $.inArray(this.current(), this._pages);
3191
+ length = this._pages.length;
3192
+ successor ? ++position : --position;
3193
+ position = this._pages[((position % length) + length) % length].start;
3194
+ } else {
3195
+ position = this._core.relative(this._core.current());
3196
+ length = this._core.items().length;
3197
+ successor ? position += settings.slideBy : position -= settings.slideBy;
3198
+ }
3199
+
3200
+ return position;
3201
+ };
3202
+
3203
+ /**
3204
+ * Slides to the next item or page.
3205
+ * @public
3206
+ * @param {Number} [speed=false] - The time in milliseconds for the transition.
3207
+ */
3208
+ Navigation.prototype.next = function(speed) {
3209
+ $.proxy(this._overrides.to, this._core)(this.getPosition(true), speed);
3210
+ };
3211
+
3212
+ /**
3213
+ * Slides to the previous item or page.
3214
+ * @public
3215
+ * @param {Number} [speed=false] - The time in milliseconds for the transition.
3216
+ */
3217
+ Navigation.prototype.prev = function(speed) {
3218
+ $.proxy(this._overrides.to, this._core)(this.getPosition(false), speed);
3219
+ };
3220
+
3221
+ /**
3222
+ * Slides to the specified item or page.
3223
+ * @public
3224
+ * @param {Number} position - The position of the item or page.
3225
+ * @param {Number} [speed] - The time in milliseconds for the transition.
3226
+ * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not.
3227
+ */
3228
+ Navigation.prototype.to = function(position, speed, standard) {
3229
+ var length;
3230
+
3231
+ if (!standard && this._pages.length) {
3232
+ length = this._pages.length;
3233
+ $.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed);
3234
+ } else {
3235
+ $.proxy(this._overrides.to, this._core)(position, speed);
3236
+ }
3237
+ };
3238
+
3239
+ $.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation;
3240
+
3241
+ })(window.Zepto || window.jQuery, window, document);
3242
+
3243
+ /**
3244
+ * Hash Plugin
3245
+ * @version 2.3.4
3246
+ * @author Artus Kolanowski
3247
+ * @author David Deutsch
3248
+ * @license The MIT License (MIT)
3249
+ */
3250
+ ;(function($, window, document, undefined) {
3251
+ 'use strict';
3252
+
3253
+ /**
3254
+ * Creates the hash plugin.
3255
+ * @class The Hash Plugin
3256
+ * @param {Owl} carousel - The Owl Carousel
3257
+ */
3258
+ var Hash = function(carousel) {
3259
+ /**
3260
+ * Reference to the core.
3261
+ * @protected
3262
+ * @type {Owl}
3263
+ */
3264
+ this._core = carousel;
3265
+
3266
+ /**
3267
+ * Hash index for the items.
3268
+ * @protected
3269
+ * @type {Object}
3270
+ */
3271
+ this._hashes = {};
3272
+
3273
+ /**
3274
+ * The carousel element.
3275
+ * @type {jQuery}
3276
+ */
3277
+ this.$element = this._core.$element;
3278
+
3279
+ /**
3280
+ * All event handlers.
3281
+ * @protected
3282
+ * @type {Object}
3283
+ */
3284
+ this._handlers = {
3285
+ 'initialized.owl.carousel': $.proxy(function(e) {
3286
+ if (e.namespace && this._core.settings.startPosition === 'URLHash') {
3287
+ $(window).trigger('hashchange.owl.navigation');
3288
+ }
3289
+ }, this),
3290
+ 'prepared.owl.carousel': $.proxy(function(e) {
3291
+ if (e.namespace) {
3292
+ var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash');
3293
+
3294
+ if (!hash) {
3295
+ return;
3296
+ }
3297
+
3298
+ this._hashes[hash] = e.content;
3299
+ }
3300
+ }, this),
3301
+ 'changed.owl.carousel': $.proxy(function(e) {
3302
+ if (e.namespace && e.property.name === 'position') {
3303
+ var current = this._core.items(this._core.relative(this._core.current())),
3304
+ hash = $.map(this._hashes, function(item, hash) {
3305
+ return item === current ? hash : null;
3306
+ }).join();
3307
+
3308
+ if (!hash || window.location.hash.slice(1) === hash) {
3309
+ return;
3310
+ }
3311
+
3312
+ window.location.hash = hash;
3313
+ }
3314
+ }, this)
3315
+ };
3316
+
3317
+ // set default options
3318
+ this._core.options = $.extend({}, Hash.Defaults, this._core.options);
3319
+
3320
+ // register the event handlers
3321
+ this.$element.on(this._handlers);
3322
+
3323
+ // register event listener for hash navigation
3324
+ $(window).on('hashchange.owl.navigation', $.proxy(function(e) {
3325
+ var hash = window.location.hash.substring(1),
3326
+ items = this._core.$stage.children(),
3327
+ position = this._hashes[hash] && items.index(this._hashes[hash]);
3328
+
3329
+ if (position === undefined || position === this._core.current()) {
3330
+ return;
3331
+ }
3332
+
3333
+ this._core.to(this._core.relative(position), false, true);
3334
+ }, this));
3335
+ };
3336
+
3337
+ /**
3338
+ * Default options.
3339
+ * @public
3340
+ */
3341
+ Hash.Defaults = {
3342
+ URLhashListener: false
3343
+ };
3344
+
3345
+ /**
3346
+ * Destroys the plugin.
3347
+ * @public
3348
+ */
3349
+ Hash.prototype.destroy = function() {
3350
+ var handler, property;
3351
+
3352
+ $(window).off('hashchange.owl.navigation');
3353
+
3354
+ for (handler in this._handlers) {
3355
+ this._core.$element.off(handler, this._handlers[handler]);
3356
+ }
3357
+ for (property in Object.getOwnPropertyNames(this)) {
3358
+ typeof this[property] != 'function' && (this[property] = null);
3359
+ }
3360
+ };
3361
+
3362
+ $.fn.owlCarousel.Constructor.Plugins.Hash = Hash;
3363
+
3364
+ })(window.Zepto || window.jQuery, window, document);
3365
+
3366
+ /**
3367
+ * Support Plugin
3368
+ *
3369
+ * @version 2.3.4
3370
+ * @author Vivid Planet Software GmbH
3371
+ * @author Artus Kolanowski
3372
+ * @author David Deutsch
3373
+ * @license The MIT License (MIT)
3374
+ */
3375
+ ;(function($, window, document, undefined) {
3376
+
3377
+ var style = $('<support>').get(0).style,
3378
+ prefixes = 'Webkit Moz O ms'.split(' '),
3379
+ events = {
3380
+ transition: {
3381
+ end: {
3382
+ WebkitTransition: 'webkitTransitionEnd',
3383
+ MozTransition: 'transitionend',
3384
+ OTransition: 'oTransitionEnd',
3385
+ transition: 'transitionend'
3386
+ }
3387
+ },
3388
+ animation: {
3389
+ end: {
3390
+ WebkitAnimation: 'webkitAnimationEnd',
3391
+ MozAnimation: 'animationend',
3392
+ OAnimation: 'oAnimationEnd',
3393
+ animation: 'animationend'
3394
+ }
3395
+ }
3396
+ },
3397
+ tests = {
3398
+ csstransforms: function() {
3399
+ return !!test('transform');
3400
+ },
3401
+ csstransforms3d: function() {
3402
+ return !!test('perspective');
3403
+ },
3404
+ csstransitions: function() {
3405
+ return !!test('transition');
3406
+ },
3407
+ cssanimations: function() {
3408
+ return !!test('animation');
3409
+ }
3410
+ };
3411
+
3412
+ function test(property, prefixed) {
3413
+ var result = false,
3414
+ upper = property.charAt(0).toUpperCase() + property.slice(1);
3415
+
3416
+ $.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) {
3417
+ if (style[property] !== undefined) {
3418
+ result = prefixed ? property : true;
3419
+ return false;
3420
+ }
3421
+ });
3422
+
3423
+ return result;
3424
+ }
3425
+
3426
+ function prefixed(property) {
3427
+ return test(property, true);
3428
+ }
3429
+
3430
+ if (tests.csstransitions()) {
3431
+ /* jshint -W053 */
3432
+ $.support.transition = new String(prefixed('transition'))
3433
+ $.support.transition.end = events.transition.end[ $.support.transition ];
3434
+ }
3435
+
3436
+ if (tests.cssanimations()) {
3437
+ /* jshint -W053 */
3438
+ $.support.animation = new String(prefixed('animation'))
3439
+ $.support.animation.end = events.animation.end[ $.support.animation ];
3440
+ }
3441
+
3442
+ if (tests.csstransforms()) {
3443
+ /* jshint -W053 */
3444
+ $.support.transform = new String(prefixed('transform'));
3445
+ $.support.transform3d = tests.csstransforms3d();
3446
+ }
3447
+
3448
+ })(window.Zepto || window.jQuery, window, document);
assets_libraries/owl-carousel-new/owl.carousel.min.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /**
2
+ * Owl Carousel v2.3.4
3
+ * Copyright 2013-2018 David Deutsch
4
+ * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
5
+ */
6
+ !function(a,b,c,d){function e(b,c){this.settings=null,this.options=a.extend({},e.Defaults,c),this.$element=a(b),this._handlers={},this._plugins={},this._supress={},this._current=null,this._speed=null,this._coordinates=[],this._breakpoint=null,this._width=null,this._items=[],this._clones=[],this._mergers=[],this._widths=[],this._invalidated={},this._pipe=[],this._drag={time:null,target:null,pointer:null,stage:{start:null,current:null},direction:null},this._states={current:{},tags:{initializing:["busy"],animating:["busy"],dragging:["interacting"]}},a.each(["onResize","onThrottledResize"],a.proxy(function(b,c){this._handlers[c]=a.proxy(this[c],this)},this)),a.each(e.Plugins,a.proxy(function(a,b){this._plugins[a.charAt(0).toLowerCase()+a.slice(1)]=new b(this)},this)),a.each(e.Workers,a.proxy(function(b,c){this._pipe.push({filter:c.filter,run:a.proxy(c.run,this)})},this)),this.setup(),this.initialize()}e.Defaults={items:3,loop:!1,center:!1,rewind:!1,checkVisibility:!0,mouseDrag:!0,touchDrag:!0,pullDrag:!0,freeDrag:!1,margin:0,stagePadding:0,merge:!1,mergeFit:!0,autoWidth:!1,startPosition:0,rtl:!1,smartSpeed:250,fluidSpeed:!1,dragEndSpeed:!1,responsive:{},responsiveRefreshRate:200,responsiveBaseElement:b,fallbackEasing:"swing",slideTransition:"",info:!1,nestedItemSelector:!1,itemElement:"div",stageElement:"div",refreshClass:"owl-refresh",loadedClass:"owl-loaded",loadingClass:"owl-loading",rtlClass:"owl-rtl",responsiveClass:"owl-responsive",dragClass:"owl-drag",itemClass:"owl-item",stageClass:"owl-stage",stageOuterClass:"owl-stage-outer",grabClass:"owl-grab"},e.Width={Default:"default",Inner:"inner",Outer:"outer"},e.Type={Event:"event",State:"state"},e.Plugins={},e.Workers=[{filter:["width","settings"],run:function(){this._width=this.$element.width()}},{filter:["width","items","settings"],run:function(a){a.current=this._items&&this._items[this.relative(this._current)]}},{filter:["items","settings"],run:function(){this.$stage.children(".cloned").remove()}},{filter:["width","items","settings"],run:function(a){var b=this.settings.margin||"",c=!this.settings.autoWidth,d=this.settings.rtl,e={width:"auto","margin-left":d?b:"","margin-right":d?"":b};!c&&this.$stage.children().css(e),a.css=e}},{filter:["width","items","settings"],run:function(a){var b=(this.width()/this.settings.items).toFixed(3)-this.settings.margin,c=null,d=this._items.length,e=!this.settings.autoWidth,f=[];for(a.items={merge:!1,width:b};d--;)c=this._mergers[d],c=this.settings.mergeFit&&Math.min(c,this.settings.items)||c,a.items.merge=c>1||a.items.merge,f[d]=e?b*c:this._items[d].width();this._widths=f}},{filter:["items","settings"],run:function(){var b=[],c=this._items,d=this.settings,e=Math.max(2*d.items,4),f=2*Math.ceil(c.length/2),g=d.loop&&c.length?d.rewind?e:Math.max(e,f):0,h="",i="";for(g/=2;g>0;)b.push(this.normalize(b.length/2,!0)),h+=c[b[b.length-1]][0].outerHTML,b.push(this.normalize(c.length-1-(b.length-1)/2,!0)),i=c[b[b.length-1]][0].outerHTML+i,g-=1;this._clones=b,a(h).addClass("cloned").appendTo(this.$stage),a(i).addClass("cloned").prependTo(this.$stage)}},{filter:["width","items","settings"],run:function(){for(var a=this.settings.rtl?1:-1,b=this._clones.length+this._items.length,c=-1,d=0,e=0,f=[];++c<b;)d=f[c-1]||0,e=this._widths[this.relative(c)]+this.settings.margin,f.push(d+e*a);this._coordinates=f}},{filter:["width","items","settings"],run:function(){var a=this.settings.stagePadding,b=this._coordinates,c={width:Math.ceil(Math.abs(b[b.length-1]))+2*a,"padding-left":a||"","padding-right":a||""};this.$stage.css(c)}},{filter:["width","items","settings"],run:function(a){var b=this._coordinates.length,c=!this.settings.autoWidth,d=this.$stage.children();if(c&&a.items.merge)for(;b--;)a.css.width=this._widths[this.relative(b)],d.eq(b).css(a.css);else c&&(a.css.width=a.items.width,d.css(a.css))}},{filter:["items"],run:function(){this._coordinates.length<1&&this.$stage.removeAttr("style")}},{filter:["width","items","settings"],run:function(a){a.current=a.current?this.$stage.children().index(a.current):0,a.current=Math.max(this.minimum(),Math.min(this.maximum(),a.current)),this.reset(a.current)}},{filter:["position"],run:function(){this.animate(this.coordinates(this._current))}},{filter:["width","position","items","settings"],run:function(){var a,b,c,d,e=this.settings.rtl?1:-1,f=2*this.settings.stagePadding,g=this.coordinates(this.current())+f,h=g+this.width()*e,i=[];for(c=0,d=this._coordinates.length;c<d;c++)a=this._coordinates[c-1]||0,b=Math.abs(this._coordinates[c])+f*e,(this.op(a,"<=",g)&&this.op(a,">",h)||this.op(b,"<",g)&&this.op(b,">",h))&&i.push(c);this.$stage.children(".active").removeClass("active"),this.$stage.children(":eq("+i.join("), :eq(")+")").addClass("active"),this.$stage.children(".center").removeClass("center"),this.settings.center&&this.$stage.children().eq(this.current()).addClass("center")}}],e.prototype.initializeStage=function(){this.$stage=this.$element.find("."+this.settings.stageClass),this.$stage.length||(this.$element.addClass(this.options.loadingClass),this.$stage=a("<"+this.settings.stageElement+">",{class:this.settings.stageClass}).wrap(a("<div/>",{class:this.settings.stageOuterClass})),this.$element.append(this.$stage.parent()))},e.prototype.initializeItems=function(){var b=this.$element.find(".owl-item");if(b.length)return this._items=b.get().map(function(b){return a(b)}),this._mergers=this._items.map(function(){return 1}),void this.refresh();this.replace(this.$element.children().not(this.$stage.parent())),this.isVisible()?this.refresh():this.invalidate("width"),this.$element.removeClass(this.options.loadingClass).addClass(this.options.loadedClass)},e.prototype.initialize=function(){if(this.enter("initializing"),this.trigger("initialize"),this.$element.toggleClass(this.settings.rtlClass,this.settings.rtl),this.settings.autoWidth&&!this.is("pre-loading")){var a,b,c;a=this.$element.find("img"),b=this.settings.nestedItemSelector?"."+this.settings.nestedItemSelector:d,c=this.$element.children(b).width(),a.length&&c<=0&&this.preloadAutoWidthImages(a)}this.initializeStage(),this.initializeItems(),this.registerEventHandlers(),this.leave("initializing"),this.trigger("initialized")},e.prototype.isVisible=function(){return!this.settings.checkVisibility||this.$element.is(":visible")},e.prototype.setup=function(){var b=this.viewport(),c=this.options.responsive,d=-1,e=null;c?(a.each(c,function(a){a<=b&&a>d&&(d=Number(a))}),e=a.extend({},this.options,c[d]),"function"==typeof e.stagePadding&&(e.stagePadding=e.stagePadding()),delete e.responsive,e.responsiveClass&&this.$element.attr("class",this.$element.attr("class").replace(new RegExp("("+this.options.responsiveClass+"-)\\S+\\s","g"),"$1"+d))):e=a.extend({},this.options),this.trigger("change",{property:{name:"settings",value:e}}),this._breakpoint=d,this.settings=e,this.invalidate("settings"),this.trigger("changed",{property:{name:"settings",value:this.settings}})},e.prototype.optionsLogic=function(){this.settings.autoWidth&&(this.settings.stagePadding=!1,this.settings.merge=!1)},e.prototype.prepare=function(b){var c=this.trigger("prepare",{content:b});return c.data||(c.data=a("<"+this.settings.itemElement+"/>").addClass(this.options.itemClass).append(b)),this.trigger("prepared",{content:c.data}),c.data},e.prototype.update=function(){for(var b=0,c=this._pipe.length,d=a.proxy(function(a){return this[a]},this._invalidated),e={};b<c;)(this._invalidated.all||a.grep(this._pipe[b].filter,d).length>0)&&this._pipe[b].run(e),b++;this._invalidated={},!this.is("valid")&&this.enter("valid")},e.prototype.width=function(a){switch(a=a||e.Width.Default){case e.Width.Inner:case e.Width.Outer:return this._width;default:return this._width-2*this.settings.stagePadding+this.settings.margin}},e.prototype.refresh=function(){this.enter("refreshing"),this.trigger("refresh"),this.setup(),this.optionsLogic(),this.$element.addClass(this.options.refreshClass),this.update(),this.$element.removeClass(this.options.refreshClass),this.leave("refreshing"),this.trigger("refreshed")},e.prototype.onThrottledResize=function(){b.clearTimeout(this.resizeTimer),this.resizeTimer=b.setTimeout(this._handlers.onResize,this.settings.responsiveRefreshRate)},e.prototype.onResize=function(){return!!this._items.length&&(this._width!==this.$element.width()&&(!!this.isVisible()&&(this.enter("resizing"),this.trigger("resize").isDefaultPrevented()?(this.leave("resizing"),!1):(this.invalidate("width"),this.refresh(),this.leave("resizing"),void this.trigger("resized")))))},e.prototype.registerEventHandlers=function(){a.support.transition&&this.$stage.on(a.support.transition.end+".owl.core",a.proxy(this.onTransitionEnd,this)),!1!==this.settings.responsive&&this.on(b,"resize",this._handlers.onThrottledResize),this.settings.mouseDrag&&(this.$element.addClass(this.options.dragClass),this.$stage.on("mousedown.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("dragstart.owl.core selectstart.owl.core",function(){return!1})),this.settings.touchDrag&&(this.$stage.on("touchstart.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("touchcancel.owl.core",a.proxy(this.onDragEnd,this)))},e.prototype.onDragStart=function(b){var d=null;3!==b.which&&(a.support.transform?(d=this.$stage.css("transform").replace(/.*\(|\)| /g,"").split(","),d={x:d[16===d.length?12:4],y:d[16===d.length?13:5]}):(d=this.$stage.position(),d={x:this.settings.rtl?d.left+this.$stage.width()-this.width()+this.settings.margin:d.left,y:d.top}),this.is("animating")&&(a.support.transform?this.animate(d.x):this.$stage.stop(),this.invalidate("position")),this.$element.toggleClass(this.options.grabClass,"mousedown"===b.type),this.speed(0),this._drag.time=(new Date).getTime(),this._drag.target=a(b.target),this._drag.stage.start=d,this._drag.stage.current=d,this._drag.pointer=this.pointer(b),a(c).on("mouseup.owl.core touchend.owl.core",a.proxy(this.onDragEnd,this)),a(c).one("mousemove.owl.core touchmove.owl.core",a.proxy(function(b){var d=this.difference(this._drag.pointer,this.pointer(b));a(c).on("mousemove.owl.core touchmove.owl.core",a.proxy(this.onDragMove,this)),Math.abs(d.x)<Math.abs(d.y)&&this.is("valid")||(b.preventDefault(),this.enter("dragging"),this.trigger("drag"))},this)))},e.prototype.onDragMove=function(a){var b=null,c=null,d=null,e=this.difference(this._drag.pointer,this.pointer(a)),f=this.difference(this._drag.stage.start,e);this.is("dragging")&&(a.preventDefault(),this.settings.loop?(b=this.coordinates(this.minimum()),c=this.coordinates(this.maximum()+1)-b,f.x=((f.x-b)%c+c)%c+b):(b=this.settings.rtl?this.coordinates(this.maximum()):this.coordinates(this.minimum()),c=this.settings.rtl?this.coordinates(this.minimum()):this.coordinates(this.maximum()),d=this.settings.pullDrag?-1*e.x/5:0,f.x=Math.max(Math.min(f.x,b+d),c+d)),this._drag.stage.current=f,this.animate(f.x))},e.prototype.onDragEnd=function(b){var d=this.difference(this._drag.pointer,this.pointer(b)),e=this._drag.stage.current,f=d.x>0^this.settings.rtl?"left":"right";a(c).off(".owl.core"),this.$element.removeClass(this.options.grabClass),(0!==d.x&&this.is("dragging")||!this.is("valid"))&&(this.speed(this.settings.dragEndSpeed||this.settings.smartSpeed),this.current(this.closest(e.x,0!==d.x?f:this._drag.direction)),this.invalidate("position"),this.update(),this._drag.direction=f,(Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)&&this._drag.target.one("click.owl.core",function(){return!1})),this.is("dragging")&&(this.leave("dragging"),this.trigger("dragged"))},e.prototype.closest=function(b,c){var e=-1,f=30,g=this.width(),h=this.coordinates();return this.settings.freeDrag||a.each(h,a.proxy(function(a,i){return"left"===c&&b>i-f&&b<i+f?e=a:"right"===c&&b>i-g-f&&b<i-g+f?e=a+1:this.op(b,"<",i)&&this.op(b,">",h[a+1]!==d?h[a+1]:i-g)&&(e="left"===c?a+1:a),-1===e},this)),this.settings.loop||(this.op(b,">",h[this.minimum()])?e=b=this.minimum():this.op(b,"<",h[this.maximum()])&&(e=b=this.maximum())),e},e.prototype.animate=function(b){var c=this.speed()>0;this.is("animating")&&this.onTransitionEnd(),c&&(this.enter("animating"),this.trigger("translate")),a.support.transform3d&&a.support.transition?this.$stage.css({transform:"translate3d("+b+"px,0px,0px)",transition:this.speed()/1e3+"s"+(this.settings.slideTransition?" "+this.settings.slideTransition:"")}):c?this.$stage.animate({left:b+"px"},this.speed(),this.settings.fallbackEasing,a.proxy(this.onTransitionEnd,this)):this.$stage.css({left:b+"px"})},e.prototype.is=function(a){return this._states.current[a]&&this._states.current[a]>0},e.prototype.current=function(a){if(a===d)return this._current;if(0===this._items.length)return d;if(a=this.normalize(a),this._current!==a){var b=this.trigger("change",{property:{name:"position",value:a}});b.data!==d&&(a=this.normalize(b.data)),this._current=a,this.invalidate("position"),this.trigger("changed",{property:{name:"position",value:this._current}})}return this._current},e.prototype.invalidate=function(b){return"string"===a.type(b)&&(this._invalidated[b]=!0,this.is("valid")&&this.leave("valid")),a.map(this._invalidated,function(a,b){return b})},e.prototype.reset=function(a){(a=this.normalize(a))!==d&&(this._speed=0,this._current=a,this.suppress(["translate","translated"]),this.animate(this.coordinates(a)),this.release(["translate","translated"]))},e.prototype.normalize=function(a,b){var c=this._items.length,e=b?0:this._clones.length;return!this.isNumeric(a)||c<1?a=d:(a<0||a>=c+e)&&(a=((a-e/2)%c+c)%c+e/2),a},e.prototype.relative=function(a){return a-=this._clones.length/2,this.normalize(a,!0)},e.prototype.maximum=function(a){var b,c,d,e=this.settings,f=this._coordinates.length;if(e.loop)f=this._clones.length/2+this._items.length-1;else if(e.autoWidth||e.merge){if(b=this._items.length)for(c=this._items[--b].width(),d=this.$element.width();b--&&!((c+=this._items[b].width()+this.settings.margin)>d););f=b+1}else f=e.center?this._items.length-1:this._items.length-e.items;return a&&(f-=this._clones.length/2),Math.max(f,0)},e.prototype.minimum=function(a){return a?0:this._clones.length/2},e.prototype.items=function(a){return a===d?this._items.slice():(a=this.normalize(a,!0),this._items[a])},e.prototype.mergers=function(a){return a===d?this._mergers.slice():(a=this.normalize(a,!0),this._mergers[a])},e.prototype.clones=function(b){var c=this._clones.length/2,e=c+this._items.length,f=function(a){return a%2==0?e+a/2:c-(a+1)/2};return b===d?a.map(this._clones,function(a,b){return f(b)}):a.map(this._clones,function(a,c){return a===b?f(c):null})},e.prototype.speed=function(a){return a!==d&&(this._speed=a),this._speed},e.prototype.coordinates=function(b){var c,e=1,f=b-1;return b===d?a.map(this._coordinates,a.proxy(function(a,b){return this.coordinates(b)},this)):(this.settings.center?(this.settings.rtl&&(e=-1,f=b+1),c=this._coordinates[b],c+=(this.width()-c+(this._coordinates[f]||0))/2*e):c=this._coordinates[f]||0,c=Math.ceil(c))},e.prototype.duration=function(a,b,c){return 0===c?0:Math.min(Math.max(Math.abs(b-a),1),6)*Math.abs(c||this.settings.smartSpeed)},e.prototype.to=function(a,b){var c=this.current(),d=null,e=a-this.relative(c),f=(e>0)-(e<0),g=this._items.length,h=this.minimum(),i=this.maximum();this.settings.loop?(!this.settings.rewind&&Math.abs(e)>g/2&&(e+=-1*f*g),a=c+e,(d=((a-h)%g+g)%g+h)!==a&&d-e<=i&&d-e>0&&(c=d-e,a=d,this.reset(c))):this.settings.rewind?(i+=1,a=(a%i+i)%i):a=Math.max(h,Math.min(i,a)),this.speed(this.duration(c,a,b)),this.current(a),this.isVisible()&&this.update()},e.prototype.next=function(a){a=a||!1,this.to(this.relative(this.current())+1,a)},e.prototype.prev=function(a){a=a||!1,this.to(this.relative(this.current())-1,a)},e.prototype.onTransitionEnd=function(a){if(a!==d&&(a.stopPropagation(),(a.target||a.srcElement||a.originalTarget)!==this.$stage.get(0)))return!1;this.leave("animating"),this.trigger("translated")},e.prototype.viewport=function(){var d;return this.options.responsiveBaseElement!==b?d=a(this.options.responsiveBaseElement).width():b.innerWidth?d=b.innerWidth:c.documentElement&&c.documentElement.clientWidth?d=c.documentElement.clientWidth:console.warn("Can not detect viewport width."),d},e.prototype.replace=function(b){this.$stage.empty(),this._items=[],b&&(b=b instanceof jQuery?b:a(b)),this.settings.nestedItemSelector&&(b=b.find("."+this.settings.nestedItemSelector)),b.filter(function(){return 1===this.nodeType}).each(a.proxy(function(a,b){b=this.prepare(b),this.$stage.append(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)},this)),this.reset(this.isNumeric(this.settings.startPosition)?this.settings.startPosition:0),this.invalidate("items")},e.prototype.add=function(b,c){var e=this.relative(this._current);c=c===d?this._items.length:this.normalize(c,!0),b=b instanceof jQuery?b:a(b),this.trigger("add",{content:b,position:c}),b=this.prepare(b),0===this._items.length||c===this._items.length?(0===this._items.length&&this.$stage.append(b),0!==this._items.length&&this._items[c-1].after(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)):(this._items[c].before(b),this._items.splice(c,0,b),this._mergers.splice(c,0,1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)),this._items[e]&&this.reset(this._items[e].index()),this.invalidate("items"),this.trigger("added",{content:b,position:c})},e.prototype.remove=function(a){(a=this.normalize(a,!0))!==d&&(this.trigger("remove",{content:this._items[a],position:a}),this._items[a].remove(),this._items.splice(a,1),this._mergers.splice(a,1),this.invalidate("items"),this.trigger("removed",{content:null,position:a}))},e.prototype.preloadAutoWidthImages=function(b){b.each(a.proxy(function(b,c){this.enter("pre-loading"),c=a(c),a(new Image).one("load",a.proxy(function(a){c.attr("src",a.target.src),c.css("opacity",1),this.leave("pre-loading"),!this.is("pre-loading")&&!this.is("initializing")&&this.refresh()},this)).attr("src",c.attr("src")||c.attr("data-src")||c.attr("data-src-retina"))},this))},e.prototype.destroy=function(){this.$element.off(".owl.core"),this.$stage.off(".owl.core"),a(c).off(".owl.core"),!1!==this.settings.responsive&&(b.clearTimeout(this.resizeTimer),this.off(b,"resize",this._handlers.onThrottledResize));for(var d in this._plugins)this._plugins[d].destroy();this.$stage.children(".cloned").remove(),this.$stage.unwrap(),this.$stage.children().contents().unwrap(),this.$stage.children().unwrap(),this.$stage.remove(),this.$element.removeClass(this.options.refreshClass).removeClass(this.options.loadingClass).removeClass(this.options.loadedClass).removeClass(this.options.rtlClass).removeClass(this.options.dragClass).removeClass(this.options.grabClass).attr("class",this.$element.attr("class").replace(new RegExp(this.options.responsiveClass+"-\\S+\\s","g"),"")).removeData("owl.carousel")},e.prototype.op=function(a,b,c){var d=this.settings.rtl;switch(b){case"<":return d?a>c:a<c;case">":return d?a<c:a>c;case">=":return d?a<=c:a>=c;case"<=":return d?a>=c:a<=c}},e.prototype.on=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},e.prototype.off=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)},e.prototype.trigger=function(b,c,d,f,g){var h={item:{count:this._items.length,index:this.current()}},i=a.camelCase(a.grep(["on",b,d],function(a){return a}).join("-").toLowerCase()),j=a.Event([b,"owl",d||"carousel"].join(".").toLowerCase(),a.extend({relatedTarget:this},h,c));return this._supress[b]||(a.each(this._plugins,function(a,b){b.onTrigger&&b.onTrigger(j)}),this.register({type:e.Type.Event,name:b}),this.$element.trigger(j),this.settings&&"function"==typeof this.settings[i]&&this.settings[i].call(this,j)),j},e.prototype.enter=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]===d&&(this._states.current[b]=0),this._states.current[b]++},this))},e.prototype.leave=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]--},this))},e.prototype.register=function(b){if(b.type===e.Type.Event){if(a.event.special[b.name]||(a.event.special[b.name]={}),!a.event.special[b.name].owl){var c=a.event.special[b.name]._default;a.event.special[b.name]._default=function(a){return!c||!c.apply||a.namespace&&-1!==a.namespace.indexOf("owl")?a.namespace&&a.namespace.indexOf("owl")>-1:c.apply(this,arguments)},a.event.special[b.name].owl=!0}}else b.type===e.Type.State&&(this._states.tags[b.name]?this._states.tags[b.name]=this._states.tags[b.name].concat(b.tags):this._states.tags[b.name]=b.tags,this._states.tags[b.name]=a.grep(this._states.tags[b.name],a.proxy(function(c,d){return a.inArray(c,this._states.tags[b.name])===d},this)))},e.prototype.suppress=function(b){a.each(b,a.proxy(function(a,b){this._supress[b]=!0},this))},e.prototype.release=function(b){a.each(b,a.proxy(function(a,b){delete this._supress[b]},this))},e.prototype.pointer=function(a){var c={x:null,y:null};return a=a.originalEvent||a||b.event,a=a.touches&&a.touches.length?a.touches[0]:a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:a,a.pageX?(c.x=a.pageX,c.y=a.pageY):(c.x=a.clientX,c.y=a.clientY),c},e.prototype.isNumeric=function(a){return!isNaN(parseFloat(a))},e.prototype.difference=function(a,b){return{x:a.x-b.x,y:a.y-b.y}},a.fn.owlCarousel=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=a(this),f=d.data("owl.carousel");f||(f=new e(this,"object"==typeof b&&b),d.data("owl.carousel",f),a.each(["next","prev","to","destroy","refresh","replace","add","remove"],function(b,c){f.register({type:e.Type.Event,name:c}),f.$element.on(c+".owl.carousel.core",a.proxy(function(a){a.namespace&&a.relatedTarget!==this&&(this.suppress([c]),f[c].apply(this,[].slice.call(arguments,1)),this.release([c]))},f))})),"string"==typeof b&&"_"!==b.charAt(0)&&f[b].apply(f,c)})},a.fn.owlCarousel.Constructor=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._interval=null,this._visible=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoRefresh&&this.watch()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers)};e.Defaults={autoRefresh:!0,autoRefreshInterval:500},e.prototype.watch=function(){this._interval||(this._visible=this._core.isVisible(),this._interval=b.setInterval(a.proxy(this.refresh,this),this._core.settings.autoRefreshInterval))},e.prototype.refresh=function(){this._core.isVisible()!==this._visible&&(this._visible=!this._visible,this._core.$element.toggleClass("owl-hidden",!this._visible),this._visible&&this._core.invalidate("width")&&this._core.refresh())},e.prototype.destroy=function(){var a,c;b.clearInterval(this._interval);for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoRefresh=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._loaded=[],this._handlers={"initialized.owl.carousel change.owl.carousel resized.owl.carousel":a.proxy(function(b){if(b.namespace&&this._core.settings&&this._core.settings.lazyLoad&&(b.property&&"position"==b.property.name||"initialized"==b.type)){var c=this._core.settings,e=c.center&&Math.ceil(c.items/2)||c.items,f=c.center&&-1*e||0,g=(b.property&&b.property.value!==d?b.property.value:this._core.current())+f,h=this._core.clones().length,i=a.proxy(function(a,b){this.load(b)},this);for(c.lazyLoadEager>0&&(e+=c.lazyLoadEager,c.loop&&(g-=c.lazyLoadEager,e++));f++<e;)this.load(h/2+this._core.relative(g)),h&&a.each(this._core.clones(this._core.relative(g)),i),g++}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers)};e.Defaults={lazyLoad:!1,lazyLoadEager:0},e.prototype.load=function(c){var d=this._core.$stage.children().eq(c),e=d&&d.find(".owl-lazy");!e||a.inArray(d.get(0),this._loaded)>-1||(e.each(a.proxy(function(c,d){var e,f=a(d),g=b.devicePixelRatio>1&&f.attr("data-src-retina")||f.attr("data-src")||f.attr("data-srcset");this._core.trigger("load",{element:f,url:g},"lazy"),f.is("img")?f.one("load.owl.lazy",a.proxy(function(){f.css("opacity",1),this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("src",g):f.is("source")?f.one("load.owl.lazy",a.proxy(function(){this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("srcset",g):(e=new Image,e.onload=a.proxy(function(){f.css({"background-image":'url("'+g+'")',opacity:"1"}),this._core.trigger("loaded",{element:f,url:g},"lazy")},this),e.src=g)},this)),this._loaded.push(d.get(0)))},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this._core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Lazy=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(c){this._core=c,this._previousHeight=null,this._handlers={"initialized.owl.carousel refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&this.update()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&"position"===a.property.name&&this.update()},this),"loaded.owl.lazy":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&a.element.closest("."+this._core.settings.itemClass).index()===this._core.current()&&this.update()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._intervalId=null;var d=this;a(b).on("load",function(){d._core.settings.autoHeight&&d.update()}),a(b).resize(function(){d._core.settings.autoHeight&&(null!=d._intervalId&&clearTimeout(d._intervalId),d._intervalId=setTimeout(function(){d.update()},250))})};e.Defaults={autoHeight:!1,autoHeightClass:"owl-height"},e.prototype.update=function(){var b=this._core._current,c=b+this._core.settings.items,d=this._core.settings.lazyLoad,e=this._core.$stage.children().toArray().slice(b,c),f=[],g=0;a.each(e,function(b,c){f.push(a(c).height())}),g=Math.max.apply(null,f),g<=1&&d&&this._previousHeight&&(g=this._previousHeight),this._previousHeight=g,this._core.$stage.parent().height(g).addClass(this._core.settings.autoHeightClass)},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoHeight=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._videos={},this._playing=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.register({type:"state",name:"playing",tags:["interacting"]})},this),"resize.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.video&&this.isInFullScreen()&&a.preventDefault()},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.is("resizing")&&this._core.$stage.find(".cloned .owl-video-frame").remove()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this._playing&&this.stop()},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find(".owl-video");c.length&&(c.css("display","none"),this.fetch(c,a(b.content)))}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._core.$element.on("click.owl.video",".owl-video-play-icon",a.proxy(function(a){this.play(a)},this))};e.Defaults={video:!1,videoHeight:!1,videoWidth:!1},e.prototype.fetch=function(a,b){var c=function(){return a.attr("data-vimeo-id")?"vimeo":a.attr("data-vzaar-id")?"vzaar":"youtube"}(),d=a.attr("data-vimeo-id")||a.attr("data-youtube-id")||a.attr("data-vzaar-id"),e=a.attr("data-width")||this._core.settings.videoWidth,f=a.attr("data-height")||this._core.settings.videoHeight,g=a.attr("href");if(!g)throw new Error("Missing video URL.");if(d=g.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),d[3].indexOf("youtu")>-1)c="youtube";else if(d[3].indexOf("vimeo")>-1)c="vimeo";else{if(!(d[3].indexOf("vzaar")>-1))throw new Error("Video URL not supported.");c="vzaar"}d=d[6],this._videos[g]={type:c,id:d,width:e,height:f},b.attr("data-video",g),this.thumbnail(a,this._videos[g])},e.prototype.thumbnail=function(b,c){var d,e,f,g=c.width&&c.height?"width:"+c.width+"px;height:"+c.height+"px;":"",h=b.find("img"),i="src",j="",k=this._core.settings,l=function(c){e='<div class="owl-video-play-icon"></div>',d=k.lazyLoad?a("<div/>",{class:"owl-video-tn "+j,srcType:c}):a("<div/>",{class:"owl-video-tn",style:"opacity:1;background-image:url("+c+")"}),b.after(d),b.after(e)};if(b.wrap(a("<div/>",{class:"owl-video-wrapper",style:g})),this._core.settings.lazyLoad&&(i="data-src",j="owl-lazy"),h.length)return l(h.attr(i)),h.remove(),!1;"youtube"===c.type?(f="//img.youtube.com/vi/"+c.id+"/hqdefault.jpg",l(f)):"vimeo"===c.type?a.ajax({type:"GET",url:"//vimeo.com/api/v2/video/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a[0].thumbnail_large,l(f)}}):"vzaar"===c.type&&a.ajax({type:"GET",url:"//vzaar.com/api/videos/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a.framegrab_url,l(f)}})},e.prototype.stop=function(){this._core.trigger("stop",null,"video"),this._playing.find(".owl-video-frame").remove(),this._playing.removeClass("owl-video-playing"),this._playing=null,this._core.leave("playing"),this._core.trigger("stopped",null,"video")},e.prototype.play=function(b){var c,d=a(b.target),e=d.closest("."+this._core.settings.itemClass),f=this._videos[e.attr("data-video")],g=f.width||"100%",h=f.height||this._core.$stage.height();this._playing||(this._core.enter("playing"),this._core.trigger("play",null,"video"),e=this._core.items(this._core.relative(e.index())),this._core.reset(e.index()),c=a('<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>'),c.attr("height",h),c.attr("width",g),"youtube"===f.type?c.attr("src","//www.youtube.com/embed/"+f.id+"?autoplay=1&rel=0&v="+f.id):"vimeo"===f.type?c.attr("src","//player.vimeo.com/video/"+f.id+"?autoplay=1"):"vzaar"===f.type&&c.attr("src","//view.vzaar.com/"+f.id+"/player?autoplay=true"),a(c).wrap('<div class="owl-video-frame" />').insertAfter(e.find(".owl-video")),this._playing=e.addClass("owl-video-playing"))},e.prototype.isInFullScreen=function(){var b=c.fullscreenElement||c.mozFullScreenElement||c.webkitFullscreenElement;return b&&a(b).parent().hasClass("owl-video-frame")},e.prototype.destroy=function(){var a,b;this._core.$element.off("click.owl.video");for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Video=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this.core=b,this.core.options=a.extend({},e.Defaults,this.core.options),this.swapping=!0,this.previous=d,this.next=d,this.handlers={"change.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&(this.previous=this.core.current(),this.next=a.property.value)},this),"drag.owl.carousel dragged.owl.carousel translated.owl.carousel":a.proxy(function(a){a.namespace&&(this.swapping="translated"==a.type)},this),"translate.owl.carousel":a.proxy(function(a){a.namespace&&this.swapping&&(this.core.options.animateOut||this.core.options.animateIn)&&this.swap()},this)},this.core.$element.on(this.handlers)};e.Defaults={animateOut:!1,
7
+ animateIn:!1},e.prototype.swap=function(){if(1===this.core.settings.items&&a.support.animation&&a.support.transition){this.core.speed(0);var b,c=a.proxy(this.clear,this),d=this.core.$stage.children().eq(this.previous),e=this.core.$stage.children().eq(this.next),f=this.core.settings.animateIn,g=this.core.settings.animateOut;this.core.current()!==this.previous&&(g&&(b=this.core.coordinates(this.previous)-this.core.coordinates(this.next),d.one(a.support.animation.end,c).css({left:b+"px"}).addClass("animated owl-animated-out").addClass(g)),f&&e.one(a.support.animation.end,c).addClass("animated owl-animated-in").addClass(f))}},e.prototype.clear=function(b){a(b.target).css({left:""}).removeClass("animated owl-animated-out owl-animated-in").removeClass(this.core.settings.animateIn).removeClass(this.core.settings.animateOut),this.core.onTransitionEnd()},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this.core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Animate=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._call=null,this._time=0,this._timeout=0,this._paused=!0,this._handlers={"changed.owl.carousel":a.proxy(function(a){a.namespace&&"settings"===a.property.name?this._core.settings.autoplay?this.play():this.stop():a.namespace&&"position"===a.property.name&&this._paused&&(this._time=0)},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoplay&&this.play()},this),"play.owl.autoplay":a.proxy(function(a,b,c){a.namespace&&this.play(b,c)},this),"stop.owl.autoplay":a.proxy(function(a){a.namespace&&this.stop()},this),"mouseover.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"mouseleave.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.play()},this),"touchstart.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"touchend.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this.play()},this)},this._core.$element.on(this._handlers),this._core.options=a.extend({},e.Defaults,this._core.options)};e.Defaults={autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!1,autoplaySpeed:!1},e.prototype._next=function(d){this._call=b.setTimeout(a.proxy(this._next,this,d),this._timeout*(Math.round(this.read()/this._timeout)+1)-this.read()),this._core.is("interacting")||c.hidden||this._core.next(d||this._core.settings.autoplaySpeed)},e.prototype.read=function(){return(new Date).getTime()-this._time},e.prototype.play=function(c,d){var e;this._core.is("rotating")||this._core.enter("rotating"),c=c||this._core.settings.autoplayTimeout,e=Math.min(this._time%(this._timeout||c),c),this._paused?(this._time=this.read(),this._paused=!1):b.clearTimeout(this._call),this._time+=this.read()%c-e,this._timeout=c,this._call=b.setTimeout(a.proxy(this._next,this,d),c-e)},e.prototype.stop=function(){this._core.is("rotating")&&(this._time=0,this._paused=!0,b.clearTimeout(this._call),this._core.leave("rotating"))},e.prototype.pause=function(){this._core.is("rotating")&&!this._paused&&(this._time=this.read(),this._paused=!0,b.clearTimeout(this._call))},e.prototype.destroy=function(){var a,b;this.stop();for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.autoplay=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(b){this._core=b,this._initialized=!1,this._pages=[],this._controls={},this._templates=[],this.$element=this._core.$element,this._overrides={next:this._core.next,prev:this._core.prev,to:this._core.to},this._handlers={"prepared.owl.carousel":a.proxy(function(b){b.namespace&&this._core.settings.dotsData&&this._templates.push('<div class="'+this._core.settings.dotClass+'">'+a(b.content).find("[data-dot]").addBack("[data-dot]").attr("data-dot")+"</div>")},this),"added.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,0,this._templates.pop())},this),"remove.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,1)},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&this.draw()},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&!this._initialized&&(this._core.trigger("initialize",null,"navigation"),this.initialize(),this.update(),this.draw(),this._initialized=!0,this._core.trigger("initialized",null,"navigation"))},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._initialized&&(this._core.trigger("refresh",null,"navigation"),this.update(),this.draw(),this._core.trigger("refreshed",null,"navigation"))},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers)};e.Defaults={nav:!1,navText:['<span aria-label="Previous">&#x2039;</span>','<span aria-label="Next">&#x203a;</span>'],navSpeed:!1,navElement:'button type="button" role="presentation"',navContainer:!1,navContainerClass:"owl-nav",navClass:["owl-prev","owl-next"],slideBy:1,dotClass:"owl-dot",dotsClass:"owl-dots",dots:!0,dotsEach:!1,dotsData:!1,dotsSpeed:!1,dotsContainer:!1},e.prototype.initialize=function(){var b,c=this._core.settings;this._controls.$relative=(c.navContainer?a(c.navContainer):a("<div>").addClass(c.navContainerClass).appendTo(this.$element)).addClass("disabled"),this._controls.$previous=a("<"+c.navElement+">").addClass(c.navClass[0]).html(c.navText[0]).prependTo(this._controls.$relative).on("click",a.proxy(function(a){this.prev(c.navSpeed)},this)),this._controls.$next=a("<"+c.navElement+">").addClass(c.navClass[1]).html(c.navText[1]).appendTo(this._controls.$relative).on("click",a.proxy(function(a){this.next(c.navSpeed)},this)),c.dotsData||(this._templates=[a('<button role="button">').addClass(c.dotClass).append(a("<span>")).prop("outerHTML")]),this._controls.$absolute=(c.dotsContainer?a(c.dotsContainer):a("<div>").addClass(c.dotsClass).appendTo(this.$element)).addClass("disabled"),this._controls.$absolute.on("click","button",a.proxy(function(b){var d=a(b.target).parent().is(this._controls.$absolute)?a(b.target).index():a(b.target).parent().index();b.preventDefault(),this.to(d,c.dotsSpeed)},this));for(b in this._overrides)this._core[b]=a.proxy(this[b],this)},e.prototype.destroy=function(){var a,b,c,d,e;e=this._core.settings;for(a in this._handlers)this.$element.off(a,this._handlers[a]);for(b in this._controls)"$relative"===b&&e.navContainer?this._controls[b].html(""):this._controls[b].remove();for(d in this.overides)this._core[d]=this._overrides[d];for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},e.prototype.update=function(){var a,b,c,d=this._core.clones().length/2,e=d+this._core.items().length,f=this._core.maximum(!0),g=this._core.settings,h=g.center||g.autoWidth||g.dotsData?1:g.dotsEach||g.items;if("page"!==g.slideBy&&(g.slideBy=Math.min(g.slideBy,g.items)),g.dots||"page"==g.slideBy)for(this._pages=[],a=d,b=0,c=0;a<e;a++){if(b>=h||0===b){if(this._pages.push({start:Math.min(f,a-d),end:a-d+h-1}),Math.min(f,a-d)===f)break;b=0,++c}b+=this._core.mergers(this._core.relative(a))}},e.prototype.draw=function(){var b,c=this._core.settings,d=this._core.items().length<=c.items,e=this._core.relative(this._core.current()),f=c.loop||c.rewind;this._controls.$relative.toggleClass("disabled",!c.nav||d),c.nav&&(this._controls.$previous.toggleClass("disabled",!f&&e<=this._core.minimum(!0)),this._controls.$next.toggleClass("disabled",!f&&e>=this._core.maximum(!0))),this._controls.$absolute.toggleClass("disabled",!c.dots||d),c.dots&&(b=this._pages.length-this._controls.$absolute.children().length,c.dotsData&&0!==b?this._controls.$absolute.html(this._templates.join("")):b>0?this._controls.$absolute.append(new Array(b+1).join(this._templates[0])):b<0&&this._controls.$absolute.children().slice(b).remove(),this._controls.$absolute.find(".active").removeClass("active"),this._controls.$absolute.children().eq(a.inArray(this.current(),this._pages)).addClass("active"))},e.prototype.onTrigger=function(b){var c=this._core.settings;b.page={index:a.inArray(this.current(),this._pages),count:this._pages.length,size:c&&(c.center||c.autoWidth||c.dotsData?1:c.dotsEach||c.items)}},e.prototype.current=function(){var b=this._core.relative(this._core.current());return a.grep(this._pages,a.proxy(function(a,c){return a.start<=b&&a.end>=b},this)).pop()},e.prototype.getPosition=function(b){var c,d,e=this._core.settings;return"page"==e.slideBy?(c=a.inArray(this.current(),this._pages),d=this._pages.length,b?++c:--c,c=this._pages[(c%d+d)%d].start):(c=this._core.relative(this._core.current()),d=this._core.items().length,b?c+=e.slideBy:c-=e.slideBy),c},e.prototype.next=function(b){a.proxy(this._overrides.to,this._core)(this.getPosition(!0),b)},e.prototype.prev=function(b){a.proxy(this._overrides.to,this._core)(this.getPosition(!1),b)},e.prototype.to=function(b,c,d){var e;!d&&this._pages.length?(e=this._pages.length,a.proxy(this._overrides.to,this._core)(this._pages[(b%e+e)%e].start,c)):a.proxy(this._overrides.to,this._core)(b,c)},a.fn.owlCarousel.Constructor.Plugins.Navigation=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(c){this._core=c,this._hashes={},this.$element=this._core.$element,this._handlers={"initialized.owl.carousel":a.proxy(function(c){c.namespace&&"URLHash"===this._core.settings.startPosition&&a(b).trigger("hashchange.owl.navigation")},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find("[data-hash]").addBack("[data-hash]").attr("data-hash");if(!c)return;this._hashes[c]=b.content}},this),"changed.owl.carousel":a.proxy(function(c){if(c.namespace&&"position"===c.property.name){var d=this._core.items(this._core.relative(this._core.current())),e=a.map(this._hashes,function(a,b){return a===d?b:null}).join();if(!e||b.location.hash.slice(1)===e)return;b.location.hash=e}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers),a(b).on("hashchange.owl.navigation",a.proxy(function(a){var c=b.location.hash.substring(1),e=this._core.$stage.children(),f=this._hashes[c]&&e.index(this._hashes[c]);f!==d&&f!==this._core.current()&&this._core.to(this._core.relative(f),!1,!0)},this))};e.Defaults={URLhashListener:!1},e.prototype.destroy=function(){var c,d;a(b).off("hashchange.owl.navigation");for(c in this._handlers)this._core.$element.off(c,this._handlers[c]);for(d in Object.getOwnPropertyNames(this))"function"!=typeof this[d]&&(this[d]=null)},a.fn.owlCarousel.Constructor.Plugins.Hash=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){function e(b,c){var e=!1,f=b.charAt(0).toUpperCase()+b.slice(1);return a.each((b+" "+h.join(f+" ")+f).split(" "),function(a,b){if(g[b]!==d)return e=!c||b,!1}),e}function f(a){return e(a,!0)}var g=a("<support>").get(0).style,h="Webkit Moz O ms".split(" "),i={transition:{end:{WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"}},animation:{end:{WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd",animation:"animationend"}}},j={csstransforms:function(){return!!e("transform")},csstransforms3d:function(){return!!e("perspective")},csstransitions:function(){return!!e("transition")},cssanimations:function(){return!!e("animation")}};j.csstransitions()&&(a.support.transition=new String(f("transition")),a.support.transition.end=i.transition.end[a.support.transition]),j.cssanimations()&&(a.support.animation=new String(f("animation")),a.support.animation.end=i.animation.end[a.support.animation]),j.csstransforms()&&(a.support.transform=new String(f("transform")),a.support.transform3d=j.csstransforms3d())}(window.Zepto||window.jQuery,window,document);
css/unitecreator_styles.css CHANGED
@@ -424,6 +424,10 @@
424
  padding-bottom: 20px;
425
  }
426
 
 
 
 
 
427
  .uc-attr-wrapper.uc-has-cats{
428
  display:flex;
429
  }
424
  padding-bottom: 20px;
425
  }
426
 
427
+ #attr_wrapper_items{
428
+ border-bottom:1px solid
429
+ }
430
+
431
  .uc-attr-wrapper.uc-has-cats{
432
  display:flex;
433
  }
images/no_image_placeholder.jpg ADDED
Binary file
inc_php/framework/font_manager.class.php CHANGED
@@ -28,7 +28,7 @@ class UniteFontManagerUC{
28
  $filename = "fontawesome-all.css";
29
 
30
  $pathCssFile = GlobalsUC::$pathLibrary."font-awesome5/css/{$filename}";
31
-
32
  UniteFunctionsUC::validateFilepath($pathCssFile,"css file");
33
  $content = file_get_contents($pathCssFile);
34
 
@@ -56,6 +56,8 @@ class UniteFontManagerUC{
56
  */
57
  private function fetchIconsFromCss_getArrIconsFromSvg($type){
58
 
 
 
59
  switch($type){
60
 
61
  case "brand":
@@ -67,16 +69,23 @@ class UniteFontManagerUC{
67
  case "solid":
68
  $filename = "fa-solid-900.svg";
69
  break;
 
 
 
 
70
  default:
71
  UniteFunctionsUC::throwError("Wrong icons type: $type");
72
  break;
73
  }
74
 
 
 
75
 
76
- $pathCssFile = GlobalsUC::$pathLibrary."font-awesome5/css/{$filename}";
77
  UniteFunctionsUC::validateFilepath($pathCssFile,"css file");
78
  $content = file_get_contents($pathCssFile);
79
 
 
80
  $arrLines = explode("\n", $content);
81
  $arrIcons = array();
82
 
@@ -102,7 +111,6 @@ class UniteFontManagerUC{
102
  $arrIcons[$icon] = true;
103
  }
104
 
105
-
106
  return($arrIcons);
107
  }
108
 
@@ -139,7 +147,7 @@ class UniteFontManagerUC{
139
  private function fetchIconsFromCss(){
140
 
141
  $arrIcons = $this->fetchIconsFromCss_getArrIcons();
142
-
143
  $arrBrandIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("brand");
144
  $arrRegularIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("regular");
145
  $arrSolidIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("solid");
@@ -179,6 +187,21 @@ class UniteFontManagerUC{
179
  $this->printIcons($arrAllIcons);
180
  }
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
  /**
184
  * fetch font awsome icons array from site
@@ -257,6 +280,18 @@ class UniteFontManagerUC{
257
  return($jsonIconsFA5);
258
  }
259
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  /**
262
  * get brand icons
@@ -424,7 +459,9 @@ class UniteFontManagerUC{
424
  */
425
  public function fetchIcons(){
426
 
427
- $this->fetchIconsFromCss();
 
 
428
 
429
  }
430
 
28
  $filename = "fontawesome-all.css";
29
 
30
  $pathCssFile = GlobalsUC::$pathLibrary."font-awesome5/css/{$filename}";
31
+
32
  UniteFunctionsUC::validateFilepath($pathCssFile,"css file");
33
  $content = file_get_contents($pathCssFile);
34
 
56
  */
57
  private function fetchIconsFromCss_getArrIconsFromSvg($type){
58
 
59
+ $pathCssFile = null;
60
+
61
  switch($type){
62
 
63
  case "brand":
69
  case "solid":
70
  $filename = "fa-solid-900.svg";
71
  break;
72
+ case "eicons":
73
+
74
+ $pathCssFile = GlobalsUC::$path_base."wp-content/plugins/elementor/assets/lib/eicons/fonts/eicons.svg";
75
+ break;
76
  default:
77
  UniteFunctionsUC::throwError("Wrong icons type: $type");
78
  break;
79
  }
80
 
81
+ if(empty($pathCssFile))
82
+ $pathCssFile = GlobalsUC::$pathLibrary."font-awesome5/css/{$filename}";
83
 
84
+
85
  UniteFunctionsUC::validateFilepath($pathCssFile,"css file");
86
  $content = file_get_contents($pathCssFile);
87
 
88
+
89
  $arrLines = explode("\n", $content);
90
  $arrIcons = array();
91
 
111
  $arrIcons[$icon] = true;
112
  }
113
 
 
114
  return($arrIcons);
115
  }
116
 
147
  private function fetchIconsFromCss(){
148
 
149
  $arrIcons = $this->fetchIconsFromCss_getArrIcons();
150
+
151
  $arrBrandIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("brand");
152
  $arrRegularIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("regular");
153
  $arrSolidIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("solid");
187
  $this->printIcons($arrAllIcons);
188
  }
189
 
190
+ /**
191
+ * print elementor icons
192
+ */
193
+ private function printElementorIcons(){
194
+
195
+ $arrIcons = $this->fetchIconsFromCss_getArrIconsFromSvg("eicons");
196
+
197
+ $output = array();
198
+
199
+ foreach($arrIcons as $key=>$stam)
200
+ $output[] = "eicon-".$key;
201
+
202
+ $this->printIcons($output);
203
+
204
+ }
205
 
206
  /**
207
  * fetch font awsome icons array from site
280
  return($jsonIconsFA5);
281
  }
282
 
283
+ /**
284
+ * get elementor icons
285
+ */
286
+ public static function elementor_getJsonIcons(){
287
+
288
+ if(!defined("ELEMENTOR_VERSION"))
289
+ return('[]');
290
+
291
+ $jsonIconsElementor = '["eicon-editor-link","eicon-editor-unlink","eicon-editor-external-link","eicon-editor-close","eicon-editor-list-ol","eicon-editor-list-ul","eicon-editor-bold","eicon-editor-italic","eicon-editor-underline","eicon-editor-paragraph","eicon-editor-h1","eicon-editor-h2","eicon-editor-h3","eicon-editor-h4","eicon-editor-h5","eicon-editor-h6","eicon-editor-quote","eicon-editor-code","eicon-elementor","eicon-elementor-circle","eicon-pojome","eicon-plus","eicon-menu-bar","eicon-apps","eicon-accordion","eicon-alert","eicon-animation-text","eicon-animation","eicon-banner","eicon-blockquote","eicon-button","eicon-call-to-action","eicon-captcha","eicon-carousel","eicon-checkbox","eicon-columns","eicon-countdown","eicon-counter","eicon-date","eicon-divider-shape","eicon-divider","eicon-download-button","eicon-dual-button","eicon-email-field","eicon-facebook-comments","eicon-facebook-like-box","eicon-form-horizontal","eicon-form-vertical","eicon-gallery-grid","eicon-gallery-group","eicon-gallery-justified","eicon-gallery-masonry","eicon-icon-box","eicon-image-before-after","eicon-image-box","eicon-image-hotspot","eicon-image-rollover","eicon-info-box","eicon-inner-section","eicon-mailchimp","eicon-menu-card","eicon-navigation-horizontal","eicon-nav-menu","eicon-navigation-vertical","eicon-number-field","eicon-parallax","eicon-php7","eicon-post-list","eicon-post-slider","eicon-post","eicon-posts-carousel","eicon-posts-grid","eicon-posts-group","eicon-posts-justified","eicon-posts-masonry","eicon-posts-ticker","eicon-price-list","eicon-price-table","eicon-radio","eicon-rtl","eicon-scroll","eicon-search","eicon-select","eicon-share","eicon-sidebar","eicon-skill-bar","eicon-slider-3d","eicon-slider-album","eicon-slider-device","eicon-slider-full-screen","eicon-slider-push","eicon-slider-vertical","eicon-slider-video","eicon-slides","eicon-social-icons","eicon-spacer","eicon-table","eicon-tabs","eicon-tel-field","eicon-text-area","eicon-text-field","eicon-thumbnails-down","eicon-thumbnails-half","eicon-thumbnails-right","eicon-time-line","eicon-toggle","eicon-url","eicon-t-letter","eicon-wordpress","eicon-text","eicon-anchor","eicon-bullet-list","eicon-code","eicon-favorite","eicon-google-maps","eicon-image","eicon-photo-library","eicon-woocommerce","eicon-youtube","eicon-flip-box","eicon-settings","eicon-headphones","eicon-testimonial","eicon-counter-circle","eicon-person","eicon-chevron-right","eicon-chevron-left","eicon-close","eicon-file-download","eicon-save","eicon-zoom-in","eicon-shortcode","eicon-nerd","eicon-device-desktop","eicon-device-tablet","eicon-device-mobile","eicon-document-file","eicon-folder-o","eicon-hypster","eicon-h-align-left","eicon-h-align-right","eicon-h-align-center","eicon-h-align-stretch","eicon-v-align-top","eicon-v-align-bottom","eicon-v-align-middle","eicon-v-align-stretch","eicon-pro-icon","eicon-mail","eicon-lock-user","eicon-testimonial-carousel","eicon-media-carousel","eicon-section","eicon-column","eicon-edit","eicon-clone","eicon-trash","eicon-play","eicon-angle-right","eicon-angle-left","eicon-animated-headline","eicon-menu-toggle","eicon-fb-embed","eicon-fb-feed","eicon-twitter-embed","eicon-twitter-feed","eicon-sync","eicon-import-export","eicon-check-circle","eicon-library-save","eicon-library-download","eicon-insert","eicon-preview-medium","eicon-sort-down","eicon-sort-up","eicon-heading","eicon-logo","eicon-meta-data","eicon-post-content","eicon-post-excerpt","eicon-post-navigation","eicon-yoast","eicon-nerd-chuckle","eicon-nerd-wink","eicon-comments","eicon-download-circle-o","eicon-library-upload","eicon-save-o","eicon-upload-circle-o","eicon-ellipsis-h","eicon-ellipsis-v","eicon-arrow-left","eicon-arrow-right","eicon-arrow-up","eicon-arrow-down","eicon-play-o","eicon-archive-posts","eicon-archive-title","eicon-featured-image","eicon-post-info","eicon-post-title","eicon-site-logo","eicon-site-search","eicon-site-title","eicon-plus-square","eicon-minus-square","eicon-cloud-check","eicon-drag-n-drop","eicon-welcome","eicon-handle","eicon-cart","eicon-product-add-to-cart","eicon-product-breadcrumbs","eicon-product-categories","eicon-product-description","eicon-product-images","eicon-product-info","eicon-product-meta","eicon-product-pages","eicon-product-price","eicon-product-rating","eicon-product-related","eicon-product-stock","eicon-product-tabs","eicon-product-title","eicon-product-upsell","eicon-products","eicon-bag-light","eicon-bag-medium","eicon-bag-solid","eicon-basket-light","eicon-basket-medium","eicon-basket-solid","eicon-cart-light","eicon-cart-medium","eicon-cart-solid","eicon-exchange","eicon-preview-thin","eicon-device-laptop","eicon-collapse","eicon-expand","eicon-navigator","eicon-plug","eicon-dashboard","eicon-typography","eicon-info-circle-o","eicon-integration","eicon-plus-circle-o","eicon-rating","eicon-review","eicon-tools","eicon-loading","eicon-sitemap","eicon-click","eicon-clock","eicon-library-open","eicon-warning","eicon-flow","eicon-cursor-move","eicon-arrow-circle-left","eicon-flash","eicon-redo","eicon-ban","eicon-barcode","eicon-calendar","eicon-caret-left","eicon-caret-right","eicon-caret-up","eicon-chain-broken","eicon-check-circle-o","eicon-check","eicon-chevron-double-left","eicon-chevron-double-right","eicon-undo","eicon-filter","eicon-circle-o","eicon-circle","eicon-clock-o","eicon-cog","eicon-cogs","eicon-commenting-o","eicon-copy","eicon-database","eicon-dot-circle-o","eicon-envelope","eicon-external-link-square","eicon-eyedropper","eicon-folder","eicon-font","eicon-adjust","eicon-lightbox","eicon-heart-o","eicon-history","eicon-image-bold","eicon-info-circle","eicon-link","eicon-long-arrow-left","eicon-long-arrow-right","eicon-caret-down","eicon-paint-brush","eicon-pencil","eicon-plus-circle","eicon-zoom-in-bold","eicon-sort-amount-desc","eicon-sign-out","eicon-spinner","eicon-square","eicon-star-o","eicon-star","eicon-text-align-justify","eicon-text-align-center","eicon-tags","eicon-text-align-left","eicon-text-align-right","eicon-close-circle","eicon-trash-o","eicon-font-awesome","eicon-user-circle-o","eicon-video-camera","eicon-heart","eicon-wrench","eicon-help","eicon-help-o","eicon-zoom-out-bold","eicon-plus-square-o","eicon-minus-square-o","eicon-minus-circle","eicon-minus-circle-o","eicon-code-bold","eicon-cloud-upload","eicon-search-bold","eicon-map-pin","eicon-meetup","eicon-slideshow","eicon-t-letter-bold","eicon-preferences","eicon-table-of-contents","eicon-tv","eicon-upload","eicon-instagram-comments","eicon-instagram-nested-gallery","eicon-instagram-post","eicon-instagram-video","eicon-instagram-gallery","eicon-instagram-likes","eicon-facebook","eicon-twitter","eicon-pinterest","eicon-frame-expand","eicon-frame-minimize","eicon-archive","eicon-colors-typography","eicon-custom","eicon-footer","eicon-header","eicon-layout-settings","eicon-lightbox-expand","eicon-error-404","eicon-theme-style","eicon-search-results","eicon-single-post","eicon-site-identity","eicon-theme-builder","eicon-download-bold","eicon-share-arrow","eicon-global-settings","eicon-user-preferences","eicon-lock","eicon-export-kit","eicon-import-kit","eicon-lottie","eicon-products-archive","eicon-single-product","eicon-disable-trash-o","eicon-single-page","eicon-wordpress-light","eicon-cogs-check","eicon-custom-css","eicon-global-colors","eicon-globe","eicon-typography-1","eicon-background","eicon-device-responsive","eicon-device-wide","eicon-code-highlight","eicon-video-playlist","eicon-download-kit","eicon-kit-details","eicon-kit-parts","eicon-kit-upload","eicon-kit-plugins","eicon-kit-upload-alt","eicon-hotspot","eicon-paypal-button","eicon-shape","eicon-wordart","eicon-checkout","eicon-container","eicon-flip","eicon-info","eicon-my-account","eicon-purchase-summary","eicon-page-transition","eicon-spotify","eicon-stripe-button","eicon-woo-settings","eicon-woo-cart"]';
292
+
293
+ return($jsonIconsElementor);
294
+ }
295
 
296
  /**
297
  * get brand icons
459
  */
460
  public function fetchIcons(){
461
 
462
+ $this->printElementorIcons();
463
+
464
+ //$this->fetchIconsFromCss();
465
 
466
  }
467
 
inc_php/framework/functions.class.php CHANGED
@@ -1470,7 +1470,7 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1470
  /**
1471
  * get base url from any url
1472
  */
1473
- public static function getBaseUrl($url){
1474
 
1475
  $arrUrl = parse_url($url);
1476
 
@@ -1480,9 +1480,50 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1480
 
1481
  $url = "{$scheme}://{$host}{$path}";
1482
 
 
 
 
 
 
 
 
 
 
1483
  return($url);
1484
  }
1485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1486
 
1487
  public static function z___________VALIDATIONS_________(){}
1488
 
1470
  /**
1471
  * get base url from any url
1472
  */
1473
+ public static function getBaseUrl($url, $stripPagination = false){
1474
 
1475
  $arrUrl = parse_url($url);
1476
 
1480
 
1481
  $url = "{$scheme}://{$host}{$path}";
1482
 
1483
+ if($stripPagination == true){
1484
+
1485
+ //strip pagination
1486
+ if(strpos($url, "/page/") !== false){
1487
+ $numPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
1488
+ $url = str_replace("/page/$numPage/", "/", $url);
1489
+ }
1490
+ }
1491
+
1492
  return($url);
1493
  }
1494
 
1495
+ /**
1496
+ * get links from some content
1497
+ */
1498
+ public static function parseHTMLGetLinks($html){
1499
+
1500
+ $htmlDom = new DOMDocument;
1501
+
1502
+ @$htmlDom->loadHTML($html);
1503
+
1504
+ $links = $htmlDom->getElementsByTagName('a');
1505
+
1506
+ if(empty($links))
1507
+ return(array());
1508
+
1509
+ if($links->length == 0)
1510
+ return(array());
1511
+
1512
+ $arrLinks = array();
1513
+ foreach($links as $link){
1514
+
1515
+ $linkHref = $link->getAttribute('href');
1516
+ if(strlen(trim($linkHref)) == 0)
1517
+ continue;
1518
+ if($linkHref[0] == '#')
1519
+ continue;
1520
+
1521
+ $arrLinks[] = $linkHref;
1522
+ }
1523
+
1524
+ return($arrLinks);
1525
+ }
1526
+
1527
 
1528
  public static function z___________VALIDATIONS_________(){}
1529
 
inc_php/framework/settings.class.php CHANGED
@@ -1170,8 +1170,12 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1170
  $visibility = (string)UniteFunctionsUC::getVal($attribs, "visibility");
1171
 
1172
  $isForceShow = false;
1173
- if($sapName == "copy_paste_mode" && defined("UC_ENABLE_COPYPASTE"))
 
 
 
1174
  $isForceShow = true;
 
1175
 
1176
  if($visibility == "dev" && GlobalsUC::$inDev == false && $isForceShow == false)
1177
  continue;
1170
  $visibility = (string)UniteFunctionsUC::getVal($attribs, "visibility");
1171
 
1172
  $isForceShow = false;
1173
+
1174
+ /*
1175
+ * //demo for show setting
1176
+ if($sapName == "my_setting" && defined("UC_ENABLE_COPYPASTE"))
1177
  $isForceShow = true;
1178
+ */
1179
 
1180
  if($visibility == "dev" && GlobalsUC::$inDev == false && $isForceShow == false)
1181
  continue;
inc_php/unitecreator_actions.class.php CHANGED
@@ -77,12 +77,12 @@ class UniteCreatorActions{
77
 
78
  //check front actions
79
  switch($action){
80
- case "get_section_zip":
81
- case "paste_section_front":
82
-
83
  $this->onAjaxFrontAction();
84
  exit();
85
  break;
 
86
  }
87
 
88
  $operations = new ProviderOperationsUC();
@@ -106,11 +106,12 @@ class UniteCreatorActions{
106
 
107
 
108
  try{
109
-
110
  if(method_exists("UniteProviderFunctionsUC", "verifyNonce")){
111
  $nonce = UniteFunctionsUC::getPostGetVariable("nonce","",UniteFunctionsUC::SANITIZE_NOTHING);
112
  UniteProviderFunctionsUC::verifyNonce($nonce);
113
  }
 
114
  switch($action){
115
 
116
  case "remove_category":
@@ -272,6 +273,7 @@ class UniteCreatorActions{
272
  HelperUC::ajaxResponseSuccess(esc_html__("Test data deleted","unlimited-elements-for-elementor"));
273
  break;
274
  case "export_addon":
 
275
  $addons->exportAddon($data);
276
  exit();
277
  break;
@@ -536,28 +538,7 @@ class UniteCreatorActions{
536
 
537
  try{
538
 
539
- switch($action){
540
- case "get_section_zip":
541
-
542
- $objCopyPaste = new UniteCreatorElementorCopyPaste();
543
- $rawData = $objCopyPaste->getSectionZipFromData($data);
544
-
545
- echo $rawData;
546
- exit();
547
- break;
548
- case "paste_section_front":
549
-
550
- $objCopyPaste = new UniteCreatorElementorCopyPaste();
551
- $success = $objCopyPaste->pasteSectionAjaxAction($data);
552
-
553
- HelperUC::ajaxResponseSuccess("Section Pasted");
554
-
555
- break;
556
- default:
557
-
558
- HelperUC::ajaxResponseError("wrong ajax action: <b>$action</b> ");
559
- break;
560
- }
561
 
562
  }
563
  catch(Exception $e){
77
 
78
  //check front actions
79
  switch($action){
80
+ /*
81
+ case "get_filters_data":
 
82
  $this->onAjaxFrontAction();
83
  exit();
84
  break;
85
+ */
86
  }
87
 
88
  $operations = new ProviderOperationsUC();
106
 
107
 
108
  try{
109
+
110
  if(method_exists("UniteProviderFunctionsUC", "verifyNonce")){
111
  $nonce = UniteFunctionsUC::getPostGetVariable("nonce","",UniteFunctionsUC::SANITIZE_NOTHING);
112
  UniteProviderFunctionsUC::verifyNonce($nonce);
113
  }
114
+
115
  switch($action){
116
 
117
  case "remove_category":
273
  HelperUC::ajaxResponseSuccess(esc_html__("Test data deleted","unlimited-elements-for-elementor"));
274
  break;
275
  case "export_addon":
276
+
277
  $addons->exportAddon($data);
278
  exit();
279
  break;
538
 
539
  try{
540
 
541
+ //switch($action){}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
 
543
  }
544
  catch(Exception $e){
inc_php/unitecreator_addon.class.php CHANGED
@@ -1616,7 +1616,7 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1616
  $arrCssIncludes = array();
1617
 
1618
  $objLibrary = new UniteCreatorLibrary();
1619
-
1620
  foreach($this->includesJSLib as $libName){
1621
 
1622
  //process provider library instead of get files
@@ -1628,7 +1628,7 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1628
  }
1629
 
1630
  $response = $objLibrary->getLibraryIncludes($libName);
1631
-
1632
  $arrJs = $response["js"];
1633
  $arrCss = $response["css"];
1634
  $arrJsIncludes = array_merge($arrJsIncludes, $arrJs);
@@ -2118,8 +2118,8 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2118
  $this->validateInited();
2119
 
2120
  if(empty($arrValues))
2121
- return($arrParams);
2122
-
2123
  if(!is_array($arrValues))
2124
  UniteFunctionsUC::throwError("The values shoud be array");
2125
 
@@ -2186,7 +2186,11 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2186
  */
2187
  public function setParamsValues($arrValues){
2188
 
 
 
 
2189
  $this->params = $this->setParamsValuesWork($arrValues, $this->params, "main");
 
2190
  }
2191
 
2192
  /**
1616
  $arrCssIncludes = array();
1617
 
1618
  $objLibrary = new UniteCreatorLibrary();
1619
+
1620
  foreach($this->includesJSLib as $libName){
1621
 
1622
  //process provider library instead of get files
1628
  }
1629
 
1630
  $response = $objLibrary->getLibraryIncludes($libName);
1631
+
1632
  $arrJs = $response["js"];
1633
  $arrCss = $response["css"];
1634
  $arrJsIncludes = array_merge($arrJsIncludes, $arrJs);
2118
  $this->validateInited();
2119
 
2120
  if(empty($arrValues))
2121
+ $arrValues = array();
2122
+
2123
  if(!is_array($arrValues))
2124
  UniteFunctionsUC::throwError("The values shoud be array");
2125
 
2186
  */
2187
  public function setParamsValues($arrValues){
2188
 
2189
+ if(empty($arrValues))
2190
+ $arrValues = array();
2191
+
2192
  $this->params = $this->setParamsValuesWork($arrValues, $this->params, "main");
2193
+
2194
  }
2195
 
2196
  /**
inc_php/unitecreator_addons.class.php CHANGED
@@ -1252,13 +1252,11 @@ class UniteCreatorAddons extends UniteElementsBaseUC{
1252
  $objAddon->initByName($addonName);
1253
  }
1254
 
1255
- if(is_array($arrConfig)){
1256
- $objAddon->setParamsValues($arrConfig);
1257
- }
1258
 
1259
  if(is_array($arrItemsData))
1260
  $objAddon->setArrItems($arrItemsData);
1261
-
1262
  if(!empty($arrFonts) && is_array($arrFonts))
1263
  $objAddon->setArrFonts($arrFonts);
1264
 
@@ -1279,7 +1277,7 @@ class UniteCreatorAddons extends UniteElementsBaseUC{
1279
  try{
1280
 
1281
  $objAddon = $this->initAddonByData($data);
1282
-
1283
  $objOutput = new UniteCreatorOutput();
1284
  $objOutput->setPreviewAddonMode();
1285
 
1252
  $objAddon->initByName($addonName);
1253
  }
1254
 
1255
+ $objAddon->setParamsValues($arrConfig);
 
 
1256
 
1257
  if(is_array($arrItemsData))
1258
  $objAddon->setArrItems($arrItemsData);
1259
+
1260
  if(!empty($arrFonts) && is_array($arrFonts))
1261
  $objAddon->setArrFonts($arrFonts);
1262
 
1277
  try{
1278
 
1279
  $objAddon = $this->initAddonByData($data);
1280
+
1281
  $objOutput = new UniteCreatorOutput();
1282
  $objOutput->setPreviewAddonMode();
1283
 
inc_php/unitecreator_dialog_param.class.php CHANGED
@@ -22,6 +22,7 @@ class UniteCreatorDialogParamWork{
22
  const PARAM_DROPDOWN = "uc_dropdown";
23
  const PARAM_MULTIPLE_SELECT = "uc_multiple_select";
24
  const PARAM_HR = "uc_hr";
 
25
  const PARAM_CONTENT = "uc_content";
26
  const PARAM_POST = "uc_post";
27
  const PARAM_DATASET = "uc_dataset";
@@ -64,9 +65,10 @@ class UniteCreatorDialogParamWork{
64
  const PARAM_BORDER_DIMENTIONS = "uc_border_dimentions";
65
  const PARAM_CSS_FILTERS = "uc_css_filters";
66
  const PARAM_HOVER_ANIMATIONS = "uc_hover_animations";
 
67
 
68
  const PARAM_VAR_GET = "uc_var_get";
69
-
70
 
71
  protected $addon, $objSettings, $objDatasets, $addonType;
72
  private $type;
@@ -174,8 +176,9 @@ class UniteCreatorDialogParamWork{
174
  $this->addParam(self::PARAM_MULTIPLE_SELECT, esc_html__("Multiple Select", "unlimited-elements-for-elementor"));
175
  $this->addParam(self::PARAM_COLORPICKER, esc_html__("Color Picker", "unlimited-elements-for-elementor"));
176
  $this->addParam(self::PARAM_LINK, esc_html__("Link", "unlimited-elements-for-elementor"));
177
- $this->addParam(self::PARAM_IMAGE, esc_html__("Image", "unlimited-elements-for-elementor"));
178
  $this->addParam(self::PARAM_HR, esc_html__("HR Line", "unlimited-elements-for-elementor"));
 
179
  $this->addParam(self::PARAM_FONT_OVERRIDE, esc_html__("Font Override", "unlimited-elements-for-elementor"));
180
  $this->addParam(self::PARAM_ADDONPICKER, esc_html__("Addon Picker", "unlimited-elements-for-elementor"));
181
 
@@ -203,6 +206,8 @@ class UniteCreatorDialogParamWork{
203
  $this->addParam("uc_varitem_simple", esc_html__("Simple Variable", "unlimited-elements-for-elementor"));
204
  $this->addParam("uc_var_paramrelated", esc_html__("Attribute Related", "unlimited-elements-for-elementor"));
205
  $this->addParam("uc_var_paramitemrelated", esc_html__("Item Attribute Related", "unlimited-elements-for-elementor"));
 
 
206
  $this->addParam(self::PARAM_VAR_GET, esc_html__("GET Param", "unlimited-elements-for-elementor"));
207
  $this->addParam(self::PARAM_TYPOGRAPHY, esc_html__("Typography", "unlimited-elements-for-elementor"));
208
  $this->addParam(self::PARAM_MARGINS, esc_html__("Margins", "unlimited-elements-for-elementor"));
@@ -219,6 +224,8 @@ class UniteCreatorDialogParamWork{
219
  $this->addParam(self::PARAM_CSS_FILTERS, esc_html__("Css Filters", "unlimited-elements-for-elementor"));
220
  $this->addParam(self::PARAM_HOVER_ANIMATIONS, esc_html__("Hover Animations", "unlimited-elements-for-elementor"));
221
 
 
 
222
  }
223
 
224
 
@@ -368,7 +375,7 @@ class UniteCreatorDialogParamWork{
368
  /**
369
  * put default value param in params dialog
370
  */
371
- protected function putDefaultValueParam($isTextarea = false, $class="", $addStyleChekbox = false){
372
 
373
  //disable in form item mode
374
  $putTextareaText = true;
@@ -377,14 +384,21 @@ class UniteCreatorDialogParamWork{
377
  $addStyleChekbox = false;
378
  $putTextareaText = false;
379
  }
380
-
 
 
 
 
 
 
 
381
  $strClass = "";
382
  if(!empty($class))
383
  $strClass = "class='{$class}'";
384
-
385
  ?>
386
  <div class="unite-inputs-label">
387
- <?php esc_html_e("Default Value", "unlimited-elements-for-elementor")?>:
388
  </div>
389
 
390
  <?php if($isTextarea == false):?>
@@ -552,20 +566,54 @@ class UniteCreatorDialogParamWork{
552
  <?php
553
  }
554
 
 
555
  /**
556
  * put image param settings
557
  */
558
  private function putImageParam(){
559
 
 
 
 
 
 
 
560
  ?>
 
 
561
  <div class="unite-inputs-sap"></div>
562
-
563
- <?php $this->putImageSelectInput("default_value",esc_html__("Default Image","unlimited-elements-for-elementor")); ?>
564
 
565
  <div class="unite-inputs-sap-double"></div>
566
 
567
- <?php $this->putCheckbox("add_image_sizes", __("Add Image Size Select","unlimited-elements-for-elementor"))?>
568
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  <?php
570
  }
571
 
@@ -844,6 +892,12 @@ class UniteCreatorDialogParamWork{
844
  $this->putCheckbox("is_filterable", __("Enable Filterable Options", "unlimited-elements-for-elementor"));
845
  ?>
846
  <?php endif?>
 
 
 
 
 
 
847
 
848
  <div class="vert_sap10"></div>
849
 
@@ -932,6 +986,18 @@ class UniteCreatorDialogParamWork{
932
  exit();
933
  }
934
 
 
 
 
 
 
 
 
 
 
 
 
 
935
 
936
  private function a___________DROPDOWN_PARAM________(){}
937
 
@@ -1202,6 +1268,32 @@ class UniteCreatorDialogParamWork{
1202
 
1203
  }
1204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1205
 
1206
  /**
1207
  * put param content
@@ -1287,6 +1379,9 @@ class UniteCreatorDialogParamWork{
1287
  case self::PARAM_HR:
1288
  $this->putNoDefaultValueText();
1289
  break;
 
 
 
1290
  case self::PARAM_FONT_OVERRIDE:
1291
  $text = esc_html__("Use this font override in css tab using special function", "unlimited-elements-for-elementor");
1292
  $this->putNoDefaultValueText($text);
@@ -1301,6 +1396,9 @@ class UniteCreatorDialogParamWork{
1301
  case "uc_var_paramitemrelated":
1302
  $this->putParamsRelatedFields("item");
1303
  break;
 
 
 
1304
  case self::PARAM_MENU:
1305
  $this->putMenuParam();
1306
  break;
@@ -1343,6 +1441,9 @@ class UniteCreatorDialogParamWork{
1343
  case self::PARAM_HOVER_ANIMATIONS:
1344
  $this->putHoverAnimations();
1345
  break;
 
 
 
1346
  case self::PARAM_VAR_GET:
1347
  $this->putGetParamFields();
1348
  break;
@@ -1435,6 +1536,8 @@ class UniteCreatorDialogParamWork{
1435
  $checkboxID = "uc_dialog_left_condition_".$this->type;
1436
  $tableID = "uc_dialog_left_condition_table".$this->type;
1437
 
 
 
1438
  ?>
1439
 
1440
  <div class="unite-inputs-sap"></div>
@@ -1482,6 +1585,14 @@ class UniteCreatorDialogParamWork{
1482
 
1483
  </div>
1484
 
 
 
 
 
 
 
 
 
1485
  <?php
1486
  }
1487
 
@@ -1669,6 +1780,7 @@ class UniteCreatorDialogParamWork{
1669
  self::PARAM_LINK,
1670
  self::PARAM_EDITOR,
1671
  self::PARAM_HR,
 
1672
  self::PARAM_IMAGE,
1673
  self::PARAM_AUDIO,
1674
  self::PARAM_ICON,
@@ -1705,6 +1817,7 @@ class UniteCreatorDialogParamWork{
1705
  self::PARAM_LINK,
1706
  self::PARAM_EDITOR,
1707
  self::PARAM_HR,
 
1708
  self::PARAM_IMAGE,
1709
  self::PARAM_AUDIO,
1710
  self::PARAM_ICON,
@@ -1724,7 +1837,7 @@ class UniteCreatorDialogParamWork{
1724
 
1725
  $this->option_putAdminLabel = false;
1726
  $this->option_putTitle = false;
1727
- $this->option_arrTexts["add_title"] = esc_html__("Add Item Variable","unlimited-elements-for-elementor");
1728
  $this->option_arrTexts["add_button"] = esc_html__("Add Variable","unlimited-elements-for-elementor");
1729
  $this->option_arrTexts["update_button"] = esc_html__("Update Variable","unlimited-elements-for-elementor");
1730
  $this->option_arrTexts["edit_title"] = esc_html__("Edit Variable","unlimited-elements-for-elementor");
@@ -1740,8 +1853,10 @@ class UniteCreatorDialogParamWork{
1740
  $this->initVariableCommon();
1741
 
1742
  $this->arrParams = array(
 
1743
  "uc_var_paramrelated",
1744
- self::PARAM_VAR_GET
 
1745
  );
1746
 
1747
  }
22
  const PARAM_DROPDOWN = "uc_dropdown";
23
  const PARAM_MULTIPLE_SELECT = "uc_multiple_select";
24
  const PARAM_HR = "uc_hr";
25
+ const PARAM_HEADING = "uc_heading";
26
  const PARAM_CONTENT = "uc_content";
27
  const PARAM_POST = "uc_post";
28
  const PARAM_DATASET = "uc_dataset";
65
  const PARAM_BORDER_DIMENTIONS = "uc_border_dimentions";
66
  const PARAM_CSS_FILTERS = "uc_css_filters";
67
  const PARAM_HOVER_ANIMATIONS = "uc_hover_animations";
68
+ const PARAM_SPECIAL = "uc_special";
69
 
70
  const PARAM_VAR_GET = "uc_var_get";
71
+ const PARAM_VAR_FILTER = "uc_var_filter";
72
 
73
  protected $addon, $objSettings, $objDatasets, $addonType;
74
  private $type;
176
  $this->addParam(self::PARAM_MULTIPLE_SELECT, esc_html__("Multiple Select", "unlimited-elements-for-elementor"));
177
  $this->addParam(self::PARAM_COLORPICKER, esc_html__("Color Picker", "unlimited-elements-for-elementor"));
178
  $this->addParam(self::PARAM_LINK, esc_html__("Link", "unlimited-elements-for-elementor"));
179
+ $this->addParam(self::PARAM_IMAGE, esc_html__("Image (media)", "unlimited-elements-for-elementor"));
180
  $this->addParam(self::PARAM_HR, esc_html__("HR Line", "unlimited-elements-for-elementor"));
181
+ $this->addParam(self::PARAM_HEADING, esc_html__("Heading", "unlimited-elements-for-elementor"));
182
  $this->addParam(self::PARAM_FONT_OVERRIDE, esc_html__("Font Override", "unlimited-elements-for-elementor"));
183
  $this->addParam(self::PARAM_ADDONPICKER, esc_html__("Addon Picker", "unlimited-elements-for-elementor"));
184
 
206
  $this->addParam("uc_varitem_simple", esc_html__("Simple Variable", "unlimited-elements-for-elementor"));
207
  $this->addParam("uc_var_paramrelated", esc_html__("Attribute Related", "unlimited-elements-for-elementor"));
208
  $this->addParam("uc_var_paramitemrelated", esc_html__("Item Attribute Related", "unlimited-elements-for-elementor"));
209
+ $this->addParam(self::PARAM_VAR_FILTER, esc_html__("By Filter Hook", "unlimited-elements-for-elementor"));
210
+
211
  $this->addParam(self::PARAM_VAR_GET, esc_html__("GET Param", "unlimited-elements-for-elementor"));
212
  $this->addParam(self::PARAM_TYPOGRAPHY, esc_html__("Typography", "unlimited-elements-for-elementor"));
213
  $this->addParam(self::PARAM_MARGINS, esc_html__("Margins", "unlimited-elements-for-elementor"));
224
  $this->addParam(self::PARAM_CSS_FILTERS, esc_html__("Css Filters", "unlimited-elements-for-elementor"));
225
  $this->addParam(self::PARAM_HOVER_ANIMATIONS, esc_html__("Hover Animations", "unlimited-elements-for-elementor"));
226
 
227
+ $this->addParam(self::PARAM_SPECIAL, esc_html__("Special Attribute", "unlimited-elements-for-elementor"));
228
+
229
  }
230
 
231
 
375
  /**
376
  * put default value param in params dialog
377
  */
378
+ protected function putDefaultValueParam($isTextarea = false, $class="", $addStyleChekbox = false, $useFor = ""){
379
 
380
  //disable in form item mode
381
  $putTextareaText = true;
384
  $addStyleChekbox = false;
385
  $putTextareaText = false;
386
  }
387
+
388
+ $text = __("Default Value", "unlimited-elements-for-elementor");
389
+
390
+ if($useFor == "heading"){
391
+ $putTextareaText = false;
392
+ $text = __("Enter Text", "unlimited-elements-for-elementor");
393
+ }
394
+
395
  $strClass = "";
396
  if(!empty($class))
397
  $strClass = "class='{$class}'";
398
+
399
  ?>
400
  <div class="unite-inputs-label">
401
+ <?php echo $text?>:
402
  </div>
403
 
404
  <?php if($isTextarea == false):?>
566
  <?php
567
  }
568
 
569
+
570
  /**
571
  * put image param settings
572
  */
573
  private function putImageParam(){
574
 
575
+ $arrTypes = array();
576
+ $arrTypes["image"] = "Image";
577
+ $arrTypes["json"] = "Json (lottie)";
578
+
579
+ $htmlSelect = HelperHtmlUC::getHTMLSelect($arrTypes,"image", "name='media_type' class='uc-control' data-controlled-selector='.uc-media-param-image-attributes'",true);
580
+
581
  ?>
582
+ <?php _e("Media Type","unlimited-elements-for-elementor") ?>:
583
+
584
  <div class="unite-inputs-sap"></div>
585
+
586
+ <?php echo $htmlSelect?>
587
 
588
  <div class="unite-inputs-sap-double"></div>
589
 
590
+ <div class="uc-media-param-image-attributes" data-control="image">
591
+
592
+
593
+ <?php $this->putImageSelectInput("default_value",esc_html__("Default Image","unlimited-elements-for-elementor")); ?>
594
+
595
+ <div class="unite-inputs-sap-double"></div>
596
+
597
+ <?php $this->putCheckbox("add_image_sizes", __("Add Image Size Select","unlimited-elements-for-elementor"))?>
598
+
599
+ </div>
600
+
601
+ <div class="uc-media-param-image-attributes" data-control="json">
602
+
603
+ <div class="unite-inputs-label">
604
+ <?php esc_html_e("Default Json File", "unlimited-elements-for-elementor")?>
605
+ </div>
606
+
607
+ <input type="text" name="default_value_json" value="">
608
+
609
+ <div class="unite-inputs-description">
610
+ * <?php esc_html_e("Write a json file, from assets folder. Important to specify it that the widget will not look empty.", "unlimited-elements-for-elementor")?>
611
+ </div>
612
+
613
+ </div>
614
+
615
+
616
+
617
  <?php
618
  }
619
 
892
  $this->putCheckbox("is_filterable", __("Enable Filterable Options", "unlimited-elements-for-elementor"));
893
  ?>
894
  <?php endif?>
895
+
896
+ <div class="vert_sap10"></div>
897
+
898
+ <?php
899
+ $this->putCheckbox("enable_ajax", __("Enable Ajax Options", "unlimited-elements-for-elementor"));
900
+ ?>
901
 
902
  <div class="vert_sap10"></div>
903
 
986
  exit();
987
  }
988
 
989
+ /**
990
+ *
991
+ * function for override
992
+ */
993
+ protected function putSpecialAttribute(){
994
+
995
+
996
+ dmp("putSpecialAttribute: function for override");
997
+ exit();
998
+
999
+ }
1000
+
1001
 
1002
  private function a___________DROPDOWN_PARAM________(){}
1003
 
1268
 
1269
  }
1270
 
1271
+ /**
1272
+ * put filter param
1273
+ */
1274
+ private function putVarFilter(){
1275
+ ?>
1276
+ <div class="unite-inputs-label">
1277
+ <?php esc_html_e("Filter Name", "unlimited-elements-for-elementor")?>:
1278
+ </div>
1279
+
1280
+ <input type="text" name="filter_name" value="" class="uc_default_value">
1281
+
1282
+
1283
+ <div class="unite-inputs-sap"></div>
1284
+
1285
+ <div class="unite-inputs-label">
1286
+ <?php esc_html_e("Filter Parameter", "unlimited-elements-for-elementor")?>:
1287
+ </div>
1288
+
1289
+ <input type="text" name="filter_param" value="" >
1290
+
1291
+ <div class="unite-dialog-description-right">
1292
+ * <?php esc_html_e("Write every filter name that could be run by apply_filters php function", "unlimited-elements-for-elementor")?>
1293
+ </div>
1294
+
1295
+ <?php
1296
+ }
1297
 
1298
  /**
1299
  * put param content
1379
  case self::PARAM_HR:
1380
  $this->putNoDefaultValueText();
1381
  break;
1382
+ case self::PARAM_HEADING:
1383
+ $this->putDefaultValueParam(true,"",false,"heading");
1384
+ break;
1385
  case self::PARAM_FONT_OVERRIDE:
1386
  $text = esc_html__("Use this font override in css tab using special function", "unlimited-elements-for-elementor");
1387
  $this->putNoDefaultValueText($text);
1396
  case "uc_var_paramitemrelated":
1397
  $this->putParamsRelatedFields("item");
1398
  break;
1399
+ case self::PARAM_VAR_FILTER:
1400
+ $this->putVarFilter();
1401
+ break;
1402
  case self::PARAM_MENU:
1403
  $this->putMenuParam();
1404
  break;
1441
  case self::PARAM_HOVER_ANIMATIONS:
1442
  $this->putHoverAnimations();
1443
  break;
1444
+ case self::PARAM_SPECIAL:
1445
+ $this->putSpecialAttribute();
1446
+ break;
1447
  case self::PARAM_VAR_GET:
1448
  $this->putGetParamFields();
1449
  break;
1536
  $checkboxID = "uc_dialog_left_condition_".$this->type;
1537
  $tableID = "uc_dialog_left_condition_table".$this->type;
1538
 
1539
+ $checkboxBlockLabelID = "uc_dialog_left_blocklabel_".$this->type;;
1540
+
1541
  ?>
1542
 
1543
  <div class="unite-inputs-sap"></div>
1585
 
1586
  </div>
1587
 
1588
+ <div class="unite-inputs-sap"></div>
1589
+
1590
+ <label for="<?php echo $checkboxBlockLabelID?>" class="unite-inputs-label-inline-free">
1591
+ <?php esc_html_e("Label Block", "unlimited-elements-for-elementor")?>:
1592
+ </label>
1593
+ <input id="<?php echo $checkboxBlockLabelID?>" type="checkbox" name="label_block">
1594
+
1595
+
1596
  <?php
1597
  }
1598
 
1780
  self::PARAM_LINK,
1781
  self::PARAM_EDITOR,
1782
  self::PARAM_HR,
1783
+ self::PARAM_HEADING,
1784
  self::PARAM_IMAGE,
1785
  self::PARAM_AUDIO,
1786
  self::PARAM_ICON,
1817
  self::PARAM_LINK,
1818
  self::PARAM_EDITOR,
1819
  self::PARAM_HR,
1820
+ self::PARAM_HEADING,
1821
  self::PARAM_IMAGE,
1822
  self::PARAM_AUDIO,
1823
  self::PARAM_ICON,
1837
 
1838
  $this->option_putAdminLabel = false;
1839
  $this->option_putTitle = false;
1840
+ $this->option_arrTexts["add_title"] = esc_html__("Add Variable","unlimited-elements-for-elementor");
1841
  $this->option_arrTexts["add_button"] = esc_html__("Add Variable","unlimited-elements-for-elementor");
1842
  $this->option_arrTexts["update_button"] = esc_html__("Update Variable","unlimited-elements-for-elementor");
1843
  $this->option_arrTexts["edit_title"] = esc_html__("Edit Variable","unlimited-elements-for-elementor");
1853
  $this->initVariableCommon();
1854
 
1855
  $this->arrParams = array(
1856
+ "uc_varitem_simple",
1857
  "uc_var_paramrelated",
1858
+ self::PARAM_VAR_GET,
1859
+ self::PARAM_VAR_FILTER
1860
  );
1861
 
1862
  }
inc_php/unitecreator_filters_process.class.php CHANGED
@@ -9,12 +9,19 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
9
 
10
  class UniteCreatorFiltersProcess{
11
 
 
 
12
  private static $filters = null;
13
  private static $arrInputFiltersCache = null;
14
  private static $arrFiltersAssocCache = null;
15
-
 
 
16
  private static $isFilesAdded = false;
 
 
17
  private static $showDebug = false;
 
18
 
19
  const TYPE_TERMS = "terms";
20
 
@@ -31,31 +38,36 @@ class UniteCreatorFiltersProcess{
31
  return($request);
32
  }
33
 
34
-
35
-
36
  /**
37
- * get filters array from input
38
  */
39
- private function getArrInputFilters(){
40
-
41
- if(!empty(self::$arrInputFiltersCache))
42
- return(self::$arrInputFiltersCache);
43
 
44
- $request = $this->getArrRequest();
 
45
 
46
- $strFilters = UniteFunctionsUC::getVal($request, "ucfilters");
47
 
48
- if(empty($strFilters))
49
  return(null);
50
-
51
- if(self::$showDebug == true){
 
52
 
53
- dmp("input filters found: $strFilters");
54
- }
55
 
 
 
 
 
 
 
 
 
56
 
57
  $strFilters = trim($strFilters);
58
-
59
  $arrFilters = explode(";", $strFilters);
60
 
61
  //fill the terms
@@ -88,6 +100,32 @@ class UniteCreatorFiltersProcess{
88
  if(!empty($arrTerms))
89
  $arrOutput[self::TYPE_TERMS] = $arrTerms;
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  self::$arrInputFiltersCache = $arrOutput;
92
 
93
  return($arrOutput);
@@ -136,14 +174,14 @@ class UniteCreatorFiltersProcess{
136
  return(self::$filters);
137
 
138
  self::$filters = array();
139
-
140
  $arrInputFilters = $this->getArrInputFilters();
141
 
142
  if(empty($arrInputFilters))
143
  return(self::$filters);
144
 
145
  $arrTerms = UniteFunctionsUC::getVal($arrInputFilters, self::TYPE_TERMS);
146
-
147
  if(empty($arrTerms))
148
  $arrTerms = array();
149
 
@@ -227,6 +265,321 @@ class UniteCreatorFiltersProcess{
227
  return(false);
228
  }
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
  private function _______WIDGET__________(){}
232
 
@@ -246,6 +599,59 @@ class UniteCreatorFiltersProcess{
246
  self::$isFilesAdded = true;
247
  }
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
250
  /**
251
  * put terms checkboxes
@@ -275,7 +681,7 @@ class UniteCreatorFiltersProcess{
275
  $checkboxName = "ucfilter_term__{$taxonomy}--{$slug}";
276
 
277
  $html .= "<label class='ucfilters-label-checkbox'>$name ($count)
278
- <input type='checkbox' class='uc-listing-filter uc-filter-checkbox'
279
  name='{$checkboxName}'
280
  data-type='term'
281
  data-taxonomy='{$taxonomy}'
@@ -290,6 +696,7 @@ class UniteCreatorFiltersProcess{
290
 
291
  }
292
 
 
293
  /**
294
  * get active archive terms
295
  */
@@ -298,8 +705,11 @@ class UniteCreatorFiltersProcess{
298
  if(is_archive() == false)
299
  return(null);
300
 
301
- $currentTerm = get_queried_object();
302
-
 
 
 
303
  if($currentTerm instanceof WP_Term == false)
304
  return(null);
305
 
@@ -319,64 +729,83 @@ class UniteCreatorFiltersProcess{
319
  * put checkbox filters test
320
  */
321
  public function putCheckboxFiltersTest($data){
322
-
323
  $arrActiveFilters = $this->getInputFiltersAssoc();
324
 
325
- $this->includeJSFiles();
326
-
327
  $taxonomy = UniteFunctionsUC::getVal($data, "taxonomy", "category");
328
-
329
  //remove me
330
  $taxonomy = "product_cat";
331
 
332
  $terms = $this->getActiveArchiveTerms($taxonomy);
333
-
334
  if(empty($terms))
335
  return(null);
336
 
 
 
337
  $html = $this->getHtml_termsCheckboxes($terms, $arrActiveFilters,$taxonomy);
338
 
339
  echo $html;
340
  }
341
 
 
342
 
343
  /**
344
- * get base page url
 
345
  */
346
- private function getBasePageUrl(){
347
-
348
- $url = UniteFunctionsUC::getBaseUrl(GlobalsUC::$current_page_url);
349
-
350
- //strip pagination
351
- if(strpos($url, "/page/") !== false){
352
- $numPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
353
- $url = str_replace("/page/$numPage/", "/", $url);
354
-
355
- }
356
 
357
- return($url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  }
359
 
 
360
  /**
361
- * add widget variables
362
- * uc_listing_addclass, uc_listing_attributes
363
- *
364
  */
365
- public function addWidgetFilterableVariables($data){
366
 
367
- $urlBase = $this->getBasePageUrl();
368
 
369
  $arrData = array();
370
  $arrData["urlbase"] = $urlBase;
 
 
 
371
 
372
- $strAttributes = UniteFunctionsUC::jsonEncodeForHtmlData($arrData,"ucfilters");
373
-
374
- $data["uc_listing_attributes"] = $strAttributes;
375
- $data["uc_listing_addclass"] = " uc-filterable-listing";
376
-
377
- return($data);
378
  }
379
 
 
380
  private function _______ARCHIVE_QUERY__________(){}
381
 
382
 
@@ -389,135 +818,88 @@ class UniteCreatorFiltersProcess{
389
  if(is_single())
390
  return(false);
391
 
 
 
392
  $arrFilters = $this->getRequestFilters();
393
-
394
  if(empty($arrFilters))
395
  return(true);
396
-
397
  $args = UniteFunctionsWPUC::getPostsArgs($arrFilters, true);
398
 
399
  if(empty($args))
400
  return(false);
401
-
 
402
  $query->query_vars = array_merge($query->query_vars, $args);
403
 
 
404
  }
405
 
406
-
407
  /**
408
- * init wordpress front filters
409
  */
410
- public function initWPFrontFilters(){
411
 
412
- if(GlobalsUC::$inDev == false)
413
- return(false);
414
 
415
- add_action("parse_request", array($this, "checkModifyMainQuery"));
 
 
 
 
 
 
 
 
416
 
417
  }
418
 
419
-
420
- private function _______TEMP__________(){}
421
-
422
  /**
423
- * put ajax scripts
424
  */
425
- private function putScriptsAjax(){
426
 
427
- ?>
428
-
429
- <script>
430
-
431
- /**
432
- * parse response html - get the body
433
- */
434
- function parseResponseHtml(html){
435
-
436
- var objParsed = jQuery.parseHTML(html);
437
-
438
- var objBody = [];
439
-
440
- jQuery.each(objParsed, function(index){
441
-
442
- var item = objParsed[index];
443
- var type = typeof item;
444
-
445
- var tagName = item.tagName;
446
- if(!tagName)
447
- return(true);
448
-
449
- tagName = tagName.toLowerCase();
450
-
451
- switch(tagName){
452
- case "header":
453
- case "main":
454
- case "footer":
455
- break;
456
- default:
457
- return(true);
458
- break;
459
  }
460
-
461
- objBody.push(jQuery(item));
462
- });
463
-
464
- return(objBody);
465
- }
466
 
467
- /**
468
- * operate html response from ajax
469
- */
470
- function operateHTMLResponse(html){
471
-
472
- var objBody = parseResponseHtml(html);
473
-
474
- var objPostList = jQuery(".uc_post_list");
475
-
476
- var objNewPostList = objBody[1].find(".uc_post_list");
477
-
478
- objPostList.html(objNewPostList.html());
479
-
480
- //var objBody = objDom.find("body");
481
- //trace(objDom);
482
- //trace(objBody);
483
-
484
- }
485
 
486
- /**
487
- * on ajax filter click
488
- */
489
- function onFilterAjaxClick(event){
490
-
491
- event.preventDefault();
492
-
493
- var objFilter = jQuery(this);
494
-
495
- var link = objFilter.prop("href");
496
-
497
- var ajaxSettings = {
498
- dataType:"html",
499
- complete:function(response){
500
- var responseText = response.responseText;
501
- if(responseText)
502
- operateHTMLResponse(responseText);
503
  }
504
- };
505
-
506
- jQuery.ajax(link, ajaxSettings);
507
 
508
- }
509
-
510
- jQuery(document).ready(function(){
511
-
512
- var objFilters = jQuery(".uc-filters .uc-filter-ajax");
513
-
514
- objFilters.click(onFilterAjaxClick);
515
 
516
- });
517
-
518
- </script>
 
 
 
 
 
519
 
520
- <?php
 
 
 
521
  }
522
 
523
 
9
 
10
  class UniteCreatorFiltersProcess{
11
 
12
+ const DEBUG_MAIN_QUERY = false;
13
+
14
  private static $filters = null;
15
  private static $arrInputFiltersCache = null;
16
  private static $arrFiltersAssocCache = null;
17
+ private static $currentTermCache = null;
18
+
19
+ private static $isScriptAdded = false;
20
  private static $isFilesAdded = false;
21
+ private static $isStyleAdded = false;
22
+
23
  private static $showDebug = false;
24
+ private static $originalQueryVars = null;
25
 
26
  const TYPE_TERMS = "terms";
27
 
38
  return($request);
39
  }
40
 
 
 
41
  /**
42
+ * parse base query
43
  */
44
+ private function parseBaseFilters($strBase){
 
 
 
45
 
46
+ if(empty($strBase))
47
+ return(null);
48
 
49
+ $arrFilter = explode("~", $strBase);
50
 
51
+ if(count($arrFilter) != 2)
52
  return(null);
53
+
54
+ $term = $arrFilter[0];
55
+ $value = $arrFilter[1];
56
 
57
+ $arrBase = array();
58
+ $arrBase[$term] = $value;
59
 
60
+ return($arrBase);
61
+ }
62
+
63
+
64
+ /**
65
+ * parse filters string
66
+ */
67
+ private function parseStrFilters($strFilters){
68
 
69
  $strFilters = trim($strFilters);
70
+
71
  $arrFilters = explode(";", $strFilters);
72
 
73
  //fill the terms
100
  if(!empty($arrTerms))
101
  $arrOutput[self::TYPE_TERMS] = $arrTerms;
102
 
103
+ return($arrOutput);
104
+ }
105
+
106
+
107
+ /**
108
+ * get filters array from input
109
+ */
110
+ private function getArrInputFilters(){
111
+
112
+ if(!empty(self::$arrInputFiltersCache))
113
+ return(self::$arrInputFiltersCache);
114
+
115
+ $request = $this->getArrRequest();
116
+
117
+ $strFilters = UniteFunctionsUC::getVal($request, "ucfilters");
118
+
119
+ if(empty($strFilters))
120
+ return(null);
121
+
122
+ if(self::$showDebug == true){
123
+
124
+ dmp("input filters found: $strFilters");
125
+ }
126
+
127
+ $arrOutput = $this->parseStrFilters($strFilters);
128
+
129
  self::$arrInputFiltersCache = $arrOutput;
130
 
131
  return($arrOutput);
174
  return(self::$filters);
175
 
176
  self::$filters = array();
177
+
178
  $arrInputFilters = $this->getArrInputFilters();
179
 
180
  if(empty($arrInputFilters))
181
  return(self::$filters);
182
 
183
  $arrTerms = UniteFunctionsUC::getVal($arrInputFilters, self::TYPE_TERMS);
184
+
185
  if(empty($arrTerms))
186
  $arrTerms = array();
187
 
265
  return(false);
266
  }
267
 
268
+ /**
269
+ * get current term by query vars
270
+ */
271
+ private function getCurrentTermByQueryVars($queryVars){
272
+
273
+ if(is_array($queryVars) == false)
274
+ return(null);
275
+
276
+ if(empty($queryVars))
277
+ return(null);
278
+
279
+ if(count($queryVars) > 1)
280
+ return(null);
281
+
282
+ $postType = null;
283
+ if(isset($queryVars["post_type"])){
284
+
285
+ $postType = $queryVars["post_type"];
286
+ unset($queryVars["post_type"]);
287
+ }
288
+
289
+ $args = array();
290
+ if(!empty($postType))
291
+ $args["post_type"] = $postType;
292
+
293
+ if(!empty($queryVars)){
294
+ $taxonomy = null;
295
+ $slug = null;
296
+
297
+ foreach($queryVars as $queryTax=>$querySlug){
298
+
299
+ $taxonomy = $queryTax;
300
+ $slug = $querySlug;
301
+ }
302
+
303
+ $args = array();
304
+ $args["taxonomy"] = $taxonomy;
305
+ $args["slug"] = $slug;
306
+ }
307
+
308
+ $arrTerms = get_terms($args);
309
+
310
+ $isError = is_wp_error($arrTerms);
311
+
312
+ if($isError == true){
313
+ if(self::$showDebug == true){
314
+
315
+ dmp("error get terms");
316
+ dmp($args);
317
+ dmp($arrTerms);
318
+ }
319
+
320
+ UniteFunctionsUC::throwError("cannot get the terms");
321
+ }
322
+
323
+ if(empty($arrTerms))
324
+ return(null);
325
+
326
+ $term = $arrTerms[0];
327
+
328
+ return($term);
329
+ }
330
+
331
+
332
+ /**
333
+ * get current term
334
+ */
335
+ private function getCurrentTerm(){
336
+
337
+ if(!empty(self::$currentTermCache))
338
+ return(self::$currentTermCache);
339
+
340
+ if(is_archive() == false)
341
+ return(null);
342
+
343
+ if(!empty(self::$originalQueryVars)){
344
+
345
+ $currentTerm = $this->getCurrentTermByQueryVars(self::$originalQueryVars);
346
+ }else{
347
+ $currentTerm = get_queried_object();
348
+
349
+
350
+
351
+ if($currentTerm instanceof WP_Term == false)
352
+ $currentTerm = null;
353
+ }
354
+
355
+ self::$currentTermCache = $currentTerm;
356
+
357
+ return($currentTerm);
358
+ }
359
+
360
+ private function _______AJAX__________(){}
361
+
362
+ /**
363
+ * get addon post list name
364
+ */
365
+ private function getAddonPostListName($addon){
366
+
367
+ $paramPostList = $addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
368
+
369
+ $postListName = UniteFunctionsUC::getVal($paramPostList, "name");
370
+
371
+ return($postListName);
372
+ }
373
+
374
+
375
+ /**
376
+ * validate if the addon ajax ready
377
+ * if it's have post list and has option that enable ajax
378
+ */
379
+ private function validateAddonAjaxReady($addon, $arrSettingsValues){
380
+
381
+ $paramPostList = $addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
382
+
383
+ if(empty($paramPostList))
384
+ UniteFunctionsUC::throwError("Widget not ready for ajax");
385
+
386
+ $postListName = UniteFunctionsUC::getVal($paramPostList, "name");
387
+
388
+ $isAjaxReady = UniteFunctionsUC::getVal($arrSettingsValues, $postListName."_isajax");
389
+ $isAjaxReady = UniteFunctionsUC::strToBool($isAjaxReady);
390
+
391
+ if($isAjaxReady == false)
392
+ UniteFunctionsUC::throwError("The ajax is not ready for this widget");
393
+
394
+ return($postListName);
395
+ }
396
+
397
+
398
+ /**
399
+ * process the html output - convert all the links, remove the query part
400
+ */
401
+ private function processAjaxHtmlOutput($html){
402
+
403
+ $currentUrl = GlobalsUC::$current_page_url;
404
+
405
+ $arrUrl = parse_url($currentUrl);
406
+
407
+ $query = "?".UniteFunctionsUC::getVal($arrUrl, "query");
408
+
409
+ $html = str_replace($query, "", $html);
410
+
411
+ $query = str_replace("&", "&#038;", $query);
412
+
413
+ $html = str_replace($query, "", $html);
414
+
415
+ return($html);
416
+ }
417
+
418
+ /**
419
+ * modify settings values before set to addon
420
+ * set pagination type to post list values
421
+ */
422
+ private function modifySettingsValues($arrSettingsValues, $postListName){
423
+
424
+ $paginationType = UniteFunctionsUC::getVal($arrSettingsValues, "pagination_type");
425
+
426
+ if(!empty($paginationType))
427
+ $arrSettingsValues[$postListName."_pagination_type"] = $paginationType;
428
+
429
+ return($arrSettingsValues);
430
+ }
431
+
432
+ /**
433
+ * get content element html
434
+ */
435
+ private function getContentWidgetHtml($arrContent, $elementID, $isGrid = true){
436
+
437
+ $arrElement = HelperProviderCoreUC_EL::getArrElementFromContent($arrContent, $elementID);
438
+
439
+ if(empty($arrElement))
440
+ UniteFunctionsUC::throwError("Elementor Widget not found");
441
+
442
+ $type = UniteFunctionsUC::getVal($arrElement, "elType");
443
+
444
+ if($type != "widget")
445
+ UniteFunctionsUC::throwError("The element is not a widget");
446
+
447
+ $widgetType = UniteFunctionsUC::getVal($arrElement, "widgetType");
448
+
449
+ if(strpos($widgetType, "ucaddon_") === false)
450
+ UniteFunctionsUC::throwError("Cannot output widget content");
451
+
452
+ $arrSettingsValues = UniteFunctionsUC::getVal($arrElement, "settings");
453
+
454
+ $widgetName = str_replace("ucaddon_", "", $widgetType);
455
+
456
+ $addon = new UniteCreatorAddon();
457
+ $addon->initByAlias($widgetName, GlobalsUC::ADDON_TYPE_ELEMENTOR);
458
+
459
+ //make a check that ajax option is on in this widget
460
+
461
+ if($isGrid == true){
462
+
463
+ $postListName = $this->validateAddonAjaxReady($addon, $arrSettingsValues);
464
+
465
+ $arrSettingsValues = $this->modifySettingsValues($arrSettingsValues, $postListName);
466
+ }
467
+
468
+ $addon->setParamsValues($arrSettingsValues);
469
+
470
+ //------ get the html output
471
+
472
+ //collect the debug html
473
+
474
+ if($isGrid == true)
475
+ ob_start();
476
+
477
+ $objOutput = new UniteCreatorOutput();
478
+ $objOutput->initByAddon($addon);
479
+
480
+ if($isGrid == true){
481
+ $htmlDebug = ob_get_contents();
482
+ ob_end_clean();
483
+ }
484
+
485
+
486
+ $output = array();
487
+
488
+ //get only items
489
+ if($isGrid == true){
490
+ $htmlGridItems = $objOutput->getHtmlItems();
491
+ $output["html"] = $htmlGridItems;
492
+ }
493
+
494
+ //get output of the html template
495
+ if($isGrid == false){
496
+
497
+ $htmlBody = $objOutput->getHtmlOnly();
498
+
499
+ $htmlBody = $this->processAjaxHtmlOutput($htmlBody);
500
+
501
+ $output["html"] = $htmlBody;
502
+ }
503
+
504
+ if($isGrid == true && !empty($htmlDebug))
505
+ $output["html_debug"] = $htmlDebug;
506
+
507
+ return($output);
508
+ }
509
+
510
+
511
+ /**
512
+ * get content widgets html
513
+ */
514
+ private function getContentWidgetsHTML($arrContent, $strIDs){
515
+
516
+ if(empty($strIDs))
517
+ return(null);
518
+
519
+ $arrIDs = explode(",", $strIDs);
520
+
521
+ $arrHTML = array();
522
+
523
+ foreach($arrIDs as $elementID){
524
+
525
+ $output = $this->getContentWidgetHtml($arrContent, $elementID, false);
526
+
527
+ $html = UniteFunctionsUC::getVal($output, "html");
528
+
529
+ $arrHTML[$elementID] = $html;
530
+ }
531
+
532
+ return($arrHTML);
533
+ }
534
+
535
+ /**
536
+ * get widget ajax data
537
+ */
538
+ private function putWidgetGridFrontAjaxData(){
539
+
540
+ //validate by response code
541
+
542
+ $responseCode = http_response_code();
543
+ if($responseCode != 200){
544
+ http_response_code(200);
545
+ UniteFunctionsUC::throwError("Request not allowed, please make sure the pagination is allowed for the ajax grid");
546
+ }
547
+
548
+
549
+ //init widget by post id and element id
550
+
551
+ $layoutID = UniteFunctionsUC::getPostGetVariable("layoutid","",UniteFunctionsUC::SANITIZE_KEY);
552
+ $elementID = UniteFunctionsUC::getPostGetVariable("elid","",UniteFunctionsUC::SANITIZE_KEY);
553
+
554
+ $addElIDs = UniteFunctionsUC::getPostGetVariable("addelids","",UniteFunctionsUC::SANITIZE_TEXT_FIELD);
555
+
556
+ $arrContent = HelperProviderCoreUC_EL::getElementorContentByPostID($layoutID);
557
+
558
+ if(empty($arrContent))
559
+ UniteFunctionsUC::throwError("Elementor content not found");
560
+
561
+ $arrHtmlWidget = $this->getContentWidgetHtml($arrContent, $elementID);
562
+
563
+ $htmlGridItems = UniteFunctionsUC::getVal($arrHtmlWidget, "html");
564
+ $htmlDebug = UniteFunctionsUC::getVal($arrHtmlWidget, "html_debug");
565
+
566
+ $addWidgetsHTML = $this->getContentWidgetsHTML($arrContent, $addElIDs);
567
+
568
+ //output the html
569
+ $outputData = array();
570
+
571
+ if(!empty($htmlDebug))
572
+ $outputData["html_debug"] = $htmlDebug;
573
+
574
+ $outputData["html_items"] = $htmlGridItems;
575
+
576
+ if(!empty($addWidgetsHTML))
577
+ $outputData["html_widgets"] = $addWidgetsHTML;
578
+
579
+ HelperUC::ajaxResponseData($outputData);
580
+
581
+ }
582
+
583
 
584
  private function _______WIDGET__________(){}
585
 
599
  self::$isFilesAdded = true;
600
  }
601
 
602
+ /**
603
+ * put custom scripts
604
+ */
605
+ private function putCustomJsScripts(){
606
+
607
+ if(self::$isScriptAdded == true)
608
+ return(false);
609
+
610
+ self::$isScriptAdded = true;
611
+
612
+ $arrData = $this->getFiltersJSData();
613
+
614
+ $strData = UniteFunctionsUC::jsonEncodeForClientSide($arrData);
615
+
616
+ $script = "//Unlimited Elements Filters \n";
617
+ $script .= "var g_strFiltersData = $strData";
618
+
619
+ UniteProviderFunctionsUC::printCustomScript($script);
620
+ }
621
+
622
+ /**
623
+ * put custom style
624
+ */
625
+ private function putCustomStyle(){
626
+
627
+ if(self::$isStyleAdded == true)
628
+ return(false);
629
+
630
+ self::$isStyleAdded = true;
631
+
632
+ $style = "
633
+ .uc-ajax-loading{
634
+ opacity:0.6;
635
+ }
636
+ ";
637
+
638
+ UniteProviderFunctionsUC::printCustomStyle($style);
639
+ }
640
+
641
+
642
+ /**
643
+ * include the client side scripts
644
+ */
645
+ private function includeClientSideScripts(){
646
+
647
+ $this->includeJSFiles();
648
+
649
+ $this->putCustomJsScripts();
650
+
651
+ $this->putCustomStyle();
652
+
653
+ }
654
+
655
 
656
  /**
657
  * put terms checkboxes
681
  $checkboxName = "ucfilter_term__{$taxonomy}--{$slug}";
682
 
683
  $html .= "<label class='ucfilters-label-checkbox'>$name ($count)
684
+ <input type='checkbox' class='uc-grid-filter uc-filter-checkbox'
685
  name='{$checkboxName}'
686
  data-type='term'
687
  data-taxonomy='{$taxonomy}'
696
 
697
  }
698
 
699
+
700
  /**
701
  * get active archive terms
702
  */
705
  if(is_archive() == false)
706
  return(null);
707
 
708
+ $currentTerm = $this->getCurrentTerm();
709
+
710
+ if(empty($currentTerm))
711
+ return(null);
712
+
713
  if($currentTerm instanceof WP_Term == false)
714
  return(null);
715
 
729
  * put checkbox filters test
730
  */
731
  public function putCheckboxFiltersTest($data){
732
+
733
  $arrActiveFilters = $this->getInputFiltersAssoc();
734
 
 
 
735
  $taxonomy = UniteFunctionsUC::getVal($data, "taxonomy", "category");
736
+
737
  //remove me
738
  $taxonomy = "product_cat";
739
 
740
  $terms = $this->getActiveArchiveTerms($taxonomy);
741
+
742
  if(empty($terms))
743
  return(null);
744
 
745
+ $this->includeClientSideScripts();
746
+
747
  $html = $this->getHtml_termsCheckboxes($terms, $arrActiveFilters,$taxonomy);
748
 
749
  echo $html;
750
  }
751
 
752
+
753
 
754
  /**
755
+ * add widget variables
756
+ * uc_listing_addclass, uc_listing_attributes
757
  */
758
+ public function addWidgetFilterableVariables($data, $addon){
 
 
 
 
 
 
 
 
 
759
 
760
+ $param = $addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
761
+
762
+ $postListName = UniteFunctionsUC::getVal($param, "name");
763
+
764
+ $dataPosts = UniteFunctionsUC::getVal($data, $postListName);
765
+
766
+ //check if ajax related
767
+ $isAjax = UniteFunctionsUC::getVal($dataPosts, $postListName."_isajax");
768
+ $isAjax = UniteFunctionsUC::strToBool($isAjax);
769
+
770
+ if($isAjax == false)
771
+ return($data);
772
+
773
+ if(empty($param))
774
+ return($data);
775
+
776
+ //check if ajax
777
+ $strAttributes = "";
778
+
779
+ if($isAjax == true)
780
+ $strAttributes .= " data-ajax='true' ";
781
+
782
+ $this->includeClientSideScripts();
783
+
784
+ $data["uc_filtering_attributes"] = $strAttributes;
785
+ $data["uc_filtering_addclass"] = " uc-filterable-grid";
786
+
787
+
788
+ return($data);
789
  }
790
 
791
+
792
  /**
793
+ * get filters attributes
 
 
794
  */
795
+ private function getFiltersJSData(){
796
 
797
+ $urlBase = UniteFunctionsUC::getBaseUrl(GlobalsUC::$current_page_url);
798
 
799
  $arrData = array();
800
  $arrData["urlbase"] = $urlBase;
801
+ $arrData["urlajax"] = GlobalsUC::$url_ajax_full;
802
+ $arrData["querybase"] = self::$originalQueryVars;
803
+
804
 
805
+ return($arrData);
 
 
 
 
 
806
  }
807
 
808
+
809
  private function _______ARCHIVE_QUERY__________(){}
810
 
811
 
818
  if(is_single())
819
  return(false);
820
 
821
+ self::$originalQueryVars = $query->query_vars;
822
+
823
  $arrFilters = $this->getRequestFilters();
824
+
825
  if(empty($arrFilters))
826
  return(true);
827
+
828
  $args = UniteFunctionsWPUC::getPostsArgs($arrFilters, true);
829
 
830
  if(empty($args))
831
  return(false);
832
+
833
+
834
  $query->query_vars = array_merge($query->query_vars, $args);
835
 
836
+
837
  }
838
 
 
839
  /**
840
+ * show the main query debug
841
  */
842
+ private function showMainQueryDebug(){
843
 
 
 
844
 
845
+ global $wp_query;
846
+
847
+ $args = $wp_query->query_vars;
848
+
849
+ $argsForDebug = UniteFunctionsWPUC::cleanQueryArgsForDebug($args);
850
+
851
+ dmp("MAIN QUERY DEBUG");
852
+
853
+ dmp($argsForDebug);
854
 
855
  }
856
 
 
 
 
857
  /**
858
+ * test the request filter
859
  */
860
+ public function operateAjaxResponse(){
861
 
862
+ if(self::DEBUG_MAIN_QUERY == true){
863
+ $this->showMainQueryDebug();
864
+ exit();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
  }
 
 
 
 
 
 
866
 
867
+ $frontAjaxAction = UniteFunctionsUC::getPostGetVariable("ucfrontajaxaction","",UniteFunctionsUC::SANITIZE_KEY);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
868
 
869
+ if(empty($frontAjaxAction))
870
+ return(false);
871
+
872
+ try{
873
+
874
+ switch($frontAjaxAction){
875
+ case "getfiltersdata":
876
+ $this->putWidgetGridFrontAjaxData();
877
+ break;
878
+ }
879
+
880
+ }catch(Exception $e){
881
+
882
+ $message = $e->getMessage();
883
+
884
+ HelperUC::ajaxResponseError($message);
885
+
886
  }
 
 
 
887
 
888
+ }
 
 
 
 
 
 
889
 
890
+
891
+ /**
892
+ * init wordpress front filters
893
+ */
894
+ public function initWPFrontFilters(){
895
+
896
+ if(is_admin() == true)
897
+ return(false);
898
 
899
+ add_action("wp", array($this, "operateAjaxResponse"));
900
+
901
+ add_action("parse_request", array($this, "checkModifyMainQuery"));
902
+
903
  }
904
 
905
 
inc_php/unitecreator_globals.class.php CHANGED
@@ -115,6 +115,8 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
115
  public static $url_base;
116
  public static $url_images;
117
  public static $url_images_screenshots;
 
 
118
  public static $url_component_client;
119
  public static $url_component_admin;
120
  public static $url_component_admin_nowindow;
@@ -214,6 +216,8 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
214
 
215
  self::$urlPluginImages = self::$urlPlugin."images/";
216
 
 
 
217
  self::$pathLibrary = self::$pathPlugin."assets_libraries/";
218
 
219
 
115
  public static $url_base;
116
  public static $url_images;
117
  public static $url_images_screenshots;
118
+ public static $url_no_image_placeholder;
119
+
120
  public static $url_component_client;
121
  public static $url_component_admin;
122
  public static $url_component_admin_nowindow;
216
 
217
  self::$urlPluginImages = self::$urlPlugin."images/";
218
 
219
+ self::$url_no_image_placeholder = self::$urlPluginImages."no_image_placeholder.jpg";
220
+
221
  self::$pathLibrary = self::$pathPlugin."assets_libraries/";
222
 
223
 
inc_php/unitecreator_helper.class.php CHANGED
@@ -1743,8 +1743,11 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1743
 
1744
  }
1745
 
 
1746
  }
1747
 
 
 
1748
  //init the operations
1749
  HelperUC::$operations = new UCOperations();
1750
 
1743
 
1744
  }
1745
 
1746
+
1747
  }
1748
 
1749
+
1750
+
1751
  //init the operations
1752
  HelperUC::$operations = new UCOperations();
1753
 
inc_php/unitecreator_helperhtml.class.php CHANGED
@@ -175,11 +175,17 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
175
  $jsonFaIcons = UniteFontManagerUC::fa_getJsonIcons();
176
  $js .= self::TAB2.'var g_ucFaIcons = '.$jsonFaIcons.';'.self::BR;
177
 
 
 
 
 
 
178
  //output shapes
 
179
  $objShapes = new UniteShapeManagerUC();
180
  $jsonShapes = $objShapes->getJsonShapes();
181
  $js .= self::TAB2.'var g_ucArrSvgShapes = '.$jsonShapes.';'.self::BR;
182
-
183
 
184
  //get nonce
185
  if(method_exists("UniteProviderFunctionsUC", "getNonce"))
175
  $jsonFaIcons = UniteFontManagerUC::fa_getJsonIcons();
176
  $js .= self::TAB2.'var g_ucFaIcons = '.$jsonFaIcons.';'.self::BR;
177
 
178
+ //output elementor icons
179
+ $jsonElementorIcons = UniteFontManagerUC::elementor_getJsonIcons();
180
+ $js .= self::TAB2.'var g_ucElIcons = '.$jsonElementorIcons.';'.self::BR;
181
+
182
+
183
  //output shapes
184
+ /*
185
  $objShapes = new UniteShapeManagerUC();
186
  $jsonShapes = $objShapes->getJsonShapes();
187
  $js .= self::TAB2.'var g_ucArrSvgShapes = '.$jsonShapes.';'.self::BR;
188
+ */
189
 
190
  //get nonce
191
  if(method_exists("UniteProviderFunctionsUC", "getNonce"))
inc_php/unitecreator_library.class.php CHANGED
@@ -44,7 +44,7 @@ class UniteCreatorLibraryWork{
44
  * function for override
45
  */
46
  protected function getUrlPlatformInclude($handle){
47
-
48
  return(null);
49
  }
50
 
@@ -60,6 +60,7 @@ class UniteCreatorLibraryWork{
60
 
61
  $arrIncludes = array();
62
 
 
63
  foreach($objIncludes as $objInclude){
64
  $attribs = $objInclude->attributes();
65
 
@@ -79,7 +80,7 @@ class UniteCreatorLibraryWork{
79
  }
80
 
81
  $urlPlatformInclude = $this->getUrlPlatformInclude($handle);
82
-
83
  if(!empty($urlPlatformInclude))
84
  $urlInclude = $urlPlatformInclude;
85
 
@@ -121,6 +122,7 @@ class UniteCreatorLibraryWork{
121
  $items = array($items);
122
  }
123
 
 
124
  foreach($items as $objItem){
125
  $attribs = $objItem->attributes();
126
 
@@ -165,7 +167,7 @@ class UniteCreatorLibraryWork{
165
  * output urls in array of js and css saparately
166
  */
167
  public function getLibraryIncludes($name){
168
-
169
  $urlBase = GlobalsUC::$url_assets_libraries;
170
 
171
  $arrJs = array();
44
  * function for override
45
  */
46
  protected function getUrlPlatformInclude($handle){
47
+
48
  return(null);
49
  }
50
 
60
 
61
  $arrIncludes = array();
62
 
63
+
64
  foreach($objIncludes as $objInclude){
65
  $attribs = $objInclude->attributes();
66
 
80
  }
81
 
82
  $urlPlatformInclude = $this->getUrlPlatformInclude($handle);
83
+
84
  if(!empty($urlPlatformInclude))
85
  $urlInclude = $urlPlatformInclude;
86
 
122
  $items = array($items);
123
  }
124
 
125
+
126
  foreach($items as $objItem){
127
  $attribs = $objItem->attributes();
128
 
167
  * output urls in array of js and css saparately
168
  */
169
  public function getLibraryIncludes($name){
170
+
171
  $urlBase = GlobalsUC::$url_assets_libraries;
172
 
173
  $arrJs = array();
inc_php/unitecreator_output.class.php CHANGED
@@ -32,6 +32,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
32
  private $isShowDebugData = false;
33
  private $debugDataType = "";
34
 
 
35
  private static $arrUrlCacheCss = array();
36
  private static $arrHandleCacheCss = array();
37
 
@@ -288,6 +289,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
288
 
289
  //get all libraries without provider process
290
  $arrLibraries = $this->addon->getArrLibraryIncludesUrls($processProviderLibrary);
 
291
  }
292
 
293
 
@@ -802,7 +804,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
802
  * process number param
803
  */
804
  private function processParamCSSSelector_number($param, $selector){
805
-
806
  $name = UniteFunctionsUC::getVal($param, "name");
807
  $value = UniteFunctionsUC::getVal($param, "value");
808
  $selectorValue = UniteFunctionsUC::getVal($param, "selector_value");
@@ -824,6 +826,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
824
 
825
  $style = $selector."{{$selectorValue}}";
826
 
 
827
  if(empty($style))
828
  return(null);
829
 
@@ -1038,7 +1041,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1038
  public function getPreviewHtml(){
1039
 
1040
  $this->validateInited();
1041
-
1042
  $outputs = "";
1043
 
1044
  $title = $this->addon->getTitle();
@@ -1047,11 +1050,11 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1047
 
1048
  //get libraries, but not process provider
1049
  $htmlBody = $this->getHtmlBody(false);
1050
-
1051
  $arrIncludes = $this->getProcessedIncludes(true, false);
1052
-
1053
  $arrIncludes = $this->modifyPreviewIncludes($arrIncludes);
1054
-
1055
  $htmlInlcudesCss = $this->getHtmlIncludes($arrIncludes,"css");
1056
  $htmlInlcudesJS = $this->getHtmlIncludes($arrIncludes,"js");
1057
 
@@ -1064,9 +1067,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1064
 
1065
  $arrJsCustomScripts = UniteProviderFunctionsUC::getCustomScripts();
1066
  $htmlJSScripts = HelperHtmlUC::getHtmlCustomScripts($arrJsCustomScripts);
1067
-
1068
- //set options
1069
-
1070
  $options = $this->addon->getOptions();
1071
 
1072
  $bgCol = $this->addon->getOption("preview_bgcol");
@@ -1230,45 +1231,6 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1230
  $this->addon->addParam($arrParam);
1231
  }
1232
 
1233
-
1234
- private function a________GENERAL___________(){}
1235
-
1236
-
1237
- /**
1238
- * modify items data for show
1239
- */
1240
- private function modifyItemsDataForShow($arrItemData){
1241
-
1242
- if(is_array($arrItemData) == false)
1243
- return(null);
1244
-
1245
- $arrItemsForShow = array();
1246
-
1247
-
1248
- foreach($arrItemData as $item){
1249
-
1250
- if(is_array($item) == false){
1251
- $arrItemsForShow[] = $item;
1252
- continue;
1253
- }
1254
-
1255
-
1256
- $item = UniteFunctionsUC::getVal($item, "item");
1257
-
1258
- $itemFirstValue = UniteFunctionsUC::getArrFirstValue($item);
1259
-
1260
- if(is_array($itemFirstValue))
1261
- $item = UniteFunctionsUC::modifyDataArrayForShow($itemFirstValue);
1262
- else
1263
- $item = UniteFunctionsUC::modifyDataArrayForShow($item);
1264
-
1265
- $arrItemsForShow[] = $item;
1266
- }
1267
-
1268
- return($arrItemsForShow);
1269
- }
1270
-
1271
-
1272
  private function ___________DEBUG_DATA___________(){}
1273
 
1274
 
@@ -1411,7 +1373,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1411
  * put debug data
1412
  */
1413
  private function putDebugDataHtml($arrData, $arrItemData){
1414
-
1415
  echo "<div style='font-size:16px;color:black;text-decoration:none;background-color:white;'>";
1416
 
1417
  dmp("<b>Widget Debug Data</b> (turned on by setting in widget advanced section)<br>");
@@ -1441,6 +1403,46 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1441
  }
1442
 
1443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1444
  /**
1445
  * process html before output, function for override
1446
  */
@@ -1449,6 +1451,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1449
  return($html);
1450
  }
1451
 
 
1452
  /**
1453
  * set to show debug data of the addon
1454
  */
@@ -1471,12 +1474,43 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1471
  return($html);
1472
  }
1473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1474
 
1475
  /**
1476
  * place output by shortcode
1477
  */
1478
  public function getHtmlBody($scriptHardCoded = true, $putCssIncludes = false, $putCssInline = true, $params = null){
1479
-
1480
  $this->validateInited();
1481
 
1482
  $title = $this->addon->getTitle(true);
@@ -1486,8 +1520,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1486
  $settings = HelperProviderCoreUC_EL::getGeneralSettingsValues();
1487
  $isOutputComments = UniteFunctionsUC::strToBool($isOutputComments);
1488
 
1489
-
1490
-
1491
  try{
1492
 
1493
  $html = $this->objTemplate->getRenderedHtml(self::TEMPLATE_HTML);
@@ -1628,7 +1661,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1628
 
1629
  if(!empty($this->cacheConstants))
1630
  return($this->cacheConstants);
1631
-
1632
  $data = array();
1633
 
1634
  $prefix = "ucid";
@@ -1822,7 +1855,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1822
  case "post": //move posts data from main to items
1823
 
1824
  $paramPostsList = $this->addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
1825
-
1826
  if(empty($paramPostsList))
1827
  UniteFunctionsUC::throwError("Some posts list param should be found");
1828
 
@@ -1871,7 +1904,7 @@ class UniteCreatorOutputWork extends HtmlOutputBaseUC{
1871
 
1872
  $arrItemData[$key]["item"] = $arrItem;
1873
  }
1874
-
1875
  $this->objTemplate->setParams($arrData);
1876
 
1877
  $this->objTemplate->setArrItems($arrItemData);
32
  private $isShowDebugData = false;
33
  private $debugDataType = "";
34
 
35
+
36
  private static $arrUrlCacheCss = array();
37
  private static $arrHandleCacheCss = array();
38
 
289
 
290
  //get all libraries without provider process
291
  $arrLibraries = $this->addon->getArrLibraryIncludesUrls($processProviderLibrary);
292
+
293
  }
294
 
295
 
804
  * process number param
805
  */
806
  private function processParamCSSSelector_number($param, $selector){
807
+
808
  $name = UniteFunctionsUC::getVal($param, "name");
809
  $value = UniteFunctionsUC::getVal($param, "value");
810
  $selectorValue = UniteFunctionsUC::getVal($param, "selector_value");
826
 
827
  $style = $selector."{{$selectorValue}}";
828
 
829
+
830
  if(empty($style))
831
  return(null);
832
 
1041
  public function getPreviewHtml(){
1042
 
1043
  $this->validateInited();
1044
+
1045
  $outputs = "";
1046
 
1047
  $title = $this->addon->getTitle();
1050
 
1051
  //get libraries, but not process provider
1052
  $htmlBody = $this->getHtmlBody(false);
1053
+
1054
  $arrIncludes = $this->getProcessedIncludes(true, false);
1055
+
1056
  $arrIncludes = $this->modifyPreviewIncludes($arrIncludes);
1057
+
1058
  $htmlInlcudesCss = $this->getHtmlIncludes($arrIncludes,"css");
1059
  $htmlInlcudesJS = $this->getHtmlIncludes($arrIncludes,"js");
1060
 
1067
 
1068
  $arrJsCustomScripts = UniteProviderFunctionsUC::getCustomScripts();
1069
  $htmlJSScripts = HelperHtmlUC::getHtmlCustomScripts($arrJsCustomScripts);
1070
+
 
 
1071
  $options = $this->addon->getOptions();
1072
 
1073
  $bgCol = $this->addon->getOption("preview_bgcol");
1231
  $this->addon->addParam($arrParam);
1232
  }
1233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1234
  private function ___________DEBUG_DATA___________(){}
1235
 
1236
 
1373
  * put debug data
1374
  */
1375
  private function putDebugDataHtml($arrData, $arrItemData){
1376
+
1377
  echo "<div style='font-size:16px;color:black;text-decoration:none;background-color:white;'>";
1378
 
1379
  dmp("<b>Widget Debug Data</b> (turned on by setting in widget advanced section)<br>");
1403
  }
1404
 
1405
 
1406
+ private function a________GENERAL___________(){}
1407
+
1408
+
1409
+ /**
1410
+ * modify items data for show
1411
+ */
1412
+ private function modifyItemsDataForShow($arrItemData){
1413
+
1414
+ if(is_array($arrItemData) == false)
1415
+ return(null);
1416
+
1417
+ $arrItemsForShow = array();
1418
+
1419
+
1420
+ foreach($arrItemData as $item){
1421
+
1422
+ if(is_array($item) == false){
1423
+ $arrItemsForShow[] = $item;
1424
+ continue;
1425
+ }
1426
+
1427
+
1428
+ $item = UniteFunctionsUC::getVal($item, "item");
1429
+
1430
+ $itemFirstValue = UniteFunctionsUC::getArrFirstValue($item);
1431
+
1432
+ if(is_array($itemFirstValue))
1433
+ $item = UniteFunctionsUC::modifyDataArrayForShow($itemFirstValue);
1434
+ else
1435
+ $item = UniteFunctionsUC::modifyDataArrayForShow($item);
1436
+
1437
+ $arrItemsForShow[] = $item;
1438
+ }
1439
+
1440
+ return($arrItemsForShow);
1441
+ }
1442
+
1443
+
1444
+
1445
+
1446
  /**
1447
  * process html before output, function for override
1448
  */
1451
  return($html);
1452
  }
1453
 
1454
+
1455
  /**
1456
  * set to show debug data of the addon
1457
  */
1474
  return($html);
1475
  }
1476
 
1477
+ /**
1478
+ * get items html
1479
+ */
1480
+ public function getHtmlItems(){
1481
+
1482
+ $keyTemplate = "uc_template_items_special";
1483
+
1484
+ $htmlTemplate = "{{put_items()}}";
1485
+
1486
+ $html = $this->objTemplate->addTemplate($keyTemplate, $htmlTemplate, false);
1487
+
1488
+ $html = $this->objTemplate->getRenderedHtml($keyTemplate);
1489
+
1490
+
1491
+ return($html);
1492
+ }
1493
+
1494
+
1495
+ /**
1496
+ * get only html template output, no css and no js
1497
+ */
1498
+ public function getHtmlOnly(){
1499
+
1500
+ $this->validateInited();
1501
+
1502
+ $html = $this->objTemplate->getRenderedHtml(self::TEMPLATE_HTML);
1503
+ $html = $this->processHtml($html);
1504
+
1505
+ return($html);
1506
+ }
1507
+
1508
 
1509
  /**
1510
  * place output by shortcode
1511
  */
1512
  public function getHtmlBody($scriptHardCoded = true, $putCssIncludes = false, $putCssInline = true, $params = null){
1513
+
1514
  $this->validateInited();
1515
 
1516
  $title = $this->addon->getTitle(true);
1520
  $settings = HelperProviderCoreUC_EL::getGeneralSettingsValues();
1521
  $isOutputComments = UniteFunctionsUC::strToBool($isOutputComments);
1522
 
1523
+
 
1524
  try{
1525
 
1526
  $html = $this->objTemplate->getRenderedHtml(self::TEMPLATE_HTML);
1661
 
1662
  if(!empty($this->cacheConstants))
1663
  return($this->cacheConstants);
1664
+
1665
  $data = array();
1666
 
1667
  $prefix = "ucid";
1855
  case "post": //move posts data from main to items
1856
 
1857
  $paramPostsList = $this->addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
1858
+
1859
  if(empty($paramPostsList))
1860
  UniteFunctionsUC::throwError("Some posts list param should be found");
1861
 
1904
 
1905
  $arrItemData[$key]["item"] = $arrItem;
1906
  }
1907
+
1908
  $this->objTemplate->setParams($arrData);
1909
 
1910
  $this->objTemplate->setArrItems($arrItemData);
inc_php/unitecreator_params_processor.class.php CHANGED
@@ -10,7 +10,7 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
10
  class UniteCreatorParamsProcessorWork{
11
 
12
  private $objShapes;
13
- private $addon;
14
  private $processType;
15
  private static $counter = 0;
16
 
@@ -139,7 +139,7 @@ class UniteCreatorParamsProcessorWork{
139
 
140
  //for auto complete
141
  //$this->addon = new UniteCreatorAddon();
142
-
143
  $this->addon = $addon;
144
  }
145
 
@@ -708,7 +708,7 @@ class UniteCreatorParamsProcessorWork{
708
  * create param with full fields
709
  */
710
  protected function getImageFields($data, $name, $value){
711
-
712
  if(empty($data))
713
  $data = array();
714
 
@@ -720,6 +720,7 @@ class UniteCreatorParamsProcessorWork{
720
  $data[$name] = $value;
721
  $data = $this->getProcessedParamsValue_image($data, $value, $param);
722
 
 
723
  return($data);
724
  }
725
 
@@ -760,7 +761,7 @@ class UniteCreatorParamsProcessorWork{
760
  * add image attributes
761
  */
762
  private function addImageAttributes($data, $name, $param){
763
-
764
  $addImageSizes = UniteFunctionsUC::getVal($param, "add_image_sizes");
765
  $addImageSizes = UniteFunctionsUC::strToBool($addImageSizes);
766
 
@@ -813,14 +814,81 @@ class UniteCreatorParamsProcessorWork{
813
  return($data);
814
  }
815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
  /**
817
  * process image param value, add to data
818
  * @param $param
819
  */
820
  protected function getProcessedParamsValue_image($data, $value, $param){
 
 
821
 
822
  $name = $param["name"];
823
 
 
 
 
 
 
 
 
824
  $urlImage = $value; //in case that the value is image id
825
  if(is_numeric($value)){
826
  $urlImage = UniteProviderFunctionsUC::getImageUrlFromImageID($value);
@@ -830,7 +898,8 @@ class UniteCreatorParamsProcessorWork{
830
  $value = HelperUC::URLtoFull($value);
831
  $data[$name] = $value;
832
  }
833
-
 
834
  $sizeFilters = UniteFunctionsUC::getVal($param, "size_filters");
835
  $isNoAttributes = UniteFunctionsUC::getVal($param, "no_attributes");
836
  $isNoImageData = UniteFunctionsUC::getVal($param, "no_image_data");
@@ -1082,7 +1151,7 @@ class UniteCreatorParamsProcessorWork{
1082
 
1083
  if(empty($arrParams))
1084
  return(array());
1085
-
1086
  $arrParamsNew = array();
1087
  foreach($arrParams as $param){
1088
 
@@ -1101,7 +1170,7 @@ class UniteCreatorParamsProcessorWork{
1101
  }
1102
 
1103
  }
1104
-
1105
  return($arrParamsNew);
1106
  }
1107
 
@@ -1459,9 +1528,7 @@ class UniteCreatorParamsProcessorWork{
1459
  $data = $this->getProcessedParamsValue_responsive($data, $param);
1460
  break;
1461
  case UniteCreatorDialogParam::PARAM_IMAGE:
1462
-
1463
  $data = $this->getProcessedParamsValue_image($data, $value, $param);
1464
-
1465
  break;
1466
  case UniteCreatorDialogParam::PARAM_POST:
1467
  $data = $this->getProcessedParamsValue_post($data, $value, $param, $processType);
@@ -1559,8 +1626,7 @@ class UniteCreatorParamsProcessorWork{
1559
 
1560
  if($type != "imagebase_fields")
1561
  $data[$name] = $value;
1562
-
1563
-
1564
  $data = $this->getProcessedParamData($data, $value, $param, $processType);
1565
  }
1566
 
@@ -1689,7 +1755,7 @@ class UniteCreatorParamsProcessorWork{
1689
  $arrItemParams = $this->initProcessParams($arrItemParams);
1690
 
1691
  $numItems = count($arrItems);
1692
-
1693
  foreach($arrItems as $index => $arrItemValues){
1694
 
1695
  $elementorID = UniteFunctionsUC::getVal($arrItemValues, "_id");
@@ -1701,7 +1767,7 @@ class UniteCreatorParamsProcessorWork{
1701
  $arrParamsNew = $this->addon->setParamsValuesItems($arrItemValues, $arrItemParams);
1702
 
1703
  $item = $this->getProcessedParamsValues($arrParamsNew, $processType, $filterType);
1704
-
1705
  if($this->isOutputProcessType($processType) == true){
1706
  $item = $this->processFonts($item, "items", $index);
1707
  }
@@ -1720,18 +1786,26 @@ class UniteCreatorParamsProcessorWork{
1720
  case UniteCreatorAddon::ITEMS_TYPE_IMAGE:
1721
  //add thumb
1722
  $urlImage = UniteFunctionsUC::getVal($item, "image");
1723
-
1724
  $urlThumb = UniteFunctionsUC::getVal($item, "image_thumb_large");
1725
 
1726
- $item["thumb"] = $urlThumb;
 
1727
 
 
 
 
 
 
 
1728
  break;
1729
  }
1730
 
 
1731
  //add item variables
1732
  $arrVarsData = $this->getItemsVariablesProcessed($item, $index, $numItems);
1733
  $item = array_merge($item, $arrVarsData);
1734
 
 
1735
  //add elementor id
1736
  if($itemsType != UniteCreatorAddon::ITEMS_TYPE_IMAGE)
1737
  $item["item_repeater_class"] = "elementor-repeater-item-".$elementorID;
10
  class UniteCreatorParamsProcessorWork{
11
 
12
  private $objShapes;
13
+ protected $addon;
14
  private $processType;
15
  private static $counter = 0;
16
 
139
 
140
  //for auto complete
141
  //$this->addon = new UniteCreatorAddon();
142
+
143
  $this->addon = $addon;
144
  }
145
 
708
  * create param with full fields
709
  */
710
  protected function getImageFields($data, $name, $value){
711
+
712
  if(empty($data))
713
  $data = array();
714
 
720
  $data[$name] = $value;
721
  $data = $this->getProcessedParamsValue_image($data, $value, $param);
722
 
723
+
724
  return($data);
725
  }
726
 
761
  * add image attributes
762
  */
763
  private function addImageAttributes($data, $name, $param){
764
+
765
  $addImageSizes = UniteFunctionsUC::getVal($param, "add_image_sizes");
766
  $addImageSizes = UniteFunctionsUC::strToBool($addImageSizes);
767
 
814
  return($data);
815
  }
816
 
817
+ /**
818
+ * get default url of json image
819
+ */
820
+ private function getImageJsonDefaultUrl($param){
821
+
822
+ //no value at all - return nothing
823
+
824
+ $defaultValue = UniteFunctionsUC::getVal($param, "default_value_json");
825
+ if(empty($defaultValue)){
826
+ return("");
827
+ }
828
+
829
+ //only default:
830
+
831
+ $urlAssets = $this->addon->getUrlAssets();
832
+
833
+ if(empty($urlAssets))
834
+ return("");
835
+
836
+ $urlDefault = $urlAssets.$defaultValue;
837
+
838
+ return($urlDefault);
839
+ }
840
+
841
+ /**
842
+ * get image as json processed data
843
+ */
844
+ private function getProcessedParamsValue_imageJson($data, $value, $param){
845
+
846
+ //if the value is emtpy
847
+ if(empty($value)){
848
+
849
+ $urlDefault = $this->getImageJsonDefaultUrl($param);
850
+ return($urlDefault);
851
+ }
852
+
853
+ //if the value is string, must be a url, return it
854
+
855
+ if(is_numeric($value) == false)
856
+ return($value);
857
+
858
+ //if the value is number, get the url
859
+
860
+ $postThumb = get_post($value);
861
+
862
+ //if no thumb found by id - return default
863
+ if(empty($postThumb)){
864
+
865
+ $urlDefault = $this->getImageJsonDefaultUrl($param);
866
+ return($urlDefault);
867
+ }
868
+
869
+ $urlJson = $postThumb->guid;
870
+
871
+ return($urlJson);
872
+ }
873
+
874
+
875
  /**
876
  * process image param value, add to data
877
  * @param $param
878
  */
879
  protected function getProcessedParamsValue_image($data, $value, $param){
880
+
881
+ $mediaType = UniteFunctionsUC::getVal($param, "media_type");
882
 
883
  $name = $param["name"];
884
 
885
+ if($mediaType == "json"){
886
+
887
+ $data[$name] = $this->getProcessedParamsValue_imageJson($data, $value, $param);
888
+
889
+ return($data);
890
+ }
891
+
892
  $urlImage = $value; //in case that the value is image id
893
  if(is_numeric($value)){
894
  $urlImage = UniteProviderFunctionsUC::getImageUrlFromImageID($value);
898
  $value = HelperUC::URLtoFull($value);
899
  $data[$name] = $value;
900
  }
901
+
902
+
903
  $sizeFilters = UniteFunctionsUC::getVal($param, "size_filters");
904
  $isNoAttributes = UniteFunctionsUC::getVal($param, "no_attributes");
905
  $isNoImageData = UniteFunctionsUC::getVal($param, "no_image_data");
1151
 
1152
  if(empty($arrParams))
1153
  return(array());
1154
+
1155
  $arrParamsNew = array();
1156
  foreach($arrParams as $param){
1157
 
1170
  }
1171
 
1172
  }
1173
+
1174
  return($arrParamsNew);
1175
  }
1176
 
1528
  $data = $this->getProcessedParamsValue_responsive($data, $param);
1529
  break;
1530
  case UniteCreatorDialogParam::PARAM_IMAGE:
 
1531
  $data = $this->getProcessedParamsValue_image($data, $value, $param);
 
1532
  break;
1533
  case UniteCreatorDialogParam::PARAM_POST:
1534
  $data = $this->getProcessedParamsValue_post($data, $value, $param, $processType);
1626
 
1627
  if($type != "imagebase_fields")
1628
  $data[$name] = $value;
1629
+
 
1630
  $data = $this->getProcessedParamData($data, $value, $param, $processType);
1631
  }
1632
 
1755
  $arrItemParams = $this->initProcessParams($arrItemParams);
1756
 
1757
  $numItems = count($arrItems);
1758
+
1759
  foreach($arrItems as $index => $arrItemValues){
1760
 
1761
  $elementorID = UniteFunctionsUC::getVal($arrItemValues, "_id");
1767
  $arrParamsNew = $this->addon->setParamsValuesItems($arrItemValues, $arrItemParams);
1768
 
1769
  $item = $this->getProcessedParamsValues($arrParamsNew, $processType, $filterType);
1770
+
1771
  if($this->isOutputProcessType($processType) == true){
1772
  $item = $this->processFonts($item, "items", $index);
1773
  }
1786
  case UniteCreatorAddon::ITEMS_TYPE_IMAGE:
1787
  //add thumb
1788
  $urlImage = UniteFunctionsUC::getVal($item, "image");
 
1789
  $urlThumb = UniteFunctionsUC::getVal($item, "image_thumb_large");
1790
 
1791
+ if(empty($urlThumb))
1792
+ $urlThumb = $urlImage;
1793
 
1794
+ $item["thumb"] = $urlThumb;
1795
+
1796
+ $item["image_id"] = UniteFunctionsUC::getVal($arrItemValues, "image_id");
1797
+ $item["raw_caption"] = UniteFunctionsUC::getVal($arrItemValues, "raw_caption");
1798
+ $item["raw_title"] = UniteFunctionsUC::getVal($arrItemValues, "raw_title");
1799
+
1800
  break;
1801
  }
1802
 
1803
+
1804
  //add item variables
1805
  $arrVarsData = $this->getItemsVariablesProcessed($item, $index, $numItems);
1806
  $item = array_merge($item, $arrVarsData);
1807
 
1808
+
1809
  //add elementor id
1810
  if($itemsType != UniteCreatorAddon::ITEMS_TYPE_IMAGE)
1811
  $item["item_repeater_class"] = "elementor-repeater-item-".$elementorID;
inc_php/unitecreator_settings.class.php CHANGED
@@ -157,7 +157,8 @@ class UniteCreatorSettingsWork extends UniteSettingsAdvancedUC{
157
  "uc_icon",
158
  UniteCreatorDialogParam::PARAM_ICON_LIBRARY,
159
  UniteCreatorDialogParam::PARAM_SHAPE,
160
- "uc_hr",
 
161
  "uc_font_override",
162
  UniteCreatorDialogParam::PARAM_POST,
163
  UniteCreatorDialogParam::PARAM_POSTS_LIST,
@@ -697,9 +698,15 @@ class UniteCreatorSettingsWork extends UniteSettingsAdvancedUC{
697
  case UniteCreatorDialogParam::PARAM_MAP:
698
  $this->addGoogleMap($name,$value,$title,$extra);
699
  break;
700
- case "uc_hr":
701
  $this->addHr($name);
702
  $isUpdateValue = false;
 
 
 
 
 
 
703
  break;
704
  case "uc_font_override":
705
  //don't draw anything
@@ -848,6 +855,11 @@ class UniteCreatorSettingsWork extends UniteSettingsAdvancedUC{
848
 
849
  $this->addVisibleInElementorOnlySetting("Hover Animations");
850
 
 
 
 
 
 
851
  break;
852
  case UniteCreatorDialogParam::PARAM_DATETIME:
853
 
157
  "uc_icon",
158
  UniteCreatorDialogParam::PARAM_ICON_LIBRARY,
159
  UniteCreatorDialogParam::PARAM_SHAPE,
160
+ UniteCreatorDialogParam::PARAM_HR,
161
+ UniteCreatorDialogParam::PARAM_HEADING,
162
  "uc_font_override",
163
  UniteCreatorDialogParam::PARAM_POST,
164
  UniteCreatorDialogParam::PARAM_POSTS_LIST,
698
  case UniteCreatorDialogParam::PARAM_MAP:
699
  $this->addGoogleMap($name,$value,$title,$extra);
700
  break;
701
+ case UniteCreatorDialogParam::PARAM_HR:
702
  $this->addHr($name);
703
  $isUpdateValue = false;
704
+ break;
705
+ case UniteCreatorDialogParam::PARAM_HEADING:
706
+
707
+ $this->addStaticText($value);
708
+
709
+
710
  break;
711
  case "uc_font_override":
712
  //don't draw anything
855
 
856
  $this->addVisibleInElementorOnlySetting("Hover Animations");
857
 
858
+ break;
859
+ case UniteCreatorDialogParam::PARAM_SPECIAL:
860
+
861
+ $this->addVisibleInElementorOnlySetting("Special Attribute");
862
+
863
  break;
864
  case UniteCreatorDialogParam::PARAM_DATETIME:
865
 
inc_php/unitecreator_template_engine.class.php CHANGED
@@ -632,16 +632,19 @@ class UniteCreatorTemplateEngineWork{
632
  * put listing loop
633
  */
634
  public function putListingItemTemplate($item, $templateID){
635
-
636
- HelperProviderCoreUC_EL::putListingItemTemplate($item, $templateID);
637
 
 
638
  }
639
 
640
  /**
641
  * put dynamic loop template, similar to put listing template
642
  */
643
  public function putDynamicLoopTemplate($item, $templateID){
644
- HelperProviderCoreUC_EL::putListingItemTemplate($item, $templateID);
 
 
 
 
645
  }
646
 
647
 
@@ -773,7 +776,7 @@ class UniteCreatorTemplateEngineWork{
773
  dmP("put built in placeholder");
774
  exit();
775
  }
776
-
777
  dmp("image placeholders");
778
  dmp($arrPost);
779
  //exit();
@@ -823,10 +826,31 @@ class UniteCreatorTemplateEngineWork{
823
  $objFilters = new UniteCreatorFiltersProcess();
824
  $objFilters->putCheckboxFiltersTest($arg1);
825
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
826
 
827
  break;
828
  default:
829
- $strTypes = "put_date_range, get_general_setting, run_code_once, put_single_filter";
 
 
830
 
831
  $type = UniteFunctionsUC::sanitizeAttr($type);
832
 
@@ -1036,7 +1060,7 @@ class UniteCreatorTemplateEngineWork{
1036
  * return if some template exists
1037
  * @param $name
1038
  */
1039
- private function isTemplateExists($name){
1040
 
1041
  $isExists = array_key_exists($name, $this->arrTemplates);
1042
 
@@ -1044,15 +1068,24 @@ class UniteCreatorTemplateEngineWork{
1044
  }
1045
 
1046
 
 
1047
  /**
1048
  * add template
1049
  */
1050
- public function addTemplate($name, $html){
1051
 
1052
  $this->validateNotInited();
1053
 
1054
- if(isset($this->arrTemplates[$name]))
 
 
 
 
 
 
1055
  UniteFunctionsUC::throwError("template with name: $name already exists");
 
 
1056
 
1057
  $this->arrTemplates[$name] = $html;
1058
  }
632
  * put listing loop
633
  */
634
  public function putListingItemTemplate($item, $templateID){
 
 
635
 
636
+ $this->putDynamicLoopTemplate($item, $templateID);
637
  }
638
 
639
  /**
640
  * put dynamic loop template, similar to put listing template
641
  */
642
  public function putDynamicLoopTemplate($item, $templateID){
643
+
644
+ $widgetID = UniteFunctionsUC::getVal($this->arrParams, "uc_id");
645
+
646
+ HelperProviderCoreUC_EL::putListingItemTemplate($item, $templateID, $widgetID);
647
+
648
  }
649
 
650
 
776
  dmP("put built in placeholder");
777
  exit();
778
  }
779
+
780
  dmp("image placeholders");
781
  dmp($arrPost);
782
  //exit();
826
  $objFilters = new UniteCreatorFiltersProcess();
827
  $objFilters->putCheckboxFiltersTest($arg1);
828
 
829
+ break;
830
+ case "get_post_term":
831
+
832
+ //arg1 - postID
833
+ //arg2 - taxonomy
834
+ //arg3 - term slug
835
+
836
+ $term = HelperProviderUC::getPostTermForTemplate($arg1, $arg2, $arg3);
837
+ return($term);
838
+
839
+ break;
840
+ case "is_post_has_term":
841
+
842
+ $term = HelperProviderUC::getPostTermForTemplate($arg1, $arg2, $arg3);
843
+
844
+ if(!empty($term))
845
+ return("yes");
846
+ else
847
+ return("no");
848
 
849
  break;
850
  default:
851
+ $strTypes = "put_date_range, get_general_setting,
852
+ run_code_once, get_post_term,
853
+ is_post_has_term, get_from_sql";
854
 
855
  $type = UniteFunctionsUC::sanitizeAttr($type);
856
 
1060
  * return if some template exists
1061
  * @param $name
1062
  */
1063
+ public function isTemplateExists($name){
1064
 
1065
  $isExists = array_key_exists($name, $this->arrTemplates);
1066
 
1068
  }
1069
 
1070
 
1071
+
1072
  /**
1073
  * add template
1074
  */
1075
+ public function addTemplate($name, $html, $showError = true){
1076
 
1077
  $this->validateNotInited();
1078
 
1079
+ $isExists = isset($this->arrTemplates[$name]);
1080
+
1081
+ if($isExists == true){
1082
+
1083
+ if($showError == false)
1084
+ return(false);
1085
+
1086
  UniteFunctionsUC::throwError("template with name: $name already exists");
1087
+ }
1088
+
1089
 
1090
  $this->arrTemplates[$name] = $html;
1091
  }
inc_php/unitecreator_variables_output.class.php CHANGED
@@ -143,6 +143,26 @@ class UniteCreatorVariablesOutput{
143
  return($content);
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  /**
148
  * get main var content
@@ -160,6 +180,9 @@ class UniteCreatorVariablesOutput{
160
  case UniteCreatorDialogParam::PARAM_VAR_GET:
161
  $content = $this->getContent_GETParam();
162
  break;
 
 
 
163
  default:
164
  UniteFunctionsUC::throwError("Wrong main variable type: <b>{$type}</b>");
165
  break;
143
  return($content);
144
  }
145
 
146
+ /**
147
+ * get content by filter
148
+ */
149
+ private function getContent_filter(){
150
+
151
+ $filterName = UniteFunctionsUC::getVal($this->var, "filter_name");
152
+
153
+ $filterParam = UniteFunctionsUC::getVal($this->var, "filter_param");
154
+
155
+ if(empty($filterName))
156
+ return("");
157
+
158
+ if(empty($filterParam))
159
+ $content = apply_filters($filterName, "");
160
+ else
161
+ $content = apply_filters($filterName, "", $filterParam);
162
+
163
+ return($content);
164
+ }
165
+
166
 
167
  /**
168
  * get main var content
180
  case UniteCreatorDialogParam::PARAM_VAR_GET:
181
  $content = $this->getContent_GETParam();
182
  break;
183
+ case UniteCreatorDialogParam::PARAM_VAR_FILTER:
184
+ $content = $this->getContent_filter();
185
+ break;
186
  default:
187
  UniteFunctionsUC::throwError("Wrong main variable type: <b>{$type}</b>");
188
  break;
includes.php CHANGED
@@ -12,7 +12,7 @@ if(!defined('UNLIMITED_ELEMENTS_INC'))
12
  defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
13
 
14
  if(!defined("UNLIMITED_ELEMENTS_VERSION"))
15
- define("UNLIMITED_ELEMENTS_VERSION", "1.4.79");
16
 
17
  $currentFile = __FILE__;
18
  $currentFolder = dirname($currentFile);
12
  defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
13
 
14
  if(!defined("UNLIMITED_ELEMENTS_VERSION"))
15
+ define("UNLIMITED_ELEMENTS_VERSION", "1.4.81");
16
 
17
  $currentFile = __FILE__;
18
  $currentFolder = dirname($currentFile);
js/codemirror/old/codemirror.css DELETED
@@ -1,323 +0,0 @@
1
- /* BASICS */
2
-
3
- .CodeMirror {
4
- /* Set height, width, borders, and global font properties here */
5
- font-family: monospace;
6
- height: 300px;
7
- color: black;
8
- }
9
-
10
- /* PADDING */
11
-
12
- .CodeMirror-lines {
13
- padding: 4px 0; /* Vertical padding around content */
14
- }
15
- .CodeMirror pre {
16
- padding: 0 4px; /* Horizontal padding of content */
17
- }
18
-
19
- .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
20
- background-color: white; /* The little square between H and V scrollbars */
21
- }
22
-
23
- /* GUTTER */
24
-
25
- .CodeMirror-gutters {
26
- border-right: 1px solid #ddd;
27
- background-color: #f7f7f7;
28
- white-space: nowrap;
29
- }
30
- .CodeMirror-linenumbers {}
31
- .CodeMirror-linenumber {
32
- padding: 0 3px 0 5px;
33
- min-width: 20px;
34
- text-align: right;
35
- color: #999;
36
- white-space: nowrap;
37
- }
38
-
39
- .CodeMirror-guttermarker { color: black; }
40
- .CodeMirror-guttermarker-subtle { color: #999; }
41
-
42
- /* CURSOR */
43
-
44
- .CodeMirror div.CodeMirror-cursor {
45
- border-left: 1px solid black;
46
- }
47
- /* Shown when moving in bi-directional text */
48
- .CodeMirror div.CodeMirror-secondarycursor {
49
- border-left: 1px solid silver;
50
- }
51
- .CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
52
- width: auto;
53
- border: 0;
54
- background: #7e7;
55
- }
56
- .CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
57
- z-index: 1;
58
- }
59
-
60
- .cm-animate-fat-cursor {
61
- width: auto;
62
- border: 0;
63
- -webkit-animation: blink 1.06s steps(1) infinite;
64
- -moz-animation: blink 1.06s steps(1) infinite;
65
- animation: blink 1.06s steps(1) infinite;
66
- }
67
- @-moz-keyframes blink {
68
- 0% { background: #7e7; }
69
- 50% { background: none; }
70
- 100% { background: #7e7; }
71
- }
72
- @-webkit-keyframes blink {
73
- 0% { background: #7e7; }
74
- 50% { background: none; }
75
- 100% { background: #7e7; }
76
- }
77
- @keyframes blink {
78
- 0% { background: #7e7; }
79
- 50% { background: none; }
80
- 100% { background: #7e7; }
81
- }
82
-
83
- /* Can style cursor different in overwrite (non-insert) mode */
84
- div.CodeMirror-overwrite div.CodeMirror-cursor {}
85
-
86
- .cm-tab { display: inline-block; text-decoration: inherit; }
87
-
88
- .CodeMirror-ruler {
89
- border-left: 1px solid #ccc;
90
- position: absolute;
91
- }
92
-
93
- /* DEFAULT THEME */
94
-
95
- .cm-s-default .cm-keyword {color: #708;}
96
- .cm-s-default .cm-atom {color: #219;}
97
- .cm-s-default .cm-number {color: #164;}
98
- .cm-s-default .cm-def {color: #00f;}
99
- .cm-s-default .cm-variable,
100
- .cm-s-default .cm-punctuation,
101
- .cm-s-default .cm-property,
102
- .cm-s-default .cm-operator {}
103
- .cm-s-default .cm-variable-2 {color: #05a;}
104
- .cm-s-default .cm-variable-3 {color: #085;}
105
- .cm-s-default .cm-comment {color: #a50;}
106
- .cm-s-default .cm-string {color: #a11;}
107
- .cm-s-default .cm-string-2 {color: #f50;}
108
- .cm-s-default .cm-meta {color: #555;}
109
- .cm-s-default .cm-qualifier {color: #555;}
110
- .cm-s-default .cm-builtin {color: #30a;}
111
- .cm-s-default .cm-bracket {color: #997;}
112
- .cm-s-default .cm-tag {color: #170;}
113
- .cm-s-default .cm-attribute {color: #00c;}
114
- .cm-s-default .cm-header {color: blue;}
115
- .cm-s-default .cm-quote {color: #090;}
116
- .cm-s-default .cm-hr {color: #999;}
117
- .cm-s-default .cm-link {color: #00c;}
118
-
119
- .cm-negative {color: #d44;}
120
- .cm-positive {color: #292;}
121
- .cm-header, .cm-strong {font-weight: bold;}
122
- .cm-em {font-style: italic;}
123
- .cm-link {text-decoration: underline;}
124
- .cm-strikethrough {text-decoration: line-through;}
125
-
126
- .cm-s-default .cm-error {color: #f00;}
127
- .cm-invalidchar {color: #f00;}
128
-
129
- /* Default styles for common addons */
130
-
131
- div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
132
- div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
133
- .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
134
- .CodeMirror-activeline-background {background: #e8f2ff;}
135
-
136
- /* STOP */
137
-
138
- /* The rest of this file contains styles related to the mechanics of
139
- the editor. You probably shouldn't touch them. */
140
-
141
- .CodeMirror {
142
- position: relative;
143
- overflow: hidden;
144
- background: white;
145
- }
146
-
147
- .CodeMirror-scroll {
148
- overflow: scroll !important; /* Things will break if this is overridden */
149
- /* 30px is the magic margin used to hide the element's real scrollbars */
150
- /* See overflow: hidden in .CodeMirror */
151
- margin-bottom: -30px; margin-right: -30px;
152
- padding-bottom: 30px;
153
- height: 100%;
154
- outline: none; /* Prevent dragging from highlighting the element */
155
- position: relative;
156
- }
157
- .CodeMirror-sizer {
158
- position: relative;
159
- border-right: 30px solid transparent;
160
- }
161
-
162
- /* The fake, visible scrollbars. Used to force redraw during scrolling
163
- before actuall scrolling happens, thus preventing shaking and
164
- flickering artifacts. */
165
- .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
166
- position: absolute;
167
- z-index: 6;
168
- display: none;
169
- }
170
- .CodeMirror-vscrollbar {
171
- right: 0; top: 0;
172
- overflow-x: hidden;
173
- overflow-y: scroll;
174
- }
175
- .CodeMirror-hscrollbar {
176
- bottom: 0; left: 0;
177
- overflow-y: hidden;
178
- overflow-x: scroll;
179
- }
180
- .CodeMirror-scrollbar-filler {
181
- right: 0; bottom: 0;
182
- }
183
- .CodeMirror-gutter-filler {
184
- left: 0; bottom: 0;
185
- }
186
-
187
- .CodeMirror-gutters {
188
- position: absolute; left: 0; top: 0;
189
- z-index: 3;
190
- }
191
- .CodeMirror-gutter {
192
- white-space: normal;
193
- height: 100%;
194
- display: inline-block;
195
- margin-bottom: -30px;
196
- /* Hack to make IE7 behave */
197
- *zoom:1;
198
- *display:inline;
199
- }
200
- .CodeMirror-gutter-wrapper {
201
- position: absolute;
202
- z-index: 4;
203
- height: 100%;
204
- }
205
- .CodeMirror-gutter-elt {
206
- position: absolute;
207
- cursor: default;
208
- z-index: 4;
209
- }
210
- .CodeMirror-gutter-wrapper {
211
- -webkit-user-select: none;
212
- -moz-user-select: none;
213
- user-select: none;
214
- }
215
-
216
- .CodeMirror-lines {
217
- cursor: text;
218
- min-height: 1px; /* prevents collapsing before first draw */
219
- }
220
- .CodeMirror pre {
221
- /* Reset some styles that the rest of the page might have set */
222
- -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
223
- border-width: 0;
224
- background: transparent;
225
- font-family: inherit;
226
- font-size: inherit;
227
- margin: 0;
228
- white-space: pre;
229
- word-wrap: normal;
230
- line-height: inherit;
231
- color: inherit;
232
- z-index: 2;
233
- position: relative;
234
- overflow: visible;
235
- -webkit-tap-highlight-color: transparent;
236
- }
237
- .CodeMirror-wrap pre {
238
- word-wrap: break-word;
239
- white-space: pre-wrap;
240
- word-break: normal;
241
- }
242
-
243
- .CodeMirror-linebackground {
244
- position: absolute;
245
- left: 0; right: 0; top: 0; bottom: 0;
246
- z-index: 0;
247
- }
248
-
249
- .CodeMirror-linewidget {
250
- position: relative;
251
- z-index: 2;
252
- overflow: auto;
253
- }
254
-
255
- .CodeMirror-widget {}
256
-
257
- .CodeMirror-code {
258
- outline: none;
259
- }
260
-
261
- /* Force content-box sizing for the elements where we expect it */
262
- .CodeMirror-scroll,
263
- .CodeMirror-sizer,
264
- .CodeMirror-gutter,
265
- .CodeMirror-gutters,
266
- .CodeMirror-linenumber {
267
- -moz-box-sizing: content-box;
268
- box-sizing: content-box;
269
- }
270
-
271
- .CodeMirror-measure {
272
- position: absolute;
273
- width: 100%;
274
- height: 0;
275
- overflow: hidden;
276
- visibility: hidden;
277
- }
278
- .CodeMirror-measure pre { position: static; }
279
-
280
- .CodeMirror div.CodeMirror-cursor {
281
- position: absolute;
282
- border-right: none;
283
- width: 0;
284
- }
285
-
286
- div.CodeMirror-cursors {
287
- visibility: hidden;
288
- position: relative;
289
- z-index: 3;
290
- }
291
- .CodeMirror-focused div.CodeMirror-cursors {
292
- visibility: visible;
293
- }
294
-
295
- .CodeMirror-selected { background: #d9d9d9; }
296
- .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
297
- .CodeMirror-crosshair { cursor: crosshair; }
298
- .CodeMirror ::selection { background: #d7d4f0; }
299
- .CodeMirror ::-moz-selection { background: #d7d4f0; }
300
-
301
- .cm-searching {
302
- background: #ffa;
303
- background: rgba(255, 255, 0, .4);
304
- }
305
-
306
- /* IE7 hack to prevent it from returning funny offsetTops on the spans */
307
- .CodeMirror span { *vertical-align: text-bottom; }
308
-
309
- /* Used to force a border model for a node */
310
- .cm-force-border { padding-right: .1px; }
311
-
312
- @media print {
313
- /* Hide the cursor when printing */
314
- .CodeMirror div.CodeMirror-cursors {
315
- visibility: hidden;
316
- }
317
- }
318
-
319
- /* See issue #2901 */
320
- .cm-tab-wrap-hack:after { content: ''; }
321
-
322
- /* Help users use markselection to safely style text background */
323
- span.CodeMirror-selectedtext { background: none; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/codemirror/old/codemirror.js DELETED
@@ -1,8658 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- // This is CodeMirror (http://codemirror.net), a code editor
5
- // implemented in JavaScript on top of the browser's DOM.
6
- //
7
- // You can find some technical background for some of the code below
8
- // at http://marijnhaverbeke.nl/blog/#cm-internals .
9
-
10
- (function(mod) {
11
- if (typeof exports == "object" && typeof module == "object") // CommonJS
12
- module.exports = mod();
13
- else if (typeof define == "function" && define.amd) // AMD
14
- return define([], mod);
15
- else // Plain browser env
16
- this.CodeMirror = mod();
17
- })(function() {
18
- "use strict";
19
-
20
- // BROWSER SNIFFING
21
-
22
- // Kludges for bugs and behavior differences that can't be feature
23
- // detected are enabled based on userAgent etc sniffing.
24
-
25
- var gecko = /gecko\/\d/i.test(navigator.userAgent);
26
- var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
27
- var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
28
- var ie = ie_upto10 || ie_11up;
29
- var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
30
- var webkit = /WebKit\//.test(navigator.userAgent);
31
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
32
- var chrome = /Chrome\//.test(navigator.userAgent);
33
- var presto = /Opera\//.test(navigator.userAgent);
34
- var safari = /Apple Computer/.test(navigator.vendor);
35
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
36
- var phantom = /PhantomJS/.test(navigator.userAgent);
37
-
38
- var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
39
- // This is woefully incomplete. Suggestions for alternative methods welcome.
40
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
41
- var mac = ios || /Mac/.test(navigator.platform);
42
- var windows = /win/i.test(navigator.platform);
43
-
44
- var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
45
- if (presto_version) presto_version = Number(presto_version[1]);
46
- if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
47
- // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
48
- var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
49
- var captureRightClick = gecko || (ie && ie_version >= 9);
50
-
51
- // Optimize some code when these features are not used.
52
- var sawReadOnlySpans = false, sawCollapsedSpans = false;
53
-
54
- // EDITOR CONSTRUCTOR
55
-
56
- // A CodeMirror instance represents an editor. This is the object
57
- // that user code is usually dealing with.
58
-
59
- function CodeMirror(place, options) {
60
- if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
61
-
62
- this.options = options = options ? copyObj(options) : {};
63
- // Determine effective options based on given values and defaults.
64
- copyObj(defaults, options, false);
65
- setGuttersForLineNumbers(options);
66
-
67
- var doc = options.value;
68
- if (typeof doc == "string") doc = new Doc(doc, options.mode);
69
- this.doc = doc;
70
-
71
- var input = new CodeMirror.inputStyles[options.inputStyle](this);
72
- var display = this.display = new Display(place, doc, input);
73
- display.wrapper.CodeMirror = this;
74
- updateGutters(this);
75
- themeChanged(this);
76
- if (options.lineWrapping)
77
- this.display.wrapper.className += " CodeMirror-wrap";
78
- if (options.autofocus && !mobile) display.input.focus();
79
- initScrollbars(this);
80
-
81
- this.state = {
82
- keyMaps: [], // stores maps added by addKeyMap
83
- overlays: [], // highlighting overlays, as added by addOverlay
84
- modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
85
- overwrite: false, focused: false,
86
- suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
87
- pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
88
- draggingText: false,
89
- highlight: new Delayed(), // stores highlight worker timeout
90
- keySeq: null, // Unfinished key sequence
91
- specialChars: null
92
- };
93
-
94
- var cm = this;
95
-
96
- // Override magic textarea content restore that IE sometimes does
97
- // on our hidden textarea on reload
98
- if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
99
-
100
- registerEventHandlers(this);
101
- ensureGlobalHandlers();
102
-
103
- startOperation(this);
104
- this.curOp.forceUpdate = true;
105
- attachDoc(this, doc);
106
-
107
- if ((options.autofocus && !mobile) || cm.hasFocus())
108
- setTimeout(bind(onFocus, this), 20);
109
- else
110
- onBlur(this);
111
-
112
- for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
113
- optionHandlers[opt](this, options[opt], Init);
114
- maybeUpdateLineNumberWidth(this);
115
- if (options.finishInit) options.finishInit(this);
116
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
117
- endOperation(this);
118
- // Suppress optimizelegibility in Webkit, since it breaks text
119
- // measuring on line wrapping boundaries.
120
- if (webkit && options.lineWrapping &&
121
- getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
122
- display.lineDiv.style.textRendering = "auto";
123
- }
124
-
125
- // DISPLAY CONSTRUCTOR
126
-
127
- // The display handles the DOM integration, both for input reading
128
- // and content drawing. It holds references to DOM nodes and
129
- // display-related state.
130
-
131
- function Display(place, doc, input) {
132
- var d = this;
133
- this.input = input;
134
-
135
- // Covers bottom-right square when both scrollbars are present.
136
- d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
137
- d.scrollbarFiller.setAttribute("cm-not-content", "true");
138
- // Covers bottom of gutter when coverGutterNextToScrollbar is on
139
- // and h scrollbar is present.
140
- d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
141
- d.gutterFiller.setAttribute("cm-not-content", "true");
142
- // Will contain the actual code, positioned to cover the viewport.
143
- d.lineDiv = elt("div", null, "CodeMirror-code");
144
- // Elements are added to these to represent selection and cursors.
145
- d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
146
- d.cursorDiv = elt("div", null, "CodeMirror-cursors");
147
- // A visibility: hidden element used to find the size of things.
148
- d.measure = elt("div", null, "CodeMirror-measure");
149
- // When lines outside of the viewport are measured, they are drawn in this.
150
- d.lineMeasure = elt("div", null, "CodeMirror-measure");
151
- // Wraps everything that needs to exist inside the vertically-padded coordinate system
152
- d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
153
- null, "position: relative; outline: none");
154
- // Moved around its parent to cover visible view.
155
- d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
156
- // Set to the height of the document, allowing scrolling.
157
- d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
158
- d.sizerWidth = null;
159
- // Behavior of elts with overflow: auto and padding is
160
- // inconsistent across browsers. This is used to ensure the
161
- // scrollable area is big enough.
162
- d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
163
- // Will contain the gutters, if any.
164
- d.gutters = elt("div", null, "CodeMirror-gutters");
165
- d.lineGutter = null;
166
- // Actual scrollable element.
167
- d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
168
- d.scroller.setAttribute("tabIndex", "-1");
169
- // The element in which the editor lives.
170
- d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
171
-
172
- // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
173
- if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
174
- if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
175
-
176
- if (place) {
177
- if (place.appendChild) place.appendChild(d.wrapper);
178
- else place(d.wrapper);
179
- }
180
-
181
- // Current rendered range (may be bigger than the view window).
182
- d.viewFrom = d.viewTo = doc.first;
183
- d.reportedViewFrom = d.reportedViewTo = doc.first;
184
- // Information about the rendered lines.
185
- d.view = [];
186
- d.renderedView = null;
187
- // Holds info about a single rendered line when it was rendered
188
- // for measurement, while not in view.
189
- d.externalMeasured = null;
190
- // Empty space (in pixels) above the view
191
- d.viewOffset = 0;
192
- d.lastWrapHeight = d.lastWrapWidth = 0;
193
- d.updateLineNumbers = null;
194
-
195
- d.nativeBarWidth = d.barHeight = d.barWidth = 0;
196
- d.scrollbarsClipped = false;
197
-
198
- // Used to only resize the line number gutter when necessary (when
199
- // the amount of lines crosses a boundary that makes its width change)
200
- d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
201
- // Set to true when a non-horizontal-scrolling line widget is
202
- // added. As an optimization, line widget aligning is skipped when
203
- // this is false.
204
- d.alignWidgets = false;
205
-
206
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
207
-
208
- // Tracks the maximum line length so that the horizontal scrollbar
209
- // can be kept static when scrolling.
210
- d.maxLine = null;
211
- d.maxLineLength = 0;
212
- d.maxLineChanged = false;
213
-
214
- // Used for measuring wheel scrolling granularity
215
- d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
216
-
217
- // True when shift is held down.
218
- d.shift = false;
219
-
220
- // Used to track whether anything happened since the context menu
221
- // was opened.
222
- d.selForContextMenu = null;
223
-
224
- d.activeTouch = null;
225
-
226
- input.init(d);
227
- }
228
-
229
- // STATE UPDATES
230
-
231
- // Used to get the editor into a consistent state again when options change.
232
-
233
- function loadMode(cm) {
234
- cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
235
- resetModeState(cm);
236
- }
237
-
238
- function resetModeState(cm) {
239
- cm.doc.iter(function(line) {
240
- if (line.stateAfter) line.stateAfter = null;
241
- if (line.styles) line.styles = null;
242
- });
243
- cm.doc.frontier = cm.doc.first;
244
- startWorker(cm, 100);
245
- cm.state.modeGen++;
246
- if (cm.curOp) regChange(cm);
247
- }
248
-
249
- function wrappingChanged(cm) {
250
- if (cm.options.lineWrapping) {
251
- addClass(cm.display.wrapper, "CodeMirror-wrap");
252
- cm.display.sizer.style.minWidth = "";
253
- cm.display.sizerWidth = null;
254
- } else {
255
- rmClass(cm.display.wrapper, "CodeMirror-wrap");
256
- findMaxLine(cm);
257
- }
258
- estimateLineHeights(cm);
259
- regChange(cm);
260
- clearCaches(cm);
261
- setTimeout(function(){updateScrollbars(cm);}, 100);
262
- }
263
-
264
- // Returns a function that estimates the height of a line, to use as
265
- // first approximation until the line becomes visible (and is thus
266
- // properly measurable).
267
- function estimateHeight(cm) {
268
- var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
269
- var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
270
- return function(line) {
271
- if (lineIsHidden(cm.doc, line)) return 0;
272
-
273
- var widgetsHeight = 0;
274
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
275
- if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
276
- }
277
-
278
- if (wrapping)
279
- return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
280
- else
281
- return widgetsHeight + th;
282
- };
283
- }
284
-
285
- function estimateLineHeights(cm) {
286
- var doc = cm.doc, est = estimateHeight(cm);
287
- doc.iter(function(line) {
288
- var estHeight = est(line);
289
- if (estHeight != line.height) updateLineHeight(line, estHeight);
290
- });
291
- }
292
-
293
- function themeChanged(cm) {
294
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
295
- cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
296
- clearCaches(cm);
297
- }
298
-
299
- function guttersChanged(cm) {
300
- updateGutters(cm);
301
- regChange(cm);
302
- setTimeout(function(){alignHorizontally(cm);}, 20);
303
- }
304
-
305
- // Rebuild the gutter elements, ensure the margin to the left of the
306
- // code matches their width.
307
- function updateGutters(cm) {
308
- var gutters = cm.display.gutters, specs = cm.options.gutters;
309
- removeChildren(gutters);
310
- for (var i = 0; i < specs.length; ++i) {
311
- var gutterClass = specs[i];
312
- var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
313
- if (gutterClass == "CodeMirror-linenumbers") {
314
- cm.display.lineGutter = gElt;
315
- gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
316
- }
317
- }
318
- gutters.style.display = i ? "" : "none";
319
- updateGutterSpace(cm);
320
- }
321
-
322
- function updateGutterSpace(cm) {
323
- var width = cm.display.gutters.offsetWidth;
324
- cm.display.sizer.style.marginLeft = width + "px";
325
- }
326
-
327
- // Compute the character length of a line, taking into account
328
- // collapsed ranges (see markText) that might hide parts, and join
329
- // other lines onto it.
330
- function lineLength(line) {
331
- if (line.height == 0) return 0;
332
- var len = line.text.length, merged, cur = line;
333
- while (merged = collapsedSpanAtStart(cur)) {
334
- var found = merged.find(0, true);
335
- cur = found.from.line;
336
- len += found.from.ch - found.to.ch;
337
- }
338
- cur = line;
339
- while (merged = collapsedSpanAtEnd(cur)) {
340
- var found = merged.find(0, true);
341
- len -= cur.text.length - found.from.ch;
342
- cur = found.to.line;
343
- len += cur.text.length - found.to.ch;
344
- }
345
- return len;
346
- }
347
-
348
- // Find the longest line in the document.
349
- function findMaxLine(cm) {
350
- var d = cm.display, doc = cm.doc;
351
- d.maxLine = getLine(doc, doc.first);
352
- d.maxLineLength = lineLength(d.maxLine);
353
- d.maxLineChanged = true;
354
- doc.iter(function(line) {
355
- var len = lineLength(line);
356
- if (len > d.maxLineLength) {
357
- d.maxLineLength = len;
358
- d.maxLine = line;
359
- }
360
- });
361
- }
362
-
363
- // Make sure the gutters options contains the element
364
- // "CodeMirror-linenumbers" when the lineNumbers option is true.
365
- function setGuttersForLineNumbers(options) {
366
- var found = indexOf(options.gutters, "CodeMirror-linenumbers");
367
- if (found == -1 && options.lineNumbers) {
368
- options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
369
- } else if (found > -1 && !options.lineNumbers) {
370
- options.gutters = options.gutters.slice(0);
371
- options.gutters.splice(found, 1);
372
- }
373
- }
374
-
375
- // SCROLLBARS
376
-
377
- // Prepare DOM reads needed to update the scrollbars. Done in one
378
- // shot to minimize update/measure roundtrips.
379
- function measureForScrollbars(cm) {
380
- var d = cm.display, gutterW = d.gutters.offsetWidth;
381
- var docH = Math.round(cm.doc.height + paddingVert(cm.display));
382
- return {
383
- clientHeight: d.scroller.clientHeight,
384
- viewHeight: d.wrapper.clientHeight,
385
- scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
386
- viewWidth: d.wrapper.clientWidth,
387
- barLeft: cm.options.fixedGutter ? gutterW : 0,
388
- docHeight: docH,
389
- scrollHeight: docH + scrollGap(cm) + d.barHeight,
390
- nativeBarWidth: d.nativeBarWidth,
391
- gutterWidth: gutterW
392
- };
393
- }
394
-
395
- function NativeScrollbars(place, scroll, cm) {
396
- this.cm = cm;
397
- var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
398
- var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
399
- place(vert); place(horiz);
400
-
401
- on(vert, "scroll", function() {
402
- if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
403
- });
404
- on(horiz, "scroll", function() {
405
- if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
406
- });
407
-
408
- this.checkedOverlay = false;
409
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
410
- if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
411
- }
412
-
413
- NativeScrollbars.prototype = copyObj({
414
- update: function(measure) {
415
- var needsH = measure.scrollWidth > measure.clientWidth + 1;
416
- var needsV = measure.scrollHeight > measure.clientHeight + 1;
417
- var sWidth = measure.nativeBarWidth;
418
-
419
- if (needsV) {
420
- this.vert.style.display = "block";
421
- this.vert.style.bottom = needsH ? sWidth + "px" : "0";
422
- var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
423
- // A bug in IE8 can cause this value to be negative, so guard it.
424
- this.vert.firstChild.style.height =
425
- Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
426
- } else {
427
- this.vert.style.display = "";
428
- this.vert.firstChild.style.height = "0";
429
- }
430
-
431
- if (needsH) {
432
- this.horiz.style.display = "block";
433
- this.horiz.style.right = needsV ? sWidth + "px" : "0";
434
- this.horiz.style.left = measure.barLeft + "px";
435
- var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
436
- this.horiz.firstChild.style.width =
437
- (measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
438
- } else {
439
- this.horiz.style.display = "";
440
- this.horiz.firstChild.style.width = "0";
441
- }
442
-
443
- if (!this.checkedOverlay && measure.clientHeight > 0) {
444
- if (sWidth == 0) this.overlayHack();
445
- this.checkedOverlay = true;
446
- }
447
-
448
- return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
449
- },
450
- setScrollLeft: function(pos) {
451
- if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
452
- },
453
- setScrollTop: function(pos) {
454
- if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
455
- },
456
- overlayHack: function() {
457
- var w = mac && !mac_geMountainLion ? "12px" : "18px";
458
- this.horiz.style.minHeight = this.vert.style.minWidth = w;
459
- var self = this;
460
- var barMouseDown = function(e) {
461
- if (e_target(e) != self.vert && e_target(e) != self.horiz)
462
- operation(self.cm, onMouseDown)(e);
463
- };
464
- on(this.vert, "mousedown", barMouseDown);
465
- on(this.horiz, "mousedown", barMouseDown);
466
- },
467
- clear: function() {
468
- var parent = this.horiz.parentNode;
469
- parent.removeChild(this.horiz);
470
- parent.removeChild(this.vert);
471
- }
472
- }, NativeScrollbars.prototype);
473
-
474
- function NullScrollbars() {}
475
-
476
- NullScrollbars.prototype = copyObj({
477
- update: function() { return {bottom: 0, right: 0}; },
478
- setScrollLeft: function() {},
479
- setScrollTop: function() {},
480
- clear: function() {}
481
- }, NullScrollbars.prototype);
482
-
483
- CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
484
-
485
- function initScrollbars(cm) {
486
- if (cm.display.scrollbars) {
487
- cm.display.scrollbars.clear();
488
- if (cm.display.scrollbars.addClass)
489
- rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
490
- }
491
-
492
- cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
493
- cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
494
- // Prevent clicks in the scrollbars from killing focus
495
- on(node, "mousedown", function() {
496
- if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
497
- });
498
- node.setAttribute("cm-not-content", "true");
499
- }, function(pos, axis) {
500
- if (axis == "horizontal") setScrollLeft(cm, pos);
501
- else setScrollTop(cm, pos);
502
- }, cm);
503
- if (cm.display.scrollbars.addClass)
504
- addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
505
- }
506
-
507
- function updateScrollbars(cm, measure) {
508
- if (!measure) measure = measureForScrollbars(cm);
509
- var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
510
- updateScrollbarsInner(cm, measure);
511
- for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
512
- if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
513
- updateHeightsInViewport(cm);
514
- updateScrollbarsInner(cm, measureForScrollbars(cm));
515
- startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
516
- }
517
- }
518
-
519
- // Re-synchronize the fake scrollbars with the actual size of the
520
- // content.
521
- function updateScrollbarsInner(cm, measure) {
522
- var d = cm.display;
523
- var sizes = d.scrollbars.update(measure);
524
-
525
- d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
526
- d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
527
-
528
- if (sizes.right && sizes.bottom) {
529
- d.scrollbarFiller.style.display = "block";
530
- d.scrollbarFiller.style.height = sizes.bottom + "px";
531
- d.scrollbarFiller.style.width = sizes.right + "px";
532
- } else d.scrollbarFiller.style.display = "";
533
- if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
534
- d.gutterFiller.style.display = "block";
535
- d.gutterFiller.style.height = sizes.bottom + "px";
536
- d.gutterFiller.style.width = measure.gutterWidth + "px";
537
- } else d.gutterFiller.style.display = "";
538
- }
539
-
540
- // Compute the lines that are visible in a given viewport (defaults
541
- // the the current scroll position). viewport may contain top,
542
- // height, and ensure (see op.scrollToPos) properties.
543
- function visibleLines(display, doc, viewport) {
544
- var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
545
- top = Math.floor(top - paddingTop(display));
546
- var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
547
-
548
- var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
549
- // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
550
- // forces those lines into the viewport (if possible).
551
- if (viewport && viewport.ensure) {
552
- var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
553
- if (ensureFrom < from) {
554
- from = ensureFrom;
555
- to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
556
- } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
557
- from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
558
- to = ensureTo;
559
- }
560
- }
561
- return {from: from, to: Math.max(to, from + 1)};
562
- }
563
-
564
- // LINE NUMBERS
565
-
566
- // Re-align line numbers and gutter marks to compensate for
567
- // horizontal scrolling.
568
- function alignHorizontally(cm) {
569
- var display = cm.display, view = display.view;
570
- if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
571
- var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
572
- var gutterW = display.gutters.offsetWidth, left = comp + "px";
573
- for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
574
- if (cm.options.fixedGutter && view[i].gutter)
575
- view[i].gutter.style.left = left;
576
- var align = view[i].alignable;
577
- if (align) for (var j = 0; j < align.length; j++)
578
- align[j].style.left = left;
579
- }
580
- if (cm.options.fixedGutter)
581
- display.gutters.style.left = (comp + gutterW) + "px";
582
- }
583
-
584
- // Used to ensure that the line number gutter is still the right
585
- // size for the current document size. Returns true when an update
586
- // is needed.
587
- function maybeUpdateLineNumberWidth(cm) {
588
- if (!cm.options.lineNumbers) return false;
589
- var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
590
- if (last.length != display.lineNumChars) {
591
- var test = display.measure.appendChild(elt("div", [elt("div", last)],
592
- "CodeMirror-linenumber CodeMirror-gutter-elt"));
593
- var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
594
- display.lineGutter.style.width = "";
595
- display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
596
- display.lineNumWidth = display.lineNumInnerWidth + padding;
597
- display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
598
- display.lineGutter.style.width = display.lineNumWidth + "px";
599
- updateGutterSpace(cm);
600
- return true;
601
- }
602
- return false;
603
- }
604
-
605
- function lineNumberFor(options, i) {
606
- return String(options.lineNumberFormatter(i + options.firstLineNumber));
607
- }
608
-
609
- // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
610
- // but using getBoundingClientRect to get a sub-pixel-accurate
611
- // result.
612
- function compensateForHScroll(display) {
613
- return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
614
- }
615
-
616
- // DISPLAY DRAWING
617
-
618
- function DisplayUpdate(cm, viewport, force) {
619
- var display = cm.display;
620
-
621
- this.viewport = viewport;
622
- // Store some values that we'll need later (but don't want to force a relayout for)
623
- this.visible = visibleLines(display, cm.doc, viewport);
624
- this.editorIsHidden = !display.wrapper.offsetWidth;
625
- this.wrapperHeight = display.wrapper.clientHeight;
626
- this.wrapperWidth = display.wrapper.clientWidth;
627
- this.oldDisplayWidth = displayWidth(cm);
628
- this.force = force;
629
- this.dims = getDimensions(cm);
630
- this.events = [];
631
- }
632
-
633
- DisplayUpdate.prototype.signal = function(emitter, type) {
634
- if (hasHandler(emitter, type))
635
- this.events.push(arguments);
636
- };
637
- DisplayUpdate.prototype.finish = function() {
638
- for (var i = 0; i < this.events.length; i++)
639
- signal.apply(null, this.events[i]);
640
- };
641
-
642
- function maybeClipScrollbars(cm) {
643
- var display = cm.display;
644
- if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
645
- display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
646
- display.heightForcer.style.height = scrollGap(cm) + "px";
647
- display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
648
- display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
649
- display.scrollbarsClipped = true;
650
- }
651
- }
652
-
653
- // Does the actual updating of the line display. Bails out
654
- // (returning false) when there is nothing to be done and forced is
655
- // false.
656
- function updateDisplayIfNeeded(cm, update) {
657
- var display = cm.display, doc = cm.doc;
658
-
659
- if (update.editorIsHidden) {
660
- resetView(cm);
661
- return false;
662
- }
663
-
664
- // Bail out if the visible area is already rendered and nothing changed.
665
- if (!update.force &&
666
- update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
667
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
668
- display.renderedView == display.view && countDirtyView(cm) == 0)
669
- return false;
670
-
671
- if (maybeUpdateLineNumberWidth(cm)) {
672
- resetView(cm);
673
- update.dims = getDimensions(cm);
674
- }
675
-
676
- // Compute a suitable new viewport (from & to)
677
- var end = doc.first + doc.size;
678
- var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
679
- var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
680
- if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
681
- if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
682
- if (sawCollapsedSpans) {
683
- from = visualLineNo(cm.doc, from);
684
- to = visualLineEndNo(cm.doc, to);
685
- }
686
-
687
- var different = from != display.viewFrom || to != display.viewTo ||
688
- display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
689
- adjustView(cm, from, to);
690
-
691
- display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
692
- // Position the mover div to align with the current scroll position
693
- cm.display.mover.style.top = display.viewOffset + "px";
694
-
695
- var toUpdate = countDirtyView(cm);
696
- if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
697
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
698
- return false;
699
-
700
- // For big changes, we hide the enclosing element during the
701
- // update, since that speeds up the operations on most browsers.
702
- var focused = activeElt();
703
- if (toUpdate > 4) display.lineDiv.style.display = "none";
704
- patchDisplay(cm, display.updateLineNumbers, update.dims);
705
- if (toUpdate > 4) display.lineDiv.style.display = "";
706
- display.renderedView = display.view;
707
- // There might have been a widget with a focused element that got
708
- // hidden or updated, if so re-focus it.
709
- if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
710
-
711
- // Prevent selection and cursors from interfering with the scroll
712
- // width and height.
713
- removeChildren(display.cursorDiv);
714
- removeChildren(display.selectionDiv);
715
- display.gutters.style.height = 0;
716
-
717
- if (different) {
718
- display.lastWrapHeight = update.wrapperHeight;
719
- display.lastWrapWidth = update.wrapperWidth;
720
- startWorker(cm, 400);
721
- }
722
-
723
- display.updateLineNumbers = null;
724
-
725
- return true;
726
- }
727
-
728
- function postUpdateDisplay(cm, update) {
729
- var force = update.force, viewport = update.viewport;
730
- for (var first = true;; first = false) {
731
- if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) {
732
- force = true;
733
- } else {
734
- force = false;
735
- // Clip forced viewport to actual scrollable area.
736
- if (viewport && viewport.top != null)
737
- viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
738
- // Updated line heights might result in the drawn area not
739
- // actually covering the viewport. Keep looping until it does.
740
- update.visible = visibleLines(cm.display, cm.doc, viewport);
741
- if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
742
- break;
743
- }
744
- if (!updateDisplayIfNeeded(cm, update)) break;
745
- updateHeightsInViewport(cm);
746
- var barMeasure = measureForScrollbars(cm);
747
- updateSelection(cm);
748
- setDocumentHeight(cm, barMeasure);
749
- updateScrollbars(cm, barMeasure);
750
- }
751
-
752
- update.signal(cm, "update", cm);
753
- if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
754
- update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
755
- cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
756
- }
757
- }
758
-
759
- function updateDisplaySimple(cm, viewport) {
760
- var update = new DisplayUpdate(cm, viewport);
761
- if (updateDisplayIfNeeded(cm, update)) {
762
- updateHeightsInViewport(cm);
763
- postUpdateDisplay(cm, update);
764
- var barMeasure = measureForScrollbars(cm);
765
- updateSelection(cm);
766
- setDocumentHeight(cm, barMeasure);
767
- updateScrollbars(cm, barMeasure);
768
- update.finish();
769
- }
770
- }
771
-
772
- function setDocumentHeight(cm, measure) {
773
- cm.display.sizer.style.minHeight = measure.docHeight + "px";
774
- var total = measure.docHeight + cm.display.barHeight;
775
- cm.display.heightForcer.style.top = total + "px";
776
- cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
777
- }
778
-
779
- // Read the actual heights of the rendered lines, and update their
780
- // stored heights to match.
781
- function updateHeightsInViewport(cm) {
782
- var display = cm.display;
783
- var prevBottom = display.lineDiv.offsetTop;
784
- for (var i = 0; i < display.view.length; i++) {
785
- var cur = display.view[i], height;
786
- if (cur.hidden) continue;
787
- if (ie && ie_version < 8) {
788
- var bot = cur.node.offsetTop + cur.node.offsetHeight;
789
- height = bot - prevBottom;
790
- prevBottom = bot;
791
- } else {
792
- var box = cur.node.getBoundingClientRect();
793
- height = box.bottom - box.top;
794
- }
795
- var diff = cur.line.height - height;
796
- if (height < 2) height = textHeight(display);
797
- if (diff > .001 || diff < -.001) {
798
- updateLineHeight(cur.line, height);
799
- updateWidgetHeight(cur.line);
800
- if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
801
- updateWidgetHeight(cur.rest[j]);
802
- }
803
- }
804
- }
805
-
806
- // Read and store the height of line widgets associated with the
807
- // given line.
808
- function updateWidgetHeight(line) {
809
- if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
810
- line.widgets[i].height = line.widgets[i].node.offsetHeight;
811
- }
812
-
813
- // Do a bulk-read of the DOM positions and sizes needed to draw the
814
- // view, so that we don't interleave reading and writing to the DOM.
815
- function getDimensions(cm) {
816
- var d = cm.display, left = {}, width = {};
817
- var gutterLeft = d.gutters.clientLeft;
818
- for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
819
- left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
820
- width[cm.options.gutters[i]] = n.clientWidth;
821
- }
822
- return {fixedPos: compensateForHScroll(d),
823
- gutterTotalWidth: d.gutters.offsetWidth,
824
- gutterLeft: left,
825
- gutterWidth: width,
826
- wrapperWidth: d.wrapper.clientWidth};
827
- }
828
-
829
- // Sync the actual display DOM structure with display.view, removing
830
- // nodes for lines that are no longer in view, and creating the ones
831
- // that are not there yet, and updating the ones that are out of
832
- // date.
833
- function patchDisplay(cm, updateNumbersFrom, dims) {
834
- var display = cm.display, lineNumbers = cm.options.lineNumbers;
835
- var container = display.lineDiv, cur = container.firstChild;
836
-
837
- function rm(node) {
838
- var next = node.nextSibling;
839
- // Works around a throw-scroll bug in OS X Webkit
840
- if (webkit && mac && cm.display.currentWheelTarget == node)
841
- node.style.display = "none";
842
- else
843
- node.parentNode.removeChild(node);
844
- return next;
845
- }
846
-
847
- var view = display.view, lineN = display.viewFrom;
848
- // Loop over the elements in the view, syncing cur (the DOM nodes
849
- // in display.lineDiv) with the view as we go.
850
- for (var i = 0; i < view.length; i++) {
851
- var lineView = view[i];
852
- if (lineView.hidden) {
853
- } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
854
- var node = buildLineElement(cm, lineView, lineN, dims);
855
- container.insertBefore(node, cur);
856
- } else { // Already drawn
857
- while (cur != lineView.node) cur = rm(cur);
858
- var updateNumber = lineNumbers && updateNumbersFrom != null &&
859
- updateNumbersFrom <= lineN && lineView.lineNumber;
860
- if (lineView.changes) {
861
- if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
862
- updateLineForChanges(cm, lineView, lineN, dims);
863
- }
864
- if (updateNumber) {
865
- removeChildren(lineView.lineNumber);
866
- lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
867
- }
868
- cur = lineView.node.nextSibling;
869
- }
870
- lineN += lineView.size;
871
- }
872
- while (cur) cur = rm(cur);
873
- }
874
-
875
- // When an aspect of a line changes, a string is added to
876
- // lineView.changes. This updates the relevant part of the line's
877
- // DOM structure.
878
- function updateLineForChanges(cm, lineView, lineN, dims) {
879
- for (var j = 0; j < lineView.changes.length; j++) {
880
- var type = lineView.changes[j];
881
- if (type == "text") updateLineText(cm, lineView);
882
- else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
883
- else if (type == "class") updateLineClasses(lineView);
884
- else if (type == "widget") updateLineWidgets(cm, lineView, dims);
885
- }
886
- lineView.changes = null;
887
- }
888
-
889
- // Lines with gutter elements, widgets or a background class need to
890
- // be wrapped, and have the extra elements added to the wrapper div
891
- function ensureLineWrapped(lineView) {
892
- if (lineView.node == lineView.text) {
893
- lineView.node = elt("div", null, null, "position: relative");
894
- if (lineView.text.parentNode)
895
- lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
896
- lineView.node.appendChild(lineView.text);
897
- if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
898
- }
899
- return lineView.node;
900
- }
901
-
902
- function updateLineBackground(lineView) {
903
- var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
904
- if (cls) cls += " CodeMirror-linebackground";
905
- if (lineView.background) {
906
- if (cls) lineView.background.className = cls;
907
- else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
908
- } else if (cls) {
909
- var wrap = ensureLineWrapped(lineView);
910
- lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
911
- }
912
- }
913
-
914
- // Wrapper around buildLineContent which will reuse the structure
915
- // in display.externalMeasured when possible.
916
- function getLineContent(cm, lineView) {
917
- var ext = cm.display.externalMeasured;
918
- if (ext && ext.line == lineView.line) {
919
- cm.display.externalMeasured = null;
920
- lineView.measure = ext.measure;
921
- return ext.built;
922
- }
923
- return buildLineContent(cm, lineView);
924
- }
925
-
926
- // Redraw the line's text. Interacts with the background and text
927
- // classes because the mode may output tokens that influence these
928
- // classes.
929
- function updateLineText(cm, lineView) {
930
- var cls = lineView.text.className;
931
- var built = getLineContent(cm, lineView);
932
- if (lineView.text == lineView.node) lineView.node = built.pre;
933
- lineView.text.parentNode.replaceChild(built.pre, lineView.text);
934
- lineView.text = built.pre;
935
- if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
936
- lineView.bgClass = built.bgClass;
937
- lineView.textClass = built.textClass;
938
- updateLineClasses(lineView);
939
- } else if (cls) {
940
- lineView.text.className = cls;
941
- }
942
- }
943
-
944
- function updateLineClasses(lineView) {
945
- updateLineBackground(lineView);
946
- if (lineView.line.wrapClass)
947
- ensureLineWrapped(lineView).className = lineView.line.wrapClass;
948
- else if (lineView.node != lineView.text)
949
- lineView.node.className = "";
950
- var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
951
- lineView.text.className = textClass || "";
952
- }
953
-
954
- function updateLineGutter(cm, lineView, lineN, dims) {
955
- if (lineView.gutter) {
956
- lineView.node.removeChild(lineView.gutter);
957
- lineView.gutter = null;
958
- }
959
- var markers = lineView.line.gutterMarkers;
960
- if (cm.options.lineNumbers || markers) {
961
- var wrap = ensureLineWrapped(lineView);
962
- var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
963
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
964
- "px; width: " + dims.gutterTotalWidth + "px");
965
- cm.display.input.setUneditable(gutterWrap);
966
- wrap.insertBefore(gutterWrap, lineView.text);
967
- if (lineView.line.gutterClass)
968
- gutterWrap.className += " " + lineView.line.gutterClass;
969
- if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
970
- lineView.lineNumber = gutterWrap.appendChild(
971
- elt("div", lineNumberFor(cm.options, lineN),
972
- "CodeMirror-linenumber CodeMirror-gutter-elt",
973
- "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
974
- + cm.display.lineNumInnerWidth + "px"));
975
- if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
976
- var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
977
- if (found)
978
- gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
979
- dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
980
- }
981
- }
982
- }
983
-
984
- function updateLineWidgets(cm, lineView, dims) {
985
- if (lineView.alignable) lineView.alignable = null;
986
- for (var node = lineView.node.firstChild, next; node; node = next) {
987
- var next = node.nextSibling;
988
- if (node.className == "CodeMirror-linewidget")
989
- lineView.node.removeChild(node);
990
- }
991
- insertLineWidgets(cm, lineView, dims);
992
- }
993
-
994
- // Build a line's DOM representation from scratch
995
- function buildLineElement(cm, lineView, lineN, dims) {
996
- var built = getLineContent(cm, lineView);
997
- lineView.text = lineView.node = built.pre;
998
- if (built.bgClass) lineView.bgClass = built.bgClass;
999
- if (built.textClass) lineView.textClass = built.textClass;
1000
-
1001
- updateLineClasses(lineView);
1002
- updateLineGutter(cm, lineView, lineN, dims);
1003
- insertLineWidgets(cm, lineView, dims);
1004
- return lineView.node;
1005
- }
1006
-
1007
- // A lineView may contain multiple logical lines (when merged by
1008
- // collapsed spans). The widgets for all of them need to be drawn.
1009
- function insertLineWidgets(cm, lineView, dims) {
1010
- insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
1011
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
1012
- insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
1013
- }
1014
-
1015
- function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
1016
- if (!line.widgets) return;
1017
- var wrap = ensureLineWrapped(lineView);
1018
- for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
1019
- var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
1020
- if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
1021
- positionLineWidget(widget, node, lineView, dims);
1022
- cm.display.input.setUneditable(node);
1023
- if (allowAbove && widget.above)
1024
- wrap.insertBefore(node, lineView.gutter || lineView.text);
1025
- else
1026
- wrap.appendChild(node);
1027
- signalLater(widget, "redraw");
1028
- }
1029
- }
1030
-
1031
- function positionLineWidget(widget, node, lineView, dims) {
1032
- if (widget.noHScroll) {
1033
- (lineView.alignable || (lineView.alignable = [])).push(node);
1034
- var width = dims.wrapperWidth;
1035
- node.style.left = dims.fixedPos + "px";
1036
- if (!widget.coverGutter) {
1037
- width -= dims.gutterTotalWidth;
1038
- node.style.paddingLeft = dims.gutterTotalWidth + "px";
1039
- }
1040
- node.style.width = width + "px";
1041
- }
1042
- if (widget.coverGutter) {
1043
- node.style.zIndex = 5;
1044
- node.style.position = "relative";
1045
- if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
1046
- }
1047
- }
1048
-
1049
- // POSITION OBJECT
1050
-
1051
- // A Pos instance represents a position within the text.
1052
- var Pos = CodeMirror.Pos = function(line, ch) {
1053
- if (!(this instanceof Pos)) return new Pos(line, ch);
1054
- this.line = line; this.ch = ch;
1055
- };
1056
-
1057
- // Compare two positions, return 0 if they are the same, a negative
1058
- // number when a is less, and a positive number otherwise.
1059
- var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
1060
-
1061
- function copyPos(x) {return Pos(x.line, x.ch);}
1062
- function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
1063
- function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
1064
-
1065
- // INPUT HANDLING
1066
-
1067
- function ensureFocus(cm) {
1068
- if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
1069
- }
1070
-
1071
- function isReadOnly(cm) {
1072
- return cm.options.readOnly || cm.doc.cantEdit;
1073
- }
1074
-
1075
- // This will be set to an array of strings when copying, so that,
1076
- // when pasting, we know what kind of selections the copied text
1077
- // was made out of.
1078
- var lastCopied = null;
1079
-
1080
- function applyTextInput(cm, inserted, deleted, sel) {
1081
- var doc = cm.doc;
1082
- cm.display.shift = false;
1083
- if (!sel) sel = doc.sel;
1084
-
1085
- var textLines = splitLines(inserted), multiPaste = null;
1086
- // When pasing N lines into N selections, insert one line per selection
1087
- if (cm.state.pasteIncoming && sel.ranges.length > 1) {
1088
- if (lastCopied && lastCopied.join("\n") == inserted)
1089
- multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
1090
- else if (textLines.length == sel.ranges.length)
1091
- multiPaste = map(textLines, function(l) { return [l]; });
1092
- }
1093
-
1094
- // Normal behavior is to insert the new text into every selection
1095
- for (var i = sel.ranges.length - 1; i >= 0; i--) {
1096
- var range = sel.ranges[i];
1097
- var from = range.from(), to = range.to();
1098
- if (range.empty()) {
1099
- if (deleted && deleted > 0) // Handle deletion
1100
- from = Pos(from.line, from.ch - deleted);
1101
- else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite
1102
- to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
1103
- }
1104
- var updateInput = cm.curOp.updateInput;
1105
- var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
1106
- origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
1107
- makeChange(cm.doc, changeEvent);
1108
- signalLater(cm, "inputRead", cm, changeEvent);
1109
- // When an 'electric' character is inserted, immediately trigger a reindent
1110
- if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
1111
- cm.options.smartIndent && range.head.ch < 100 &&
1112
- (!i || sel.ranges[i - 1].head.line != range.head.line)) {
1113
- var mode = cm.getModeAt(range.head);
1114
- var end = changeEnd(changeEvent);
1115
- if (mode.electricChars) {
1116
- for (var j = 0; j < mode.electricChars.length; j++)
1117
- if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
1118
- indentLine(cm, end.line, "smart");
1119
- break;
1120
- }
1121
- } else if (mode.electricInput) {
1122
- if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
1123
- indentLine(cm, end.line, "smart");
1124
- }
1125
- }
1126
- }
1127
- ensureCursorVisible(cm);
1128
- cm.curOp.updateInput = updateInput;
1129
- cm.curOp.typing = true;
1130
- cm.state.pasteIncoming = cm.state.cutIncoming = false;
1131
- }
1132
-
1133
- function copyableRanges(cm) {
1134
- var text = [], ranges = [];
1135
- for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
1136
- var line = cm.doc.sel.ranges[i].head.line;
1137
- var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
1138
- ranges.push(lineRange);
1139
- text.push(cm.getRange(lineRange.anchor, lineRange.head));
1140
- }
1141
- return {text: text, ranges: ranges};
1142
- }
1143
-
1144
- function disableBrowserMagic(field) {
1145
- field.setAttribute("autocorrect", "off");
1146
- field.setAttribute("autocapitalize", "off");
1147
- field.setAttribute("spellcheck", "false");
1148
- }
1149
-
1150
- // TEXTAREA INPUT STYLE
1151
-
1152
- function TextareaInput(cm) {
1153
- this.cm = cm;
1154
- // See input.poll and input.reset
1155
- this.prevInput = "";
1156
-
1157
- // Flag that indicates whether we expect input to appear real soon
1158
- // now (after some event like 'keypress' or 'input') and are
1159
- // polling intensively.
1160
- this.pollingFast = false;
1161
- // Self-resetting timeout for the poller
1162
- this.polling = new Delayed();
1163
- // Tracks when input.reset has punted to just putting a short
1164
- // string into the textarea instead of the full selection.
1165
- this.inaccurateSelection = false;
1166
- // Used to work around IE issue with selection being forgotten when focus moves away from textarea
1167
- this.hasSelection = false;
1168
- };
1169
-
1170
- function hiddenTextarea() {
1171
- var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
1172
- var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
1173
- // The textarea is kept positioned near the cursor to prevent the
1174
- // fact that it'll be scrolled into view on input from scrolling
1175
- // our fake cursor out of view. On webkit, when wrap=off, paste is
1176
- // very slow. So make the area wide instead.
1177
- if (webkit) te.style.width = "1000px";
1178
- else te.setAttribute("wrap", "off");
1179
- // If border: 0; -- iOS fails to open keyboard (issue #1287)
1180
- if (ios) te.style.border = "1px solid black";
1181
- disableBrowserMagic(te);
1182
- return div;
1183
- }
1184
-
1185
- TextareaInput.prototype = copyObj({
1186
- init: function(display) {
1187
- var input = this, cm = this.cm;
1188
-
1189
- // Wraps and hides input textarea
1190
- var div = this.wrapper = hiddenTextarea();
1191
- // The semihidden textarea that is focused when the editor is
1192
- // focused, and receives input.
1193
- var te = this.textarea = div.firstChild;
1194
- display.wrapper.insertBefore(div, display.wrapper.firstChild);
1195
-
1196
- // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
1197
- if (ios) te.style.width = "0px";
1198
-
1199
- on(te, "input", function() {
1200
- if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
1201
- input.poll();
1202
- });
1203
-
1204
- on(te, "paste", function() {
1205
- // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
1206
- // Add a char to the end of textarea before paste occur so that
1207
- // selection doesn't span to the end of textarea.
1208
- if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
1209
- var start = te.selectionStart, end = te.selectionEnd;
1210
- te.value += "$";
1211
- // The selection end needs to be set before the start, otherwise there
1212
- // can be an intermediate non-empty selection between the two, which
1213
- // can override the middle-click paste buffer on linux and cause the
1214
- // wrong thing to get pasted.
1215
- te.selectionEnd = end;
1216
- te.selectionStart = start;
1217
- cm.state.fakedLastChar = true;
1218
- }
1219
- cm.state.pasteIncoming = true;
1220
- input.fastPoll();
1221
- });
1222
-
1223
- function prepareCopyCut(e) {
1224
- if (cm.somethingSelected()) {
1225
- lastCopied = cm.getSelections();
1226
- if (input.inaccurateSelection) {
1227
- input.prevInput = "";
1228
- input.inaccurateSelection = false;
1229
- te.value = lastCopied.join("\n");
1230
- selectInput(te);
1231
- }
1232
- } else {
1233
- var ranges = copyableRanges(cm);
1234
- lastCopied = ranges.text;
1235
- if (e.type == "cut") {
1236
- cm.setSelections(ranges.ranges, null, sel_dontScroll);
1237
- } else {
1238
- input.prevInput = "";
1239
- te.value = ranges.text.join("\n");
1240
- selectInput(te);
1241
- }
1242
- }
1243
- if (e.type == "cut") cm.state.cutIncoming = true;
1244
- }
1245
- on(te, "cut", prepareCopyCut);
1246
- on(te, "copy", prepareCopyCut);
1247
-
1248
- on(display.scroller, "paste", function(e) {
1249
- if (eventInWidget(display, e)) return;
1250
- cm.state.pasteIncoming = true;
1251
- input.focus();
1252
- });
1253
-
1254
- // Prevent normal selection in the editor (we handle our own)
1255
- on(display.lineSpace, "selectstart", function(e) {
1256
- if (!eventInWidget(display, e)) e_preventDefault(e);
1257
- });
1258
- },
1259
-
1260
- prepareSelection: function() {
1261
- // Redraw the selection and/or cursor
1262
- var cm = this.cm, display = cm.display, doc = cm.doc;
1263
- var result = prepareSelection(cm);
1264
-
1265
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
1266
- if (cm.options.moveInputWithCursor) {
1267
- var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
1268
- var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
1269
- result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
1270
- headPos.top + lineOff.top - wrapOff.top));
1271
- result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
1272
- headPos.left + lineOff.left - wrapOff.left));
1273
- }
1274
-
1275
- return result;
1276
- },
1277
-
1278
- showSelection: function(drawn) {
1279
- var cm = this.cm, display = cm.display;
1280
- removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
1281
- removeChildrenAndAdd(display.selectionDiv, drawn.selection);
1282
- if (drawn.teTop != null) {
1283
- this.wrapper.style.top = drawn.teTop + "px";
1284
- this.wrapper.style.left = drawn.teLeft + "px";
1285
- }
1286
- },
1287
-
1288
- // Reset the input to correspond to the selection (or to be empty,
1289
- // when not typing and nothing is selected)
1290
- reset: function(typing) {
1291
- if (this.contextMenuPending) return;
1292
- var minimal, selected, cm = this.cm, doc = cm.doc;
1293
- if (cm.somethingSelected()) {
1294
- this.prevInput = "";
1295
- var range = doc.sel.primary();
1296
- minimal = hasCopyEvent &&
1297
- (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
1298
- var content = minimal ? "-" : selected || cm.getSelection();
1299
- this.textarea.value = content;
1300
- if (cm.state.focused) selectInput(this.textarea);
1301
- if (ie && ie_version >= 9) this.hasSelection = content;
1302
- } else if (!typing) {
1303
- this.prevInput = this.textarea.value = "";
1304
- if (ie && ie_version >= 9) this.hasSelection = null;
1305
- }
1306
- this.inaccurateSelection = minimal;
1307
- },
1308
-
1309
- getField: function() { return this.textarea; },
1310
-
1311
- supportsTouch: function() { return false; },
1312
-
1313
- focus: function() {
1314
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
1315
- try { this.textarea.focus(); }
1316
- catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
1317
- }
1318
- },
1319
-
1320
- blur: function() { this.textarea.blur(); },
1321
-
1322
- resetPosition: function() {
1323
- this.wrapper.style.top = this.wrapper.style.left = 0;
1324
- },
1325
-
1326
- receivedFocus: function() { this.slowPoll(); },
1327
-
1328
- // Poll for input changes, using the normal rate of polling. This
1329
- // runs as long as the editor is focused.
1330
- slowPoll: function() {
1331
- var input = this;
1332
- if (input.pollingFast) return;
1333
- input.polling.set(this.cm.options.pollInterval, function() {
1334
- input.poll();
1335
- if (input.cm.state.focused) input.slowPoll();
1336
- });
1337
- },
1338
-
1339
- // When an event has just come in that is likely to add or change
1340
- // something in the input textarea, we poll faster, to ensure that
1341
- // the change appears on the screen quickly.
1342
- fastPoll: function() {
1343
- var missed = false, input = this;
1344
- input.pollingFast = true;
1345
- function p() {
1346
- var changed = input.poll();
1347
- if (!changed && !missed) {missed = true; input.polling.set(60, p);}
1348
- else {input.pollingFast = false; input.slowPoll();}
1349
- }
1350
- input.polling.set(20, p);
1351
- },
1352
-
1353
- // Read input from the textarea, and update the document to match.
1354
- // When something is selected, it is present in the textarea, and
1355
- // selected (unless it is huge, in which case a placeholder is
1356
- // used). When nothing is selected, the cursor sits after previously
1357
- // seen text (can be empty), which is stored in prevInput (we must
1358
- // not reset the textarea when typing, because that breaks IME).
1359
- poll: function() {
1360
- var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
1361
- // Since this is called a *lot*, try to bail out as cheaply as
1362
- // possible when it is clear that nothing happened. hasSelection
1363
- // will be the case when there is a lot of text in the textarea,
1364
- // in which case reading its value would be expensive.
1365
- if (!cm.state.focused || (hasSelection(input) && !prevInput) ||
1366
- isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
1367
- return false;
1368
- // See paste handler for more on the fakedLastChar kludge
1369
- if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
1370
- input.value = input.value.substring(0, input.value.length - 1);
1371
- cm.state.fakedLastChar = false;
1372
- }
1373
- var text = input.value;
1374
- // If nothing changed, bail.
1375
- if (text == prevInput && !cm.somethingSelected()) return false;
1376
- // Work around nonsensical selection resetting in IE9/10, and
1377
- // inexplicable appearance of private area unicode characters on
1378
- // some key combos in Mac (#2689).
1379
- if (ie && ie_version >= 9 && this.hasSelection === text ||
1380
- mac && /[\uf700-\uf7ff]/.test(text)) {
1381
- cm.display.input.reset();
1382
- return false;
1383
- }
1384
-
1385
- if (text.charCodeAt(0) == 0x200b && cm.doc.sel == cm.display.selForContextMenu && !prevInput)
1386
- prevInput = "\u200b";
1387
- // Find the part of the input that is actually new
1388
- var same = 0, l = Math.min(prevInput.length, text.length);
1389
- while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
1390
-
1391
- var self = this;
1392
- runInOp(cm, function() {
1393
- applyTextInput(cm, text.slice(same), prevInput.length - same);
1394
-
1395
- // Don't leave long text in the textarea, since it makes further polling slow
1396
- if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
1397
- else self.prevInput = text;
1398
- });
1399
- return true;
1400
- },
1401
-
1402
- ensurePolled: function() {
1403
- if (this.pollingFast && this.poll()) this.pollingFast = false;
1404
- },
1405
-
1406
- onKeyPress: function() {
1407
- if (ie && ie_version >= 9) this.hasSelection = null;
1408
- this.fastPoll();
1409
- },
1410
-
1411
- onContextMenu: function(e) {
1412
- var input = this, cm = input.cm, display = cm.display, te = input.textarea;
1413
- var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
1414
- if (!pos || presto) return; // Opera is difficult.
1415
-
1416
- // Reset the current text selection only if the click is done outside of the selection
1417
- // and 'resetSelectionOnContextMenu' option is true.
1418
- var reset = cm.options.resetSelectionOnContextMenu;
1419
- if (reset && cm.doc.sel.contains(pos) == -1)
1420
- operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
1421
-
1422
- var oldCSS = te.style.cssText;
1423
- input.wrapper.style.position = "absolute";
1424
- te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
1425
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
1426
- (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
1427
- "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
1428
- if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
1429
- display.input.focus();
1430
- if (webkit) window.scrollTo(null, oldScrollY);
1431
- display.input.reset();
1432
- // Adds "Select all" to context menu in FF
1433
- if (!cm.somethingSelected()) te.value = input.prevInput = " ";
1434
- input.contextMenuPending = true;
1435
- display.selForContextMenu = cm.doc.sel;
1436
- clearTimeout(display.detectingSelectAll);
1437
-
1438
- // Select-all will be greyed out if there's nothing to select, so
1439
- // this adds a zero-width space so that we can later check whether
1440
- // it got selected.
1441
- function prepareSelectAllHack() {
1442
- if (te.selectionStart != null) {
1443
- var selected = cm.somethingSelected();
1444
- var extval = te.value = "\u200b" + (selected ? te.value : "");
1445
- input.prevInput = selected ? "" : "\u200b";
1446
- te.selectionStart = 1; te.selectionEnd = extval.length;
1447
- // Re-set this, in case some other handler touched the
1448
- // selection in the meantime.
1449
- display.selForContextMenu = cm.doc.sel;
1450
- }
1451
- }
1452
- function rehide() {
1453
- input.contextMenuPending = false;
1454
- input.wrapper.style.position = "relative";
1455
- te.style.cssText = oldCSS;
1456
- if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
1457
-
1458
- // Try to detect the user choosing select-all
1459
- if (te.selectionStart != null) {
1460
- if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
1461
- var i = 0, poll = function() {
1462
- if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0)
1463
- operation(cm, commands.selectAll)(cm);
1464
- else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
1465
- else display.input.reset();
1466
- };
1467
- display.detectingSelectAll = setTimeout(poll, 200);
1468
- }
1469
- }
1470
-
1471
- if (ie && ie_version >= 9) prepareSelectAllHack();
1472
- if (captureRightClick) {
1473
- e_stop(e);
1474
- var mouseup = function() {
1475
- off(window, "mouseup", mouseup);
1476
- setTimeout(rehide, 20);
1477
- };
1478
- on(window, "mouseup", mouseup);
1479
- } else {
1480
- setTimeout(rehide, 50);
1481
- }
1482
- },
1483
-
1484
- setUneditable: nothing,
1485
-
1486
- needsContentAttribute: false
1487
- }, TextareaInput.prototype);
1488
-
1489
- // CONTENTEDITABLE INPUT STYLE
1490
-
1491
- function ContentEditableInput(cm) {
1492
- this.cm = cm;
1493
- this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
1494
- this.polling = new Delayed();
1495
- this.gracePeriod = false;
1496
- }
1497
-
1498
- ContentEditableInput.prototype = copyObj({
1499
- init: function(display) {
1500
- var input = this, cm = input.cm;
1501
- var div = input.div = display.lineDiv;
1502
- div.contentEditable = "true";
1503
- disableBrowserMagic(div);
1504
-
1505
- on(div, "paste", function(e) {
1506
- var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
1507
- if (pasted) {
1508
- e.preventDefault();
1509
- cm.replaceSelection(pasted, null, "paste");
1510
- }
1511
- });
1512
-
1513
- on(div, "compositionstart", function(e) {
1514
- var data = e.data;
1515
- input.composing = {sel: cm.doc.sel, data: data, startData: data};
1516
- if (!data) return;
1517
- var prim = cm.doc.sel.primary();
1518
- var line = cm.getLine(prim.head.line);
1519
- var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
1520
- if (found > -1 && found <= prim.head.ch)
1521
- input.composing.sel = simpleSelection(Pos(prim.head.line, found),
1522
- Pos(prim.head.line, found + data.length));
1523
- });
1524
- on(div, "compositionupdate", function(e) {
1525
- input.composing.data = e.data;
1526
- });
1527
- on(div, "compositionend", function(e) {
1528
- var ours = input.composing;
1529
- if (!ours) return;
1530
- if (e.data != ours.startData && !/\u200b/.test(e.data))
1531
- ours.data = e.data;
1532
- // Need a small delay to prevent other code (input event,
1533
- // selection polling) from doing damage when fired right after
1534
- // compositionend.
1535
- setTimeout(function() {
1536
- if (!ours.handled)
1537
- input.applyComposition(ours);
1538
- if (input.composing == ours)
1539
- input.composing = null;
1540
- }, 50);
1541
- });
1542
-
1543
- on(div, "touchstart", function() {
1544
- input.forceCompositionEnd();
1545
- });
1546
-
1547
- on(div, "input", function() {
1548
- if (input.composing) return;
1549
- if (!input.pollContent())
1550
- runInOp(input.cm, function() {regChange(cm);});
1551
- });
1552
-
1553
- function onCopyCut(e) {
1554
- if (cm.somethingSelected()) {
1555
- lastCopied = cm.getSelections();
1556
- if (e.type == "cut") cm.replaceSelection("", null, "cut");
1557
- } else {
1558
- var ranges = copyableRanges(cm);
1559
- lastCopied = ranges.text;
1560
- if (e.type == "cut") {
1561
- cm.operation(function() {
1562
- cm.setSelections(ranges.ranges, 0, sel_dontScroll);
1563
- cm.replaceSelection("", null, "cut");
1564
- });
1565
- }
1566
- }
1567
- // iOS exposes the clipboard API, but seems to discard content inserted into it
1568
- if (e.clipboardData && !ios) {
1569
- e.preventDefault();
1570
- e.clipboardData.clearData();
1571
- e.clipboardData.setData("text/plain", lastCopied.join("\n"));
1572
- } else {
1573
- // Old-fashioned briefly-focus-a-textarea hack
1574
- var kludge = hiddenTextarea(), te = kludge.firstChild;
1575
- cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
1576
- te.value = lastCopied.join("\n");
1577
- var hadFocus = document.activeElement;
1578
- selectInput(te);
1579
- setTimeout(function() {
1580
- cm.display.lineSpace.removeChild(kludge);
1581
- hadFocus.focus();
1582
- }, 50);
1583
- }
1584
- }
1585
- on(div, "copy", onCopyCut);
1586
- on(div, "cut", onCopyCut);
1587
- },
1588
-
1589
- prepareSelection: function() {
1590
- var result = prepareSelection(this.cm, false);
1591
- result.focus = this.cm.state.focused;
1592
- return result;
1593
- },
1594
-
1595
- showSelection: function(info) {
1596
- if (!info || !this.cm.display.view.length) return;
1597
- if (info.focus) this.showPrimarySelection();
1598
- this.showMultipleSelections(info);
1599
- },
1600
-
1601
- showPrimarySelection: function() {
1602
- var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
1603
- var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
1604
- var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
1605
- if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
1606
- cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
1607
- cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
1608
- return;
1609
-
1610
- var start = posToDOM(this.cm, prim.from());
1611
- var end = posToDOM(this.cm, prim.to());
1612
- if (!start && !end) return;
1613
-
1614
- var view = this.cm.display.view;
1615
- var old = sel.rangeCount && sel.getRangeAt(0);
1616
- if (!start) {
1617
- start = {node: view[0].measure.map[2], offset: 0};
1618
- } else if (!end) { // FIXME dangerously hacky
1619
- var measure = view[view.length - 1].measure;
1620
- var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
1621
- end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
1622
- }
1623
-
1624
- try { var rng = range(start.node, start.offset, end.offset, end.node); }
1625
- catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
1626
- if (rng) {
1627
- sel.removeAllRanges();
1628
- sel.addRange(rng);
1629
- if (old && sel.anchorNode == null) sel.addRange(old);
1630
- else if (gecko) this.startGracePeriod();
1631
- }
1632
- this.rememberSelection();
1633
- },
1634
-
1635
- startGracePeriod: function() {
1636
- var input = this;
1637
- clearTimeout(this.gracePeriod);
1638
- this.gracePeriod = setTimeout(function() {
1639
- input.gracePeriod = false;
1640
- if (input.selectionChanged())
1641
- input.cm.operation(function() { input.cm.curOp.selectionChanged = true; });
1642
- }, 20);
1643
- },
1644
-
1645
- showMultipleSelections: function(info) {
1646
- removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
1647
- removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
1648
- },
1649
-
1650
- rememberSelection: function() {
1651
- var sel = window.getSelection();
1652
- this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
1653
- this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
1654
- },
1655
-
1656
- selectionInEditor: function() {
1657
- var sel = window.getSelection();
1658
- if (!sel.rangeCount) return false;
1659
- var node = sel.getRangeAt(0).commonAncestorContainer;
1660
- return contains(this.div, node);
1661
- },
1662
-
1663
- focus: function() {
1664
- if (this.cm.options.readOnly != "nocursor") this.div.focus();
1665
- },
1666
- blur: function() { this.div.blur(); },
1667
- getField: function() { return this.div; },
1668
-
1669
- supportsTouch: function() { return true; },
1670
-
1671
- receivedFocus: function() {
1672
- var input = this;
1673
- if (this.selectionInEditor())
1674
- this.pollSelection();
1675
- else
1676
- runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
1677
-
1678
- function poll() {
1679
- if (input.cm.state.focused) {
1680
- input.pollSelection();
1681
- input.polling.set(input.cm.options.pollInterval, poll);
1682
- }
1683
- }
1684
- this.polling.set(this.cm.options.pollInterval, poll);
1685
- },
1686
-
1687
- selectionChanged: function() {
1688
- var sel = window.getSelection();
1689
- return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
1690
- sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
1691
- },
1692
-
1693
- pollSelection: function() {
1694
- if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
1695
- var sel = window.getSelection(), cm = this.cm;
1696
- this.rememberSelection();
1697
- var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
1698
- var head = domToPos(cm, sel.focusNode, sel.focusOffset);
1699
- if (anchor && head) runInOp(cm, function() {
1700
- setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
1701
- if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
1702
- });
1703
- }
1704
- },
1705
-
1706
- pollContent: function() {
1707
- var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
1708
- var from = sel.from(), to = sel.to();
1709
- if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
1710
-
1711
- var fromIndex;
1712
- if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
1713
- var fromLine = lineNo(display.view[0].line);
1714
- var fromNode = display.view[0].node;
1715
- } else {
1716
- var fromLine = lineNo(display.view[fromIndex].line);
1717
- var fromNode = display.view[fromIndex - 1].node.nextSibling;
1718
- }
1719
- var toIndex = findViewIndex(cm, to.line);
1720
- if (toIndex == display.view.length - 1) {
1721
- var toLine = display.viewTo - 1;
1722
- var toNode = display.view[toIndex].node;
1723
- } else {
1724
- var toLine = lineNo(display.view[toIndex + 1].line) - 1;
1725
- var toNode = display.view[toIndex + 1].node.previousSibling;
1726
- }
1727
-
1728
- var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
1729
- var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
1730
- while (newText.length > 1 && oldText.length > 1) {
1731
- if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
1732
- else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
1733
- else break;
1734
- }
1735
-
1736
- var cutFront = 0, cutEnd = 0;
1737
- var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
1738
- while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
1739
- ++cutFront;
1740
- var newBot = lst(newText), oldBot = lst(oldText);
1741
- var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
1742
- oldBot.length - (oldText.length == 1 ? cutFront : 0));
1743
- while (cutEnd < maxCutEnd &&
1744
- newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
1745
- ++cutEnd;
1746
-
1747
- newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
1748
- newText[0] = newText[0].slice(cutFront);
1749
-
1750
- var chFrom = Pos(fromLine, cutFront);
1751
- var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
1752
- if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
1753
- replaceRange(cm.doc, newText, chFrom, chTo, "+input");
1754
- return true;
1755
- }
1756
- },
1757
-
1758
- ensurePolled: function() {
1759
- this.forceCompositionEnd();
1760
- },
1761
- reset: function() {
1762
- this.forceCompositionEnd();
1763
- },
1764
- forceCompositionEnd: function() {
1765
- if (!this.composing || this.composing.handled) return;
1766
- this.applyComposition(this.composing);
1767
- this.composing.handled = true;
1768
- this.div.blur();
1769
- this.div.focus();
1770
- },
1771
- applyComposition: function(composing) {
1772
- if (composing.data && composing.data != composing.startData)
1773
- operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
1774
- },
1775
-
1776
- setUneditable: function(node) {
1777
- node.setAttribute("contenteditable", "false");
1778
- },
1779
-
1780
- onKeyPress: function(e) {
1781
- e.preventDefault();
1782
- operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
1783
- },
1784
-
1785
- onContextMenu: nothing,
1786
- resetPosition: nothing,
1787
-
1788
- needsContentAttribute: true
1789
- }, ContentEditableInput.prototype);
1790
-
1791
- function posToDOM(cm, pos) {
1792
- var view = findViewForLine(cm, pos.line);
1793
- if (!view || view.hidden) return null;
1794
- var line = getLine(cm.doc, pos.line);
1795
- var info = mapFromLineView(view, line, pos.line);
1796
-
1797
- var order = getOrder(line), side = "left";
1798
- if (order) {
1799
- var partPos = getBidiPartAt(order, pos.ch);
1800
- side = partPos % 2 ? "right" : "left";
1801
- }
1802
- var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left");
1803
- result.offset = result.collapse == "right" ? result.end : result.start;
1804
- return result;
1805
- }
1806
-
1807
- function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
1808
-
1809
- function domToPos(cm, node, offset) {
1810
- var lineNode;
1811
- if (node == cm.display.lineDiv) {
1812
- lineNode = cm.display.lineDiv.childNodes[offset];
1813
- if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
1814
- node = null; offset = 0;
1815
- } else {
1816
- for (lineNode = node;; lineNode = lineNode.parentNode) {
1817
- if (!lineNode || lineNode == cm.display.lineDiv) return null;
1818
- if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
1819
- }
1820
- }
1821
- for (var i = 0; i < cm.display.view.length; i++) {
1822
- var lineView = cm.display.view[i];
1823
- if (lineView.node == lineNode)
1824
- return locateNodeInLineView(lineView, node, offset);
1825
- }
1826
- }
1827
-
1828
- function locateNodeInLineView(lineView, node, offset) {
1829
- var wrapper = lineView.text.firstChild, bad = false;
1830
- if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
1831
- if (node == wrapper) {
1832
- bad = true;
1833
- node = wrapper.childNodes[offset];
1834
- offset = 0;
1835
- if (!node) {
1836
- var line = lineView.rest ? lst(lineView.rest) : lineView.line;
1837
- return badPos(Pos(lineNo(line), line.text.length), bad);
1838
- }
1839
- }
1840
-
1841
- var textNode = node.nodeType == 3 ? node : null, topNode = node;
1842
- if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
1843
- textNode = node.firstChild;
1844
- if (offset) offset = textNode.nodeValue.length;
1845
- }
1846
- while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
1847
- var measure = lineView.measure, maps = measure.maps;
1848
-
1849
- function find(textNode, topNode, offset) {
1850
- for (var i = -1; i < (maps ? maps.length : 0); i++) {
1851
- var map = i < 0 ? measure.map : maps[i];
1852
- for (var j = 0; j < map.length; j += 3) {
1853
- var curNode = map[j + 2];
1854
- if (curNode == textNode || curNode == topNode) {
1855
- var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
1856
- var ch = map[j] + offset;
1857
- if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
1858
- return Pos(line, ch);
1859
- }
1860
- }
1861
- }
1862
- }
1863
- var found = find(textNode, topNode, offset);
1864
- if (found) return badPos(found, bad);
1865
-
1866
- // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
1867
- for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
1868
- found = find(after, after.firstChild, 0);
1869
- if (found)
1870
- return badPos(Pos(found.line, found.ch - dist), bad);
1871
- else
1872
- dist += after.textContent.length;
1873
- }
1874
- for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
1875
- found = find(before, before.firstChild, -1);
1876
- if (found)
1877
- return badPos(Pos(found.line, found.ch + dist), bad);
1878
- else
1879
- dist += after.textContent.length;
1880
- }
1881
- }
1882
-
1883
- function domTextBetween(cm, from, to, fromLine, toLine) {
1884
- var text = "", closing = false;
1885
- function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
1886
- function walk(node) {
1887
- if (node.nodeType == 1) {
1888
- var cmText = node.getAttribute("cm-text");
1889
- if (cmText != null) {
1890
- if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
1891
- text += cmText;
1892
- return;
1893
- }
1894
- var markerID = node.getAttribute("cm-marker"), range;
1895
- if (markerID) {
1896
- var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
1897
- if (found.length && (range = found[0].find()))
1898
- text += getBetween(cm.doc, range.from, range.to).join("\n");
1899
- return;
1900
- }
1901
- if (node.getAttribute("contenteditable") == "false") return;
1902
- for (var i = 0; i < node.childNodes.length; i++)
1903
- walk(node.childNodes[i]);
1904
- if (/^(pre|div|p)$/i.test(node.nodeName))
1905
- closing = true;
1906
- } else if (node.nodeType == 3) {
1907
- var val = node.nodeValue;
1908
- if (!val) return;
1909
- if (closing) {
1910
- text += "\n";
1911
- closing = false;
1912
- }
1913
- text += val;
1914
- }
1915
- }
1916
- for (;;) {
1917
- walk(from);
1918
- if (from == to) break;
1919
- from = from.nextSibling;
1920
- }
1921
- return text;
1922
- }
1923
-
1924
- CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
1925
-
1926
- // SELECTION / CURSOR
1927
-
1928
- // Selection objects are immutable. A new one is created every time
1929
- // the selection changes. A selection is one or more non-overlapping
1930
- // (and non-touching) ranges, sorted, and an integer that indicates
1931
- // which one is the primary selection (the one that's scrolled into
1932
- // view, that getCursor returns, etc).
1933
- function Selection(ranges, primIndex) {
1934
- this.ranges = ranges;
1935
- this.primIndex = primIndex;
1936
- }
1937
-
1938
- Selection.prototype = {
1939
- primary: function() { return this.ranges[this.primIndex]; },
1940
- equals: function(other) {
1941
- if (other == this) return true;
1942
- if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
1943
- for (var i = 0; i < this.ranges.length; i++) {
1944
- var here = this.ranges[i], there = other.ranges[i];
1945
- if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
1946
- }
1947
- return true;
1948
- },
1949
- deepCopy: function() {
1950
- for (var out = [], i = 0; i < this.ranges.length; i++)
1951
- out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
1952
- return new Selection(out, this.primIndex);
1953
- },
1954
- somethingSelected: function() {
1955
- for (var i = 0; i < this.ranges.length; i++)
1956
- if (!this.ranges[i].empty()) return true;
1957
- return false;
1958
- },
1959
- contains: function(pos, end) {
1960
- if (!end) end = pos;
1961
- for (var i = 0; i < this.ranges.length; i++) {
1962
- var range = this.ranges[i];
1963
- if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
1964
- return i;
1965
- }
1966
- return -1;
1967
- }
1968
- };
1969
-
1970
- function Range(anchor, head) {
1971
- this.anchor = anchor; this.head = head;
1972
- }
1973
-
1974
- Range.prototype = {
1975
- from: function() { return minPos(this.anchor, this.head); },
1976
- to: function() { return maxPos(this.anchor, this.head); },
1977
- empty: function() {
1978
- return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
1979
- }
1980
- };
1981
-
1982
- // Take an unsorted, potentially overlapping set of ranges, and
1983
- // build a selection out of it. 'Consumes' ranges array (modifying
1984
- // it).
1985
- function normalizeSelection(ranges, primIndex) {
1986
- var prim = ranges[primIndex];
1987
- ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
1988
- primIndex = indexOf(ranges, prim);
1989
- for (var i = 1; i < ranges.length; i++) {
1990
- var cur = ranges[i], prev = ranges[i - 1];
1991
- if (cmp(prev.to(), cur.from()) >= 0) {
1992
- var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
1993
- var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
1994
- if (i <= primIndex) --primIndex;
1995
- ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
1996
- }
1997
- }
1998
- return new Selection(ranges, primIndex);
1999
- }
2000
-
2001
- function simpleSelection(anchor, head) {
2002
- return new Selection([new Range(anchor, head || anchor)], 0);
2003
- }
2004
-
2005
- // Most of the external API clips given positions to make sure they
2006
- // actually exist within the document.
2007
- function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
2008
- function clipPos(doc, pos) {
2009
- if (pos.line < doc.first) return Pos(doc.first, 0);
2010
- var last = doc.first + doc.size - 1;
2011
- if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
2012
- return clipToLen(pos, getLine(doc, pos.line).text.length);
2013
- }
2014
- function clipToLen(pos, linelen) {
2015
- var ch = pos.ch;
2016
- if (ch == null || ch > linelen) return Pos(pos.line, linelen);
2017
- else if (ch < 0) return Pos(pos.line, 0);
2018
- else return pos;
2019
- }
2020
- function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
2021
- function clipPosArray(doc, array) {
2022
- for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
2023
- return out;
2024
- }
2025
-
2026
- // SELECTION UPDATES
2027
-
2028
- // The 'scroll' parameter given to many of these indicated whether
2029
- // the new cursor position should be scrolled into view after
2030
- // modifying the selection.
2031
-
2032
- // If shift is held or the extend flag is set, extends a range to
2033
- // include a given position (and optionally a second position).
2034
- // Otherwise, simply returns the range between the given positions.
2035
- // Used for cursor motion and such.
2036
- function extendRange(doc, range, head, other) {
2037
- if (doc.cm && doc.cm.display.shift || doc.extend) {
2038
- var anchor = range.anchor;
2039
- if (other) {
2040
- var posBefore = cmp(head, anchor) < 0;
2041
- if (posBefore != (cmp(other, anchor) < 0)) {
2042
- anchor = head;
2043
- head = other;
2044
- } else if (posBefore != (cmp(head, other) < 0)) {
2045
- head = other;
2046
- }
2047
- }
2048
- return new Range(anchor, head);
2049
- } else {
2050
- return new Range(other || head, head);
2051
- }
2052
- }
2053
-
2054
- // Extend the primary selection range, discard the rest.
2055
- function extendSelection(doc, head, other, options) {
2056
- setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
2057
- }
2058
-
2059
- // Extend all selections (pos is an array of selections with length
2060
- // equal the number of selections)
2061
- function extendSelections(doc, heads, options) {
2062
- for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
2063
- out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
2064
- var newSel = normalizeSelection(out, doc.sel.primIndex);
2065
- setSelection(doc, newSel, options);
2066
- }
2067
-
2068
- // Updates a single range in the selection.
2069
- function replaceOneSelection(doc, i, range, options) {
2070
- var ranges = doc.sel.ranges.slice(0);
2071
- ranges[i] = range;
2072
- setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
2073
- }
2074
-
2075
- // Reset the selection to a single range.
2076
- function setSimpleSelection(doc, anchor, head, options) {
2077
- setSelection(doc, simpleSelection(anchor, head), options);
2078
- }
2079
-
2080
- // Give beforeSelectionChange handlers a change to influence a
2081
- // selection update.
2082
- function filterSelectionChange(doc, sel) {
2083
- var obj = {
2084
- ranges: sel.ranges,
2085
- update: function(ranges) {
2086
- this.ranges = [];
2087
- for (var i = 0; i < ranges.length; i++)
2088
- this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
2089
- clipPos(doc, ranges[i].head));
2090
- }
2091
- };
2092
- signal(doc, "beforeSelectionChange", doc, obj);
2093
- if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
2094
- if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
2095
- else return sel;
2096
- }
2097
-
2098
- function setSelectionReplaceHistory(doc, sel, options) {
2099
- var done = doc.history.done, last = lst(done);
2100
- if (last && last.ranges) {
2101
- done[done.length - 1] = sel;
2102
- setSelectionNoUndo(doc, sel, options);
2103
- } else {
2104
- setSelection(doc, sel, options);
2105
- }
2106
- }
2107
-
2108
- // Set a new selection.
2109
- function setSelection(doc, sel, options) {
2110
- setSelectionNoUndo(doc, sel, options);
2111
- addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
2112
- }
2113
-
2114
- function setSelectionNoUndo(doc, sel, options) {
2115
- if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
2116
- sel = filterSelectionChange(doc, sel);
2117
-
2118
- var bias = options && options.bias ||
2119
- (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
2120
- setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
2121
-
2122
- if (!(options && options.scroll === false) && doc.cm)
2123
- ensureCursorVisible(doc.cm);
2124
- }
2125
-
2126
- function setSelectionInner(doc, sel) {
2127
- if (sel.equals(doc.sel)) return;
2128
-
2129
- doc.sel = sel;
2130
-
2131
- if (doc.cm) {
2132
- doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
2133
- signalCursorActivity(doc.cm);
2134
- }
2135
- signalLater(doc, "cursorActivity", doc);
2136
- }
2137
-
2138
- // Verify that the selection does not partially select any atomic
2139
- // marked ranges.
2140
- function reCheckSelection(doc) {
2141
- setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
2142
- }
2143
-
2144
- // Return a selection that does not partially select any atomic
2145
- // ranges.
2146
- function skipAtomicInSelection(doc, sel, bias, mayClear) {
2147
- var out;
2148
- for (var i = 0; i < sel.ranges.length; i++) {
2149
- var range = sel.ranges[i];
2150
- var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
2151
- var newHead = skipAtomic(doc, range.head, bias, mayClear);
2152
- if (out || newAnchor != range.anchor || newHead != range.head) {
2153
- if (!out) out = sel.ranges.slice(0, i);
2154
- out[i] = new Range(newAnchor, newHead);
2155
- }
2156
- }
2157
- return out ? normalizeSelection(out, sel.primIndex) : sel;
2158
- }
2159
-
2160
- // Ensure a given position is not inside an atomic range.
2161
- function skipAtomic(doc, pos, bias, mayClear) {
2162
- var flipped = false, curPos = pos;
2163
- var dir = bias || 1;
2164
- doc.cantEdit = false;
2165
- search: for (;;) {
2166
- var line = getLine(doc, curPos.line);
2167
- if (line.markedSpans) {
2168
- for (var i = 0; i < line.markedSpans.length; ++i) {
2169
- var sp = line.markedSpans[i], m = sp.marker;
2170
- if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
2171
- (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
2172
- if (mayClear) {
2173
- signal(m, "beforeCursorEnter");
2174
- if (m.explicitlyCleared) {
2175
- if (!line.markedSpans) break;
2176
- else {--i; continue;}
2177
- }
2178
- }
2179
- if (!m.atomic) continue;
2180
- var newPos = m.find(dir < 0 ? -1 : 1);
2181
- if (cmp(newPos, curPos) == 0) {
2182
- newPos.ch += dir;
2183
- if (newPos.ch < 0) {
2184
- if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
2185
- else newPos = null;
2186
- } else if (newPos.ch > line.text.length) {
2187
- if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
2188
- else newPos = null;
2189
- }
2190
- if (!newPos) {
2191
- if (flipped) {
2192
- // Driven in a corner -- no valid cursor position found at all
2193
- // -- try again *with* clearing, if we didn't already
2194
- if (!mayClear) return skipAtomic(doc, pos, bias, true);
2195
- // Otherwise, turn off editing until further notice, and return the start of the doc
2196
- doc.cantEdit = true;
2197
- return Pos(doc.first, 0);
2198
- }
2199
- flipped = true; newPos = pos; dir = -dir;
2200
- }
2201
- }
2202
- curPos = newPos;
2203
- continue search;
2204
- }
2205
- }
2206
- }
2207
- return curPos;
2208
- }
2209
- }
2210
-
2211
- // SELECTION DRAWING
2212
-
2213
- function updateSelection(cm) {
2214
- cm.display.input.showSelection(cm.display.input.prepareSelection());
2215
- }
2216
-
2217
- function prepareSelection(cm, primary) {
2218
- var doc = cm.doc, result = {};
2219
- var curFragment = result.cursors = document.createDocumentFragment();
2220
- var selFragment = result.selection = document.createDocumentFragment();
2221
-
2222
- for (var i = 0; i < doc.sel.ranges.length; i++) {
2223
- if (primary === false && i == doc.sel.primIndex) continue;
2224
- var range = doc.sel.ranges[i];
2225
- var collapsed = range.empty();
2226
- if (collapsed || cm.options.showCursorWhenSelecting)
2227
- drawSelectionCursor(cm, range, curFragment);
2228
- if (!collapsed)
2229
- drawSelectionRange(cm, range, selFragment);
2230
- }
2231
- return result;
2232
- }
2233
-
2234
- // Draws a cursor for the given range
2235
- function drawSelectionCursor(cm, range, output) {
2236
- var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
2237
-
2238
- var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
2239
- cursor.style.left = pos.left + "px";
2240
- cursor.style.top = pos.top + "px";
2241
- cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
2242
-
2243
- if (pos.other) {
2244
- // Secondary cursor, shown when on a 'jump' in bi-directional text
2245
- var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
2246
- otherCursor.style.display = "";
2247
- otherCursor.style.left = pos.other.left + "px";
2248
- otherCursor.style.top = pos.other.top + "px";
2249
- otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
2250
- }
2251
- }
2252
-
2253
- // Draws the given range as a highlighted selection
2254
- function drawSelectionRange(cm, range, output) {
2255
- var display = cm.display, doc = cm.doc;
2256
- var fragment = document.createDocumentFragment();
2257
- var padding = paddingH(cm.display), leftSide = padding.left;
2258
- var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
2259
-
2260
- function add(left, top, width, bottom) {
2261
- if (top < 0) top = 0;
2262
- top = Math.round(top);
2263
- bottom = Math.round(bottom);
2264
- fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
2265
- "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
2266
- "px; height: " + (bottom - top) + "px"));
2267
- }
2268
-
2269
- function drawForLine(line, fromArg, toArg) {
2270
- var lineObj = getLine(doc, line);
2271
- var lineLen = lineObj.text.length;
2272
- var start, end;
2273
- function coords(ch, bias) {
2274
- return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
2275
- }
2276
-
2277
- iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
2278
- var leftPos = coords(from, "left"), rightPos, left, right;
2279
- if (from == to) {
2280
- rightPos = leftPos;
2281
- left = right = leftPos.left;
2282
- } else {
2283
- rightPos = coords(to - 1, "right");
2284
- if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
2285
- left = leftPos.left;
2286
- right = rightPos.right;
2287
- }
2288
- if (fromArg == null && from == 0) left = leftSide;
2289
- if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
2290
- add(left, leftPos.top, null, leftPos.bottom);
2291
- left = leftSide;
2292
- if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
2293
- }
2294
- if (toArg == null && to == lineLen) right = rightSide;
2295
- if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
2296
- start = leftPos;
2297
- if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
2298
- end = rightPos;
2299
- if (left < leftSide + 1) left = leftSide;
2300
- add(left, rightPos.top, right - left, rightPos.bottom);
2301
- });
2302
- return {start: start, end: end};
2303
- }
2304
-
2305
- var sFrom = range.from(), sTo = range.to();
2306
- if (sFrom.line == sTo.line) {
2307
- drawForLine(sFrom.line, sFrom.ch, sTo.ch);
2308
- } else {
2309
- var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
2310
- var singleVLine = visualLine(fromLine) == visualLine(toLine);
2311
- var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
2312
- var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
2313
- if (singleVLine) {
2314
- if (leftEnd.top < rightStart.top - 2) {
2315
- add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
2316
- add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
2317
- } else {
2318
- add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
2319
- }
2320
- }
2321
- if (leftEnd.bottom < rightStart.top)
2322
- add(leftSide, leftEnd.bottom, null, rightStart.top);
2323
- }
2324
-
2325
- output.appendChild(fragment);
2326
- }
2327
-
2328
- // Cursor-blinking
2329
- function restartBlink(cm) {
2330
- if (!cm.state.focused) return;
2331
- var display = cm.display;
2332
- clearInterval(display.blinker);
2333
- var on = true;
2334
- display.cursorDiv.style.visibility = "";
2335
- if (cm.options.cursorBlinkRate > 0)
2336
- display.blinker = setInterval(function() {
2337
- display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
2338
- }, cm.options.cursorBlinkRate);
2339
- else if (cm.options.cursorBlinkRate < 0)
2340
- display.cursorDiv.style.visibility = "hidden";
2341
- }
2342
-
2343
- // HIGHLIGHT WORKER
2344
-
2345
- function startWorker(cm, time) {
2346
- if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
2347
- cm.state.highlight.set(time, bind(highlightWorker, cm));
2348
- }
2349
-
2350
- function highlightWorker(cm) {
2351
- var doc = cm.doc;
2352
- if (doc.frontier < doc.first) doc.frontier = doc.first;
2353
- if (doc.frontier >= cm.display.viewTo) return;
2354
- var end = +new Date + cm.options.workTime;
2355
- var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
2356
- var changedLines = [];
2357
-
2358
- doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
2359
- if (doc.frontier >= cm.display.viewFrom) { // Visible
2360
- var oldStyles = line.styles;
2361
- var highlighted = highlightLine(cm, line, state, true);
2362
- line.styles = highlighted.styles;
2363
- var oldCls = line.styleClasses, newCls = highlighted.classes;
2364
- if (newCls) line.styleClasses = newCls;
2365
- else if (oldCls) line.styleClasses = null;
2366
- var ischange = !oldStyles || oldStyles.length != line.styles.length ||
2367
- oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
2368
- for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
2369
- if (ischange) changedLines.push(doc.frontier);
2370
- line.stateAfter = copyState(doc.mode, state);
2371
- } else {
2372
- processLine(cm, line.text, state);
2373
- line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
2374
- }
2375
- ++doc.frontier;
2376
- if (+new Date > end) {
2377
- startWorker(cm, cm.options.workDelay);
2378
- return true;
2379
- }
2380
- });
2381
- if (changedLines.length) runInOp(cm, function() {
2382
- for (var i = 0; i < changedLines.length; i++)
2383
- regLineChange(cm, changedLines[i], "text");
2384
- });
2385
- }
2386
-
2387
- // Finds the line to start with when starting a parse. Tries to
2388
- // find a line with a stateAfter, so that it can start with a
2389
- // valid state. If that fails, it returns the line with the
2390
- // smallest indentation, which tends to need the least context to
2391
- // parse correctly.
2392
- function findStartLine(cm, n, precise) {
2393
- var minindent, minline, doc = cm.doc;
2394
- var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
2395
- for (var search = n; search > lim; --search) {
2396
- if (search <= doc.first) return doc.first;
2397
- var line = getLine(doc, search - 1);
2398
- if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
2399
- var indented = countColumn(line.text, null, cm.options.tabSize);
2400
- if (minline == null || minindent > indented) {
2401
- minline = search - 1;
2402
- minindent = indented;
2403
- }
2404
- }
2405
- return minline;
2406
- }
2407
-
2408
- function getStateBefore(cm, n, precise) {
2409
- var doc = cm.doc, display = cm.display;
2410
- if (!doc.mode.startState) return true;
2411
- var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
2412
- if (!state) state = startState(doc.mode);
2413
- else state = copyState(doc.mode, state);
2414
- doc.iter(pos, n, function(line) {
2415
- processLine(cm, line.text, state);
2416
- var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
2417
- line.stateAfter = save ? copyState(doc.mode, state) : null;
2418
- ++pos;
2419
- });
2420
- if (precise) doc.frontier = pos;
2421
- return state;
2422
- }
2423
-
2424
- // POSITION MEASUREMENT
2425
-
2426
- function paddingTop(display) {return display.lineSpace.offsetTop;}
2427
- function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
2428
- function paddingH(display) {
2429
- if (display.cachedPaddingH) return display.cachedPaddingH;
2430
- var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
2431
- var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
2432
- var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
2433
- if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
2434
- return data;
2435
- }
2436
-
2437
- function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
2438
- function displayWidth(cm) {
2439
- return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
2440
- }
2441
- function displayHeight(cm) {
2442
- return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
2443
- }
2444
-
2445
- // Ensure the lineView.wrapping.heights array is populated. This is
2446
- // an array of bottom offsets for the lines that make up a drawn
2447
- // line. When lineWrapping is on, there might be more than one
2448
- // height.
2449
- function ensureLineHeights(cm, lineView, rect) {
2450
- var wrapping = cm.options.lineWrapping;
2451
- var curWidth = wrapping && displayWidth(cm);
2452
- if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
2453
- var heights = lineView.measure.heights = [];
2454
- if (wrapping) {
2455
- lineView.measure.width = curWidth;
2456
- var rects = lineView.text.firstChild.getClientRects();
2457
- for (var i = 0; i < rects.length - 1; i++) {
2458
- var cur = rects[i], next = rects[i + 1];
2459
- if (Math.abs(cur.bottom - next.bottom) > 2)
2460
- heights.push((cur.bottom + next.top) / 2 - rect.top);
2461
- }
2462
- }
2463
- heights.push(rect.bottom - rect.top);
2464
- }
2465
- }
2466
-
2467
- // Find a line map (mapping character offsets to text nodes) and a
2468
- // measurement cache for the given line number. (A line view might
2469
- // contain multiple lines when collapsed ranges are present.)
2470
- function mapFromLineView(lineView, line, lineN) {
2471
- if (lineView.line == line)
2472
- return {map: lineView.measure.map, cache: lineView.measure.cache};
2473
- for (var i = 0; i < lineView.rest.length; i++)
2474
- if (lineView.rest[i] == line)
2475
- return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
2476
- for (var i = 0; i < lineView.rest.length; i++)
2477
- if (lineNo(lineView.rest[i]) > lineN)
2478
- return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
2479
- }
2480
-
2481
- // Render a line into the hidden node display.externalMeasured. Used
2482
- // when measurement is needed for a line that's not in the viewport.
2483
- function updateExternalMeasurement(cm, line) {
2484
- line = visualLine(line);
2485
- var lineN = lineNo(line);
2486
- var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
2487
- view.lineN = lineN;
2488
- var built = view.built = buildLineContent(cm, view);
2489
- view.text = built.pre;
2490
- removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
2491
- return view;
2492
- }
2493
-
2494
- // Get a {top, bottom, left, right} box (in line-local coordinates)
2495
- // for a given character.
2496
- function measureChar(cm, line, ch, bias) {
2497
- return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
2498
- }
2499
-
2500
- // Find a line view that corresponds to the given line number.
2501
- function findViewForLine(cm, lineN) {
2502
- if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
2503
- return cm.display.view[findViewIndex(cm, lineN)];
2504
- var ext = cm.display.externalMeasured;
2505
- if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
2506
- return ext;
2507
- }
2508
-
2509
- // Measurement can be split in two steps, the set-up work that
2510
- // applies to the whole line, and the measurement of the actual
2511
- // character. Functions like coordsChar, that need to do a lot of
2512
- // measurements in a row, can thus ensure that the set-up work is
2513
- // only done once.
2514
- function prepareMeasureForLine(cm, line) {
2515
- var lineN = lineNo(line);
2516
- var view = findViewForLine(cm, lineN);
2517
- if (view && !view.text)
2518
- view = null;
2519
- else if (view && view.changes)
2520
- updateLineForChanges(cm, view, lineN, getDimensions(cm));
2521
- if (!view)
2522
- view = updateExternalMeasurement(cm, line);
2523
-
2524
- var info = mapFromLineView(view, line, lineN);
2525
- return {
2526
- line: line, view: view, rect: null,
2527
- map: info.map, cache: info.cache, before: info.before,
2528
- hasHeights: false
2529
- };
2530
- }
2531
-
2532
- // Given a prepared measurement object, measures the position of an
2533
- // actual character (or fetches it from the cache).
2534
- function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
2535
- if (prepared.before) ch = -1;
2536
- var key = ch + (bias || ""), found;
2537
- if (prepared.cache.hasOwnProperty(key)) {
2538
- found = prepared.cache[key];
2539
- } else {
2540
- if (!prepared.rect)
2541
- prepared.rect = prepared.view.text.getBoundingClientRect();
2542
- if (!prepared.hasHeights) {
2543
- ensureLineHeights(cm, prepared.view, prepared.rect);
2544
- prepared.hasHeights = true;
2545
- }
2546
- found = measureCharInner(cm, prepared, ch, bias);
2547
- if (!found.bogus) prepared.cache[key] = found;
2548
- }
2549
- return {left: found.left, right: found.right,
2550
- top: varHeight ? found.rtop : found.top,
2551
- bottom: varHeight ? found.rbottom : found.bottom};
2552
- }
2553
-
2554
- var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
2555
-
2556
- function nodeAndOffsetInLineMap(map, ch, bias) {
2557
- var node, start, end, collapse;
2558
- // First, search the line map for the text node corresponding to,
2559
- // or closest to, the target character.
2560
- for (var i = 0; i < map.length; i += 3) {
2561
- var mStart = map[i], mEnd = map[i + 1];
2562
- if (ch < mStart) {
2563
- start = 0; end = 1;
2564
- collapse = "left";
2565
- } else if (ch < mEnd) {
2566
- start = ch - mStart;
2567
- end = start + 1;
2568
- } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
2569
- end = mEnd - mStart;
2570
- start = end - 1;
2571
- if (ch >= mEnd) collapse = "right";
2572
- }
2573
- if (start != null) {
2574
- node = map[i + 2];
2575
- if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
2576
- collapse = bias;
2577
- if (bias == "left" && start == 0)
2578
- while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
2579
- node = map[(i -= 3) + 2];
2580
- collapse = "left";
2581
- }
2582
- if (bias == "right" && start == mEnd - mStart)
2583
- while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
2584
- node = map[(i += 3) + 2];
2585
- collapse = "right";
2586
- }
2587
- break;
2588
- }
2589
- }
2590
- return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
2591
- }
2592
-
2593
- function measureCharInner(cm, prepared, ch, bias) {
2594
- var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
2595
- var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
2596
-
2597
- var rect;
2598
- if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
2599
- for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
2600
- while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
2601
- while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
2602
- if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
2603
- rect = node.parentNode.getBoundingClientRect();
2604
- } else if (ie && cm.options.lineWrapping) {
2605
- var rects = range(node, start, end).getClientRects();
2606
- if (rects.length)
2607
- rect = rects[bias == "right" ? rects.length - 1 : 0];
2608
- else
2609
- rect = nullRect;
2610
- } else {
2611
- rect = range(node, start, end).getBoundingClientRect() || nullRect;
2612
- }
2613
- if (rect.left || rect.right || start == 0) break;
2614
- end = start;
2615
- start = start - 1;
2616
- collapse = "right";
2617
- }
2618
- if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
2619
- } else { // If it is a widget, simply get the box for the whole widget.
2620
- if (start > 0) collapse = bias = "right";
2621
- var rects;
2622
- if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
2623
- rect = rects[bias == "right" ? rects.length - 1 : 0];
2624
- else
2625
- rect = node.getBoundingClientRect();
2626
- }
2627
- if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
2628
- var rSpan = node.parentNode.getClientRects()[0];
2629
- if (rSpan)
2630
- rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
2631
- else
2632
- rect = nullRect;
2633
- }
2634
-
2635
- var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
2636
- var mid = (rtop + rbot) / 2;
2637
- var heights = prepared.view.measure.heights;
2638
- for (var i = 0; i < heights.length - 1; i++)
2639
- if (mid < heights[i]) break;
2640
- var top = i ? heights[i - 1] : 0, bot = heights[i];
2641
- var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
2642
- right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
2643
- top: top, bottom: bot};
2644
- if (!rect.left && !rect.right) result.bogus = true;
2645
- if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
2646
-
2647
- return result;
2648
- }
2649
-
2650
- // Work around problem with bounding client rects on ranges being
2651
- // returned incorrectly when zoomed on IE10 and below.
2652
- function maybeUpdateRectForZooming(measure, rect) {
2653
- if (!window.screen || screen.logicalXDPI == null ||
2654
- screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
2655
- return rect;
2656
- var scaleX = screen.logicalXDPI / screen.deviceXDPI;
2657
- var scaleY = screen.logicalYDPI / screen.deviceYDPI;
2658
- return {left: rect.left * scaleX, right: rect.right * scaleX,
2659
- top: rect.top * scaleY, bottom: rect.bottom * scaleY};
2660
- }
2661
-
2662
- function clearLineMeasurementCacheFor(lineView) {
2663
- if (lineView.measure) {
2664
- lineView.measure.cache = {};
2665
- lineView.measure.heights = null;
2666
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
2667
- lineView.measure.caches[i] = {};
2668
- }
2669
- }
2670
-
2671
- function clearLineMeasurementCache(cm) {
2672
- cm.display.externalMeasure = null;
2673
- removeChildren(cm.display.lineMeasure);
2674
- for (var i = 0; i < cm.display.view.length; i++)
2675
- clearLineMeasurementCacheFor(cm.display.view[i]);
2676
- }
2677
-
2678
- function clearCaches(cm) {
2679
- clearLineMeasurementCache(cm);
2680
- cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
2681
- if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
2682
- cm.display.lineNumChars = null;
2683
- }
2684
-
2685
- function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
2686
- function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
2687
-
2688
- // Converts a {top, bottom, left, right} box from line-local
2689
- // coordinates into another coordinate system. Context may be one of
2690
- // "line", "div" (display.lineDiv), "local"/null (editor), "window",
2691
- // or "page".
2692
- function intoCoordSystem(cm, lineObj, rect, context) {
2693
- if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
2694
- var size = widgetHeight(lineObj.widgets[i]);
2695
- rect.top += size; rect.bottom += size;
2696
- }
2697
- if (context == "line") return rect;
2698
- if (!context) context = "local";
2699
- var yOff = heightAtLine(lineObj);
2700
- if (context == "local") yOff += paddingTop(cm.display);
2701
- else yOff -= cm.display.viewOffset;
2702
- if (context == "page" || context == "window") {
2703
- var lOff = cm.display.lineSpace.getBoundingClientRect();
2704
- yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
2705
- var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
2706
- rect.left += xOff; rect.right += xOff;
2707
- }
2708
- rect.top += yOff; rect.bottom += yOff;
2709
- return rect;
2710
- }
2711
-
2712
- // Coverts a box from "div" coords to another coordinate system.
2713
- // Context may be "window", "page", "div", or "local"/null.
2714
- function fromCoordSystem(cm, coords, context) {
2715
- if (context == "div") return coords;
2716
- var left = coords.left, top = coords.top;
2717
- // First move into "page" coordinate system
2718
- if (context == "page") {
2719
- left -= pageScrollX();
2720
- top -= pageScrollY();
2721
- } else if (context == "local" || !context) {
2722
- var localBox = cm.display.sizer.getBoundingClientRect();
2723
- left += localBox.left;
2724
- top += localBox.top;
2725
- }
2726
-
2727
- var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
2728
- return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
2729
- }
2730
-
2731
- function charCoords(cm, pos, context, lineObj, bias) {
2732
- if (!lineObj) lineObj = getLine(cm.doc, pos.line);
2733
- return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
2734
- }
2735
-
2736
- // Returns a box for a given cursor position, which may have an
2737
- // 'other' property containing the position of the secondary cursor
2738
- // on a bidi boundary.
2739
- function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
2740
- lineObj = lineObj || getLine(cm.doc, pos.line);
2741
- if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
2742
- function get(ch, right) {
2743
- var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
2744
- if (right) m.left = m.right; else m.right = m.left;
2745
- return intoCoordSystem(cm, lineObj, m, context);
2746
- }
2747
- function getBidi(ch, partPos) {
2748
- var part = order[partPos], right = part.level % 2;
2749
- if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
2750
- part = order[--partPos];
2751
- ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
2752
- right = true;
2753
- } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
2754
- part = order[++partPos];
2755
- ch = bidiLeft(part) - part.level % 2;
2756
- right = false;
2757
- }
2758
- if (right && ch == part.to && ch > part.from) return get(ch - 1);
2759
- return get(ch, right);
2760
- }
2761
- var order = getOrder(lineObj), ch = pos.ch;
2762
- if (!order) return get(ch);
2763
- var partPos = getBidiPartAt(order, ch);
2764
- var val = getBidi(ch, partPos);
2765
- if (bidiOther != null) val.other = getBidi(ch, bidiOther);
2766
- return val;
2767
- }
2768
-
2769
- // Used to cheaply estimate the coordinates for a position. Used for
2770
- // intermediate scroll updates.
2771
- function estimateCoords(cm, pos) {
2772
- var left = 0, pos = clipPos(cm.doc, pos);
2773
- if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
2774
- var lineObj = getLine(cm.doc, pos.line);
2775
- var top = heightAtLine(lineObj) + paddingTop(cm.display);
2776
- return {left: left, right: left, top: top, bottom: top + lineObj.height};
2777
- }
2778
-
2779
- // Positions returned by coordsChar contain some extra information.
2780
- // xRel is the relative x position of the input coordinates compared
2781
- // to the found position (so xRel > 0 means the coordinates are to
2782
- // the right of the character position, for example). When outside
2783
- // is true, that means the coordinates lie outside the line's
2784
- // vertical range.
2785
- function PosWithInfo(line, ch, outside, xRel) {
2786
- var pos = Pos(line, ch);
2787
- pos.xRel = xRel;
2788
- if (outside) pos.outside = true;
2789
- return pos;
2790
- }
2791
-
2792
- // Compute the character position closest to the given coordinates.
2793
- // Input must be lineSpace-local ("div" coordinate system).
2794
- function coordsChar(cm, x, y) {
2795
- var doc = cm.doc;
2796
- y += cm.display.viewOffset;
2797
- if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
2798
- var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
2799
- if (lineN > last)
2800
- return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
2801
- if (x < 0) x = 0;
2802
-
2803
- var lineObj = getLine(doc, lineN);
2804
- for (;;) {
2805
- var found = coordsCharInner(cm, lineObj, lineN, x, y);
2806
- var merged = collapsedSpanAtEnd(lineObj);
2807
- var mergedPos = merged && merged.find(0, true);
2808
- if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
2809
- lineN = lineNo(lineObj = mergedPos.to.line);
2810
- else
2811
- return found;
2812
- }
2813
- }
2814
-
2815
- function coordsCharInner(cm, lineObj, lineNo, x, y) {
2816
- var innerOff = y - heightAtLine(lineObj);
2817
- var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
2818
- var preparedMeasure = prepareMeasureForLine(cm, lineObj);
2819
-
2820
- function getX(ch) {
2821
- var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
2822
- wrongLine = true;
2823
- if (innerOff > sp.bottom) return sp.left - adjust;
2824
- else if (innerOff < sp.top) return sp.left + adjust;
2825
- else wrongLine = false;
2826
- return sp.left;
2827
- }
2828
-
2829
- var bidi = getOrder(lineObj), dist = lineObj.text.length;
2830
- var from = lineLeft(lineObj), to = lineRight(lineObj);
2831
- var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
2832
-
2833
- if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
2834
- // Do a binary search between these bounds.
2835
- for (;;) {
2836
- if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
2837
- var ch = x < fromX || x - fromX <= toX - x ? from : to;
2838
- var xDiff = x - (ch == from ? fromX : toX);
2839
- while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
2840
- var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
2841
- xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
2842
- return pos;
2843
- }
2844
- var step = Math.ceil(dist / 2), middle = from + step;
2845
- if (bidi) {
2846
- middle = from;
2847
- for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
2848
- }
2849
- var middleX = getX(middle);
2850
- if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
2851
- else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
2852
- }
2853
- }
2854
-
2855
- var measureText;
2856
- // Compute the default text height.
2857
- function textHeight(display) {
2858
- if (display.cachedTextHeight != null) return display.cachedTextHeight;
2859
- if (measureText == null) {
2860
- measureText = elt("pre");
2861
- // Measure a bunch of lines, for browsers that compute
2862
- // fractional heights.
2863
- for (var i = 0; i < 49; ++i) {
2864
- measureText.appendChild(document.createTextNode("x"));
2865
- measureText.appendChild(elt("br"));
2866
- }
2867
- measureText.appendChild(document.createTextNode("x"));
2868
- }
2869
- removeChildrenAndAdd(display.measure, measureText);
2870
- var height = measureText.offsetHeight / 50;
2871
- if (height > 3) display.cachedTextHeight = height;
2872
- removeChildren(display.measure);
2873
- return height || 1;
2874
- }
2875
-
2876
- // Compute the default character width.
2877
- function charWidth(display) {
2878
- if (display.cachedCharWidth != null) return display.cachedCharWidth;
2879
- var anchor = elt("span", "xxxxxxxxxx");
2880
- var pre = elt("pre", [anchor]);
2881
- removeChildrenAndAdd(display.measure, pre);
2882
- var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
2883
- if (width > 2) display.cachedCharWidth = width;
2884
- return width || 10;
2885
- }
2886
-
2887
- // OPERATIONS
2888
-
2889
- // Operations are used to wrap a series of changes to the editor
2890
- // state in such a way that each change won't have to update the
2891
- // cursor and display (which would be awkward, slow, and
2892
- // error-prone). Instead, display updates are batched and then all
2893
- // combined and executed at once.
2894
-
2895
- var operationGroup = null;
2896
-
2897
- var nextOpId = 0;
2898
- // Start a new operation.
2899
- function startOperation(cm) {
2900
- cm.curOp = {
2901
- cm: cm,
2902
- viewChanged: false, // Flag that indicates that lines might need to be redrawn
2903
- startHeight: cm.doc.height, // Used to detect need to update scrollbar
2904
- forceUpdate: false, // Used to force a redraw
2905
- updateInput: null, // Whether to reset the input textarea
2906
- typing: false, // Whether this reset should be careful to leave existing text (for compositing)
2907
- changeObjs: null, // Accumulated changes, for firing change events
2908
- cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
2909
- cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
2910
- selectionChanged: false, // Whether the selection needs to be redrawn
2911
- updateMaxLine: false, // Set when the widest line needs to be determined anew
2912
- scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
2913
- scrollToPos: null, // Used to scroll to a specific position
2914
- id: ++nextOpId // Unique ID
2915
- };
2916
- if (operationGroup) {
2917
- operationGroup.ops.push(cm.curOp);
2918
- } else {
2919
- cm.curOp.ownsGroup = operationGroup = {
2920
- ops: [cm.curOp],
2921
- delayedCallbacks: []
2922
- };
2923
- }
2924
- }
2925
-
2926
- function fireCallbacksForOps(group) {
2927
- // Calls delayed callbacks and cursorActivity handlers until no
2928
- // new ones appear
2929
- var callbacks = group.delayedCallbacks, i = 0;
2930
- do {
2931
- for (; i < callbacks.length; i++)
2932
- callbacks[i]();
2933
- for (var j = 0; j < group.ops.length; j++) {
2934
- var op = group.ops[j];
2935
- if (op.cursorActivityHandlers)
2936
- while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
2937
- op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
2938
- }
2939
- } while (i < callbacks.length);
2940
- }
2941
-
2942
- // Finish an operation, updating the display and signalling delayed events
2943
- function endOperation(cm) {
2944
- var op = cm.curOp, group = op.ownsGroup;
2945
- if (!group) return;
2946
-
2947
- try { fireCallbacksForOps(group); }
2948
- finally {
2949
- operationGroup = null;
2950
- for (var i = 0; i < group.ops.length; i++)
2951
- group.ops[i].cm.curOp = null;
2952
- endOperations(group);
2953
- }
2954
- }
2955
-
2956
- // The DOM updates done when an operation finishes are batched so
2957
- // that the minimum number of relayouts are required.
2958
- function endOperations(group) {
2959
- var ops = group.ops;
2960
- for (var i = 0; i < ops.length; i++) // Read DOM
2961
- endOperation_R1(ops[i]);
2962
- for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
2963
- endOperation_W1(ops[i]);
2964
- for (var i = 0; i < ops.length; i++) // Read DOM
2965
- endOperation_R2(ops[i]);
2966
- for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
2967
- endOperation_W2(ops[i]);
2968
- for (var i = 0; i < ops.length; i++) // Read DOM
2969
- endOperation_finish(ops[i]);
2970
- }
2971
-
2972
- function endOperation_R1(op) {
2973
- var cm = op.cm, display = cm.display;
2974
- maybeClipScrollbars(cm);
2975
- if (op.updateMaxLine) findMaxLine(cm);
2976
-
2977
- op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
2978
- op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
2979
- op.scrollToPos.to.line >= display.viewTo) ||
2980
- display.maxLineChanged && cm.options.lineWrapping;
2981
- op.update = op.mustUpdate &&
2982
- new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
2983
- }
2984
-
2985
- function endOperation_W1(op) {
2986
- op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
2987
- }
2988
-
2989
- function endOperation_R2(op) {
2990
- var cm = op.cm, display = cm.display;
2991
- if (op.updatedDisplay) updateHeightsInViewport(cm);
2992
-
2993
- op.barMeasure = measureForScrollbars(cm);
2994
-
2995
- // If the max line changed since it was last measured, measure it,
2996
- // and ensure the document's width matches it.
2997
- // updateDisplay_W2 will use these properties to do the actual resizing
2998
- if (display.maxLineChanged && !cm.options.lineWrapping) {
2999
- op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
3000
- cm.display.sizerWidth = op.adjustWidthTo;
3001
- op.barMeasure.scrollWidth =
3002
- Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
3003
- op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
3004
- }
3005
-
3006
- if (op.updatedDisplay || op.selectionChanged)
3007
- op.preparedSelection = display.input.prepareSelection();
3008
- }
3009
-
3010
- function endOperation_W2(op) {
3011
- var cm = op.cm;
3012
-
3013
- if (op.adjustWidthTo != null) {
3014
- cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
3015
- if (op.maxScrollLeft < cm.doc.scrollLeft)
3016
- setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
3017
- cm.display.maxLineChanged = false;
3018
- }
3019
-
3020
- if (op.preparedSelection)
3021
- cm.display.input.showSelection(op.preparedSelection);
3022
- if (op.updatedDisplay)
3023
- setDocumentHeight(cm, op.barMeasure);
3024
- if (op.updatedDisplay || op.startHeight != cm.doc.height)
3025
- updateScrollbars(cm, op.barMeasure);
3026
-
3027
- if (op.selectionChanged) restartBlink(cm);
3028
-
3029
- if (cm.state.focused && op.updateInput)
3030
- cm.display.input.reset(op.typing);
3031
- }
3032
-
3033
- function endOperation_finish(op) {
3034
- var cm = op.cm, display = cm.display, doc = cm.doc;
3035
-
3036
- if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
3037
-
3038
- // Abort mouse wheel delta measurement, when scrolling explicitly
3039
- if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
3040
- display.wheelStartX = display.wheelStartY = null;
3041
-
3042
- // Propagate the scroll position to the actual DOM scroller
3043
- if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
3044
- doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
3045
- display.scrollbars.setScrollTop(doc.scrollTop);
3046
- display.scroller.scrollTop = doc.scrollTop;
3047
- }
3048
- if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
3049
- doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
3050
- display.scrollbars.setScrollLeft(doc.scrollLeft);
3051
- display.scroller.scrollLeft = doc.scrollLeft;
3052
- alignHorizontally(cm);
3053
- }
3054
- // If we need to scroll a specific position into view, do so.
3055
- if (op.scrollToPos) {
3056
- var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
3057
- clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
3058
- if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
3059
- }
3060
-
3061
- // Fire events for markers that are hidden/unidden by editing or
3062
- // undoing
3063
- var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
3064
- if (hidden) for (var i = 0; i < hidden.length; ++i)
3065
- if (!hidden[i].lines.length) signal(hidden[i], "hide");
3066
- if (unhidden) for (var i = 0; i < unhidden.length; ++i)
3067
- if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
3068
-
3069
- if (display.wrapper.offsetHeight)
3070
- doc.scrollTop = cm.display.scroller.scrollTop;
3071
-
3072
- // Fire change events, and delayed event handlers
3073
- if (op.changeObjs)
3074
- signal(cm, "changes", cm, op.changeObjs);
3075
- if (op.update)
3076
- op.update.finish();
3077
- }
3078
-
3079
- // Run the given function in an operation
3080
- function runInOp(cm, f) {
3081
- if (cm.curOp) return f();
3082
- startOperation(cm);
3083
- try { return f(); }
3084
- finally { endOperation(cm); }
3085
- }
3086
- // Wraps a function in an operation. Returns the wrapped function.
3087
- function operation(cm, f) {
3088
- return function() {
3089
- if (cm.curOp) return f.apply(cm, arguments);
3090
- startOperation(cm);
3091
- try { return f.apply(cm, arguments); }
3092
- finally { endOperation(cm); }
3093
- };
3094
- }
3095
- // Used to add methods to editor and doc instances, wrapping them in
3096
- // operations.
3097
- function methodOp(f) {
3098
- return function() {
3099
- if (this.curOp) return f.apply(this, arguments);
3100
- startOperation(this);
3101
- try { return f.apply(this, arguments); }
3102
- finally { endOperation(this); }
3103
- };
3104
- }
3105
- function docMethodOp(f) {
3106
- return function() {
3107
- var cm = this.cm;
3108
- if (!cm || cm.curOp) return f.apply(this, arguments);
3109
- startOperation(cm);
3110
- try { return f.apply(this, arguments); }
3111
- finally { endOperation(cm); }
3112
- };
3113
- }
3114
-
3115
- // VIEW TRACKING
3116
-
3117
- // These objects are used to represent the visible (currently drawn)
3118
- // part of the document. A LineView may correspond to multiple
3119
- // logical lines, if those are connected by collapsed ranges.
3120
- function LineView(doc, line, lineN) {
3121
- // The starting line
3122
- this.line = line;
3123
- // Continuing lines, if any
3124
- this.rest = visualLineContinued(line);
3125
- // Number of logical lines in this visual line
3126
- this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
3127
- this.node = this.text = null;
3128
- this.hidden = lineIsHidden(doc, line);
3129
- }
3130
-
3131
- // Create a range of LineView objects for the given lines.
3132
- function buildViewArray(cm, from, to) {
3133
- var array = [], nextPos;
3134
- for (var pos = from; pos < to; pos = nextPos) {
3135
- var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
3136
- nextPos = pos + view.size;
3137
- array.push(view);
3138
- }
3139
- return array;
3140
- }
3141
-
3142
- // Updates the display.view data structure for a given change to the
3143
- // document. From and to are in pre-change coordinates. Lendiff is
3144
- // the amount of lines added or subtracted by the change. This is
3145
- // used for changes that span multiple lines, or change the way
3146
- // lines are divided into visual lines. regLineChange (below)
3147
- // registers single-line changes.
3148
- function regChange(cm, from, to, lendiff) {
3149
- if (from == null) from = cm.doc.first;
3150
- if (to == null) to = cm.doc.first + cm.doc.size;
3151
- if (!lendiff) lendiff = 0;
3152
-
3153
- var display = cm.display;
3154
- if (lendiff && to < display.viewTo &&
3155
- (display.updateLineNumbers == null || display.updateLineNumbers > from))
3156
- display.updateLineNumbers = from;
3157
-
3158
- cm.curOp.viewChanged = true;
3159
-
3160
- if (from >= display.viewTo) { // Change after
3161
- if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
3162
- resetView(cm);
3163
- } else if (to <= display.viewFrom) { // Change before
3164
- if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
3165
- resetView(cm);
3166
- } else {
3167
- display.viewFrom += lendiff;
3168
- display.viewTo += lendiff;
3169
- }
3170
- } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
3171
- resetView(cm);
3172
- } else if (from <= display.viewFrom) { // Top overlap
3173
- var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
3174
- if (cut) {
3175
- display.view = display.view.slice(cut.index);
3176
- display.viewFrom = cut.lineN;
3177
- display.viewTo += lendiff;
3178
- } else {
3179
- resetView(cm);
3180
- }
3181
- } else if (to >= display.viewTo) { // Bottom overlap
3182
- var cut = viewCuttingPoint(cm, from, from, -1);
3183
- if (cut) {
3184
- display.view = display.view.slice(0, cut.index);
3185
- display.viewTo = cut.lineN;
3186
- } else {
3187
- resetView(cm);
3188
- }
3189
- } else { // Gap in the middle
3190
- var cutTop = viewCuttingPoint(cm, from, from, -1);
3191
- var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
3192
- if (cutTop && cutBot) {
3193
- display.view = display.view.slice(0, cutTop.index)
3194
- .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
3195
- .concat(display.view.slice(cutBot.index));
3196
- display.viewTo += lendiff;
3197
- } else {
3198
- resetView(cm);
3199
- }
3200
- }
3201
-
3202
- var ext = display.externalMeasured;
3203
- if (ext) {
3204
- if (to < ext.lineN)
3205
- ext.lineN += lendiff;
3206
- else if (from < ext.lineN + ext.size)
3207
- display.externalMeasured = null;
3208
- }
3209
- }
3210
-
3211
- // Register a change to a single line. Type must be one of "text",
3212
- // "gutter", "class", "widget"
3213
- function regLineChange(cm, line, type) {
3214
- cm.curOp.viewChanged = true;
3215
- var display = cm.display, ext = cm.display.externalMeasured;
3216
- if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
3217
- display.externalMeasured = null;
3218
-
3219
- if (line < display.viewFrom || line >= display.viewTo) return;
3220
- var lineView = display.view[findViewIndex(cm, line)];
3221
- if (lineView.node == null) return;
3222
- var arr = lineView.changes || (lineView.changes = []);
3223
- if (indexOf(arr, type) == -1) arr.push(type);
3224
- }
3225
-
3226
- // Clear the view.
3227
- function resetView(cm) {
3228
- cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
3229
- cm.display.view = [];
3230
- cm.display.viewOffset = 0;
3231
- }
3232
-
3233
- // Find the view element corresponding to a given line. Return null
3234
- // when the line isn't visible.
3235
- function findViewIndex(cm, n) {
3236
- if (n >= cm.display.viewTo) return null;
3237
- n -= cm.display.viewFrom;
3238
- if (n < 0) return null;
3239
- var view = cm.display.view;
3240
- for (var i = 0; i < view.length; i++) {
3241
- n -= view[i].size;
3242
- if (n < 0) return i;
3243
- }
3244
- }
3245
-
3246
- function viewCuttingPoint(cm, oldN, newN, dir) {
3247
- var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
3248
- if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
3249
- return {index: index, lineN: newN};
3250
- for (var i = 0, n = cm.display.viewFrom; i < index; i++)
3251
- n += view[i].size;
3252
- if (n != oldN) {
3253
- if (dir > 0) {
3254
- if (index == view.length - 1) return null;
3255
- diff = (n + view[index].size) - oldN;
3256
- index++;
3257
- } else {
3258
- diff = n - oldN;
3259
- }
3260
- oldN += diff; newN += diff;
3261
- }
3262
- while (visualLineNo(cm.doc, newN) != newN) {
3263
- if (index == (dir < 0 ? 0 : view.length - 1)) return null;
3264
- newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
3265
- index += dir;
3266
- }
3267
- return {index: index, lineN: newN};
3268
- }
3269
-
3270
- // Force the view to cover a given range, adding empty view element
3271
- // or clipping off existing ones as needed.
3272
- function adjustView(cm, from, to) {
3273
- var display = cm.display, view = display.view;
3274
- if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
3275
- display.view = buildViewArray(cm, from, to);
3276
- display.viewFrom = from;
3277
- } else {
3278
- if (display.viewFrom > from)
3279
- display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
3280
- else if (display.viewFrom < from)
3281
- display.view = display.view.slice(findViewIndex(cm, from));
3282
- display.viewFrom = from;
3283
- if (display.viewTo < to)
3284
- display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
3285
- else if (display.viewTo > to)
3286
- display.view = display.view.slice(0, findViewIndex(cm, to));
3287
- }
3288
- display.viewTo = to;
3289
- }
3290
-
3291
- // Count the number of lines in the view whose DOM representation is
3292
- // out of date (or nonexistent).
3293
- function countDirtyView(cm) {
3294
- var view = cm.display.view, dirty = 0;
3295
- for (var i = 0; i < view.length; i++) {
3296
- var lineView = view[i];
3297
- if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
3298
- }
3299
- return dirty;
3300
- }
3301
-
3302
- // EVENT HANDLERS
3303
-
3304
- // Attach the necessary event handlers when initializing the editor
3305
- function registerEventHandlers(cm) {
3306
- var d = cm.display;
3307
- on(d.scroller, "mousedown", operation(cm, onMouseDown));
3308
- // Older IE's will not fire a second mousedown for a double click
3309
- if (ie && ie_version < 11)
3310
- on(d.scroller, "dblclick", operation(cm, function(e) {
3311
- if (signalDOMEvent(cm, e)) return;
3312
- var pos = posFromMouse(cm, e);
3313
- if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
3314
- e_preventDefault(e);
3315
- var word = cm.findWordAt(pos);
3316
- extendSelection(cm.doc, word.anchor, word.head);
3317
- }));
3318
- else
3319
- on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
3320
- // Some browsers fire contextmenu *after* opening the menu, at
3321
- // which point we can't mess with it anymore. Context menu is
3322
- // handled in onMouseDown for these browsers.
3323
- if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
3324
-
3325
- // Used to suppress mouse event handling when a touch happens
3326
- var touchFinished, prevTouch = {end: 0};
3327
- function finishTouch() {
3328
- if (d.activeTouch) {
3329
- touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000);
3330
- prevTouch = d.activeTouch;
3331
- prevTouch.end = +new Date;
3332
- }
3333
- };
3334
- function isMouseLikeTouchEvent(e) {
3335
- if (e.touches.length != 1) return false;
3336
- var touch = e.touches[0];
3337
- return touch.radiusX <= 1 && touch.radiusY <= 1;
3338
- }
3339
- function farAway(touch, other) {
3340
- if (other.left == null) return true;
3341
- var dx = other.left - touch.left, dy = other.top - touch.top;
3342
- return dx * dx + dy * dy > 20 * 20;
3343
- }
3344
- on(d.scroller, "touchstart", function(e) {
3345
- if (!isMouseLikeTouchEvent(e)) {
3346
- clearTimeout(touchFinished);
3347
- var now = +new Date;
3348
- d.activeTouch = {start: now, moved: false,
3349
- prev: now - prevTouch.end <= 300 ? prevTouch : null};
3350
- if (e.touches.length == 1) {
3351
- d.activeTouch.left = e.touches[0].pageX;
3352
- d.activeTouch.top = e.touches[0].pageY;
3353
- }
3354
- }
3355
- });
3356
- on(d.scroller, "touchmove", function() {
3357
- if (d.activeTouch) d.activeTouch.moved = true;
3358
- });
3359
- on(d.scroller, "touchend", function(e) {
3360
- var touch = d.activeTouch;
3361
- if (touch && !eventInWidget(d, e) && touch.left != null &&
3362
- !touch.moved && new Date - touch.start < 300) {
3363
- var pos = cm.coordsChar(d.activeTouch, "page"), range;
3364
- if (!touch.prev || farAway(touch, touch.prev)) // Single tap
3365
- range = new Range(pos, pos);
3366
- else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
3367
- range = cm.findWordAt(pos);
3368
- else // Triple tap
3369
- range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
3370
- cm.setSelection(range.anchor, range.head);
3371
- cm.focus();
3372
- e_preventDefault(e);
3373
- }
3374
- finishTouch();
3375
- });
3376
- on(d.scroller, "touchcancel", finishTouch);
3377
-
3378
- // Sync scrolling between fake scrollbars and real scrollable
3379
- // area, ensure viewport is updated when scrolling.
3380
- on(d.scroller, "scroll", function() {
3381
- if (d.scroller.clientHeight) {
3382
- setScrollTop(cm, d.scroller.scrollTop);
3383
- setScrollLeft(cm, d.scroller.scrollLeft, true);
3384
- signal(cm, "scroll", cm);
3385
- }
3386
- });
3387
-
3388
- // Listen to wheel events in order to try and update the viewport on time.
3389
- on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
3390
- on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
3391
-
3392
- // Prevent wrapper from ever scrolling
3393
- on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
3394
-
3395
- function drag_(e) {
3396
- if (!signalDOMEvent(cm, e)) e_stop(e);
3397
- }
3398
- if (cm.options.dragDrop) {
3399
- on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
3400
- on(d.scroller, "dragenter", drag_);
3401
- on(d.scroller, "dragover", drag_);
3402
- on(d.scroller, "drop", operation(cm, onDrop));
3403
- }
3404
-
3405
- var inp = d.input.getField();
3406
- on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
3407
- on(inp, "keydown", operation(cm, onKeyDown));
3408
- on(inp, "keypress", operation(cm, onKeyPress));
3409
- on(inp, "focus", bind(onFocus, cm));
3410
- on(inp, "blur", bind(onBlur, cm));
3411
- }
3412
-
3413
- // Called when the window resizes
3414
- function onResize(cm) {
3415
- var d = cm.display;
3416
- if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
3417
- return;
3418
- // Might be a text scaling operation, clear size caches.
3419
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
3420
- d.scrollbarsClipped = false;
3421
- cm.setSize();
3422
- }
3423
-
3424
- // MOUSE EVENTS
3425
-
3426
- // Return true when the given mouse event happened in a widget
3427
- function eventInWidget(display, e) {
3428
- for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
3429
- if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
3430
- (n.parentNode == display.sizer && n != display.mover))
3431
- return true;
3432
- }
3433
- }
3434
-
3435
- // Given a mouse event, find the corresponding position. If liberal
3436
- // is false, it checks whether a gutter or scrollbar was clicked,
3437
- // and returns null if it was. forRect is used by rectangular
3438
- // selections, and tries to estimate a character position even for
3439
- // coordinates beyond the right of the text.
3440
- function posFromMouse(cm, e, liberal, forRect) {
3441
- var display = cm.display;
3442
- if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
3443
-
3444
- var x, y, space = display.lineSpace.getBoundingClientRect();
3445
- // Fails unpredictably on IE[67] when mouse is dragged around quickly.
3446
- try { x = e.clientX - space.left; y = e.clientY - space.top; }
3447
- catch (e) { return null; }
3448
- var coords = coordsChar(cm, x, y), line;
3449
- if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
3450
- var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
3451
- coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
3452
- }
3453
- return coords;
3454
- }
3455
-
3456
- // A mouse down can be a single click, double click, triple click,
3457
- // start of selection drag, start of text drag, new cursor
3458
- // (ctrl-click), rectangle drag (alt-drag), or xwin
3459
- // middle-click-paste. Or it might be a click on something we should
3460
- // not interfere with, such as a scrollbar or widget.
3461
- function onMouseDown(e) {
3462
- var cm = this, display = cm.display;
3463
- if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
3464
- display.shift = e.shiftKey;
3465
-
3466
- if (eventInWidget(display, e)) {
3467
- if (!webkit) {
3468
- // Briefly turn off draggability, to allow widgets to do
3469
- // normal dragging things.
3470
- display.scroller.draggable = false;
3471
- setTimeout(function(){display.scroller.draggable = true;}, 100);
3472
- }
3473
- return;
3474
- }
3475
- if (clickInGutter(cm, e)) return;
3476
- var start = posFromMouse(cm, e);
3477
- window.focus();
3478
-
3479
- switch (e_button(e)) {
3480
- case 1:
3481
- if (start)
3482
- leftButtonDown(cm, e, start);
3483
- else if (e_target(e) == display.scroller)
3484
- e_preventDefault(e);
3485
- break;
3486
- case 2:
3487
- if (webkit) cm.state.lastMiddleDown = +new Date;
3488
- if (start) extendSelection(cm.doc, start);
3489
- setTimeout(function() {display.input.focus();}, 20);
3490
- e_preventDefault(e);
3491
- break;
3492
- case 3:
3493
- if (captureRightClick) onContextMenu(cm, e);
3494
- break;
3495
- }
3496
- }
3497
-
3498
- var lastClick, lastDoubleClick;
3499
- function leftButtonDown(cm, e, start) {
3500
- if (ie) setTimeout(bind(ensureFocus, cm), 0);
3501
- else ensureFocus(cm);
3502
-
3503
- var now = +new Date, type;
3504
- if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
3505
- type = "triple";
3506
- } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
3507
- type = "double";
3508
- lastDoubleClick = {time: now, pos: start};
3509
- } else {
3510
- type = "single";
3511
- lastClick = {time: now, pos: start};
3512
- }
3513
-
3514
- var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
3515
- if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
3516
- type == "single" && (contained = sel.contains(start)) > -1 &&
3517
- !sel.ranges[contained].empty())
3518
- leftButtonStartDrag(cm, e, start, modifier);
3519
- else
3520
- leftButtonSelect(cm, e, start, type, modifier);
3521
- }
3522
-
3523
- // Start a text drag. When it ends, see if any dragging actually
3524
- // happen, and treat as a click if it didn't.
3525
- function leftButtonStartDrag(cm, e, start, modifier) {
3526
- var display = cm.display;
3527
- var dragEnd = operation(cm, function(e2) {
3528
- if (webkit) display.scroller.draggable = false;
3529
- cm.state.draggingText = false;
3530
- off(document, "mouseup", dragEnd);
3531
- off(display.scroller, "drop", dragEnd);
3532
- if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
3533
- e_preventDefault(e2);
3534
- if (!modifier)
3535
- extendSelection(cm.doc, start);
3536
- // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
3537
- if (webkit || ie && ie_version == 9)
3538
- setTimeout(function() {document.body.focus(); display.input.focus();}, 20);
3539
- else
3540
- display.input.focus();
3541
- }
3542
- });
3543
- // Let the drag handler handle this.
3544
- if (webkit) display.scroller.draggable = true;
3545
- cm.state.draggingText = dragEnd;
3546
- // IE's approach to draggable
3547
- if (display.scroller.dragDrop) display.scroller.dragDrop();
3548
- on(document, "mouseup", dragEnd);
3549
- on(display.scroller, "drop", dragEnd);
3550
- }
3551
-
3552
- // Normal selection, as opposed to text dragging.
3553
- function leftButtonSelect(cm, e, start, type, addNew) {
3554
- var display = cm.display, doc = cm.doc;
3555
- e_preventDefault(e);
3556
-
3557
- var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
3558
- if (addNew && !e.shiftKey) {
3559
- ourIndex = doc.sel.contains(start);
3560
- if (ourIndex > -1)
3561
- ourRange = ranges[ourIndex];
3562
- else
3563
- ourRange = new Range(start, start);
3564
- } else {
3565
- ourRange = doc.sel.primary();
3566
- }
3567
-
3568
- if (e.altKey) {
3569
- type = "rect";
3570
- if (!addNew) ourRange = new Range(start, start);
3571
- start = posFromMouse(cm, e, true, true);
3572
- ourIndex = -1;
3573
- } else if (type == "double") {
3574
- var word = cm.findWordAt(start);
3575
- if (cm.display.shift || doc.extend)
3576
- ourRange = extendRange(doc, ourRange, word.anchor, word.head);
3577
- else
3578
- ourRange = word;
3579
- } else if (type == "triple") {
3580
- var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
3581
- if (cm.display.shift || doc.extend)
3582
- ourRange = extendRange(doc, ourRange, line.anchor, line.head);
3583
- else
3584
- ourRange = line;
3585
- } else {
3586
- ourRange = extendRange(doc, ourRange, start);
3587
- }
3588
-
3589
- if (!addNew) {
3590
- ourIndex = 0;
3591
- setSelection(doc, new Selection([ourRange], 0), sel_mouse);
3592
- startSel = doc.sel;
3593
- } else if (ourIndex == -1) {
3594
- ourIndex = ranges.length;
3595
- setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
3596
- {scroll: false, origin: "*mouse"});
3597
- } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single") {
3598
- setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
3599
- startSel = doc.sel;
3600
- } else {
3601
- replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
3602
- }
3603
-
3604
- var lastPos = start;
3605
- function extendTo(pos) {
3606
- if (cmp(lastPos, pos) == 0) return;
3607
- lastPos = pos;
3608
-
3609
- if (type == "rect") {
3610
- var ranges = [], tabSize = cm.options.tabSize;
3611
- var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
3612
- var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
3613
- var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
3614
- for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
3615
- line <= end; line++) {
3616
- var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
3617
- if (left == right)
3618
- ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
3619
- else if (text.length > leftPos)
3620
- ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
3621
- }
3622
- if (!ranges.length) ranges.push(new Range(start, start));
3623
- setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
3624
- {origin: "*mouse", scroll: false});
3625
- cm.scrollIntoView(pos);
3626
- } else {
3627
- var oldRange = ourRange;
3628
- var anchor = oldRange.anchor, head = pos;
3629
- if (type != "single") {
3630
- if (type == "double")
3631
- var range = cm.findWordAt(pos);
3632
- else
3633
- var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
3634
- if (cmp(range.anchor, anchor) > 0) {
3635
- head = range.head;
3636
- anchor = minPos(oldRange.from(), range.anchor);
3637
- } else {
3638
- head = range.anchor;
3639
- anchor = maxPos(oldRange.to(), range.head);
3640
- }
3641
- }
3642
- var ranges = startSel.ranges.slice(0);
3643
- ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
3644
- setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
3645
- }
3646
- }
3647
-
3648
- var editorSize = display.wrapper.getBoundingClientRect();
3649
- // Used to ensure timeout re-tries don't fire when another extend
3650
- // happened in the meantime (clearTimeout isn't reliable -- at
3651
- // least on Chrome, the timeouts still happen even when cleared,
3652
- // if the clear happens after their scheduled firing time).
3653
- var counter = 0;
3654
-
3655
- function extend(e) {
3656
- var curCount = ++counter;
3657
- var cur = posFromMouse(cm, e, true, type == "rect");
3658
- if (!cur) return;
3659
- if (cmp(cur, lastPos) != 0) {
3660
- ensureFocus(cm);
3661
- extendTo(cur);
3662
- var visible = visibleLines(display, doc);
3663
- if (cur.line >= visible.to || cur.line < visible.from)
3664
- setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
3665
- } else {
3666
- var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
3667
- if (outside) setTimeout(operation(cm, function() {
3668
- if (counter != curCount) return;
3669
- display.scroller.scrollTop += outside;
3670
- extend(e);
3671
- }), 50);
3672
- }
3673
- }
3674
-
3675
- function done(e) {
3676
- counter = Infinity;
3677
- e_preventDefault(e);
3678
- display.input.focus();
3679
- off(document, "mousemove", move);
3680
- off(document, "mouseup", up);
3681
- doc.history.lastSelOrigin = null;
3682
- }
3683
-
3684
- var move = operation(cm, function(e) {
3685
- if (!e_button(e)) done(e);
3686
- else extend(e);
3687
- });
3688
- var up = operation(cm, done);
3689
- on(document, "mousemove", move);
3690
- on(document, "mouseup", up);
3691
- }
3692
-
3693
- // Determines whether an event happened in the gutter, and fires the
3694
- // handlers for the corresponding event.
3695
- function gutterEvent(cm, e, type, prevent, signalfn) {
3696
- try { var mX = e.clientX, mY = e.clientY; }
3697
- catch(e) { return false; }
3698
- if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
3699
- if (prevent) e_preventDefault(e);
3700
-
3701
- var display = cm.display;
3702
- var lineBox = display.lineDiv.getBoundingClientRect();
3703
-
3704
- if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
3705
- mY -= lineBox.top - display.viewOffset;
3706
-
3707
- for (var i = 0; i < cm.options.gutters.length; ++i) {
3708
- var g = display.gutters.childNodes[i];
3709
- if (g && g.getBoundingClientRect().right >= mX) {
3710
- var line = lineAtHeight(cm.doc, mY);
3711
- var gutter = cm.options.gutters[i];
3712
- signalfn(cm, type, cm, line, gutter, e);
3713
- return e_defaultPrevented(e);
3714
- }
3715
- }
3716
- }
3717
-
3718
- function clickInGutter(cm, e) {
3719
- return gutterEvent(cm, e, "gutterClick", true, signalLater);
3720
- }
3721
-
3722
- // Kludge to work around strange IE behavior where it'll sometimes
3723
- // re-fire a series of drag-related events right after the drop (#1551)
3724
- var lastDrop = 0;
3725
-
3726
- function onDrop(e) {
3727
- var cm = this;
3728
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
3729
- return;
3730
- e_preventDefault(e);
3731
- if (ie) lastDrop = +new Date;
3732
- var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
3733
- if (!pos || isReadOnly(cm)) return;
3734
- // Might be a file drop, in which case we simply extract the text
3735
- // and insert it.
3736
- if (files && files.length && window.FileReader && window.File) {
3737
- var n = files.length, text = Array(n), read = 0;
3738
- var loadFile = function(file, i) {
3739
- var reader = new FileReader;
3740
- reader.onload = operation(cm, function() {
3741
- text[i] = reader.result;
3742
- if (++read == n) {
3743
- pos = clipPos(cm.doc, pos);
3744
- var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
3745
- makeChange(cm.doc, change);
3746
- setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
3747
- }
3748
- });
3749
- reader.readAsText(file);
3750
- };
3751
- for (var i = 0; i < n; ++i) loadFile(files[i], i);
3752
- } else { // Normal drop
3753
- // Don't do a replace if the drop happened inside of the selected text.
3754
- if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
3755
- cm.state.draggingText(e);
3756
- // Ensure the editor is re-focused
3757
- setTimeout(function() {cm.display.input.focus();}, 20);
3758
- return;
3759
- }
3760
- try {
3761
- var text = e.dataTransfer.getData("Text");
3762
- if (text) {
3763
- if (cm.state.draggingText && !(mac ? e.metaKey : e.ctrlKey))
3764
- var selected = cm.listSelections();
3765
- setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
3766
- if (selected) for (var i = 0; i < selected.length; ++i)
3767
- replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
3768
- cm.replaceSelection(text, "around", "paste");
3769
- cm.display.input.focus();
3770
- }
3771
- }
3772
- catch(e){}
3773
- }
3774
- }
3775
-
3776
- function onDragStart(cm, e) {
3777
- if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
3778
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
3779
-
3780
- e.dataTransfer.setData("Text", cm.getSelection());
3781
-
3782
- // Use dummy image instead of default browsers image.
3783
- // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
3784
- if (e.dataTransfer.setDragImage && !safari) {
3785
- var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
3786
- img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
3787
- if (presto) {
3788
- img.width = img.height = 1;
3789
- cm.display.wrapper.appendChild(img);
3790
- // Force a relayout, or Opera won't use our image for some obscure reason
3791
- img._top = img.offsetTop;
3792
- }
3793
- e.dataTransfer.setDragImage(img, 0, 0);
3794
- if (presto) img.parentNode.removeChild(img);
3795
- }
3796
- }
3797
-
3798
- // SCROLL EVENTS
3799
-
3800
- // Sync the scrollable area and scrollbars, ensure the viewport
3801
- // covers the visible area.
3802
- function setScrollTop(cm, val) {
3803
- if (Math.abs(cm.doc.scrollTop - val) < 2) return;
3804
- cm.doc.scrollTop = val;
3805
- if (!gecko) updateDisplaySimple(cm, {top: val});
3806
- if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
3807
- cm.display.scrollbars.setScrollTop(val);
3808
- if (gecko) updateDisplaySimple(cm);
3809
- startWorker(cm, 100);
3810
- }
3811
- // Sync scroller and scrollbar, ensure the gutter elements are
3812
- // aligned.
3813
- function setScrollLeft(cm, val, isScroller) {
3814
- if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
3815
- val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
3816
- cm.doc.scrollLeft = val;
3817
- alignHorizontally(cm);
3818
- if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
3819
- cm.display.scrollbars.setScrollLeft(val);
3820
- }
3821
-
3822
- // Since the delta values reported on mouse wheel events are
3823
- // unstandardized between browsers and even browser versions, and
3824
- // generally horribly unpredictable, this code starts by measuring
3825
- // the scroll effect that the first few mouse wheel events have,
3826
- // and, from that, detects the way it can convert deltas to pixel
3827
- // offsets afterwards.
3828
- //
3829
- // The reason we want to know the amount a wheel event will scroll
3830
- // is that it gives us a chance to update the display before the
3831
- // actual scrolling happens, reducing flickering.
3832
-
3833
- var wheelSamples = 0, wheelPixelsPerUnit = null;
3834
- // Fill in a browser-detected starting value on browsers where we
3835
- // know one. These don't have to be accurate -- the result of them
3836
- // being wrong would just be a slight flicker on the first wheel
3837
- // scroll (if it is large enough).
3838
- if (ie) wheelPixelsPerUnit = -.53;
3839
- else if (gecko) wheelPixelsPerUnit = 15;
3840
- else if (chrome) wheelPixelsPerUnit = -.7;
3841
- else if (safari) wheelPixelsPerUnit = -1/3;
3842
-
3843
- var wheelEventDelta = function(e) {
3844
- var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
3845
- if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
3846
- if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
3847
- else if (dy == null) dy = e.wheelDelta;
3848
- return {x: dx, y: dy};
3849
- };
3850
- CodeMirror.wheelEventPixels = function(e) {
3851
- var delta = wheelEventDelta(e);
3852
- delta.x *= wheelPixelsPerUnit;
3853
- delta.y *= wheelPixelsPerUnit;
3854
- return delta;
3855
- };
3856
-
3857
- function onScrollWheel(cm, e) {
3858
- var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
3859
-
3860
- var display = cm.display, scroll = display.scroller;
3861
- // Quit if there's nothing to scroll here
3862
- if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
3863
- dy && scroll.scrollHeight > scroll.clientHeight)) return;
3864
-
3865
- // Webkit browsers on OS X abort momentum scrolls when the target
3866
- // of the scroll event is removed from the scrollable element.
3867
- // This hack (see related code in patchDisplay) makes sure the
3868
- // element is kept around.
3869
- if (dy && mac && webkit) {
3870
- outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
3871
- for (var i = 0; i < view.length; i++) {
3872
- if (view[i].node == cur) {
3873
- cm.display.currentWheelTarget = cur;
3874
- break outer;
3875
- }
3876
- }
3877
- }
3878
- }
3879
-
3880
- // On some browsers, horizontal scrolling will cause redraws to
3881
- // happen before the gutter has been realigned, causing it to
3882
- // wriggle around in a most unseemly way. When we have an
3883
- // estimated pixels/delta value, we just handle horizontal
3884
- // scrolling entirely here. It'll be slightly off from native, but
3885
- // better than glitching out.
3886
- if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
3887
- if (dy)
3888
- setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
3889
- setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
3890
- e_preventDefault(e);
3891
- display.wheelStartX = null; // Abort measurement, if in progress
3892
- return;
3893
- }
3894
-
3895
- // 'Project' the visible viewport to cover the area that is being
3896
- // scrolled into view (if we know enough to estimate it).
3897
- if (dy && wheelPixelsPerUnit != null) {
3898
- var pixels = dy * wheelPixelsPerUnit;
3899
- var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
3900
- if (pixels < 0) top = Math.max(0, top + pixels - 50);
3901
- else bot = Math.min(cm.doc.height, bot + pixels + 50);
3902
- updateDisplaySimple(cm, {top: top, bottom: bot});
3903
- }
3904
-
3905
- if (wheelSamples < 20) {
3906
- if (display.wheelStartX == null) {
3907
- display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
3908
- display.wheelDX = dx; display.wheelDY = dy;
3909
- setTimeout(function() {
3910
- if (display.wheelStartX == null) return;
3911
- var movedX = scroll.scrollLeft - display.wheelStartX;
3912
- var movedY = scroll.scrollTop - display.wheelStartY;
3913
- var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
3914
- (movedX && display.wheelDX && movedX / display.wheelDX);
3915
- display.wheelStartX = display.wheelStartY = null;
3916
- if (!sample) return;
3917
- wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
3918
- ++wheelSamples;
3919
- }, 200);
3920
- } else {
3921
- display.wheelDX += dx; display.wheelDY += dy;
3922
- }
3923
- }
3924
- }
3925
-
3926
- // KEY EVENTS
3927
-
3928
- // Run a handler that was bound to a key.
3929
- function doHandleBinding(cm, bound, dropShift) {
3930
- if (typeof bound == "string") {
3931
- bound = commands[bound];
3932
- if (!bound) return false;
3933
- }
3934
- // Ensure previous input has been read, so that the handler sees a
3935
- // consistent view of the document
3936
- cm.display.input.ensurePolled();
3937
- var prevShift = cm.display.shift, done = false;
3938
- try {
3939
- if (isReadOnly(cm)) cm.state.suppressEdits = true;
3940
- if (dropShift) cm.display.shift = false;
3941
- done = bound(cm) != Pass;
3942
- } finally {
3943
- cm.display.shift = prevShift;
3944
- cm.state.suppressEdits = false;
3945
- }
3946
- return done;
3947
- }
3948
-
3949
- function lookupKeyForEditor(cm, name, handle) {
3950
- for (var i = 0; i < cm.state.keyMaps.length; i++) {
3951
- var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
3952
- if (result) return result;
3953
- }
3954
- return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
3955
- || lookupKey(name, cm.options.keyMap, handle, cm);
3956
- }
3957
-
3958
- var stopSeq = new Delayed;
3959
- function dispatchKey(cm, name, e, handle) {
3960
- var seq = cm.state.keySeq;
3961
- if (seq) {
3962
- if (isModifierKey(name)) return "handled";
3963
- stopSeq.set(50, function() {
3964
- if (cm.state.keySeq == seq) {
3965
- cm.state.keySeq = null;
3966
- cm.display.input.reset();
3967
- }
3968
- });
3969
- name = seq + " " + name;
3970
- }
3971
- var result = lookupKeyForEditor(cm, name, handle);
3972
-
3973
- if (result == "multi")
3974
- cm.state.keySeq = name;
3975
- if (result == "handled")
3976
- signalLater(cm, "keyHandled", cm, name, e);
3977
-
3978
- if (result == "handled" || result == "multi") {
3979
- e_preventDefault(e);
3980
- restartBlink(cm);
3981
- }
3982
-
3983
- if (seq && !result && /\'$/.test(name)) {
3984
- e_preventDefault(e);
3985
- return true;
3986
- }
3987
- return !!result;
3988
- }
3989
-
3990
- // Handle a key from the keydown event.
3991
- function handleKeyBinding(cm, e) {
3992
- var name = keyName(e, true);
3993
- if (!name) return false;
3994
-
3995
- if (e.shiftKey && !cm.state.keySeq) {
3996
- // First try to resolve full name (including 'Shift-'). Failing
3997
- // that, see if there is a cursor-motion command (starting with
3998
- // 'go') bound to the keyname without 'Shift-'.
3999
- return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);})
4000
- || dispatchKey(cm, name, e, function(b) {
4001
- if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
4002
- return doHandleBinding(cm, b);
4003
- });
4004
- } else {
4005
- return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); });
4006
- }
4007
- }
4008
-
4009
- // Handle a key from the keypress event
4010
- function handleCharBinding(cm, e, ch) {
4011
- return dispatchKey(cm, "'" + ch + "'", e,
4012
- function(b) { return doHandleBinding(cm, b, true); });
4013
- }
4014
-
4015
- var lastStoppedKey = null;
4016
- function onKeyDown(e) {
4017
- var cm = this;
4018
- ensureFocus(cm);
4019
- if (signalDOMEvent(cm, e)) return;
4020
- // IE does strange things with escape.
4021
- if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
4022
- var code = e.keyCode;
4023
- cm.display.shift = code == 16 || e.shiftKey;
4024
- var handled = handleKeyBinding(cm, e);
4025
- if (presto) {
4026
- lastStoppedKey = handled ? code : null;
4027
- // Opera has no cut event... we try to at least catch the key combo
4028
- if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
4029
- cm.replaceSelection("", null, "cut");
4030
- }
4031
-
4032
- // Turn mouse into crosshair when Alt is held on Mac.
4033
- if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
4034
- showCrossHair(cm);
4035
- }
4036
-
4037
- function showCrossHair(cm) {
4038
- var lineDiv = cm.display.lineDiv;
4039
- addClass(lineDiv, "CodeMirror-crosshair");
4040
-
4041
- function up(e) {
4042
- if (e.keyCode == 18 || !e.altKey) {
4043
- rmClass(lineDiv, "CodeMirror-crosshair");
4044
- off(document, "keyup", up);
4045
- off(document, "mouseover", up);
4046
- }
4047
- }
4048
- on(document, "keyup", up);
4049
- on(document, "mouseover", up);
4050
- }
4051
-
4052
- function onKeyUp(e) {
4053
- if (e.keyCode == 16) this.doc.sel.shift = false;
4054
- signalDOMEvent(this, e);
4055
- }
4056
-
4057
- function onKeyPress(e) {
4058
- var cm = this;
4059
- if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
4060
- var keyCode = e.keyCode, charCode = e.charCode;
4061
- if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
4062
- if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return;
4063
- var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
4064
- if (handleCharBinding(cm, e, ch)) return;
4065
- cm.display.input.onKeyPress(e);
4066
- }
4067
-
4068
- // FOCUS/BLUR EVENTS
4069
-
4070
- function onFocus(cm) {
4071
- if (cm.options.readOnly == "nocursor") return;
4072
- if (!cm.state.focused) {
4073
- signal(cm, "focus", cm);
4074
- cm.state.focused = true;
4075
- addClass(cm.display.wrapper, "CodeMirror-focused");
4076
- // This test prevents this from firing when a context
4077
- // menu is closed (since the input reset would kill the
4078
- // select-all detection hack)
4079
- if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
4080
- cm.display.input.reset();
4081
- if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730
4082
- }
4083
- cm.display.input.receivedFocus();
4084
- }
4085
- restartBlink(cm);
4086
- }
4087
- function onBlur(cm) {
4088
- if (cm.state.focused) {
4089
- signal(cm, "blur", cm);
4090
- cm.state.focused = false;
4091
- rmClass(cm.display.wrapper, "CodeMirror-focused");
4092
- }
4093
- clearInterval(cm.display.blinker);
4094
- setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
4095
- }
4096
-
4097
- // CONTEXT MENU HANDLING
4098
-
4099
- // To make the context menu work, we need to briefly unhide the
4100
- // textarea (making it as unobtrusive as possible) to let the
4101
- // right-click take effect on it.
4102
- function onContextMenu(cm, e) {
4103
- if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
4104
- cm.display.input.onContextMenu(e);
4105
- }
4106
-
4107
- function contextMenuInGutter(cm, e) {
4108
- if (!hasHandler(cm, "gutterContextMenu")) return false;
4109
- return gutterEvent(cm, e, "gutterContextMenu", false, signal);
4110
- }
4111
-
4112
- // UPDATING
4113
-
4114
- // Compute the position of the end of a change (its 'to' property
4115
- // refers to the pre-change end).
4116
- var changeEnd = CodeMirror.changeEnd = function(change) {
4117
- if (!change.text) return change.to;
4118
- return Pos(change.from.line + change.text.length - 1,
4119
- lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
4120
- };
4121
-
4122
- // Adjust a position to refer to the post-change position of the
4123
- // same text, or the end of the change if the change covers it.
4124
- function adjustForChange(pos, change) {
4125
- if (cmp(pos, change.from) < 0) return pos;
4126
- if (cmp(pos, change.to) <= 0) return changeEnd(change);
4127
-
4128
- var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
4129
- if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
4130
- return Pos(line, ch);
4131
- }
4132
-
4133
- function computeSelAfterChange(doc, change) {
4134
- var out = [];
4135
- for (var i = 0; i < doc.sel.ranges.length; i++) {
4136
- var range = doc.sel.ranges[i];
4137
- out.push(new Range(adjustForChange(range.anchor, change),
4138
- adjustForChange(range.head, change)));
4139
- }
4140
- return normalizeSelection(out, doc.sel.primIndex);
4141
- }
4142
-
4143
- function offsetPos(pos, old, nw) {
4144
- if (pos.line == old.line)
4145
- return Pos(nw.line, pos.ch - old.ch + nw.ch);
4146
- else
4147
- return Pos(nw.line + (pos.line - old.line), pos.ch);
4148
- }
4149
-
4150
- // Used by replaceSelections to allow moving the selection to the
4151
- // start or around the replaced test. Hint may be "start" or "around".
4152
- function computeReplacedSel(doc, changes, hint) {
4153
- var out = [];
4154
- var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
4155
- for (var i = 0; i < changes.length; i++) {
4156
- var change = changes[i];
4157
- var from = offsetPos(change.from, oldPrev, newPrev);
4158
- var to = offsetPos(changeEnd(change), oldPrev, newPrev);
4159
- oldPrev = change.to;
4160
- newPrev = to;
4161
- if (hint == "around") {
4162
- var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
4163
- out[i] = new Range(inv ? to : from, inv ? from : to);
4164
- } else {
4165
- out[i] = new Range(from, from);
4166
- }
4167
- }
4168
- return new Selection(out, doc.sel.primIndex);
4169
- }
4170
-
4171
- // Allow "beforeChange" event handlers to influence a change
4172
- function filterChange(doc, change, update) {
4173
- var obj = {
4174
- canceled: false,
4175
- from: change.from,
4176
- to: change.to,
4177
- text: change.text,
4178
- origin: change.origin,
4179
- cancel: function() { this.canceled = true; }
4180
- };
4181
- if (update) obj.update = function(from, to, text, origin) {
4182
- if (from) this.from = clipPos(doc, from);
4183
- if (to) this.to = clipPos(doc, to);
4184
- if (text) this.text = text;
4185
- if (origin !== undefined) this.origin = origin;
4186
- };
4187
- signal(doc, "beforeChange", doc, obj);
4188
- if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
4189
-
4190
- if (obj.canceled) return null;
4191
- return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
4192
- }
4193
-
4194
- // Apply a change to a document, and add it to the document's
4195
- // history, and propagating it to all linked documents.
4196
- function makeChange(doc, change, ignoreReadOnly) {
4197
- if (doc.cm) {
4198
- if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
4199
- if (doc.cm.state.suppressEdits) return;
4200
- }
4201
-
4202
- if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
4203
- change = filterChange(doc, change, true);
4204
- if (!change) return;
4205
- }
4206
-
4207
- // Possibly split or suppress the update based on the presence
4208
- // of read-only spans in its range.
4209
- var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
4210
- if (split) {
4211
- for (var i = split.length - 1; i >= 0; --i)
4212
- makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
4213
- } else {
4214
- makeChangeInner(doc, change);
4215
- }
4216
- }
4217
-
4218
- function makeChangeInner(doc, change) {
4219
- if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
4220
- var selAfter = computeSelAfterChange(doc, change);
4221
- addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
4222
-
4223
- makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
4224
- var rebased = [];
4225
-
4226
- linkedDocs(doc, function(doc, sharedHist) {
4227
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
4228
- rebaseHist(doc.history, change);
4229
- rebased.push(doc.history);
4230
- }
4231
- makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
4232
- });
4233
- }
4234
-
4235
- // Revert a change stored in a document's history.
4236
- function makeChangeFromHistory(doc, type, allowSelectionOnly) {
4237
- if (doc.cm && doc.cm.state.suppressEdits) return;
4238
-
4239
- var hist = doc.history, event, selAfter = doc.sel;
4240
- var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
4241
-
4242
- // Verify that there is a useable event (so that ctrl-z won't
4243
- // needlessly clear selection events)
4244
- for (var i = 0; i < source.length; i++) {
4245
- event = source[i];
4246
- if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
4247
- break;
4248
- }
4249
- if (i == source.length) return;
4250
- hist.lastOrigin = hist.lastSelOrigin = null;
4251
-
4252
- for (;;) {
4253
- event = source.pop();
4254
- if (event.ranges) {
4255
- pushSelectionToHistory(event, dest);
4256
- if (allowSelectionOnly && !event.equals(doc.sel)) {
4257
- setSelection(doc, event, {clearRedo: false});
4258
- return;
4259
- }
4260
- selAfter = event;
4261
- }
4262
- else break;
4263
- }
4264
-
4265
- // Build up a reverse change object to add to the opposite history
4266
- // stack (redo when undoing, and vice versa).
4267
- var antiChanges = [];
4268
- pushSelectionToHistory(selAfter, dest);
4269
- dest.push({changes: antiChanges, generation: hist.generation});
4270
- hist.generation = event.generation || ++hist.maxGeneration;
4271
-
4272
- var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
4273
-
4274
- for (var i = event.changes.length - 1; i >= 0; --i) {
4275
- var change = event.changes[i];
4276
- change.origin = type;
4277
- if (filter && !filterChange(doc, change, false)) {
4278
- source.length = 0;
4279
- return;
4280
- }
4281
-
4282
- antiChanges.push(historyChangeFromChange(doc, change));
4283
-
4284
- var after = i ? computeSelAfterChange(doc, change) : lst(source);
4285
- makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
4286
- if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
4287
- var rebased = [];
4288
-
4289
- // Propagate to the linked documents
4290
- linkedDocs(doc, function(doc, sharedHist) {
4291
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
4292
- rebaseHist(doc.history, change);
4293
- rebased.push(doc.history);
4294
- }
4295
- makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
4296
- });
4297
- }
4298
- }
4299
-
4300
- // Sub-views need their line numbers shifted when text is added
4301
- // above or below them in the parent document.
4302
- function shiftDoc(doc, distance) {
4303
- if (distance == 0) return;
4304
- doc.first += distance;
4305
- doc.sel = new Selection(map(doc.sel.ranges, function(range) {
4306
- return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
4307
- Pos(range.head.line + distance, range.head.ch));
4308
- }), doc.sel.primIndex);
4309
- if (doc.cm) {
4310
- regChange(doc.cm, doc.first, doc.first - distance, distance);
4311
- for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
4312
- regLineChange(doc.cm, l, "gutter");
4313
- }
4314
- }
4315
-
4316
- // More lower-level change function, handling only a single document
4317
- // (not linked ones).
4318
- function makeChangeSingleDoc(doc, change, selAfter, spans) {
4319
- if (doc.cm && !doc.cm.curOp)
4320
- return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
4321
-
4322
- if (change.to.line < doc.first) {
4323
- shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
4324
- return;
4325
- }
4326
- if (change.from.line > doc.lastLine()) return;
4327
-
4328
- // Clip the change to the size of this doc
4329
- if (change.from.line < doc.first) {
4330
- var shift = change.text.length - 1 - (doc.first - change.from.line);
4331
- shiftDoc(doc, shift);
4332
- change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
4333
- text: [lst(change.text)], origin: change.origin};
4334
- }
4335
- var last = doc.lastLine();
4336
- if (change.to.line > last) {
4337
- change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
4338
- text: [change.text[0]], origin: change.origin};
4339
- }
4340
-
4341
- change.removed = getBetween(doc, change.from, change.to);
4342
-
4343
- if (!selAfter) selAfter = computeSelAfterChange(doc, change);
4344
- if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
4345
- else updateDoc(doc, change, spans);
4346
- setSelectionNoUndo(doc, selAfter, sel_dontScroll);
4347
- }
4348
-
4349
- // Handle the interaction of a change to a document with the editor
4350
- // that this document is part of.
4351
- function makeChangeSingleDocInEditor(cm, change, spans) {
4352
- var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
4353
-
4354
- var recomputeMaxLength = false, checkWidthStart = from.line;
4355
- if (!cm.options.lineWrapping) {
4356
- checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
4357
- doc.iter(checkWidthStart, to.line + 1, function(line) {
4358
- if (line == display.maxLine) {
4359
- recomputeMaxLength = true;
4360
- return true;
4361
- }
4362
- });
4363
- }
4364
-
4365
- if (doc.sel.contains(change.from, change.to) > -1)
4366
- signalCursorActivity(cm);
4367
-
4368
- updateDoc(doc, change, spans, estimateHeight(cm));
4369
-
4370
- if (!cm.options.lineWrapping) {
4371
- doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
4372
- var len = lineLength(line);
4373
- if (len > display.maxLineLength) {
4374
- display.maxLine = line;
4375
- display.maxLineLength = len;
4376
- display.maxLineChanged = true;
4377
- recomputeMaxLength = false;
4378
- }
4379
- });
4380
- if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
4381
- }
4382
-
4383
- // Adjust frontier, schedule worker
4384
- doc.frontier = Math.min(doc.frontier, from.line);
4385
- startWorker(cm, 400);
4386
-
4387
- var lendiff = change.text.length - (to.line - from.line) - 1;
4388
- // Remember that these lines changed, for updating the display
4389
- if (change.full)
4390
- regChange(cm);
4391
- else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
4392
- regLineChange(cm, from.line, "text");
4393
- else
4394
- regChange(cm, from.line, to.line + 1, lendiff);
4395
-
4396
- var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
4397
- if (changeHandler || changesHandler) {
4398
- var obj = {
4399
- from: from, to: to,
4400
- text: change.text,
4401
- removed: change.removed,
4402
- origin: change.origin
4403
- };
4404
- if (changeHandler) signalLater(cm, "change", cm, obj);
4405
- if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
4406
- }
4407
- cm.display.selForContextMenu = null;
4408
- }
4409
-
4410
- function replaceRange(doc, code, from, to, origin) {
4411
- if (!to) to = from;
4412
- if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
4413
- if (typeof code == "string") code = splitLines(code);
4414
- makeChange(doc, {from: from, to: to, text: code, origin: origin});
4415
- }
4416
-
4417
- // SCROLLING THINGS INTO VIEW
4418
-
4419
- // If an editor sits on the top or bottom of the window, partially
4420
- // scrolled out of view, this ensures that the cursor is visible.
4421
- function maybeScrollWindow(cm, coords) {
4422
- if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
4423
-
4424
- var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
4425
- if (coords.top + box.top < 0) doScroll = true;
4426
- else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
4427
- if (doScroll != null && !phantom) {
4428
- var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
4429
- (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
4430
- (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
4431
- coords.left + "px; width: 2px;");
4432
- cm.display.lineSpace.appendChild(scrollNode);
4433
- scrollNode.scrollIntoView(doScroll);
4434
- cm.display.lineSpace.removeChild(scrollNode);
4435
- }
4436
- }
4437
-
4438
- // Scroll a given position into view (immediately), verifying that
4439
- // it actually became visible (as line heights are accurately
4440
- // measured, the position of something may 'drift' during drawing).
4441
- function scrollPosIntoView(cm, pos, end, margin) {
4442
- if (margin == null) margin = 0;
4443
- for (var limit = 0; limit < 5; limit++) {
4444
- var changed = false, coords = cursorCoords(cm, pos);
4445
- var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
4446
- var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
4447
- Math.min(coords.top, endCoords.top) - margin,
4448
- Math.max(coords.left, endCoords.left),
4449
- Math.max(coords.bottom, endCoords.bottom) + margin);
4450
- var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
4451
- if (scrollPos.scrollTop != null) {
4452
- setScrollTop(cm, scrollPos.scrollTop);
4453
- if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
4454
- }
4455
- if (scrollPos.scrollLeft != null) {
4456
- setScrollLeft(cm, scrollPos.scrollLeft);
4457
- if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
4458
- }
4459
- if (!changed) break;
4460
- }
4461
- return coords;
4462
- }
4463
-
4464
- // Scroll a given set of coordinates into view (immediately).
4465
- function scrollIntoView(cm, x1, y1, x2, y2) {
4466
- var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
4467
- if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
4468
- if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
4469
- }
4470
-
4471
- // Calculate a new scroll position needed to scroll the given
4472
- // rectangle into view. Returns an object with scrollTop and
4473
- // scrollLeft properties. When these are undefined, the
4474
- // vertical/horizontal position does not need to be adjusted.
4475
- function calculateScrollPos(cm, x1, y1, x2, y2) {
4476
- var display = cm.display, snapMargin = textHeight(cm.display);
4477
- if (y1 < 0) y1 = 0;
4478
- var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
4479
- var screen = displayHeight(cm), result = {};
4480
- if (y2 - y1 > screen) y2 = y1 + screen;
4481
- var docBottom = cm.doc.height + paddingVert(display);
4482
- var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
4483
- if (y1 < screentop) {
4484
- result.scrollTop = atTop ? 0 : y1;
4485
- } else if (y2 > screentop + screen) {
4486
- var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
4487
- if (newTop != screentop) result.scrollTop = newTop;
4488
- }
4489
-
4490
- var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
4491
- var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
4492
- var tooWide = x2 - x1 > screenw;
4493
- if (tooWide) x2 = x1 + screenw;
4494
- if (x1 < 10)
4495
- result.scrollLeft = 0;
4496
- else if (x1 < screenleft)
4497
- result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
4498
- else if (x2 > screenw + screenleft - 3)
4499
- result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
4500
- return result;
4501
- }
4502
-
4503
- // Store a relative adjustment to the scroll position in the current
4504
- // operation (to be applied when the operation finishes).
4505
- function addToScrollPos(cm, left, top) {
4506
- if (left != null || top != null) resolveScrollToPos(cm);
4507
- if (left != null)
4508
- cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
4509
- if (top != null)
4510
- cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
4511
- }
4512
-
4513
- // Make sure that at the end of the operation the current cursor is
4514
- // shown.
4515
- function ensureCursorVisible(cm) {
4516
- resolveScrollToPos(cm);
4517
- var cur = cm.getCursor(), from = cur, to = cur;
4518
- if (!cm.options.lineWrapping) {
4519
- from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
4520
- to = Pos(cur.line, cur.ch + 1);
4521
- }
4522
- cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
4523
- }
4524
-
4525
- // When an operation has its scrollToPos property set, and another
4526
- // scroll action is applied before the end of the operation, this
4527
- // 'simulates' scrolling that position into view in a cheap way, so
4528
- // that the effect of intermediate scroll commands is not ignored.
4529
- function resolveScrollToPos(cm) {
4530
- var range = cm.curOp.scrollToPos;
4531
- if (range) {
4532
- cm.curOp.scrollToPos = null;
4533
- var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
4534
- var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
4535
- Math.min(from.top, to.top) - range.margin,
4536
- Math.max(from.right, to.right),
4537
- Math.max(from.bottom, to.bottom) + range.margin);
4538
- cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
4539
- }
4540
- }
4541
-
4542
- // API UTILITIES
4543
-
4544
- // Indent the given line. The how parameter can be "smart",
4545
- // "add"/null, "subtract", or "prev". When aggressive is false
4546
- // (typically set to true for forced single-line indents), empty
4547
- // lines are not indented, and places where the mode returns Pass
4548
- // are left alone.
4549
- function indentLine(cm, n, how, aggressive) {
4550
- var doc = cm.doc, state;
4551
- if (how == null) how = "add";
4552
- if (how == "smart") {
4553
- // Fall back to "prev" when the mode doesn't have an indentation
4554
- // method.
4555
- if (!doc.mode.indent) how = "prev";
4556
- else state = getStateBefore(cm, n);
4557
- }
4558
-
4559
- var tabSize = cm.options.tabSize;
4560
- var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
4561
- if (line.stateAfter) line.stateAfter = null;
4562
- var curSpaceString = line.text.match(/^\s*/)[0], indentation;
4563
- if (!aggressive && !/\S/.test(line.text)) {
4564
- indentation = 0;
4565
- how = "not";
4566
- } else if (how == "smart") {
4567
- indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
4568
- if (indentation == Pass || indentation > 150) {
4569
- if (!aggressive) return;
4570
- how = "prev";
4571
- }
4572
- }
4573
- if (how == "prev") {
4574
- if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
4575
- else indentation = 0;
4576
- } else if (how == "add") {
4577
- indentation = curSpace + cm.options.indentUnit;
4578
- } else if (how == "subtract") {
4579
- indentation = curSpace - cm.options.indentUnit;
4580
- } else if (typeof how == "number") {
4581
- indentation = curSpace + how;
4582
- }
4583
- indentation = Math.max(0, indentation);
4584
-
4585
- var indentString = "", pos = 0;
4586
- if (cm.options.indentWithTabs)
4587
- for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
4588
- if (pos < indentation) indentString += spaceStr(indentation - pos);
4589
-
4590
- if (indentString != curSpaceString) {
4591
- replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
4592
- } else {
4593
- // Ensure that, if the cursor was in the whitespace at the start
4594
- // of the line, it is moved to the end of that space.
4595
- for (var i = 0; i < doc.sel.ranges.length; i++) {
4596
- var range = doc.sel.ranges[i];
4597
- if (range.head.line == n && range.head.ch < curSpaceString.length) {
4598
- var pos = Pos(n, curSpaceString.length);
4599
- replaceOneSelection(doc, i, new Range(pos, pos));
4600
- break;
4601
- }
4602
- }
4603
- }
4604
- line.stateAfter = null;
4605
- }
4606
-
4607
- // Utility for applying a change to a line by handle or number,
4608
- // returning the number and optionally registering the line as
4609
- // changed.
4610
- function changeLine(doc, handle, changeType, op) {
4611
- var no = handle, line = handle;
4612
- if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
4613
- else no = lineNo(handle);
4614
- if (no == null) return null;
4615
- if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
4616
- return line;
4617
- }
4618
-
4619
- // Helper for deleting text near the selection(s), used to implement
4620
- // backspace, delete, and similar functionality.
4621
- function deleteNearSelection(cm, compute) {
4622
- var ranges = cm.doc.sel.ranges, kill = [];
4623
- // Build up a set of ranges to kill first, merging overlapping
4624
- // ranges.
4625
- for (var i = 0; i < ranges.length; i++) {
4626
- var toKill = compute(ranges[i]);
4627
- while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
4628
- var replaced = kill.pop();
4629
- if (cmp(replaced.from, toKill.from) < 0) {
4630
- toKill.from = replaced.from;
4631
- break;
4632
- }
4633
- }
4634
- kill.push(toKill);
4635
- }
4636
- // Next, remove those actual ranges.
4637
- runInOp(cm, function() {
4638
- for (var i = kill.length - 1; i >= 0; i--)
4639
- replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
4640
- ensureCursorVisible(cm);
4641
- });
4642
- }
4643
-
4644
- // Used for horizontal relative motion. Dir is -1 or 1 (left or
4645
- // right), unit can be "char", "column" (like char, but doesn't
4646
- // cross line boundaries), "word" (across next word), or "group" (to
4647
- // the start of next group of word or non-word-non-whitespace
4648
- // chars). The visually param controls whether, in right-to-left
4649
- // text, direction 1 means to move towards the next index in the
4650
- // string, or towards the character to the right of the current
4651
- // position. The resulting position will have a hitSide=true
4652
- // property if it reached the end of the document.
4653
- function findPosH(doc, pos, dir, unit, visually) {
4654
- var line = pos.line, ch = pos.ch, origDir = dir;
4655
- var lineObj = getLine(doc, line);
4656
- var possible = true;
4657
- function findNextLine() {
4658
- var l = line + dir;
4659
- if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
4660
- line = l;
4661
- return lineObj = getLine(doc, l);
4662
- }
4663
- function moveOnce(boundToLine) {
4664
- var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
4665
- if (next == null) {
4666
- if (!boundToLine && findNextLine()) {
4667
- if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
4668
- else ch = dir < 0 ? lineObj.text.length : 0;
4669
- } else return (possible = false);
4670
- } else ch = next;
4671
- return true;
4672
- }
4673
-
4674
- if (unit == "char") moveOnce();
4675
- else if (unit == "column") moveOnce(true);
4676
- else if (unit == "word" || unit == "group") {
4677
- var sawType = null, group = unit == "group";
4678
- var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
4679
- for (var first = true;; first = false) {
4680
- if (dir < 0 && !moveOnce(!first)) break;
4681
- var cur = lineObj.text.charAt(ch) || "\n";
4682
- var type = isWordChar(cur, helper) ? "w"
4683
- : group && cur == "\n" ? "n"
4684
- : !group || /\s/.test(cur) ? null
4685
- : "p";
4686
- if (group && !first && !type) type = "s";
4687
- if (sawType && sawType != type) {
4688
- if (dir < 0) {dir = 1; moveOnce();}
4689
- break;
4690
- }
4691
-
4692
- if (type) sawType = type;
4693
- if (dir > 0 && !moveOnce(!first)) break;
4694
- }
4695
- }
4696
- var result = skipAtomic(doc, Pos(line, ch), origDir, true);
4697
- if (!possible) result.hitSide = true;
4698
- return result;
4699
- }
4700
-
4701
- // For relative vertical movement. Dir may be -1 or 1. Unit can be
4702
- // "page" or "line". The resulting position will have a hitSide=true
4703
- // property if it reached the end of the document.
4704
- function findPosV(cm, pos, dir, unit) {
4705
- var doc = cm.doc, x = pos.left, y;
4706
- if (unit == "page") {
4707
- var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
4708
- y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
4709
- } else if (unit == "line") {
4710
- y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
4711
- }
4712
- for (;;) {
4713
- var target = coordsChar(cm, x, y);
4714
- if (!target.outside) break;
4715
- if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
4716
- y += dir * 5;
4717
- }
4718
- return target;
4719
- }
4720
-
4721
- // EDITOR METHODS
4722
-
4723
- // The publicly visible API. Note that methodOp(f) means
4724
- // 'wrap f in an operation, performed on its `this` parameter'.
4725
-
4726
- // This is not the complete set of editor methods. Most of the
4727
- // methods defined on the Doc type are also injected into
4728
- // CodeMirror.prototype, for backwards compatibility and
4729
- // convenience.
4730
-
4731
- CodeMirror.prototype = {
4732
- constructor: CodeMirror,
4733
- focus: function(){window.focus(); this.display.input.focus();},
4734
-
4735
- setOption: function(option, value) {
4736
- var options = this.options, old = options[option];
4737
- if (options[option] == value && option != "mode") return;
4738
- options[option] = value;
4739
- if (optionHandlers.hasOwnProperty(option))
4740
- operation(this, optionHandlers[option])(this, value, old);
4741
- },
4742
-
4743
- getOption: function(option) {return this.options[option];},
4744
- getDoc: function() {return this.doc;},
4745
-
4746
- addKeyMap: function(map, bottom) {
4747
- this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
4748
- },
4749
- removeKeyMap: function(map) {
4750
- var maps = this.state.keyMaps;
4751
- for (var i = 0; i < maps.length; ++i)
4752
- if (maps[i] == map || maps[i].name == map) {
4753
- maps.splice(i, 1);
4754
- return true;
4755
- }
4756
- },
4757
-
4758
- addOverlay: methodOp(function(spec, options) {
4759
- var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
4760
- if (mode.startState) throw new Error("Overlays may not be stateful.");
4761
- this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
4762
- this.state.modeGen++;
4763
- regChange(this);
4764
- }),
4765
- removeOverlay: methodOp(function(spec) {
4766
- var overlays = this.state.overlays;
4767
- for (var i = 0; i < overlays.length; ++i) {
4768
- var cur = overlays[i].modeSpec;
4769
- if (cur == spec || typeof spec == "string" && cur.name == spec) {
4770
- overlays.splice(i, 1);
4771
- this.state.modeGen++;
4772
- regChange(this);
4773
- return;
4774
- }
4775
- }
4776
- }),
4777
-
4778
- indentLine: methodOp(function(n, dir, aggressive) {
4779
- if (typeof dir != "string" && typeof dir != "number") {
4780
- if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
4781
- else dir = dir ? "add" : "subtract";
4782
- }
4783
- if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
4784
- }),
4785
- indentSelection: methodOp(function(how) {
4786
- var ranges = this.doc.sel.ranges, end = -1;
4787
- for (var i = 0; i < ranges.length; i++) {
4788
- var range = ranges[i];
4789
- if (!range.empty()) {
4790
- var from = range.from(), to = range.to();
4791
- var start = Math.max(end, from.line);
4792
- end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
4793
- for (var j = start; j < end; ++j)
4794
- indentLine(this, j, how);
4795
- var newRanges = this.doc.sel.ranges;
4796
- if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
4797
- replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
4798
- } else if (range.head.line > end) {
4799
- indentLine(this, range.head.line, how, true);
4800
- end = range.head.line;
4801
- if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
4802
- }
4803
- }
4804
- }),
4805
-
4806
- // Fetch the parser token for a given character. Useful for hacks
4807
- // that want to inspect the mode state (say, for completion).
4808
- getTokenAt: function(pos, precise) {
4809
- return takeToken(this, pos, precise);
4810
- },
4811
-
4812
- getLineTokens: function(line, precise) {
4813
- return takeToken(this, Pos(line), precise, true);
4814
- },
4815
-
4816
- getTokenTypeAt: function(pos) {
4817
- pos = clipPos(this.doc, pos);
4818
- var styles = getLineStyles(this, getLine(this.doc, pos.line));
4819
- var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
4820
- var type;
4821
- if (ch == 0) type = styles[2];
4822
- else for (;;) {
4823
- var mid = (before + after) >> 1;
4824
- if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
4825
- else if (styles[mid * 2 + 1] < ch) before = mid + 1;
4826
- else { type = styles[mid * 2 + 2]; break; }
4827
- }
4828
- var cut = type ? type.indexOf("cm-overlay ") : -1;
4829
- return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
4830
- },
4831
-
4832
- getModeAt: function(pos) {
4833
- var mode = this.doc.mode;
4834
- if (!mode.innerMode) return mode;
4835
- return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
4836
- },
4837
-
4838
- getHelper: function(pos, type) {
4839
- return this.getHelpers(pos, type)[0];
4840
- },
4841
-
4842
- getHelpers: function(pos, type) {
4843
- var found = [];
4844
- if (!helpers.hasOwnProperty(type)) return found;
4845
- var help = helpers[type], mode = this.getModeAt(pos);
4846
- if (typeof mode[type] == "string") {
4847
- if (help[mode[type]]) found.push(help[mode[type]]);
4848
- } else if (mode[type]) {
4849
- for (var i = 0; i < mode[type].length; i++) {
4850
- var val = help[mode[type][i]];
4851
- if (val) found.push(val);
4852
- }
4853
- } else if (mode.helperType && help[mode.helperType]) {
4854
- found.push(help[mode.helperType]);
4855
- } else if (help[mode.name]) {
4856
- found.push(help[mode.name]);
4857
- }
4858
- for (var i = 0; i < help._global.length; i++) {
4859
- var cur = help._global[i];
4860
- if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
4861
- found.push(cur.val);
4862
- }
4863
- return found;
4864
- },
4865
-
4866
- getStateAfter: function(line, precise) {
4867
- var doc = this.doc;
4868
- line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
4869
- return getStateBefore(this, line + 1, precise);
4870
- },
4871
-
4872
- cursorCoords: function(start, mode) {
4873
- var pos, range = this.doc.sel.primary();
4874
- if (start == null) pos = range.head;
4875
- else if (typeof start == "object") pos = clipPos(this.doc, start);
4876
- else pos = start ? range.from() : range.to();
4877
- return cursorCoords(this, pos, mode || "page");
4878
- },
4879
-
4880
- charCoords: function(pos, mode) {
4881
- return charCoords(this, clipPos(this.doc, pos), mode || "page");
4882
- },
4883
-
4884
- coordsChar: function(coords, mode) {
4885
- coords = fromCoordSystem(this, coords, mode || "page");
4886
- return coordsChar(this, coords.left, coords.top);
4887
- },
4888
-
4889
- lineAtHeight: function(height, mode) {
4890
- height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
4891
- return lineAtHeight(this.doc, height + this.display.viewOffset);
4892
- },
4893
- heightAtLine: function(line, mode) {
4894
- var end = false, last = this.doc.first + this.doc.size - 1;
4895
- if (line < this.doc.first) line = this.doc.first;
4896
- else if (line > last) { line = last; end = true; }
4897
- var lineObj = getLine(this.doc, line);
4898
- return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
4899
- (end ? this.doc.height - heightAtLine(lineObj) : 0);
4900
- },
4901
-
4902
- defaultTextHeight: function() { return textHeight(this.display); },
4903
- defaultCharWidth: function() { return charWidth(this.display); },
4904
-
4905
- setGutterMarker: methodOp(function(line, gutterID, value) {
4906
- return changeLine(this.doc, line, "gutter", function(line) {
4907
- var markers = line.gutterMarkers || (line.gutterMarkers = {});
4908
- markers[gutterID] = value;
4909
- if (!value && isEmpty(markers)) line.gutterMarkers = null;
4910
- return true;
4911
- });
4912
- }),
4913
-
4914
- clearGutter: methodOp(function(gutterID) {
4915
- var cm = this, doc = cm.doc, i = doc.first;
4916
- doc.iter(function(line) {
4917
- if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
4918
- line.gutterMarkers[gutterID] = null;
4919
- regLineChange(cm, i, "gutter");
4920
- if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
4921
- }
4922
- ++i;
4923
- });
4924
- }),
4925
-
4926
- addLineWidget: methodOp(function(handle, node, options) {
4927
- return addLineWidget(this, handle, node, options);
4928
- }),
4929
-
4930
- removeLineWidget: function(widget) { widget.clear(); },
4931
-
4932
- lineInfo: function(line) {
4933
- if (typeof line == "number") {
4934
- if (!isLine(this.doc, line)) return null;
4935
- var n = line;
4936
- line = getLine(this.doc, line);
4937
- if (!line) return null;
4938
- } else {
4939
- var n = lineNo(line);
4940
- if (n == null) return null;
4941
- }
4942
- return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
4943
- textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
4944
- widgets: line.widgets};
4945
- },
4946
-
4947
- getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
4948
-
4949
- addWidget: function(pos, node, scroll, vert, horiz) {
4950
- var display = this.display;
4951
- pos = cursorCoords(this, clipPos(this.doc, pos));
4952
- var top = pos.bottom, left = pos.left;
4953
- node.style.position = "absolute";
4954
- node.setAttribute("cm-ignore-events", "true");
4955
- this.display.input.setUneditable(node);
4956
- display.sizer.appendChild(node);
4957
- if (vert == "over") {
4958
- top = pos.top;
4959
- } else if (vert == "above" || vert == "near") {
4960
- var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
4961
- hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
4962
- // Default to positioning above (if specified and possible); otherwise default to positioning below
4963
- if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
4964
- top = pos.top - node.offsetHeight;
4965
- else if (pos.bottom + node.offsetHeight <= vspace)
4966
- top = pos.bottom;
4967
- if (left + node.offsetWidth > hspace)
4968
- left = hspace - node.offsetWidth;
4969
- }
4970
- node.style.top = top + "px";
4971
- node.style.left = node.style.right = "";
4972
- if (horiz == "right") {
4973
- left = display.sizer.clientWidth - node.offsetWidth;
4974
- node.style.right = "0px";
4975
- } else {
4976
- if (horiz == "left") left = 0;
4977
- else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
4978
- node.style.left = left + "px";
4979
- }
4980
- if (scroll)
4981
- scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
4982
- },
4983
-
4984
- triggerOnKeyDown: methodOp(onKeyDown),
4985
- triggerOnKeyPress: methodOp(onKeyPress),
4986
- triggerOnKeyUp: onKeyUp,
4987
-
4988
- execCommand: function(cmd) {
4989
- if (commands.hasOwnProperty(cmd))
4990
- return commands[cmd](this);
4991
- },
4992
-
4993
- findPosH: function(from, amount, unit, visually) {
4994
- var dir = 1;
4995
- if (amount < 0) { dir = -1; amount = -amount; }
4996
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
4997
- cur = findPosH(this.doc, cur, dir, unit, visually);
4998
- if (cur.hitSide) break;
4999
- }
5000
- return cur;
5001
- },
5002
-
5003
- moveH: methodOp(function(dir, unit) {
5004
- var cm = this;
5005
- cm.extendSelectionsBy(function(range) {
5006
- if (cm.display.shift || cm.doc.extend || range.empty())
5007
- return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
5008
- else
5009
- return dir < 0 ? range.from() : range.to();
5010
- }, sel_move);
5011
- }),
5012
-
5013
- deleteH: methodOp(function(dir, unit) {
5014
- var sel = this.doc.sel, doc = this.doc;
5015
- if (sel.somethingSelected())
5016
- doc.replaceSelection("", null, "+delete");
5017
- else
5018
- deleteNearSelection(this, function(range) {
5019
- var other = findPosH(doc, range.head, dir, unit, false);
5020
- return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
5021
- });
5022
- }),
5023
-
5024
- findPosV: function(from, amount, unit, goalColumn) {
5025
- var dir = 1, x = goalColumn;
5026
- if (amount < 0) { dir = -1; amount = -amount; }
5027
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
5028
- var coords = cursorCoords(this, cur, "div");
5029
- if (x == null) x = coords.left;
5030
- else coords.left = x;
5031
- cur = findPosV(this, coords, dir, unit);
5032
- if (cur.hitSide) break;
5033
- }
5034
- return cur;
5035
- },
5036
-
5037
- moveV: methodOp(function(dir, unit) {
5038
- var cm = this, doc = this.doc, goals = [];
5039
- var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
5040
- doc.extendSelectionsBy(function(range) {
5041
- if (collapse)
5042
- return dir < 0 ? range.from() : range.to();
5043
- var headPos = cursorCoords(cm, range.head, "div");
5044
- if (range.goalColumn != null) headPos.left = range.goalColumn;
5045
- goals.push(headPos.left);
5046
- var pos = findPosV(cm, headPos, dir, unit);
5047
- if (unit == "page" && range == doc.sel.primary())
5048
- addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
5049
- return pos;
5050
- }, sel_move);
5051
- if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
5052
- doc.sel.ranges[i].goalColumn = goals[i];
5053
- }),
5054
-
5055
- // Find the word at the given position (as returned by coordsChar).
5056
- findWordAt: function(pos) {
5057
- var doc = this.doc, line = getLine(doc, pos.line).text;
5058
- var start = pos.ch, end = pos.ch;
5059
- if (line) {
5060
- var helper = this.getHelper(pos, "wordChars");
5061
- if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
5062
- var startChar = line.charAt(start);
5063
- var check = isWordChar(startChar, helper)
5064
- ? function(ch) { return isWordChar(ch, helper); }
5065
- : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
5066
- : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
5067
- while (start > 0 && check(line.charAt(start - 1))) --start;
5068
- while (end < line.length && check(line.charAt(end))) ++end;
5069
- }
5070
- return new Range(Pos(pos.line, start), Pos(pos.line, end));
5071
- },
5072
-
5073
- toggleOverwrite: function(value) {
5074
- if (value != null && value == this.state.overwrite) return;
5075
- if (this.state.overwrite = !this.state.overwrite)
5076
- addClass(this.display.cursorDiv, "CodeMirror-overwrite");
5077
- else
5078
- rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
5079
-
5080
- signal(this, "overwriteToggle", this, this.state.overwrite);
5081
- },
5082
- hasFocus: function() { return this.display.input.getField() == activeElt(); },
5083
-
5084
- scrollTo: methodOp(function(x, y) {
5085
- if (x != null || y != null) resolveScrollToPos(this);
5086
- if (x != null) this.curOp.scrollLeft = x;
5087
- if (y != null) this.curOp.scrollTop = y;
5088
- }),
5089
- getScrollInfo: function() {
5090
- var scroller = this.display.scroller;
5091
- return {left: scroller.scrollLeft, top: scroller.scrollTop,
5092
- height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
5093
- width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
5094
- clientHeight: displayHeight(this), clientWidth: displayWidth(this)};
5095
- },
5096
-
5097
- scrollIntoView: methodOp(function(range, margin) {
5098
- if (range == null) {
5099
- range = {from: this.doc.sel.primary().head, to: null};
5100
- if (margin == null) margin = this.options.cursorScrollMargin;
5101
- } else if (typeof range == "number") {
5102
- range = {from: Pos(range, 0), to: null};
5103
- } else if (range.from == null) {
5104
- range = {from: range, to: null};
5105
- }
5106
- if (!range.to) range.to = range.from;
5107
- range.margin = margin || 0;
5108
-
5109
- if (range.from.line != null) {
5110
- resolveScrollToPos(this);
5111
- this.curOp.scrollToPos = range;
5112
- } else {
5113
- var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
5114
- Math.min(range.from.top, range.to.top) - range.margin,
5115
- Math.max(range.from.right, range.to.right),
5116
- Math.max(range.from.bottom, range.to.bottom) + range.margin);
5117
- this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
5118
- }
5119
- }),
5120
-
5121
- setSize: methodOp(function(width, height) {
5122
- var cm = this;
5123
- function interpret(val) {
5124
- return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
5125
- }
5126
- if (width != null) cm.display.wrapper.style.width = interpret(width);
5127
- if (height != null) cm.display.wrapper.style.height = interpret(height);
5128
- if (cm.options.lineWrapping) clearLineMeasurementCache(this);
5129
- var lineNo = cm.display.viewFrom;
5130
- cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
5131
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
5132
- if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
5133
- ++lineNo;
5134
- });
5135
- cm.curOp.forceUpdate = true;
5136
- signal(cm, "refresh", this);
5137
- }),
5138
-
5139
- operation: function(f){return runInOp(this, f);},
5140
-
5141
- refresh: methodOp(function() {
5142
- var oldHeight = this.display.cachedTextHeight;
5143
- regChange(this);
5144
- this.curOp.forceUpdate = true;
5145
- clearCaches(this);
5146
- this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
5147
- updateGutterSpace(this);
5148
- if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
5149
- estimateLineHeights(this);
5150
- signal(this, "refresh", this);
5151
- }),
5152
-
5153
- swapDoc: methodOp(function(doc) {
5154
- var old = this.doc;
5155
- old.cm = null;
5156
- attachDoc(this, doc);
5157
- clearCaches(this);
5158
- this.display.input.reset();
5159
- this.scrollTo(doc.scrollLeft, doc.scrollTop);
5160
- this.curOp.forceScroll = true;
5161
- signalLater(this, "swapDoc", this, old);
5162
- return old;
5163
- }),
5164
-
5165
- getInputField: function(){return this.display.input.getField();},
5166
- getWrapperElement: function(){return this.display.wrapper;},
5167
- getScrollerElement: function(){return this.display.scroller;},
5168
- getGutterElement: function(){return this.display.gutters;}
5169
- };
5170
- eventMixin(CodeMirror);
5171
-
5172
- // OPTION DEFAULTS
5173
-
5174
- // The default configuration options.
5175
- var defaults = CodeMirror.defaults = {};
5176
- // Functions to run when options are changed.
5177
- var optionHandlers = CodeMirror.optionHandlers = {};
5178
-
5179
- function option(name, deflt, handle, notOnInit) {
5180
- CodeMirror.defaults[name] = deflt;
5181
- if (handle) optionHandlers[name] =
5182
- notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
5183
- }
5184
-
5185
- // Passed to option handlers when there is no old value.
5186
- var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
5187
-
5188
- // These two are, on init, called from the constructor because they
5189
- // have to be initialized before the editor can start at all.
5190
- option("value", "", function(cm, val) {
5191
- cm.setValue(val);
5192
- }, true);
5193
- option("mode", null, function(cm, val) {
5194
- cm.doc.modeOption = val;
5195
- loadMode(cm);
5196
- }, true);
5197
-
5198
- option("indentUnit", 2, loadMode, true);
5199
- option("indentWithTabs", false);
5200
- option("smartIndent", true);
5201
- option("tabSize", 4, function(cm) {
5202
- resetModeState(cm);
5203
- clearCaches(cm);
5204
- regChange(cm);
5205
- }, true);
5206
- option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
5207
- cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
5208
- if (old != CodeMirror.Init) cm.refresh();
5209
- });
5210
- option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
5211
- option("electricChars", true);
5212
- option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
5213
- throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
5214
- }, true);
5215
- option("rtlMoveVisually", !windows);
5216
- option("wholeLineUpdateBefore", true);
5217
-
5218
- option("theme", "default", function(cm) {
5219
- themeChanged(cm);
5220
- guttersChanged(cm);
5221
- }, true);
5222
- option("keyMap", "default", function(cm, val, old) {
5223
- var next = getKeyMap(val);
5224
- var prev = old != CodeMirror.Init && getKeyMap(old);
5225
- if (prev && prev.detach) prev.detach(cm, next);
5226
- if (next.attach) next.attach(cm, prev || null);
5227
- });
5228
- option("extraKeys", null);
5229
-
5230
- option("lineWrapping", false, wrappingChanged, true);
5231
- option("gutters", [], function(cm) {
5232
- setGuttersForLineNumbers(cm.options);
5233
- guttersChanged(cm);
5234
- }, true);
5235
- option("fixedGutter", true, function(cm, val) {
5236
- cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
5237
- cm.refresh();
5238
- }, true);
5239
- option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true);
5240
- option("scrollbarStyle", "native", function(cm) {
5241
- initScrollbars(cm);
5242
- updateScrollbars(cm);
5243
- cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
5244
- cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
5245
- }, true);
5246
- option("lineNumbers", false, function(cm) {
5247
- setGuttersForLineNumbers(cm.options);
5248
- guttersChanged(cm);
5249
- }, true);
5250
- option("firstLineNumber", 1, guttersChanged, true);
5251
- option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
5252
- option("showCursorWhenSelecting", false, updateSelection, true);
5253
-
5254
- option("resetSelectionOnContextMenu", true);
5255
-
5256
- option("readOnly", false, function(cm, val) {
5257
- if (val == "nocursor") {
5258
- onBlur(cm);
5259
- cm.display.input.blur();
5260
- cm.display.disabled = true;
5261
- } else {
5262
- cm.display.disabled = false;
5263
- if (!val) cm.display.input.reset();
5264
- }
5265
- });
5266
- option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
5267
- option("dragDrop", true);
5268
-
5269
- option("cursorBlinkRate", 530);
5270
- option("cursorScrollMargin", 0);
5271
- option("cursorHeight", 1, updateSelection, true);
5272
- option("singleCursorHeightPerLine", true, updateSelection, true);
5273
- option("workTime", 100);
5274
- option("workDelay", 100);
5275
- option("flattenSpans", true, resetModeState, true);
5276
- option("addModeClass", false, resetModeState, true);
5277
- option("pollInterval", 100);
5278
- option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
5279
- option("historyEventDelay", 1250);
5280
- option("viewportMargin", 10, function(cm){cm.refresh();}, true);
5281
- option("maxHighlightLength", 10000, resetModeState, true);
5282
- option("moveInputWithCursor", true, function(cm, val) {
5283
- if (!val) cm.display.input.resetPosition();
5284
- });
5285
-
5286
- option("tabindex", null, function(cm, val) {
5287
- cm.display.input.getField().tabIndex = val || "";
5288
- });
5289
- option("autofocus", null);
5290
-
5291
- // MODE DEFINITION AND QUERYING
5292
-
5293
- // Known modes, by name and by MIME
5294
- var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
5295
-
5296
- // Extra arguments are stored as the mode's dependencies, which is
5297
- // used by (legacy) mechanisms like loadmode.js to automatically
5298
- // load a mode. (Preferred mechanism is the require/define calls.)
5299
- CodeMirror.defineMode = function(name, mode) {
5300
- if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
5301
- if (arguments.length > 2)
5302
- mode.dependencies = Array.prototype.slice.call(arguments, 2);
5303
- modes[name] = mode;
5304
- };
5305
-
5306
- CodeMirror.defineMIME = function(mime, spec) {
5307
- mimeModes[mime] = spec;
5308
- };
5309
-
5310
- // Given a MIME type, a {name, ...options} config object, or a name
5311
- // string, return a mode config object.
5312
- CodeMirror.resolveMode = function(spec) {
5313
- if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
5314
- spec = mimeModes[spec];
5315
- } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
5316
- var found = mimeModes[spec.name];
5317
- if (typeof found == "string") found = {name: found};
5318
- spec = createObj(found, spec);
5319
- spec.name = found.name;
5320
- } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
5321
- return CodeMirror.resolveMode("application/xml");
5322
- }
5323
- if (typeof spec == "string") return {name: spec};
5324
- else return spec || {name: "null"};
5325
- };
5326
-
5327
- // Given a mode spec (anything that resolveMode accepts), find and
5328
- // initialize an actual mode object.
5329
- CodeMirror.getMode = function(options, spec) {
5330
- var spec = CodeMirror.resolveMode(spec);
5331
- var mfactory = modes[spec.name];
5332
- if (!mfactory) return CodeMirror.getMode(options, "text/plain");
5333
- var modeObj = mfactory(options, spec);
5334
- if (modeExtensions.hasOwnProperty(spec.name)) {
5335
- var exts = modeExtensions[spec.name];
5336
- for (var prop in exts) {
5337
- if (!exts.hasOwnProperty(prop)) continue;
5338
- if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
5339
- modeObj[prop] = exts[prop];
5340
- }
5341
- }
5342
- modeObj.name = spec.name;
5343
- if (spec.helperType) modeObj.helperType = spec.helperType;
5344
- if (spec.modeProps) for (var prop in spec.modeProps)
5345
- modeObj[prop] = spec.modeProps[prop];
5346
-
5347
- return modeObj;
5348
- };
5349
-
5350
- // Minimal default mode.
5351
- CodeMirror.defineMode("null", function() {
5352
- return {token: function(stream) {stream.skipToEnd();}};
5353
- });
5354
- CodeMirror.defineMIME("text/plain", "null");
5355
-
5356
- // This can be used to attach properties to mode objects from
5357
- // outside the actual mode definition.
5358
- var modeExtensions = CodeMirror.modeExtensions = {};
5359
- CodeMirror.extendMode = function(mode, properties) {
5360
- var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
5361
- copyObj(properties, exts);
5362
- };
5363
-
5364
- // EXTENSIONS
5365
-
5366
- CodeMirror.defineExtension = function(name, func) {
5367
- CodeMirror.prototype[name] = func;
5368
- };
5369
- CodeMirror.defineDocExtension = function(name, func) {
5370
- Doc.prototype[name] = func;
5371
- };
5372
- CodeMirror.defineOption = option;
5373
-
5374
- var initHooks = [];
5375
- CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
5376
-
5377
- var helpers = CodeMirror.helpers = {};
5378
- CodeMirror.registerHelper = function(type, name, value) {
5379
- if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
5380
- helpers[type][name] = value;
5381
- };
5382
- CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
5383
- CodeMirror.registerHelper(type, name, value);
5384
- helpers[type]._global.push({pred: predicate, val: value});
5385
- };
5386
-
5387
- // MODE STATE HANDLING
5388
-
5389
- // Utility functions for working with state. Exported because nested
5390
- // modes need to do this for their inner modes.
5391
-
5392
- var copyState = CodeMirror.copyState = function(mode, state) {
5393
- if (state === true) return state;
5394
- if (mode.copyState) return mode.copyState(state);
5395
- var nstate = {};
5396
- for (var n in state) {
5397
- var val = state[n];
5398
- if (val instanceof Array) val = val.concat([]);
5399
- nstate[n] = val;
5400
- }
5401
- return nstate;
5402
- };
5403
-
5404
- var startState = CodeMirror.startState = function(mode, a1, a2) {
5405
- return mode.startState ? mode.startState(a1, a2) : true;
5406
- };
5407
-
5408
- // Given a mode and a state (for that mode), find the inner mode and
5409
- // state at the position that the state refers to.
5410
- CodeMirror.innerMode = function(mode, state) {
5411
- while (mode.innerMode) {
5412
- var info = mode.innerMode(state);
5413
- if (!info || info.mode == mode) break;
5414
- state = info.state;
5415
- mode = info.mode;
5416
- }
5417
- return info || {mode: mode, state: state};
5418
- };
5419
-
5420
- // STANDARD COMMANDS
5421
-
5422
- // Commands are parameter-less actions that can be performed on an
5423
- // editor, mostly used for keybindings.
5424
- var commands = CodeMirror.commands = {
5425
- selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
5426
- singleSelection: function(cm) {
5427
- cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
5428
- },
5429
- killLine: function(cm) {
5430
- deleteNearSelection(cm, function(range) {
5431
- if (range.empty()) {
5432
- var len = getLine(cm.doc, range.head.line).text.length;
5433
- if (range.head.ch == len && range.head.line < cm.lastLine())
5434
- return {from: range.head, to: Pos(range.head.line + 1, 0)};
5435
- else
5436
- return {from: range.head, to: Pos(range.head.line, len)};
5437
- } else {
5438
- return {from: range.from(), to: range.to()};
5439
- }
5440
- });
5441
- },
5442
- deleteLine: function(cm) {
5443
- deleteNearSelection(cm, function(range) {
5444
- return {from: Pos(range.from().line, 0),
5445
- to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
5446
- });
5447
- },
5448
- delLineLeft: function(cm) {
5449
- deleteNearSelection(cm, function(range) {
5450
- return {from: Pos(range.from().line, 0), to: range.from()};
5451
- });
5452
- },
5453
- delWrappedLineLeft: function(cm) {
5454
- deleteNearSelection(cm, function(range) {
5455
- var top = cm.charCoords(range.head, "div").top + 5;
5456
- var leftPos = cm.coordsChar({left: 0, top: top}, "div");
5457
- return {from: leftPos, to: range.from()};
5458
- });
5459
- },
5460
- delWrappedLineRight: function(cm) {
5461
- deleteNearSelection(cm, function(range) {
5462
- var top = cm.charCoords(range.head, "div").top + 5;
5463
- var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
5464
- return {from: range.from(), to: rightPos };
5465
- });
5466
- },
5467
- undo: function(cm) {cm.undo();},
5468
- redo: function(cm) {cm.redo();},
5469
- undoSelection: function(cm) {cm.undoSelection();},
5470
- redoSelection: function(cm) {cm.redoSelection();},
5471
- goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
5472
- goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
5473
- goLineStart: function(cm) {
5474
- cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
5475
- {origin: "+move", bias: 1});
5476
- },
5477
- goLineStartSmart: function(cm) {
5478
- cm.extendSelectionsBy(function(range) {
5479
- return lineStartSmart(cm, range.head);
5480
- }, {origin: "+move", bias: 1});
5481
- },
5482
- goLineEnd: function(cm) {
5483
- cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
5484
- {origin: "+move", bias: -1});
5485
- },
5486
- goLineRight: function(cm) {
5487
- cm.extendSelectionsBy(function(range) {
5488
- var top = cm.charCoords(range.head, "div").top + 5;
5489
- return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
5490
- }, sel_move);
5491
- },
5492
- goLineLeft: function(cm) {
5493
- cm.extendSelectionsBy(function(range) {
5494
- var top = cm.charCoords(range.head, "div").top + 5;
5495
- return cm.coordsChar({left: 0, top: top}, "div");
5496
- }, sel_move);
5497
- },
5498
- goLineLeftSmart: function(cm) {
5499
- cm.extendSelectionsBy(function(range) {
5500
- var top = cm.charCoords(range.head, "div").top + 5;
5501
- var pos = cm.coordsChar({left: 0, top: top}, "div");
5502
- if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
5503
- return pos;
5504
- }, sel_move);
5505
- },
5506
- goLineUp: function(cm) {cm.moveV(-1, "line");},
5507
- goLineDown: function(cm) {cm.moveV(1, "line");},
5508
- goPageUp: function(cm) {cm.moveV(-1, "page");},
5509
- goPageDown: function(cm) {cm.moveV(1, "page");},
5510
- goCharLeft: function(cm) {cm.moveH(-1, "char");},
5511
- goCharRight: function(cm) {cm.moveH(1, "char");},
5512
- goColumnLeft: function(cm) {cm.moveH(-1, "column");},
5513
- goColumnRight: function(cm) {cm.moveH(1, "column");},
5514
- goWordLeft: function(cm) {cm.moveH(-1, "word");},
5515
- goGroupRight: function(cm) {cm.moveH(1, "group");},
5516
- goGroupLeft: function(cm) {cm.moveH(-1, "group");},
5517
- goWordRight: function(cm) {cm.moveH(1, "word");},
5518
- delCharBefore: function(cm) {cm.deleteH(-1, "char");},
5519
- delCharAfter: function(cm) {cm.deleteH(1, "char");},
5520
- delWordBefore: function(cm) {cm.deleteH(-1, "word");},
5521
- delWordAfter: function(cm) {cm.deleteH(1, "word");},
5522
- delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
5523
- delGroupAfter: function(cm) {cm.deleteH(1, "group");},
5524
- indentAuto: function(cm) {cm.indentSelection("smart");},
5525
- indentMore: function(cm) {cm.indentSelection("add");},
5526
- indentLess: function(cm) {cm.indentSelection("subtract");},
5527
- insertTab: function(cm) {cm.replaceSelection("\t");},
5528
- insertSoftTab: function(cm) {
5529
- var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
5530
- for (var i = 0; i < ranges.length; i++) {
5531
- var pos = ranges[i].from();
5532
- var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
5533
- spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
5534
- }
5535
- cm.replaceSelections(spaces);
5536
- },
5537
- defaultTab: function(cm) {
5538
- if (cm.somethingSelected()) cm.indentSelection("add");
5539
- else cm.execCommand("insertTab");
5540
- },
5541
- transposeChars: function(cm) {
5542
- runInOp(cm, function() {
5543
- var ranges = cm.listSelections(), newSel = [];
5544
- for (var i = 0; i < ranges.length; i++) {
5545
- var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
5546
- if (line) {
5547
- if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
5548
- if (cur.ch > 0) {
5549
- cur = new Pos(cur.line, cur.ch + 1);
5550
- cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
5551
- Pos(cur.line, cur.ch - 2), cur, "+transpose");
5552
- } else if (cur.line > cm.doc.first) {
5553
- var prev = getLine(cm.doc, cur.line - 1).text;
5554
- if (prev)
5555
- cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1),
5556
- Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
5557
- }
5558
- }
5559
- newSel.push(new Range(cur, cur));
5560
- }
5561
- cm.setSelections(newSel);
5562
- });
5563
- },
5564
- newlineAndIndent: function(cm) {
5565
- runInOp(cm, function() {
5566
- var len = cm.listSelections().length;
5567
- for (var i = 0; i < len; i++) {
5568
- var range = cm.listSelections()[i];
5569
- cm.replaceRange("\n", range.anchor, range.head, "+input");
5570
- cm.indentLine(range.from().line + 1, null, true);
5571
- ensureCursorVisible(cm);
5572
- }
5573
- });
5574
- },
5575
- toggleOverwrite: function(cm) {cm.toggleOverwrite();}
5576
- };
5577
-
5578
-
5579
- // STANDARD KEYMAPS
5580
-
5581
- var keyMap = CodeMirror.keyMap = {};
5582
-
5583
- keyMap.basic = {
5584
- "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
5585
- "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
5586
- "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
5587
- "Tab": "defaultTab", "Shift-Tab": "indentAuto",
5588
- "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
5589
- "Esc": "singleSelection"
5590
- };
5591
- // Note that the save and find-related commands aren't defined by
5592
- // default. User code or addons can define them. Unknown commands
5593
- // are simply ignored.
5594
- keyMap.pcDefault = {
5595
- "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
5596
- "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
5597
- "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
5598
- "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
5599
- "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
5600
- "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
5601
- "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
5602
- fallthrough: "basic"
5603
- };
5604
- // Very basic readline/emacs-style bindings, which are standard on Mac.
5605
- keyMap.emacsy = {
5606
- "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
5607
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
5608
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
5609
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
5610
- };
5611
- keyMap.macDefault = {
5612
- "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
5613
- "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
5614
- "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
5615
- "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
5616
- "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
5617
- "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
5618
- "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
5619
- fallthrough: ["basic", "emacsy"]
5620
- };
5621
- keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
5622
-
5623
- // KEYMAP DISPATCH
5624
-
5625
- function normalizeKeyName(name) {
5626
- var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
5627
- var alt, ctrl, shift, cmd;
5628
- for (var i = 0; i < parts.length - 1; i++) {
5629
- var mod = parts[i];
5630
- if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
5631
- else if (/^a(lt)?$/i.test(mod)) alt = true;
5632
- else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
5633
- else if (/^s(hift)$/i.test(mod)) shift = true;
5634
- else throw new Error("Unrecognized modifier name: " + mod);
5635
- }
5636
- if (alt) name = "Alt-" + name;
5637
- if (ctrl) name = "Ctrl-" + name;
5638
- if (cmd) name = "Cmd-" + name;
5639
- if (shift) name = "Shift-" + name;
5640
- return name;
5641
- }
5642
-
5643
- // This is a kludge to keep keymaps mostly working as raw objects
5644
- // (backwards compatibility) while at the same time support features
5645
- // like normalization and multi-stroke key bindings. It compiles a
5646
- // new normalized keymap, and then updates the old object to reflect
5647
- // this.
5648
- CodeMirror.normalizeKeyMap = function(keymap) {
5649
- var copy = {};
5650
- for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
5651
- var value = keymap[keyname];
5652
- if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
5653
- if (value == "...") { delete keymap[keyname]; continue; }
5654
-
5655
- var keys = map(keyname.split(" "), normalizeKeyName);
5656
- for (var i = 0; i < keys.length; i++) {
5657
- var val, name;
5658
- if (i == keys.length - 1) {
5659
- name = keyname;
5660
- val = value;
5661
- } else {
5662
- name = keys.slice(0, i + 1).join(" ");
5663
- val = "...";
5664
- }
5665
- var prev = copy[name];
5666
- if (!prev) copy[name] = val;
5667
- else if (prev != val) throw new Error("Inconsistent bindings for " + name);
5668
- }
5669
- delete keymap[keyname];
5670
- }
5671
- for (var prop in copy) keymap[prop] = copy[prop];
5672
- return keymap;
5673
- };
5674
-
5675
- var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
5676
- map = getKeyMap(map);
5677
- var found = map.call ? map.call(key, context) : map[key];
5678
- if (found === false) return "nothing";
5679
- if (found === "...") return "multi";
5680
- if (found != null && handle(found)) return "handled";
5681
-
5682
- if (map.fallthrough) {
5683
- if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
5684
- return lookupKey(key, map.fallthrough, handle, context);
5685
- for (var i = 0; i < map.fallthrough.length; i++) {
5686
- var result = lookupKey(key, map.fallthrough[i], handle, context);
5687
- if (result) return result;
5688
- }
5689
- }
5690
- };
5691
-
5692
- // Modifier key presses don't count as 'real' key presses for the
5693
- // purpose of keymap fallthrough.
5694
- var isModifierKey = CodeMirror.isModifierKey = function(value) {
5695
- var name = typeof value == "string" ? value : keyNames[value.keyCode];
5696
- return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
5697
- };
5698
-
5699
- // Look up the name of a key as indicated by an event object.
5700
- var keyName = CodeMirror.keyName = function(event, noShift) {
5701
- if (presto && event.keyCode == 34 && event["char"]) return false;
5702
- var base = keyNames[event.keyCode], name = base;
5703
- if (name == null || event.altGraphKey) return false;
5704
- if (event.altKey && base != "Alt") name = "Alt-" + name;
5705
- if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
5706
- if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
5707
- if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
5708
- return name;
5709
- };
5710
-
5711
- function getKeyMap(val) {
5712
- return typeof val == "string" ? keyMap[val] : val;
5713
- }
5714
-
5715
- // FROMTEXTAREA
5716
-
5717
- CodeMirror.fromTextArea = function(textarea, options) {
5718
- options = options ? copyObj(options) : {};
5719
- options.value = textarea.value;
5720
- if (!options.tabindex && textarea.tabIndex)
5721
- options.tabindex = textarea.tabIndex;
5722
- if (!options.placeholder && textarea.placeholder)
5723
- options.placeholder = textarea.placeholder;
5724
- // Set autofocus to true if this textarea is focused, or if it has
5725
- // autofocus and no other element is focused.
5726
- if (options.autofocus == null) {
5727
- var hasFocus = activeElt();
5728
- options.autofocus = hasFocus == textarea ||
5729
- textarea.getAttribute("autofocus") != null && hasFocus == document.body;
5730
- }
5731
-
5732
- function save() {textarea.value = cm.getValue();}
5733
- if (textarea.form) {
5734
- on(textarea.form, "submit", save);
5735
- // Deplorable hack to make the submit method do the right thing.
5736
- if (!options.leaveSubmitMethodAlone) {
5737
- var form = textarea.form, realSubmit = form.submit;
5738
- try {
5739
- var wrappedSubmit = form.submit = function() {
5740
- save();
5741
- form.submit = realSubmit;
5742
- form.submit();
5743
- form.submit = wrappedSubmit;
5744
- };
5745
- } catch(e) {}
5746
- }
5747
- }
5748
-
5749
- options.finishInit = function(cm) {
5750
- cm.save = save;
5751
- cm.getTextArea = function() { return textarea; };
5752
- cm.toTextArea = function() {
5753
- cm.toTextArea = isNaN; // Prevent this from being ran twice
5754
- save();
5755
- textarea.parentNode.removeChild(cm.getWrapperElement());
5756
- textarea.style.display = "";
5757
- if (textarea.form) {
5758
- off(textarea.form, "submit", save);
5759
- if (typeof textarea.form.submit == "function")
5760
- textarea.form.submit = realSubmit;
5761
- }
5762
- };
5763
- };
5764
-
5765
- textarea.style.display = "none";
5766
- var cm = CodeMirror(function(node) {
5767
- textarea.parentNode.insertBefore(node, textarea.nextSibling);
5768
- }, options);
5769
- return cm;
5770
- };
5771
-
5772
- // STRING STREAM
5773
-
5774
- // Fed to the mode parsers, provides helper functions to make
5775
- // parsers more succinct.
5776
-
5777
- var StringStream = CodeMirror.StringStream = function(string, tabSize) {
5778
- this.pos = this.start = 0;
5779
- this.string = string;
5780
- this.tabSize = tabSize || 8;
5781
- this.lastColumnPos = this.lastColumnValue = 0;
5782
- this.lineStart = 0;
5783
- };
5784
-
5785
- StringStream.prototype = {
5786
- eol: function() {return this.pos >= this.string.length;},
5787
- sol: function() {return this.pos == this.lineStart;},
5788
- peek: function() {return this.string.charAt(this.pos) || undefined;},
5789
- next: function() {
5790
- if (this.pos < this.string.length)
5791
- return this.string.charAt(this.pos++);
5792
- },
5793
- eat: function(match) {
5794
- var ch = this.string.charAt(this.pos);
5795
- if (typeof match == "string") var ok = ch == match;
5796
- else var ok = ch && (match.test ? match.test(ch) : match(ch));
5797
- if (ok) {++this.pos; return ch;}
5798
- },
5799
- eatWhile: function(match) {
5800
- var start = this.pos;
5801
- while (this.eat(match)){}
5802
- return this.pos > start;
5803
- },
5804
- eatSpace: function() {
5805
- var start = this.pos;
5806
- while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
5807
- return this.pos > start;
5808
- },
5809
- skipToEnd: function() {this.pos = this.string.length;},
5810
- skipTo: function(ch) {
5811
- var found = this.string.indexOf(ch, this.pos);
5812
- if (found > -1) {this.pos = found; return true;}
5813
- },
5814
- backUp: function(n) {this.pos -= n;},
5815
- column: function() {
5816
- if (this.lastColumnPos < this.start) {
5817
- this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
5818
- this.lastColumnPos = this.start;
5819
- }
5820
- return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
5821
- },
5822
- indentation: function() {
5823
- return countColumn(this.string, null, this.tabSize) -
5824
- (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
5825
- },
5826
- match: function(pattern, consume, caseInsensitive) {
5827
- if (typeof pattern == "string") {
5828
- var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
5829
- var substr = this.string.substr(this.pos, pattern.length);
5830
- if (cased(substr) == cased(pattern)) {
5831
- if (consume !== false) this.pos += pattern.length;
5832
- return true;
5833
- }
5834
- } else {
5835
- var match = this.string.slice(this.pos).match(pattern);
5836
- if (match && match.index > 0) return null;
5837
- if (match && consume !== false) this.pos += match[0].length;
5838
- return match;
5839
- }
5840
- },
5841
- current: function(){return this.string.slice(this.start, this.pos);},
5842
- hideFirstChars: function(n, inner) {
5843
- this.lineStart += n;
5844
- try { return inner(); }
5845
- finally { this.lineStart -= n; }
5846
- }
5847
- };
5848
-
5849
- // TEXTMARKERS
5850
-
5851
- // Created with markText and setBookmark methods. A TextMarker is a
5852
- // handle that can be used to clear or find a marked position in the
5853
- // document. Line objects hold arrays (markedSpans) containing
5854
- // {from, to, marker} object pointing to such marker objects, and
5855
- // indicating that such a marker is present on that line. Multiple
5856
- // lines may point to the same marker when it spans across lines.
5857
- // The spans will have null for their from/to properties when the
5858
- // marker continues beyond the start/end of the line. Markers have
5859
- // links back to the lines they currently touch.
5860
-
5861
- var nextMarkerId = 0;
5862
-
5863
- var TextMarker = CodeMirror.TextMarker = function(doc, type) {
5864
- this.lines = [];
5865
- this.type = type;
5866
- this.doc = doc;
5867
- this.id = ++nextMarkerId;
5868
- };
5869
- eventMixin(TextMarker);
5870
-
5871
- // Clear the marker.
5872
- TextMarker.prototype.clear = function() {
5873
- if (this.explicitlyCleared) return;
5874
- var cm = this.doc.cm, withOp = cm && !cm.curOp;
5875
- if (withOp) startOperation(cm);
5876
- if (hasHandler(this, "clear")) {
5877
- var found = this.find();
5878
- if (found) signalLater(this, "clear", found.from, found.to);
5879
- }
5880
- var min = null, max = null;
5881
- for (var i = 0; i < this.lines.length; ++i) {
5882
- var line = this.lines[i];
5883
- var span = getMarkedSpanFor(line.markedSpans, this);
5884
- if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
5885
- else if (cm) {
5886
- if (span.to != null) max = lineNo(line);
5887
- if (span.from != null) min = lineNo(line);
5888
- }
5889
- line.markedSpans = removeMarkedSpan(line.markedSpans, span);
5890
- if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
5891
- updateLineHeight(line, textHeight(cm.display));
5892
- }
5893
- if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
5894
- var visual = visualLine(this.lines[i]), len = lineLength(visual);
5895
- if (len > cm.display.maxLineLength) {
5896
- cm.display.maxLine = visual;
5897
- cm.display.maxLineLength = len;
5898
- cm.display.maxLineChanged = true;
5899
- }
5900
- }
5901
-
5902
- if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
5903
- this.lines.length = 0;
5904
- this.explicitlyCleared = true;
5905
- if (this.atomic && this.doc.cantEdit) {
5906
- this.doc.cantEdit = false;
5907
- if (cm) reCheckSelection(cm.doc);
5908
- }
5909
- if (cm) signalLater(cm, "markerCleared", cm, this);
5910
- if (withOp) endOperation(cm);
5911
- if (this.parent) this.parent.clear();
5912
- };
5913
-
5914
- // Find the position of the marker in the document. Returns a {from,
5915
- // to} object by default. Side can be passed to get a specific side
5916
- // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
5917
- // Pos objects returned contain a line object, rather than a line
5918
- // number (used to prevent looking up the same line twice).
5919
- TextMarker.prototype.find = function(side, lineObj) {
5920
- if (side == null && this.type == "bookmark") side = 1;
5921
- var from, to;
5922
- for (var i = 0; i < this.lines.length; ++i) {
5923
- var line = this.lines[i];
5924
- var span = getMarkedSpanFor(line.markedSpans, this);
5925
- if (span.from != null) {
5926
- from = Pos(lineObj ? line : lineNo(line), span.from);
5927
- if (side == -1) return from;
5928
- }
5929
- if (span.to != null) {
5930
- to = Pos(lineObj ? line : lineNo(line), span.to);
5931
- if (side == 1) return to;
5932
- }
5933
- }
5934
- return from && {from: from, to: to};
5935
- };
5936
-
5937
- // Signals that the marker's widget changed, and surrounding layout
5938
- // should be recomputed.
5939
- TextMarker.prototype.changed = function() {
5940
- var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
5941
- if (!pos || !cm) return;
5942
- runInOp(cm, function() {
5943
- var line = pos.line, lineN = lineNo(pos.line);
5944
- var view = findViewForLine(cm, lineN);
5945
- if (view) {
5946
- clearLineMeasurementCacheFor(view);
5947
- cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
5948
- }
5949
- cm.curOp.updateMaxLine = true;
5950
- if (!lineIsHidden(widget.doc, line) && widget.height != null) {
5951
- var oldHeight = widget.height;
5952
- widget.height = null;
5953
- var dHeight = widgetHeight(widget) - oldHeight;
5954
- if (dHeight)
5955
- updateLineHeight(line, line.height + dHeight);
5956
- }
5957
- });
5958
- };
5959
-
5960
- TextMarker.prototype.attachLine = function(line) {
5961
- if (!this.lines.length && this.doc.cm) {
5962
- var op = this.doc.cm.curOp;
5963
- if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
5964
- (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
5965
- }
5966
- this.lines.push(line);
5967
- };
5968
- TextMarker.prototype.detachLine = function(line) {
5969
- this.lines.splice(indexOf(this.lines, line), 1);
5970
- if (!this.lines.length && this.doc.cm) {
5971
- var op = this.doc.cm.curOp;
5972
- (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
5973
- }
5974
- };
5975
-
5976
- // Collapsed markers have unique ids, in order to be able to order
5977
- // them, which is needed for uniquely determining an outer marker
5978
- // when they overlap (they may nest, but not partially overlap).
5979
- var nextMarkerId = 0;
5980
-
5981
- // Create a marker, wire it up to the right lines, and
5982
- function markText(doc, from, to, options, type) {
5983
- // Shared markers (across linked documents) are handled separately
5984
- // (markTextShared will call out to this again, once per
5985
- // document).
5986
- if (options && options.shared) return markTextShared(doc, from, to, options, type);
5987
- // Ensure we are in an operation.
5988
- if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
5989
-
5990
- var marker = new TextMarker(doc, type), diff = cmp(from, to);
5991
- if (options) copyObj(options, marker, false);
5992
- // Don't connect empty markers unless clearWhenEmpty is false
5993
- if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
5994
- return marker;
5995
- if (marker.replacedWith) {
5996
- // Showing up as a widget implies collapsed (widget replaces text)
5997
- marker.collapsed = true;
5998
- marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
5999
- if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
6000
- if (options.insertLeft) marker.widgetNode.insertLeft = true;
6001
- }
6002
- if (marker.collapsed) {
6003
- if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
6004
- from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
6005
- throw new Error("Inserting collapsed marker partially overlapping an existing one");
6006
- sawCollapsedSpans = true;
6007
- }
6008
-
6009
- if (marker.addToHistory)
6010
- addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
6011
-
6012
- var curLine = from.line, cm = doc.cm, updateMaxLine;
6013
- doc.iter(curLine, to.line + 1, function(line) {
6014
- if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
6015
- updateMaxLine = true;
6016
- if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
6017
- addMarkedSpan(line, new MarkedSpan(marker,
6018
- curLine == from.line ? from.ch : null,
6019
- curLine == to.line ? to.ch : null));
6020
- ++curLine;
6021
- });
6022
- // lineIsHidden depends on the presence of the spans, so needs a second pass
6023
- if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
6024
- if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
6025
- });
6026
-
6027
- if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
6028
-
6029
- if (marker.readOnly) {
6030
- sawReadOnlySpans = true;
6031
- if (doc.history.done.length || doc.history.undone.length)
6032
- doc.clearHistory();
6033
- }
6034
- if (marker.collapsed) {
6035
- marker.id = ++nextMarkerId;
6036
- marker.atomic = true;
6037
- }
6038
- if (cm) {
6039
- // Sync editor state
6040
- if (updateMaxLine) cm.curOp.updateMaxLine = true;
6041
- if (marker.collapsed)
6042
- regChange(cm, from.line, to.line + 1);
6043
- else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
6044
- for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
6045
- if (marker.atomic) reCheckSelection(cm.doc);
6046
- signalLater(cm, "markerAdded", cm, marker);
6047
- }
6048
- return marker;
6049
- }
6050
-
6051
- // SHARED TEXTMARKERS
6052
-
6053
- // A shared marker spans multiple linked documents. It is
6054
- // implemented as a meta-marker-object controlling multiple normal
6055
- // markers.
6056
- var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
6057
- this.markers = markers;
6058
- this.primary = primary;
6059
- for (var i = 0; i < markers.length; ++i)
6060
- markers[i].parent = this;
6061
- };
6062
- eventMixin(SharedTextMarker);
6063
-
6064
- SharedTextMarker.prototype.clear = function() {
6065
- if (this.explicitlyCleared) return;
6066
- this.explicitlyCleared = true;
6067
- for (var i = 0; i < this.markers.length; ++i)
6068
- this.markers[i].clear();
6069
- signalLater(this, "clear");
6070
- };
6071
- SharedTextMarker.prototype.find = function(side, lineObj) {
6072
- return this.primary.find(side, lineObj);
6073
- };
6074
-
6075
- function markTextShared(doc, from, to, options, type) {
6076
- options = copyObj(options);
6077
- options.shared = false;
6078
- var markers = [markText(doc, from, to, options, type)], primary = markers[0];
6079
- var widget = options.widgetNode;
6080
- linkedDocs(doc, function(doc) {
6081
- if (widget) options.widgetNode = widget.cloneNode(true);
6082
- markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
6083
- for (var i = 0; i < doc.linked.length; ++i)
6084
- if (doc.linked[i].isParent) return;
6085
- primary = lst(markers);
6086
- });
6087
- return new SharedTextMarker(markers, primary);
6088
- }
6089
-
6090
- function findSharedMarkers(doc) {
6091
- return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
6092
- function(m) { return m.parent; });
6093
- }
6094
-
6095
- function copySharedMarkers(doc, markers) {
6096
- for (var i = 0; i < markers.length; i++) {
6097
- var marker = markers[i], pos = marker.find();
6098
- var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
6099
- if (cmp(mFrom, mTo)) {
6100
- var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
6101
- marker.markers.push(subMark);
6102
- subMark.parent = marker;
6103
- }
6104
- }
6105
- }
6106
-
6107
- function detachSharedMarkers(markers) {
6108
- for (var i = 0; i < markers.length; i++) {
6109
- var marker = markers[i], linked = [marker.primary.doc];;
6110
- linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
6111
- for (var j = 0; j < marker.markers.length; j++) {
6112
- var subMarker = marker.markers[j];
6113
- if (indexOf(linked, subMarker.doc) == -1) {
6114
- subMarker.parent = null;
6115
- marker.markers.splice(j--, 1);
6116
- }
6117
- }
6118
- }
6119
- }
6120
-
6121
- // TEXTMARKER SPANS
6122
-
6123
- function MarkedSpan(marker, from, to) {
6124
- this.marker = marker;
6125
- this.from = from; this.to = to;
6126
- }
6127
-
6128
- // Search an array of spans for a span matching the given marker.
6129
- function getMarkedSpanFor(spans, marker) {
6130
- if (spans) for (var i = 0; i < spans.length; ++i) {
6131
- var span = spans[i];
6132
- if (span.marker == marker) return span;
6133
- }
6134
- }
6135
- // Remove a span from an array, returning undefined if no spans are
6136
- // left (we don't store arrays for lines without spans).
6137
- function removeMarkedSpan(spans, span) {
6138
- for (var r, i = 0; i < spans.length; ++i)
6139
- if (spans[i] != span) (r || (r = [])).push(spans[i]);
6140
- return r;
6141
- }
6142
- // Add a span to a line.
6143
- function addMarkedSpan(line, span) {
6144
- line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
6145
- span.marker.attachLine(line);
6146
- }
6147
-
6148
- // Used for the algorithm that adjusts markers for a change in the
6149
- // document. These functions cut an array of spans at a given
6150
- // character position, returning an array of remaining chunks (or
6151
- // undefined if nothing remains).
6152
- function markedSpansBefore(old, startCh, isInsert) {
6153
- if (old) for (var i = 0, nw; i < old.length; ++i) {
6154
- var span = old[i], marker = span.marker;
6155
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
6156
- if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
6157
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
6158
- (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
6159
- }
6160
- }
6161
- return nw;
6162
- }
6163
- function markedSpansAfter(old, endCh, isInsert) {
6164
- if (old) for (var i = 0, nw; i < old.length; ++i) {
6165
- var span = old[i], marker = span.marker;
6166
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
6167
- if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
6168
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
6169
- (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
6170
- span.to == null ? null : span.to - endCh));
6171
- }
6172
- }
6173
- return nw;
6174
- }
6175
-
6176
- // Given a change object, compute the new set of marker spans that
6177
- // cover the line in which the change took place. Removes spans
6178
- // entirely within the change, reconnects spans belonging to the
6179
- // same marker that appear on both sides of the change, and cuts off
6180
- // spans partially within the change. Returns an array of span
6181
- // arrays with one element for each line in (after) the change.
6182
- function stretchSpansOverChange(doc, change) {
6183
- if (change.full) return null;
6184
- var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
6185
- var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
6186
- if (!oldFirst && !oldLast) return null;
6187
-
6188
- var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
6189
- // Get the spans that 'stick out' on both sides
6190
- var first = markedSpansBefore(oldFirst, startCh, isInsert);
6191
- var last = markedSpansAfter(oldLast, endCh, isInsert);
6192
-
6193
- // Next, merge those two ends
6194
- var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
6195
- if (first) {
6196
- // Fix up .to properties of first
6197
- for (var i = 0; i < first.length; ++i) {
6198
- var span = first[i];
6199
- if (span.to == null) {
6200
- var found = getMarkedSpanFor(last, span.marker);
6201
- if (!found) span.to = startCh;
6202
- else if (sameLine) span.to = found.to == null ? null : found.to + offset;
6203
- }
6204
- }
6205
- }
6206
- if (last) {
6207
- // Fix up .from in last (or move them into first in case of sameLine)
6208
- for (var i = 0; i < last.length; ++i) {
6209
- var span = last[i];
6210
- if (span.to != null) span.to += offset;
6211
- if (span.from == null) {
6212
- var found = getMarkedSpanFor(first, span.marker);
6213
- if (!found) {
6214
- span.from = offset;
6215
- if (sameLine) (first || (first = [])).push(span);
6216
- }
6217
- } else {
6218
- span.from += offset;
6219
- if (sameLine) (first || (first = [])).push(span);
6220
- }
6221
- }
6222
- }
6223
- // Make sure we didn't create any zero-length spans
6224
- if (first) first = clearEmptySpans(first);
6225
- if (last && last != first) last = clearEmptySpans(last);
6226
-
6227
- var newMarkers = [first];
6228
- if (!sameLine) {
6229
- // Fill gap with whole-line-spans
6230
- var gap = change.text.length - 2, gapMarkers;
6231
- if (gap > 0 && first)
6232
- for (var i = 0; i < first.length; ++i)
6233
- if (first[i].to == null)
6234
- (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
6235
- for (var i = 0; i < gap; ++i)
6236
- newMarkers.push(gapMarkers);
6237
- newMarkers.push(last);
6238
- }
6239
- return newMarkers;
6240
- }
6241
-
6242
- // Remove spans that are empty and don't have a clearWhenEmpty
6243
- // option of false.
6244
- function clearEmptySpans(spans) {
6245
- for (var i = 0; i < spans.length; ++i) {
6246
- var span = spans[i];
6247
- if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
6248
- spans.splice(i--, 1);
6249
- }
6250
- if (!spans.length) return null;
6251
- return spans;
6252
- }
6253
-
6254
- // Used for un/re-doing changes from the history. Combines the
6255
- // result of computing the existing spans with the set of spans that
6256
- // existed in the history (so that deleting around a span and then
6257
- // undoing brings back the span).
6258
- function mergeOldSpans(doc, change) {
6259
- var old = getOldSpans(doc, change);
6260
- var stretched = stretchSpansOverChange(doc, change);
6261
- if (!old) return stretched;
6262
- if (!stretched) return old;
6263
-
6264
- for (var i = 0; i < old.length; ++i) {
6265
- var oldCur = old[i], stretchCur = stretched[i];
6266
- if (oldCur && stretchCur) {
6267
- spans: for (var j = 0; j < stretchCur.length; ++j) {
6268
- var span = stretchCur[j];
6269
- for (var k = 0; k < oldCur.length; ++k)
6270
- if (oldCur[k].marker == span.marker) continue spans;
6271
- oldCur.push(span);
6272
- }
6273
- } else if (stretchCur) {
6274
- old[i] = stretchCur;
6275
- }
6276
- }
6277
- return old;
6278
- }
6279
-
6280
- // Used to 'clip' out readOnly ranges when making a change.
6281
- function removeReadOnlyRanges(doc, from, to) {
6282
- var markers = null;
6283
- doc.iter(from.line, to.line + 1, function(line) {
6284
- if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
6285
- var mark = line.markedSpans[i].marker;
6286
- if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
6287
- (markers || (markers = [])).push(mark);
6288
- }
6289
- });
6290
- if (!markers) return null;
6291
- var parts = [{from: from, to: to}];
6292
- for (var i = 0; i < markers.length; ++i) {
6293
- var mk = markers[i], m = mk.find(0);
6294
- for (var j = 0; j < parts.length; ++j) {
6295
- var p = parts[j];
6296
- if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
6297
- var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
6298
- if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
6299
- newParts.push({from: p.from, to: m.from});
6300
- if (dto > 0 || !mk.inclusiveRight && !dto)
6301
- newParts.push({from: m.to, to: p.to});
6302
- parts.splice.apply(parts, newParts);
6303
- j += newParts.length - 1;
6304
- }
6305
- }
6306
- return parts;
6307
- }
6308
-
6309
- // Connect or disconnect spans from a line.
6310
- function detachMarkedSpans(line) {
6311
- var spans = line.markedSpans;
6312
- if (!spans) return;
6313
- for (var i = 0; i < spans.length; ++i)
6314
- spans[i].marker.detachLine(line);
6315
- line.markedSpans = null;
6316
- }
6317
- function attachMarkedSpans(line, spans) {
6318
- if (!spans) return;
6319
- for (var i = 0; i < spans.length; ++i)
6320
- spans[i].marker.attachLine(line);
6321
- line.markedSpans = spans;
6322
- }
6323
-
6324
- // Helpers used when computing which overlapping collapsed span
6325
- // counts as the larger one.
6326
- function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
6327
- function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
6328
-
6329
- // Returns a number indicating which of two overlapping collapsed
6330
- // spans is larger (and thus includes the other). Falls back to
6331
- // comparing ids when the spans cover exactly the same range.
6332
- function compareCollapsedMarkers(a, b) {
6333
- var lenDiff = a.lines.length - b.lines.length;
6334
- if (lenDiff != 0) return lenDiff;
6335
- var aPos = a.find(), bPos = b.find();
6336
- var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
6337
- if (fromCmp) return -fromCmp;
6338
- var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
6339
- if (toCmp) return toCmp;
6340
- return b.id - a.id;
6341
- }
6342
-
6343
- // Find out whether a line ends or starts in a collapsed span. If
6344
- // so, return the marker for that span.
6345
- function collapsedSpanAtSide(line, start) {
6346
- var sps = sawCollapsedSpans && line.markedSpans, found;
6347
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
6348
- sp = sps[i];
6349
- if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
6350
- (!found || compareCollapsedMarkers(found, sp.marker) < 0))
6351
- found = sp.marker;
6352
- }
6353
- return found;
6354
- }
6355
- function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
6356
- function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
6357
-
6358
- // Test whether there exists a collapsed span that partially
6359
- // overlaps (covers the start or end, but not both) of a new span.
6360
- // Such overlap is not allowed.
6361
- function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
6362
- var line = getLine(doc, lineNo);
6363
- var sps = sawCollapsedSpans && line.markedSpans;
6364
- if (sps) for (var i = 0; i < sps.length; ++i) {
6365
- var sp = sps[i];
6366
- if (!sp.marker.collapsed) continue;
6367
- var found = sp.marker.find(0);
6368
- var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
6369
- var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
6370
- if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
6371
- if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
6372
- fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
6373
- return true;
6374
- }
6375
- }
6376
-
6377
- // A visual line is a line as drawn on the screen. Folding, for
6378
- // example, can cause multiple logical lines to appear on the same
6379
- // visual line. This finds the start of the visual line that the
6380
- // given line is part of (usually that is the line itself).
6381
- function visualLine(line) {
6382
- var merged;
6383
- while (merged = collapsedSpanAtStart(line))
6384
- line = merged.find(-1, true).line;
6385
- return line;
6386
- }
6387
-
6388
- // Returns an array of logical lines that continue the visual line
6389
- // started by the argument, or undefined if there are no such lines.
6390
- function visualLineContinued(line) {
6391
- var merged, lines;
6392
- while (merged = collapsedSpanAtEnd(line)) {
6393
- line = merged.find(1, true).line;
6394
- (lines || (lines = [])).push(line);
6395
- }
6396
- return lines;
6397
- }
6398
-
6399
- // Get the line number of the start of the visual line that the
6400
- // given line number is part of.
6401
- function visualLineNo(doc, lineN) {
6402
- var line = getLine(doc, lineN), vis = visualLine(line);
6403
- if (line == vis) return lineN;
6404
- return lineNo(vis);
6405
- }
6406
- // Get the line number of the start of the next visual line after
6407
- // the given line.
6408
- function visualLineEndNo(doc, lineN) {
6409
- if (lineN > doc.lastLine()) return lineN;
6410
- var line = getLine(doc, lineN), merged;
6411
- if (!lineIsHidden(doc, line)) return lineN;
6412
- while (merged = collapsedSpanAtEnd(line))
6413
- line = merged.find(1, true).line;
6414
- return lineNo(line) + 1;
6415
- }
6416
-
6417
- // Compute whether a line is hidden. Lines count as hidden when they
6418
- // are part of a visual line that starts with another line, or when
6419
- // they are entirely covered by collapsed, non-widget span.
6420
- function lineIsHidden(doc, line) {
6421
- var sps = sawCollapsedSpans && line.markedSpans;
6422
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
6423
- sp = sps[i];
6424
- if (!sp.marker.collapsed) continue;
6425
- if (sp.from == null) return true;
6426
- if (sp.marker.widgetNode) continue;
6427
- if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
6428
- return true;
6429
- }
6430
- }
6431
- function lineIsHiddenInner(doc, line, span) {
6432
- if (span.to == null) {
6433
- var end = span.marker.find(1, true);
6434
- return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
6435
- }
6436
- if (span.marker.inclusiveRight && span.to == line.text.length)
6437
- return true;
6438
- for (var sp, i = 0; i < line.markedSpans.length; ++i) {
6439
- sp = line.markedSpans[i];
6440
- if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
6441
- (sp.to == null || sp.to != span.from) &&
6442
- (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
6443
- lineIsHiddenInner(doc, line, sp)) return true;
6444
- }
6445
- }
6446
-
6447
- // LINE WIDGETS
6448
-
6449
- // Line widgets are block elements displayed above or below a line.
6450
-
6451
- var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
6452
- if (options) for (var opt in options) if (options.hasOwnProperty(opt))
6453
- this[opt] = options[opt];
6454
- this.cm = cm;
6455
- this.node = node;
6456
- };
6457
- eventMixin(LineWidget);
6458
-
6459
- function adjustScrollWhenAboveVisible(cm, line, diff) {
6460
- if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
6461
- addToScrollPos(cm, null, diff);
6462
- }
6463
-
6464
- LineWidget.prototype.clear = function() {
6465
- var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
6466
- if (no == null || !ws) return;
6467
- for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
6468
- if (!ws.length) line.widgets = null;
6469
- var height = widgetHeight(this);
6470
- runInOp(cm, function() {
6471
- adjustScrollWhenAboveVisible(cm, line, -height);
6472
- regLineChange(cm, no, "widget");
6473
- updateLineHeight(line, Math.max(0, line.height - height));
6474
- });
6475
- };
6476
- LineWidget.prototype.changed = function() {
6477
- var oldH = this.height, cm = this.cm, line = this.line;
6478
- this.height = null;
6479
- var diff = widgetHeight(this) - oldH;
6480
- if (!diff) return;
6481
- runInOp(cm, function() {
6482
- cm.curOp.forceUpdate = true;
6483
- adjustScrollWhenAboveVisible(cm, line, diff);
6484
- updateLineHeight(line, line.height + diff);
6485
- });
6486
- };
6487
-
6488
- function widgetHeight(widget) {
6489
- if (widget.height != null) return widget.height;
6490
- if (!contains(document.body, widget.node)) {
6491
- var parentStyle = "position: relative;";
6492
- if (widget.coverGutter)
6493
- parentStyle += "margin-left: -" + widget.cm.display.gutters.offsetWidth + "px;";
6494
- if (widget.noHScroll)
6495
- parentStyle += "width: " + widget.cm.display.wrapper.clientWidth + "px;";
6496
- removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, parentStyle));
6497
- }
6498
- return widget.height = widget.node.offsetHeight;
6499
- }
6500
-
6501
- function addLineWidget(cm, handle, node, options) {
6502
- var widget = new LineWidget(cm, node, options);
6503
- if (widget.noHScroll) cm.display.alignWidgets = true;
6504
- changeLine(cm.doc, handle, "widget", function(line) {
6505
- var widgets = line.widgets || (line.widgets = []);
6506
- if (widget.insertAt == null) widgets.push(widget);
6507
- else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
6508
- widget.line = line;
6509
- if (!lineIsHidden(cm.doc, line)) {
6510
- var aboveVisible = heightAtLine(line) < cm.doc.scrollTop;
6511
- updateLineHeight(line, line.height + widgetHeight(widget));
6512
- if (aboveVisible) addToScrollPos(cm, null, widget.height);
6513
- cm.curOp.forceUpdate = true;
6514
- }
6515
- return true;
6516
- });
6517
- return widget;
6518
- }
6519
-
6520
- // LINE DATA STRUCTURE
6521
-
6522
- // Line objects. These hold state related to a line, including
6523
- // highlighting info (the styles array).
6524
- var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
6525
- this.text = text;
6526
- attachMarkedSpans(this, markedSpans);
6527
- this.height = estimateHeight ? estimateHeight(this) : 1;
6528
- };
6529
- eventMixin(Line);
6530
- Line.prototype.lineNo = function() { return lineNo(this); };
6531
-
6532
- // Change the content (text, markers) of a line. Automatically
6533
- // invalidates cached information and tries to re-estimate the
6534
- // line's height.
6535
- function updateLine(line, text, markedSpans, estimateHeight) {
6536
- line.text = text;
6537
- if (line.stateAfter) line.stateAfter = null;
6538
- if (line.styles) line.styles = null;
6539
- if (line.order != null) line.order = null;
6540
- detachMarkedSpans(line);
6541
- attachMarkedSpans(line, markedSpans);
6542
- var estHeight = estimateHeight ? estimateHeight(line) : 1;
6543
- if (estHeight != line.height) updateLineHeight(line, estHeight);
6544
- }
6545
-
6546
- // Detach a line from the document tree and its markers.
6547
- function cleanUpLine(line) {
6548
- line.parent = null;
6549
- detachMarkedSpans(line);
6550
- }
6551
-
6552
- function extractLineClasses(type, output) {
6553
- if (type) for (;;) {
6554
- var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
6555
- if (!lineClass) break;
6556
- type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
6557
- var prop = lineClass[1] ? "bgClass" : "textClass";
6558
- if (output[prop] == null)
6559
- output[prop] = lineClass[2];
6560
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
6561
- output[prop] += " " + lineClass[2];
6562
- }
6563
- return type;
6564
- }
6565
-
6566
- function callBlankLine(mode, state) {
6567
- if (mode.blankLine) return mode.blankLine(state);
6568
- if (!mode.innerMode) return;
6569
- var inner = CodeMirror.innerMode(mode, state);
6570
- if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
6571
- }
6572
-
6573
- function readToken(mode, stream, state, inner) {
6574
- for (var i = 0; i < 10; i++) {
6575
- if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
6576
- var style = mode.token(stream, state);
6577
- if (stream.pos > stream.start) return style;
6578
- }
6579
- throw new Error("Mode " + mode.name + " failed to advance stream.");
6580
- }
6581
-
6582
- // Utility for getTokenAt and getLineTokens
6583
- function takeToken(cm, pos, precise, asArray) {
6584
- function getObj(copy) {
6585
- return {start: stream.start, end: stream.pos,
6586
- string: stream.current(),
6587
- type: style || null,
6588
- state: copy ? copyState(doc.mode, state) : state};
6589
- }
6590
-
6591
- var doc = cm.doc, mode = doc.mode, style;
6592
- pos = clipPos(doc, pos);
6593
- var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
6594
- var stream = new StringStream(line.text, cm.options.tabSize), tokens;
6595
- if (asArray) tokens = [];
6596
- while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
6597
- stream.start = stream.pos;
6598
- style = readToken(mode, stream, state);
6599
- if (asArray) tokens.push(getObj(true));
6600
- }
6601
- return asArray ? tokens : getObj();
6602
- }
6603
-
6604
- // Run the given mode's parser over a line, calling f for each token.
6605
- function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
6606
- var flattenSpans = mode.flattenSpans;
6607
- if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
6608
- var curStart = 0, curStyle = null;
6609
- var stream = new StringStream(text, cm.options.tabSize), style;
6610
- var inner = cm.options.addModeClass && [null];
6611
- if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
6612
- while (!stream.eol()) {
6613
- if (stream.pos > cm.options.maxHighlightLength) {
6614
- flattenSpans = false;
6615
- if (forceToEnd) processLine(cm, text, state, stream.pos);
6616
- stream.pos = text.length;
6617
- style = null;
6618
- } else {
6619
- style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
6620
- }
6621
- if (inner) {
6622
- var mName = inner[0].name;
6623
- if (mName) style = "m-" + (style ? mName + " " + style : mName);
6624
- }
6625
- if (!flattenSpans || curStyle != style) {
6626
- while (curStart < stream.start) {
6627
- curStart = Math.min(stream.start, curStart + 50000);
6628
- f(curStart, curStyle);
6629
- }
6630
- curStyle = style;
6631
- }
6632
- stream.start = stream.pos;
6633
- }
6634
- while (curStart < stream.pos) {
6635
- // Webkit seems to refuse to render text nodes longer than 57444 characters
6636
- var pos = Math.min(stream.pos, curStart + 50000);
6637
- f(pos, curStyle);
6638
- curStart = pos;
6639
- }
6640
- }
6641
-
6642
- // Compute a style array (an array starting with a mode generation
6643
- // -- for invalidation -- followed by pairs of end positions and
6644
- // style strings), which is used to highlight the tokens on the
6645
- // line.
6646
- function highlightLine(cm, line, state, forceToEnd) {
6647
- // A styles array always starts with a number identifying the
6648
- // mode/overlays that it is based on (for easy invalidation).
6649
- var st = [cm.state.modeGen], lineClasses = {};
6650
- // Compute the base array of styles
6651
- runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
6652
- st.push(end, style);
6653
- }, lineClasses, forceToEnd);
6654
-
6655
- // Run overlays, adjust style array.
6656
- for (var o = 0; o < cm.state.overlays.length; ++o) {
6657
- var overlay = cm.state.overlays[o], i = 1, at = 0;
6658
- runMode(cm, line.text, overlay.mode, true, function(end, style) {
6659
- var start = i;
6660
- // Ensure there's a token end at the current position, and that i points at it
6661
- while (at < end) {
6662
- var i_end = st[i];
6663
- if (i_end > end)
6664
- st.splice(i, 1, end, st[i+1], i_end);
6665
- i += 2;
6666
- at = Math.min(end, i_end);
6667
- }
6668
- if (!style) return;
6669
- if (overlay.opaque) {
6670
- st.splice(start, i - start, end, "cm-overlay " + style);
6671
- i = start + 2;
6672
- } else {
6673
- for (; start < i; start += 2) {
6674
- var cur = st[start+1];
6675
- st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
6676
- }
6677
- }
6678
- }, lineClasses);
6679
- }
6680
-
6681
- return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
6682
- }
6683
-
6684
- function getLineStyles(cm, line, updateFrontier) {
6685
- if (!line.styles || line.styles[0] != cm.state.modeGen) {
6686
- var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
6687
- line.styles = result.styles;
6688
- if (result.classes) line.styleClasses = result.classes;
6689
- else if (line.styleClasses) line.styleClasses = null;
6690
- if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
6691
- }
6692
- return line.styles;
6693
- }
6694
-
6695
- // Lightweight form of highlight -- proceed over this line and
6696
- // update state, but don't save a style array. Used for lines that
6697
- // aren't currently visible.
6698
- function processLine(cm, text, state, startAt) {
6699
- var mode = cm.doc.mode;
6700
- var stream = new StringStream(text, cm.options.tabSize);
6701
- stream.start = stream.pos = startAt || 0;
6702
- if (text == "") callBlankLine(mode, state);
6703
- while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
6704
- readToken(mode, stream, state);
6705
- stream.start = stream.pos;
6706
- }
6707
- }
6708
-
6709
- // Convert a style as returned by a mode (either null, or a string
6710
- // containing one or more styles) to a CSS style. This is cached,
6711
- // and also looks for line-wide styles.
6712
- var styleToClassCache = {}, styleToClassCacheWithMode = {};
6713
- function interpretTokenStyle(style, options) {
6714
- if (!style || /^\s*$/.test(style)) return null;
6715
- var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
6716
- return cache[style] ||
6717
- (cache[style] = style.replace(/\S+/g, "cm-$&"));
6718
- }
6719
-
6720
- // Render the DOM representation of the text of a line. Also builds
6721
- // up a 'line map', which points at the DOM nodes that represent
6722
- // specific stretches of text, and is used by the measuring code.
6723
- // The returned object contains the DOM node, this map, and
6724
- // information about line-wide styles that were set by the mode.
6725
- function buildLineContent(cm, lineView) {
6726
- // The padding-right forces the element to have a 'border', which
6727
- // is needed on Webkit to be able to get line-level bounding
6728
- // rectangles for it (in measureChar).
6729
- var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
6730
- var builder = {pre: elt("pre", [content]), content: content,
6731
- col: 0, pos: 0, cm: cm,
6732
- splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
6733
- lineView.measure = {};
6734
-
6735
- // Iterate over the logical lines that make up this visual line.
6736
- for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
6737
- var line = i ? lineView.rest[i - 1] : lineView.line, order;
6738
- builder.pos = 0;
6739
- builder.addToken = buildToken;
6740
- // Optionally wire in some hacks into the token-rendering
6741
- // algorithm, to deal with browser quirks.
6742
- if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
6743
- builder.addToken = buildTokenBadBidi(builder.addToken, order);
6744
- builder.map = [];
6745
- var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
6746
- insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
6747
- if (line.styleClasses) {
6748
- if (line.styleClasses.bgClass)
6749
- builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
6750
- if (line.styleClasses.textClass)
6751
- builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
6752
- }
6753
-
6754
- // Ensure at least a single node is present, for measuring.
6755
- if (builder.map.length == 0)
6756
- builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
6757
-
6758
- // Store the map and a cache object for the current logical line
6759
- if (i == 0) {
6760
- lineView.measure.map = builder.map;
6761
- lineView.measure.cache = {};
6762
- } else {
6763
- (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
6764
- (lineView.measure.caches || (lineView.measure.caches = [])).push({});
6765
- }
6766
- }
6767
-
6768
- // See issue #2901
6769
- if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
6770
- builder.content.className = "cm-tab-wrap-hack";
6771
-
6772
- signal(cm, "renderLine", cm, lineView.line, builder.pre);
6773
- if (builder.pre.className)
6774
- builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
6775
-
6776
- return builder;
6777
- }
6778
-
6779
- function defaultSpecialCharPlaceholder(ch) {
6780
- var token = elt("span", "\u2022", "cm-invalidchar");
6781
- token.title = "\\u" + ch.charCodeAt(0).toString(16);
6782
- token.setAttribute("aria-label", token.title);
6783
- return token;
6784
- }
6785
-
6786
- // Build up the DOM representation for a single token, and add it to
6787
- // the line map. Takes care to render special characters separately.
6788
- function buildToken(builder, text, style, startStyle, endStyle, title, css) {
6789
- if (!text) return;
6790
- var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text;
6791
- var special = builder.cm.state.specialChars, mustWrap = false;
6792
- if (!special.test(text)) {
6793
- builder.col += text.length;
6794
- var content = document.createTextNode(displayText);
6795
- builder.map.push(builder.pos, builder.pos + text.length, content);
6796
- if (ie && ie_version < 9) mustWrap = true;
6797
- builder.pos += text.length;
6798
- } else {
6799
- var content = document.createDocumentFragment(), pos = 0;
6800
- while (true) {
6801
- special.lastIndex = pos;
6802
- var m = special.exec(text);
6803
- var skipped = m ? m.index - pos : text.length - pos;
6804
- if (skipped) {
6805
- var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
6806
- if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
6807
- else content.appendChild(txt);
6808
- builder.map.push(builder.pos, builder.pos + skipped, txt);
6809
- builder.col += skipped;
6810
- builder.pos += skipped;
6811
- }
6812
- if (!m) break;
6813
- pos += skipped + 1;
6814
- if (m[0] == "\t") {
6815
- var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
6816
- var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
6817
- txt.setAttribute("role", "presentation");
6818
- txt.setAttribute("cm-text", "\t");
6819
- builder.col += tabWidth;
6820
- } else {
6821
- var txt = builder.cm.options.specialCharPlaceholder(m[0]);
6822
- txt.setAttribute("cm-text", m[0]);
6823
- if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
6824
- else content.appendChild(txt);
6825
- builder.col += 1;
6826
- }
6827
- builder.map.push(builder.pos, builder.pos + 1, txt);
6828
- builder.pos++;
6829
- }
6830
- }
6831
- if (style || startStyle || endStyle || mustWrap || css) {
6832
- var fullStyle = style || "";
6833
- if (startStyle) fullStyle += startStyle;
6834
- if (endStyle) fullStyle += endStyle;
6835
- var token = elt("span", [content], fullStyle, css);
6836
- if (title) token.title = title;
6837
- return builder.content.appendChild(token);
6838
- }
6839
- builder.content.appendChild(content);
6840
- }
6841
-
6842
- function splitSpaces(old) {
6843
- var out = " ";
6844
- for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
6845
- out += " ";
6846
- return out;
6847
- }
6848
-
6849
- // Work around nonsense dimensions being reported for stretches of
6850
- // right-to-left text.
6851
- function buildTokenBadBidi(inner, order) {
6852
- return function(builder, text, style, startStyle, endStyle, title, css) {
6853
- style = style ? style + " cm-force-border" : "cm-force-border";
6854
- var start = builder.pos, end = start + text.length;
6855
- for (;;) {
6856
- // Find the part that overlaps with the start of this text
6857
- for (var i = 0; i < order.length; i++) {
6858
- var part = order[i];
6859
- if (part.to > start && part.from <= start) break;
6860
- }
6861
- if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css);
6862
- inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
6863
- startStyle = null;
6864
- text = text.slice(part.to - start);
6865
- start = part.to;
6866
- }
6867
- };
6868
- }
6869
-
6870
- function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
6871
- var widget = !ignoreWidget && marker.widgetNode;
6872
- if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
6873
- if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
6874
- if (!widget)
6875
- widget = builder.content.appendChild(document.createElement("span"));
6876
- widget.setAttribute("cm-marker", marker.id);
6877
- }
6878
- if (widget) {
6879
- builder.cm.display.input.setUneditable(widget);
6880
- builder.content.appendChild(widget);
6881
- }
6882
- builder.pos += size;
6883
- }
6884
-
6885
- // Outputs a number of spans to make up a line, taking highlighting
6886
- // and marked text into account.
6887
- function insertLineContent(line, builder, styles) {
6888
- var spans = line.markedSpans, allText = line.text, at = 0;
6889
- if (!spans) {
6890
- for (var i = 1; i < styles.length; i+=2)
6891
- builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
6892
- return;
6893
- }
6894
-
6895
- var len = allText.length, pos = 0, i = 1, text = "", style, css;
6896
- var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
6897
- for (;;) {
6898
- if (nextChange == pos) { // Update current marker set
6899
- spanStyle = spanEndStyle = spanStartStyle = title = css = "";
6900
- collapsed = null; nextChange = Infinity;
6901
- var foundBookmarks = [];
6902
- for (var j = 0; j < spans.length; ++j) {
6903
- var sp = spans[j], m = sp.marker;
6904
- if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
6905
- if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
6906
- if (m.className) spanStyle += " " + m.className;
6907
- if (m.css) css = m.css;
6908
- if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
6909
- if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
6910
- if (m.title && !title) title = m.title;
6911
- if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
6912
- collapsed = sp;
6913
- } else if (sp.from > pos && nextChange > sp.from) {
6914
- nextChange = sp.from;
6915
- }
6916
- if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);
6917
- }
6918
- if (collapsed && (collapsed.from || 0) == pos) {
6919
- buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
6920
- collapsed.marker, collapsed.from == null);
6921
- if (collapsed.to == null) return;
6922
- }
6923
- if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
6924
- buildCollapsedSpan(builder, 0, foundBookmarks[j]);
6925
- }
6926
- if (pos >= len) break;
6927
-
6928
- var upto = Math.min(len, nextChange);
6929
- while (true) {
6930
- if (text) {
6931
- var end = pos + text.length;
6932
- if (!collapsed) {
6933
- var tokenText = end > upto ? text.slice(0, upto - pos) : text;
6934
- builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
6935
- spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
6936
- }
6937
- if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
6938
- pos = end;
6939
- spanStartStyle = "";
6940
- }
6941
- text = allText.slice(at, at = styles[i++]);
6942
- style = interpretTokenStyle(styles[i++], builder.cm.options);
6943
- }
6944
- }
6945
- }
6946
-
6947
- // DOCUMENT DATA STRUCTURE
6948
-
6949
- // By default, updates that start and end at the beginning of a line
6950
- // are treated specially, in order to make the association of line
6951
- // widgets and marker elements with the text behave more intuitive.
6952
- function isWholeLineUpdate(doc, change) {
6953
- return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
6954
- (!doc.cm || doc.cm.options.wholeLineUpdateBefore);
6955
- }
6956
-
6957
- // Perform a change on the document data structure.
6958
- function updateDoc(doc, change, markedSpans, estimateHeight) {
6959
- function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
6960
- function update(line, text, spans) {
6961
- updateLine(line, text, spans, estimateHeight);
6962
- signalLater(line, "change", line, change);
6963
- }
6964
- function linesFor(start, end) {
6965
- for (var i = start, result = []; i < end; ++i)
6966
- result.push(new Line(text[i], spansFor(i), estimateHeight));
6967
- return result;
6968
- }
6969
-
6970
- var from = change.from, to = change.to, text = change.text;
6971
- var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
6972
- var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
6973
-
6974
- // Adjust the line structure
6975
- if (change.full) {
6976
- doc.insert(0, linesFor(0, text.length));
6977
- doc.remove(text.length, doc.size - text.length);
6978
- } else if (isWholeLineUpdate(doc, change)) {
6979
- // This is a whole-line replace. Treated specially to make
6980
- // sure line objects move the way they are supposed to.
6981
- var added = linesFor(0, text.length - 1);
6982
- update(lastLine, lastLine.text, lastSpans);
6983
- if (nlines) doc.remove(from.line, nlines);
6984
- if (added.length) doc.insert(from.line, added);
6985
- } else if (firstLine == lastLine) {
6986
- if (text.length == 1) {
6987
- update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
6988
- } else {
6989
- var added = linesFor(1, text.length - 1);
6990
- added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
6991
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
6992
- doc.insert(from.line + 1, added);
6993
- }
6994
- } else if (text.length == 1) {
6995
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
6996
- doc.remove(from.line + 1, nlines);
6997
- } else {
6998
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
6999
- update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
7000
- var added = linesFor(1, text.length - 1);
7001
- if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
7002
- doc.insert(from.line + 1, added);
7003
- }
7004
-
7005
- signalLater(doc, "change", doc, change);
7006
- }
7007
-
7008
- // The document is represented as a BTree consisting of leaves, with
7009
- // chunk of lines in them, and branches, with up to ten leaves or
7010
- // other branch nodes below them. The top node is always a branch
7011
- // node, and is the document object itself (meaning it has
7012
- // additional methods and properties).
7013
- //
7014
- // All nodes have parent links. The tree is used both to go from
7015
- // line numbers to line objects, and to go from objects to numbers.
7016
- // It also indexes by height, and is used to convert between height
7017
- // and line object, and to find the total height of the document.
7018
- //
7019
- // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
7020
-
7021
- function LeafChunk(lines) {
7022
- this.lines = lines;
7023
- this.parent = null;
7024
- for (var i = 0, height = 0; i < lines.length; ++i) {
7025
- lines[i].parent = this;
7026
- height += lines[i].height;
7027
- }
7028
- this.height = height;
7029
- }
7030
-
7031
- LeafChunk.prototype = {
7032
- chunkSize: function() { return this.lines.length; },
7033
- // Remove the n lines at offset 'at'.
7034
- removeInner: function(at, n) {
7035
- for (var i = at, e = at + n; i < e; ++i) {
7036
- var line = this.lines[i];
7037
- this.height -= line.height;
7038
- cleanUpLine(line);
7039
- signalLater(line, "delete");
7040
- }
7041
- this.lines.splice(at, n);
7042
- },
7043
- // Helper used to collapse a small branch into a single leaf.
7044
- collapse: function(lines) {
7045
- lines.push.apply(lines, this.lines);
7046
- },
7047
- // Insert the given array of lines at offset 'at', count them as
7048
- // having the given height.
7049
- insertInner: function(at, lines, height) {
7050
- this.height += height;
7051
- this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
7052
- for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
7053
- },
7054
- // Used to iterate over a part of the tree.
7055
- iterN: function(at, n, op) {
7056
- for (var e = at + n; at < e; ++at)
7057
- if (op(this.lines[at])) return true;
7058
- }
7059
- };
7060
-
7061
- function BranchChunk(children) {
7062
- this.children = children;
7063
- var size = 0, height = 0;
7064
- for (var i = 0; i < children.length; ++i) {
7065
- var ch = children[i];
7066
- size += ch.chunkSize(); height += ch.height;
7067
- ch.parent = this;
7068
- }
7069
- this.size = size;
7070
- this.height = height;
7071
- this.parent = null;
7072
- }
7073
-
7074
- BranchChunk.prototype = {
7075
- chunkSize: function() { return this.size; },
7076
- removeInner: function(at, n) {
7077
- this.size -= n;
7078
- for (var i = 0; i < this.children.length; ++i) {
7079
- var child = this.children[i], sz = child.chunkSize();
7080
- if (at < sz) {
7081
- var rm = Math.min(n, sz - at), oldHeight = child.height;
7082
- child.removeInner(at, rm);
7083
- this.height -= oldHeight - child.height;
7084
- if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
7085
- if ((n -= rm) == 0) break;
7086
- at = 0;
7087
- } else at -= sz;
7088
- }
7089
- // If the result is smaller than 25 lines, ensure that it is a
7090
- // single leaf node.
7091
- if (this.size - n < 25 &&
7092
- (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
7093
- var lines = [];
7094
- this.collapse(lines);
7095
- this.children = [new LeafChunk(lines)];
7096
- this.children[0].parent = this;
7097
- }
7098
- },
7099
- collapse: function(lines) {
7100
- for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
7101
- },
7102
- insertInner: function(at, lines, height) {
7103
- this.size += lines.length;
7104
- this.height += height;
7105
- for (var i = 0; i < this.children.length; ++i) {
7106
- var child = this.children[i], sz = child.chunkSize();
7107
- if (at <= sz) {
7108
- child.insertInner(at, lines, height);
7109
- if (child.lines && child.lines.length > 50) {
7110
- while (child.lines.length > 50) {
7111
- var spilled = child.lines.splice(child.lines.length - 25, 25);
7112
- var newleaf = new LeafChunk(spilled);
7113
- child.height -= newleaf.height;
7114
- this.children.splice(i + 1, 0, newleaf);
7115
- newleaf.parent = this;
7116
- }
7117
- this.maybeSpill();
7118
- }
7119
- break;
7120
- }
7121
- at -= sz;
7122
- }
7123
- },
7124
- // When a node has grown, check whether it should be split.
7125
- maybeSpill: function() {
7126
- if (this.children.length <= 10) return;
7127
- var me = this;
7128
- do {
7129
- var spilled = me.children.splice(me.children.length - 5, 5);
7130
- var sibling = new BranchChunk(spilled);
7131
- if (!me.parent) { // Become the parent node
7132
- var copy = new BranchChunk(me.children);
7133
- copy.parent = me;
7134
- me.children = [copy, sibling];
7135
- me = copy;
7136
- } else {
7137
- me.size -= sibling.size;
7138
- me.height -= sibling.height;
7139
- var myIndex = indexOf(me.parent.children, me);
7140
- me.parent.children.splice(myIndex + 1, 0, sibling);
7141
- }
7142
- sibling.parent = me.parent;
7143
- } while (me.children.length > 10);
7144
- me.parent.maybeSpill();
7145
- },
7146
- iterN: function(at, n, op) {
7147
- for (var i = 0; i < this.children.length; ++i) {
7148
- var child = this.children[i], sz = child.chunkSize();
7149
- if (at < sz) {
7150
- var used = Math.min(n, sz - at);
7151
- if (child.iterN(at, used, op)) return true;
7152
- if ((n -= used) == 0) break;
7153
- at = 0;
7154
- } else at -= sz;
7155
- }
7156
- }
7157
- };
7158
-
7159
- var nextDocId = 0;
7160
- var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
7161
- if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
7162
- if (firstLine == null) firstLine = 0;
7163
-
7164
- BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
7165
- this.first = firstLine;
7166
- this.scrollTop = this.scrollLeft = 0;
7167
- this.cantEdit = false;
7168
- this.cleanGeneration = 1;
7169
- this.frontier = firstLine;
7170
- var start = Pos(firstLine, 0);
7171
- this.sel = simpleSelection(start);
7172
- this.history = new History(null);
7173
- this.id = ++nextDocId;
7174
- this.modeOption = mode;
7175
-
7176
- if (typeof text == "string") text = splitLines(text);
7177
- updateDoc(this, {from: start, to: start, text: text});
7178
- setSelection(this, simpleSelection(start), sel_dontScroll);
7179
- };
7180
-
7181
- Doc.prototype = createObj(BranchChunk.prototype, {
7182
- constructor: Doc,
7183
- // Iterate over the document. Supports two forms -- with only one
7184
- // argument, it calls that for each line in the document. With
7185
- // three, it iterates over the range given by the first two (with
7186
- // the second being non-inclusive).
7187
- iter: function(from, to, op) {
7188
- if (op) this.iterN(from - this.first, to - from, op);
7189
- else this.iterN(this.first, this.first + this.size, from);
7190
- },
7191
-
7192
- // Non-public interface for adding and removing lines.
7193
- insert: function(at, lines) {
7194
- var height = 0;
7195
- for (var i = 0; i < lines.length; ++i) height += lines[i].height;
7196
- this.insertInner(at - this.first, lines, height);
7197
- },
7198
- remove: function(at, n) { this.removeInner(at - this.first, n); },
7199
-
7200
- // From here, the methods are part of the public interface. Most
7201
- // are also available from CodeMirror (editor) instances.
7202
-
7203
- getValue: function(lineSep) {
7204
- var lines = getLines(this, this.first, this.first + this.size);
7205
- if (lineSep === false) return lines;
7206
- return lines.join(lineSep || "\n");
7207
- },
7208
- setValue: docMethodOp(function(code) {
7209
- var top = Pos(this.first, 0), last = this.first + this.size - 1;
7210
- makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
7211
- text: splitLines(code), origin: "setValue", full: true}, true);
7212
- setSelection(this, simpleSelection(top));
7213
- }),
7214
- replaceRange: function(code, from, to, origin) {
7215
- from = clipPos(this, from);
7216
- to = to ? clipPos(this, to) : from;
7217
- replaceRange(this, code, from, to, origin);
7218
- },
7219
- getRange: function(from, to, lineSep) {
7220
- var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
7221
- if (lineSep === false) return lines;
7222
- return lines.join(lineSep || "\n");
7223
- },
7224
-
7225
- getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
7226
-
7227
- getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
7228
- getLineNumber: function(line) {return lineNo(line);},
7229
-
7230
- getLineHandleVisualStart: function(line) {
7231
- if (typeof line == "number") line = getLine(this, line);
7232
- return visualLine(line);
7233
- },
7234
-
7235
- lineCount: function() {return this.size;},
7236
- firstLine: function() {return this.first;},
7237
- lastLine: function() {return this.first + this.size - 1;},
7238
-
7239
- clipPos: function(pos) {return clipPos(this, pos);},
7240
-
7241
- getCursor: function(start) {
7242
- var range = this.sel.primary(), pos;
7243
- if (start == null || start == "head") pos = range.head;
7244
- else if (start == "anchor") pos = range.anchor;
7245
- else if (start == "end" || start == "to" || start === false) pos = range.to();
7246
- else pos = range.from();
7247
- return pos;
7248
- },
7249
- listSelections: function() { return this.sel.ranges; },
7250
- somethingSelected: function() {return this.sel.somethingSelected();},
7251
-
7252
- setCursor: docMethodOp(function(line, ch, options) {
7253
- setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
7254
- }),
7255
- setSelection: docMethodOp(function(anchor, head, options) {
7256
- setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
7257
- }),
7258
- extendSelection: docMethodOp(function(head, other, options) {
7259
- extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
7260
- }),
7261
- extendSelections: docMethodOp(function(heads, options) {
7262
- extendSelections(this, clipPosArray(this, heads, options));
7263
- }),
7264
- extendSelectionsBy: docMethodOp(function(f, options) {
7265
- extendSelections(this, map(this.sel.ranges, f), options);
7266
- }),
7267
- setSelections: docMethodOp(function(ranges, primary, options) {
7268
- if (!ranges.length) return;
7269
- for (var i = 0, out = []; i < ranges.length; i++)
7270
- out[i] = new Range(clipPos(this, ranges[i].anchor),
7271
- clipPos(this, ranges[i].head));
7272
- if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
7273
- setSelection(this, normalizeSelection(out, primary), options);
7274
- }),
7275
- addSelection: docMethodOp(function(anchor, head, options) {
7276
- var ranges = this.sel.ranges.slice(0);
7277
- ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
7278
- setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
7279
- }),
7280
-
7281
- getSelection: function(lineSep) {
7282
- var ranges = this.sel.ranges, lines;
7283
- for (var i = 0; i < ranges.length; i++) {
7284
- var sel = getBetween(this, ranges[i].from(), ranges[i].to());
7285
- lines = lines ? lines.concat(sel) : sel;
7286
- }
7287
- if (lineSep === false) return lines;
7288
- else return lines.join(lineSep || "\n");
7289
- },
7290
- getSelections: function(lineSep) {
7291
- var parts = [], ranges = this.sel.ranges;
7292
- for (var i = 0; i < ranges.length; i++) {
7293
- var sel = getBetween(this, ranges[i].from(), ranges[i].to());
7294
- if (lineSep !== false) sel = sel.join(lineSep || "\n");
7295
- parts[i] = sel;
7296
- }
7297
- return parts;
7298
- },
7299
- replaceSelection: function(code, collapse, origin) {
7300
- var dup = [];
7301
- for (var i = 0; i < this.sel.ranges.length; i++)
7302
- dup[i] = code;
7303
- this.replaceSelections(dup, collapse, origin || "+input");
7304
- },
7305
- replaceSelections: docMethodOp(function(code, collapse, origin) {
7306
- var changes = [], sel = this.sel;
7307
- for (var i = 0; i < sel.ranges.length; i++) {
7308
- var range = sel.ranges[i];
7309
- changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
7310
- }
7311
- var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
7312
- for (var i = changes.length - 1; i >= 0; i--)
7313
- makeChange(this, changes[i]);
7314
- if (newSel) setSelectionReplaceHistory(this, newSel);
7315
- else if (this.cm) ensureCursorVisible(this.cm);
7316
- }),
7317
- undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
7318
- redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
7319
- undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
7320
- redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
7321
-
7322
- setExtending: function(val) {this.extend = val;},
7323
- getExtending: function() {return this.extend;},
7324
-
7325
- historySize: function() {
7326
- var hist = this.history, done = 0, undone = 0;
7327
- for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
7328
- for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
7329
- return {undo: done, redo: undone};
7330
- },
7331
- clearHistory: function() {this.history = new History(this.history.maxGeneration);},
7332
-
7333
- markClean: function() {
7334
- this.cleanGeneration = this.changeGeneration(true);
7335
- },
7336
- changeGeneration: function(forceSplit) {
7337
- if (forceSplit)
7338
- this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
7339
- return this.history.generation;
7340
- },
7341
- isClean: function (gen) {
7342
- return this.history.generation == (gen || this.cleanGeneration);
7343
- },
7344
-
7345
- getHistory: function() {
7346
- return {done: copyHistoryArray(this.history.done),
7347
- undone: copyHistoryArray(this.history.undone)};
7348
- },
7349
- setHistory: function(histData) {
7350
- var hist = this.history = new History(this.history.maxGeneration);
7351
- hist.done = copyHistoryArray(histData.done.slice(0), null, true);
7352
- hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
7353
- },
7354
-
7355
- addLineClass: docMethodOp(function(handle, where, cls) {
7356
- return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
7357
- var prop = where == "text" ? "textClass"
7358
- : where == "background" ? "bgClass"
7359
- : where == "gutter" ? "gutterClass" : "wrapClass";
7360
- if (!line[prop]) line[prop] = cls;
7361
- else if (classTest(cls).test(line[prop])) return false;
7362
- else line[prop] += " " + cls;
7363
- return true;
7364
- });
7365
- }),
7366
- removeLineClass: docMethodOp(function(handle, where, cls) {
7367
- return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
7368
- var prop = where == "text" ? "textClass"
7369
- : where == "background" ? "bgClass"
7370
- : where == "gutter" ? "gutterClass" : "wrapClass";
7371
- var cur = line[prop];
7372
- if (!cur) return false;
7373
- else if (cls == null) line[prop] = null;
7374
- else {
7375
- var found = cur.match(classTest(cls));
7376
- if (!found) return false;
7377
- var end = found.index + found[0].length;
7378
- line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
7379
- }
7380
- return true;
7381
- });
7382
- }),
7383
-
7384
- markText: function(from, to, options) {
7385
- return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
7386
- },
7387
- setBookmark: function(pos, options) {
7388
- var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
7389
- insertLeft: options && options.insertLeft,
7390
- clearWhenEmpty: false, shared: options && options.shared};
7391
- pos = clipPos(this, pos);
7392
- return markText(this, pos, pos, realOpts, "bookmark");
7393
- },
7394
- findMarksAt: function(pos) {
7395
- pos = clipPos(this, pos);
7396
- var markers = [], spans = getLine(this, pos.line).markedSpans;
7397
- if (spans) for (var i = 0; i < spans.length; ++i) {
7398
- var span = spans[i];
7399
- if ((span.from == null || span.from <= pos.ch) &&
7400
- (span.to == null || span.to >= pos.ch))
7401
- markers.push(span.marker.parent || span.marker);
7402
- }
7403
- return markers;
7404
- },
7405
- findMarks: function(from, to, filter) {
7406
- from = clipPos(this, from); to = clipPos(this, to);
7407
- var found = [], lineNo = from.line;
7408
- this.iter(from.line, to.line + 1, function(line) {
7409
- var spans = line.markedSpans;
7410
- if (spans) for (var i = 0; i < spans.length; i++) {
7411
- var span = spans[i];
7412
- if (!(lineNo == from.line && from.ch > span.to ||
7413
- span.from == null && lineNo != from.line||
7414
- lineNo == to.line && span.from > to.ch) &&
7415
- (!filter || filter(span.marker)))
7416
- found.push(span.marker.parent || span.marker);
7417
- }
7418
- ++lineNo;
7419
- });
7420
- return found;
7421
- },
7422
- getAllMarks: function() {
7423
- var markers = [];
7424
- this.iter(function(line) {
7425
- var sps = line.markedSpans;
7426
- if (sps) for (var i = 0; i < sps.length; ++i)
7427
- if (sps[i].from != null) markers.push(sps[i].marker);
7428
- });
7429
- return markers;
7430
- },
7431
-
7432
- posFromIndex: function(off) {
7433
- var ch, lineNo = this.first;
7434
- this.iter(function(line) {
7435
- var sz = line.text.length + 1;
7436
- if (sz > off) { ch = off; return true; }
7437
- off -= sz;
7438
- ++lineNo;
7439
- });
7440
- return clipPos(this, Pos(lineNo, ch));
7441
- },
7442
- indexFromPos: function (coords) {
7443
- coords = clipPos(this, coords);
7444
- var index = coords.ch;
7445
- if (coords.line < this.first || coords.ch < 0) return 0;
7446
- this.iter(this.first, coords.line, function (line) {
7447
- index += line.text.length + 1;
7448
- });
7449
- return index;
7450
- },
7451
-
7452
- copy: function(copyHistory) {
7453
- var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
7454
- doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
7455
- doc.sel = this.sel;
7456
- doc.extend = false;
7457
- if (copyHistory) {
7458
- doc.history.undoDepth = this.history.undoDepth;
7459
- doc.setHistory(this.getHistory());
7460
- }
7461
- return doc;
7462
- },
7463
-
7464
- linkedDoc: function(options) {
7465
- if (!options) options = {};
7466
- var from = this.first, to = this.first + this.size;
7467
- if (options.from != null && options.from > from) from = options.from;
7468
- if (options.to != null && options.to < to) to = options.to;
7469
- var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
7470
- if (options.sharedHist) copy.history = this.history;
7471
- (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
7472
- copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
7473
- copySharedMarkers(copy, findSharedMarkers(this));
7474
- return copy;
7475
- },
7476
- unlinkDoc: function(other) {
7477
- if (other instanceof CodeMirror) other = other.doc;
7478
- if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
7479
- var link = this.linked[i];
7480
- if (link.doc != other) continue;
7481
- this.linked.splice(i, 1);
7482
- other.unlinkDoc(this);
7483
- detachSharedMarkers(findSharedMarkers(this));
7484
- break;
7485
- }
7486
- // If the histories were shared, split them again
7487
- if (other.history == this.history) {
7488
- var splitIds = [other.id];
7489
- linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
7490
- other.history = new History(null);
7491
- other.history.done = copyHistoryArray(this.history.done, splitIds);
7492
- other.history.undone = copyHistoryArray(this.history.undone, splitIds);
7493
- }
7494
- },
7495
- iterLinkedDocs: function(f) {linkedDocs(this, f);},
7496
-
7497
- getMode: function() {return this.mode;},
7498
- getEditor: function() {return this.cm;}
7499
- });
7500
-
7501
- // Public alias.
7502
- Doc.prototype.eachLine = Doc.prototype.iter;
7503
-
7504
- // Set up methods on CodeMirror's prototype to redirect to the editor's document.
7505
- var dontDelegate = "iter insert remove copy getEditor".split(" ");
7506
- for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
7507
- CodeMirror.prototype[prop] = (function(method) {
7508
- return function() {return method.apply(this.doc, arguments);};
7509
- })(Doc.prototype[prop]);
7510
-
7511
- eventMixin(Doc);
7512
-
7513
- // Call f for all linked documents.
7514
- function linkedDocs(doc, f, sharedHistOnly) {
7515
- function propagate(doc, skip, sharedHist) {
7516
- if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
7517
- var rel = doc.linked[i];
7518
- if (rel.doc == skip) continue;
7519
- var shared = sharedHist && rel.sharedHist;
7520
- if (sharedHistOnly && !shared) continue;
7521
- f(rel.doc, shared);
7522
- propagate(rel.doc, doc, shared);
7523
- }
7524
- }
7525
- propagate(doc, null, true);
7526
- }
7527
-
7528
- // Attach a document to an editor.
7529
- function attachDoc(cm, doc) {
7530
- if (doc.cm) throw new Error("This document is already in use.");
7531
- cm.doc = doc;
7532
- doc.cm = cm;
7533
- estimateLineHeights(cm);
7534
- loadMode(cm);
7535
- if (!cm.options.lineWrapping) findMaxLine(cm);
7536
- cm.options.mode = doc.modeOption;
7537
- regChange(cm);
7538
- }
7539
-
7540
- // LINE UTILITIES
7541
-
7542
- // Find the line object corresponding to the given line number.
7543
- function getLine(doc, n) {
7544
- n -= doc.first;
7545
- if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
7546
- for (var chunk = doc; !chunk.lines;) {
7547
- for (var i = 0;; ++i) {
7548
- var child = chunk.children[i], sz = child.chunkSize();
7549
- if (n < sz) { chunk = child; break; }
7550
- n -= sz;
7551
- }
7552
- }
7553
- return chunk.lines[n];
7554
- }
7555
-
7556
- // Get the part of a document between two positions, as an array of
7557
- // strings.
7558
- function getBetween(doc, start, end) {
7559
- var out = [], n = start.line;
7560
- doc.iter(start.line, end.line + 1, function(line) {
7561
- var text = line.text;
7562
- if (n == end.line) text = text.slice(0, end.ch);
7563
- if (n == start.line) text = text.slice(start.ch);
7564
- out.push(text);
7565
- ++n;
7566
- });
7567
- return out;
7568
- }
7569
- // Get the lines between from and to, as array of strings.
7570
- function getLines(doc, from, to) {
7571
- var out = [];
7572
- doc.iter(from, to, function(line) { out.push(line.text); });
7573
- return out;
7574
- }
7575
-
7576
- // Update the height of a line, propagating the height change
7577
- // upwards to parent nodes.
7578
- function updateLineHeight(line, height) {
7579
- var diff = height - line.height;
7580
- if (diff) for (var n = line; n; n = n.parent) n.height += diff;
7581
- }
7582
-
7583
- // Given a line object, find its line number by walking up through
7584
- // its parent links.
7585
- function lineNo(line) {
7586
- if (line.parent == null) return null;
7587
- var cur = line.parent, no = indexOf(cur.lines, line);
7588
- for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
7589
- for (var i = 0;; ++i) {
7590
- if (chunk.children[i] == cur) break;
7591
- no += chunk.children[i].chunkSize();
7592
- }
7593
- }
7594
- return no + cur.first;
7595
- }
7596
-
7597
- // Find the line at the given vertical position, using the height
7598
- // information in the document tree.
7599
- function lineAtHeight(chunk, h) {
7600
- var n = chunk.first;
7601
- outer: do {
7602
- for (var i = 0; i < chunk.children.length; ++i) {
7603
- var child = chunk.children[i], ch = child.height;
7604
- if (h < ch) { chunk = child; continue outer; }
7605
- h -= ch;
7606
- n += child.chunkSize();
7607
- }
7608
- return n;
7609
- } while (!chunk.lines);
7610
- for (var i = 0; i < chunk.lines.length; ++i) {
7611
- var line = chunk.lines[i], lh = line.height;
7612
- if (h < lh) break;
7613
- h -= lh;
7614
- }
7615
- return n + i;
7616
- }
7617
-
7618
-
7619
- // Find the height above the given line.
7620
- function heightAtLine(lineObj) {
7621
- lineObj = visualLine(lineObj);
7622
-
7623
- var h = 0, chunk = lineObj.parent;
7624
- for (var i = 0; i < chunk.lines.length; ++i) {
7625
- var line = chunk.lines[i];
7626
- if (line == lineObj) break;
7627
- else h += line.height;
7628
- }
7629
- for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
7630
- for (var i = 0; i < p.children.length; ++i) {
7631
- var cur = p.children[i];
7632
- if (cur == chunk) break;
7633
- else h += cur.height;
7634
- }
7635
- }
7636
- return h;
7637
- }
7638
-
7639
- // Get the bidi ordering for the given line (and cache it). Returns
7640
- // false for lines that are fully left-to-right, and an array of
7641
- // BidiSpan objects otherwise.
7642
- function getOrder(line) {
7643
- var order = line.order;
7644
- if (order == null) order = line.order = bidiOrdering(line.text);
7645
- return order;
7646
- }
7647
-
7648
- // HISTORY
7649
-
7650
- function History(startGen) {
7651
- // Arrays of change events and selections. Doing something adds an
7652
- // event to done and clears undo. Undoing moves events from done
7653
- // to undone, redoing moves them in the other direction.
7654
- this.done = []; this.undone = [];
7655
- this.undoDepth = Infinity;
7656
- // Used to track when changes can be merged into a single undo
7657
- // event
7658
- this.lastModTime = this.lastSelTime = 0;
7659
- this.lastOp = this.lastSelOp = null;
7660
- this.lastOrigin = this.lastSelOrigin = null;
7661
- // Used by the isClean() method
7662
- this.generation = this.maxGeneration = startGen || 1;
7663
- }
7664
-
7665
- // Create a history change event from an updateDoc-style change
7666
- // object.
7667
- function historyChangeFromChange(doc, change) {
7668
- var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
7669
- attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
7670
- linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
7671
- return histChange;
7672
- }
7673
-
7674
- // Pop all selection events off the end of a history array. Stop at
7675
- // a change event.
7676
- function clearSelectionEvents(array) {
7677
- while (array.length) {
7678
- var last = lst(array);
7679
- if (last.ranges) array.pop();
7680
- else break;
7681
- }
7682
- }
7683
-
7684
- // Find the top change event in the history. Pop off selection
7685
- // events that are in the way.
7686
- function lastChangeEvent(hist, force) {
7687
- if (force) {
7688
- clearSelectionEvents(hist.done);
7689
- return lst(hist.done);
7690
- } else if (hist.done.length && !lst(hist.done).ranges) {
7691
- return lst(hist.done);
7692
- } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
7693
- hist.done.pop();
7694
- return lst(hist.done);
7695
- }
7696
- }
7697
-
7698
- // Register a change in the history. Merges changes that are within
7699
- // a single operation, ore are close together with an origin that
7700
- // allows merging (starting with "+") into a single event.
7701
- function addChangeToHistory(doc, change, selAfter, opId) {
7702
- var hist = doc.history;
7703
- hist.undone.length = 0;
7704
- var time = +new Date, cur;
7705
-
7706
- if ((hist.lastOp == opId ||
7707
- hist.lastOrigin == change.origin && change.origin &&
7708
- ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
7709
- change.origin.charAt(0) == "*")) &&
7710
- (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
7711
- // Merge this change into the last event
7712
- var last = lst(cur.changes);
7713
- if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
7714
- // Optimized case for simple insertion -- don't want to add
7715
- // new changesets for every character typed
7716
- last.to = changeEnd(change);
7717
- } else {
7718
- // Add new sub-event
7719
- cur.changes.push(historyChangeFromChange(doc, change));
7720
- }
7721
- } else {
7722
- // Can not be merged, start a new event.
7723
- var before = lst(hist.done);
7724
- if (!before || !before.ranges)
7725
- pushSelectionToHistory(doc.sel, hist.done);
7726
- cur = {changes: [historyChangeFromChange(doc, change)],
7727
- generation: hist.generation};
7728
- hist.done.push(cur);
7729
- while (hist.done.length > hist.undoDepth) {
7730
- hist.done.shift();
7731
- if (!hist.done[0].ranges) hist.done.shift();
7732
- }
7733
- }
7734
- hist.done.push(selAfter);
7735
- hist.generation = ++hist.maxGeneration;
7736
- hist.lastModTime = hist.lastSelTime = time;
7737
- hist.lastOp = hist.lastSelOp = opId;
7738
- hist.lastOrigin = hist.lastSelOrigin = change.origin;
7739
-
7740
- if (!last) signal(doc, "historyAdded");
7741
- }
7742
-
7743
- function selectionEventCanBeMerged(doc, origin, prev, sel) {
7744
- var ch = origin.charAt(0);
7745
- return ch == "*" ||
7746
- ch == "+" &&
7747
- prev.ranges.length == sel.ranges.length &&
7748
- prev.somethingSelected() == sel.somethingSelected() &&
7749
- new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
7750
- }
7751
-
7752
- // Called whenever the selection changes, sets the new selection as
7753
- // the pending selection in the history, and pushes the old pending
7754
- // selection into the 'done' array when it was significantly
7755
- // different (in number of selected ranges, emptiness, or time).
7756
- function addSelectionToHistory(doc, sel, opId, options) {
7757
- var hist = doc.history, origin = options && options.origin;
7758
-
7759
- // A new event is started when the previous origin does not match
7760
- // the current, or the origins don't allow matching. Origins
7761
- // starting with * are always merged, those starting with + are
7762
- // merged when similar and close together in time.
7763
- if (opId == hist.lastSelOp ||
7764
- (origin && hist.lastSelOrigin == origin &&
7765
- (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
7766
- selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
7767
- hist.done[hist.done.length - 1] = sel;
7768
- else
7769
- pushSelectionToHistory(sel, hist.done);
7770
-
7771
- hist.lastSelTime = +new Date;
7772
- hist.lastSelOrigin = origin;
7773
- hist.lastSelOp = opId;
7774
- if (options && options.clearRedo !== false)
7775
- clearSelectionEvents(hist.undone);
7776
- }
7777
-
7778
- function pushSelectionToHistory(sel, dest) {
7779
- var top = lst(dest);
7780
- if (!(top && top.ranges && top.equals(sel)))
7781
- dest.push(sel);
7782
- }
7783
-
7784
- // Used to store marked span information in the history.
7785
- function attachLocalSpans(doc, change, from, to) {
7786
- var existing = change["spans_" + doc.id], n = 0;
7787
- doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
7788
- if (line.markedSpans)
7789
- (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
7790
- ++n;
7791
- });
7792
- }
7793
-
7794
- // When un/re-doing restores text containing marked spans, those
7795
- // that have been explicitly cleared should not be restored.
7796
- function removeClearedSpans(spans) {
7797
- if (!spans) return null;
7798
- for (var i = 0, out; i < spans.length; ++i) {
7799
- if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
7800
- else if (out) out.push(spans[i]);
7801
- }
7802
- return !out ? spans : out.length ? out : null;
7803
- }
7804
-
7805
- // Retrieve and filter the old marked spans stored in a change event.
7806
- function getOldSpans(doc, change) {
7807
- var found = change["spans_" + doc.id];
7808
- if (!found) return null;
7809
- for (var i = 0, nw = []; i < change.text.length; ++i)
7810
- nw.push(removeClearedSpans(found[i]));
7811
- return nw;
7812
- }
7813
-
7814
- // Used both to provide a JSON-safe object in .getHistory, and, when
7815
- // detaching a document, to split the history in two
7816
- function copyHistoryArray(events, newGroup, instantiateSel) {
7817
- for (var i = 0, copy = []; i < events.length; ++i) {
7818
- var event = events[i];
7819
- if (event.ranges) {
7820
- copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
7821
- continue;
7822
- }
7823
- var changes = event.changes, newChanges = [];
7824
- copy.push({changes: newChanges});
7825
- for (var j = 0; j < changes.length; ++j) {
7826
- var change = changes[j], m;
7827
- newChanges.push({from: change.from, to: change.to, text: change.text});
7828
- if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
7829
- if (indexOf(newGroup, Number(m[1])) > -1) {
7830
- lst(newChanges)[prop] = change[prop];
7831
- delete change[prop];
7832
- }
7833
- }
7834
- }
7835
- }
7836
- return copy;
7837
- }
7838
-
7839
- // Rebasing/resetting history to deal with externally-sourced changes
7840
-
7841
- function rebaseHistSelSingle(pos, from, to, diff) {
7842
- if (to < pos.line) {
7843
- pos.line += diff;
7844
- } else if (from < pos.line) {
7845
- pos.line = from;
7846
- pos.ch = 0;
7847
- }
7848
- }
7849
-
7850
- // Tries to rebase an array of history events given a change in the
7851
- // document. If the change touches the same lines as the event, the
7852
- // event, and everything 'behind' it, is discarded. If the change is
7853
- // before the event, the event's positions are updated. Uses a
7854
- // copy-on-write scheme for the positions, to avoid having to
7855
- // reallocate them all on every rebase, but also avoid problems with
7856
- // shared position objects being unsafely updated.
7857
- function rebaseHistArray(array, from, to, diff) {
7858
- for (var i = 0; i < array.length; ++i) {
7859
- var sub = array[i], ok = true;
7860
- if (sub.ranges) {
7861
- if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
7862
- for (var j = 0; j < sub.ranges.length; j++) {
7863
- rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
7864
- rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
7865
- }
7866
- continue;
7867
- }
7868
- for (var j = 0; j < sub.changes.length; ++j) {
7869
- var cur = sub.changes[j];
7870
- if (to < cur.from.line) {
7871
- cur.from = Pos(cur.from.line + diff, cur.from.ch);
7872
- cur.to = Pos(cur.to.line + diff, cur.to.ch);
7873
- } else if (from <= cur.to.line) {
7874
- ok = false;
7875
- break;
7876
- }
7877
- }
7878
- if (!ok) {
7879
- array.splice(0, i + 1);
7880
- i = 0;
7881
- }
7882
- }
7883
- }
7884
-
7885
- function rebaseHist(hist, change) {
7886
- var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
7887
- rebaseHistArray(hist.done, from, to, diff);
7888
- rebaseHistArray(hist.undone, from, to, diff);
7889
- }
7890
-
7891
- // EVENT UTILITIES
7892
-
7893
- // Due to the fact that we still support jurassic IE versions, some
7894
- // compatibility wrappers are needed.
7895
-
7896
- var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
7897
- if (e.preventDefault) e.preventDefault();
7898
- else e.returnValue = false;
7899
- };
7900
- var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
7901
- if (e.stopPropagation) e.stopPropagation();
7902
- else e.cancelBubble = true;
7903
- };
7904
- function e_defaultPrevented(e) {
7905
- return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
7906
- }
7907
- var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
7908
-
7909
- function e_target(e) {return e.target || e.srcElement;}
7910
- function e_button(e) {
7911
- var b = e.which;
7912
- if (b == null) {
7913
- if (e.button & 1) b = 1;
7914
- else if (e.button & 2) b = 3;
7915
- else if (e.button & 4) b = 2;
7916
- }
7917
- if (mac && e.ctrlKey && b == 1) b = 3;
7918
- return b;
7919
- }
7920
-
7921
- // EVENT HANDLING
7922
-
7923
- // Lightweight event framework. on/off also work on DOM nodes,
7924
- // registering native DOM handlers.
7925
-
7926
- var on = CodeMirror.on = function(emitter, type, f) {
7927
- if (emitter.addEventListener)
7928
- emitter.addEventListener(type, f, false);
7929
- else if (emitter.attachEvent)
7930
- emitter.attachEvent("on" + type, f);
7931
- else {
7932
- var map = emitter._handlers || (emitter._handlers = {});
7933
- var arr = map[type] || (map[type] = []);
7934
- arr.push(f);
7935
- }
7936
- };
7937
-
7938
- var off = CodeMirror.off = function(emitter, type, f) {
7939
- if (emitter.removeEventListener)
7940
- emitter.removeEventListener(type, f, false);
7941
- else if (emitter.detachEvent)
7942
- emitter.detachEvent("on" + type, f);
7943
- else {
7944
- var arr = emitter._handlers && emitter._handlers[type];
7945
- if (!arr) return;
7946
- for (var i = 0; i < arr.length; ++i)
7947
- if (arr[i] == f) { arr.splice(i, 1); break; }
7948
- }
7949
- };
7950
-
7951
- var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
7952
- var arr = emitter._handlers && emitter._handlers[type];
7953
- if (!arr) return;
7954
- var args = Array.prototype.slice.call(arguments, 2);
7955
- for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
7956
- };
7957
-
7958
- var orphanDelayedCallbacks = null;
7959
-
7960
- // Often, we want to signal events at a point where we are in the
7961
- // middle of some work, but don't want the handler to start calling
7962
- // other methods on the editor, which might be in an inconsistent
7963
- // state or simply not expect any other events to happen.
7964
- // signalLater looks whether there are any handlers, and schedules
7965
- // them to be executed when the last operation ends, or, if no
7966
- // operation is active, when a timeout fires.
7967
- function signalLater(emitter, type /*, values...*/) {
7968
- var arr = emitter._handlers && emitter._handlers[type];
7969
- if (!arr) return;
7970
- var args = Array.prototype.slice.call(arguments, 2), list;
7971
- if (operationGroup) {
7972
- list = operationGroup.delayedCallbacks;
7973
- } else if (orphanDelayedCallbacks) {
7974
- list = orphanDelayedCallbacks;
7975
- } else {
7976
- list = orphanDelayedCallbacks = [];
7977
- setTimeout(fireOrphanDelayed, 0);
7978
- }
7979
- function bnd(f) {return function(){f.apply(null, args);};};
7980
- for (var i = 0; i < arr.length; ++i)
7981
- list.push(bnd(arr[i]));
7982
- }
7983
-
7984
- function fireOrphanDelayed() {
7985
- var delayed = orphanDelayedCallbacks;
7986
- orphanDelayedCallbacks = null;
7987
- for (var i = 0; i < delayed.length; ++i) delayed[i]();
7988
- }
7989
-
7990
- // The DOM events that CodeMirror handles can be overridden by
7991
- // registering a (non-DOM) handler on the editor for the event name,
7992
- // and preventDefault-ing the event in that handler.
7993
- function signalDOMEvent(cm, e, override) {
7994
- if (typeof e == "string")
7995
- e = {type: e, preventDefault: function() { this.defaultPrevented = true; }};
7996
- signal(cm, override || e.type, cm, e);
7997
- return e_defaultPrevented(e) || e.codemirrorIgnore;
7998
- }
7999
-
8000
- function signalCursorActivity(cm) {
8001
- var arr = cm._handlers && cm._handlers.cursorActivity;
8002
- if (!arr) return;
8003
- var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
8004
- for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
8005
- set.push(arr[i]);
8006
- }
8007
-
8008
- function hasHandler(emitter, type) {
8009
- var arr = emitter._handlers && emitter._handlers[type];
8010
- return arr && arr.length > 0;
8011
- }
8012
-
8013
- // Add on and off methods to a constructor's prototype, to make
8014
- // registering events on such objects more convenient.
8015
- function eventMixin(ctor) {
8016
- ctor.prototype.on = function(type, f) {on(this, type, f);};
8017
- ctor.prototype.off = function(type, f) {off(this, type, f);};
8018
- }
8019
-
8020
- // MISC UTILITIES
8021
-
8022
- // Number of pixels added to scroller and sizer to hide scrollbar
8023
- var scrollerGap = 30;
8024
-
8025
- // Returned or thrown by various protocols to signal 'I'm not
8026
- // handling this'.
8027
- var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
8028
-
8029
- // Reused option objects for setSelection & friends
8030
- var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
8031
-
8032
- function Delayed() {this.id = null;}
8033
- Delayed.prototype.set = function(ms, f) {
8034
- clearTimeout(this.id);
8035
- this.id = setTimeout(f, ms);
8036
- };
8037
-
8038
- // Counts the column offset in a string, taking tabs into account.
8039
- // Used mostly to find indentation.
8040
- var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
8041
- if (end == null) {
8042
- end = string.search(/[^\s\u00a0]/);
8043
- if (end == -1) end = string.length;
8044
- }
8045
- for (var i = startIndex || 0, n = startValue || 0;;) {
8046
- var nextTab = string.indexOf("\t", i);
8047
- if (nextTab < 0 || nextTab >= end)
8048
- return n + (end - i);
8049
- n += nextTab - i;
8050
- n += tabSize - (n % tabSize);
8051
- i = nextTab + 1;
8052
- }
8053
- };
8054
-
8055
- // The inverse of countColumn -- find the offset that corresponds to
8056
- // a particular column.
8057
- function findColumn(string, goal, tabSize) {
8058
- for (var pos = 0, col = 0;;) {
8059
- var nextTab = string.indexOf("\t", pos);
8060
- if (nextTab == -1) nextTab = string.length;
8061
- var skipped = nextTab - pos;
8062
- if (nextTab == string.length || col + skipped >= goal)
8063
- return pos + Math.min(skipped, goal - col);
8064
- col += nextTab - pos;
8065
- col += tabSize - (col % tabSize);
8066
- pos = nextTab + 1;
8067
- if (col >= goal) return pos;
8068
- }
8069
- }
8070
-
8071
- var spaceStrs = [""];
8072
- function spaceStr(n) {
8073
- while (spaceStrs.length <= n)
8074
- spaceStrs.push(lst(spaceStrs) + " ");
8075
- return spaceStrs[n];
8076
- }
8077
-
8078
- function lst(arr) { return arr[arr.length-1]; }
8079
-
8080
- var selectInput = function(node) { node.select(); };
8081
- if (ios) // Mobile Safari apparently has a bug where select() is broken.
8082
- selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
8083
- else if (ie) // Suppress mysterious IE10 errors
8084
- selectInput = function(node) { try { node.select(); } catch(_e) {} };
8085
-
8086
- function indexOf(array, elt) {
8087
- for (var i = 0; i < array.length; ++i)
8088
- if (array[i] == elt) return i;
8089
- return -1;
8090
- }
8091
- function map(array, f) {
8092
- var out = [];
8093
- for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
8094
- return out;
8095
- }
8096
-
8097
- function nothing() {}
8098
-
8099
- function createObj(base, props) {
8100
- var inst;
8101
- if (Object.create) {
8102
- inst = Object.create(base);
8103
- } else {
8104
- nothing.prototype = base;
8105
- inst = new nothing();
8106
- }
8107
- if (props) copyObj(props, inst);
8108
- return inst;
8109
- };
8110
-
8111
- function copyObj(obj, target, overwrite) {
8112
- if (!target) target = {};
8113
- for (var prop in obj)
8114
- if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
8115
- target[prop] = obj[prop];
8116
- return target;
8117
- }
8118
-
8119
- function bind(f) {
8120
- var args = Array.prototype.slice.call(arguments, 1);
8121
- return function(){return f.apply(null, args);};
8122
- }
8123
-
8124
- var nonASCIISingleCaseWordChar = /[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
8125
- var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
8126
- return /\w/.test(ch) || ch > "\x80" &&
8127
- (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
8128
- };
8129
- function isWordChar(ch, helper) {
8130
- if (!helper) return isWordCharBasic(ch);
8131
- if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
8132
- return helper.test(ch);
8133
- }
8134
-
8135
- function isEmpty(obj) {
8136
- for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
8137
- return true;
8138
- }
8139
-
8140
- // Extending unicode characters. A series of a non-extending char +
8141
- // any number of extending chars is treated as a single unit as far
8142
- // as editing and measuring is concerned. This is not fully correct,
8143
- // since some scripts/fonts/browsers also treat other configurations
8144
- // of code points as a group.
8145
- 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]/;
8146
- function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
8147
-
8148
- // DOM UTILITIES
8149
-
8150
- function elt(tag, content, className, style) {
8151
- var e = document.createElement(tag);
8152
- if (className) e.className = className;
8153
- if (style) e.style.cssText = style;
8154
- if (typeof content == "string") e.appendChild(document.createTextNode(content));
8155
- else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
8156
- return e;
8157
- }
8158
-
8159
- var range;
8160
- if (document.createRange) range = function(node, start, end, endNode) {
8161
- var r = document.createRange();
8162
- r.setEnd(endNode || node, end);
8163
- r.setStart(node, start);
8164
- return r;
8165
- };
8166
- else range = function(node, start, end) {
8167
- var r = document.body.createTextRange();
8168
- try { r.moveToElementText(node.parentNode); }
8169
- catch(e) { return r; }
8170
- r.collapse(true);
8171
- r.moveEnd("character", end);
8172
- r.moveStart("character", start);
8173
- return r;
8174
- };
8175
-
8176
- function removeChildren(e) {
8177
- for (var count = e.childNodes.length; count > 0; --count)
8178
- e.removeChild(e.firstChild);
8179
- return e;
8180
- }
8181
-
8182
- function removeChildrenAndAdd(parent, e) {
8183
- return removeChildren(parent).appendChild(e);
8184
- }
8185
-
8186
- var contains = CodeMirror.contains = function(parent, child) {
8187
- if (child.nodeType == 3) // Android browser always returns false when child is a textnode
8188
- child = child.parentNode;
8189
- if (parent.contains)
8190
- return parent.contains(child);
8191
- do {
8192
- if (child.nodeType == 11) child = child.host;
8193
- if (child == parent) return true;
8194
- } while (child = child.parentNode);
8195
- };
8196
-
8197
- function activeElt() { return document.activeElement; }
8198
- // Older versions of IE throws unspecified error when touching
8199
- // document.activeElement in some cases (during loading, in iframe)
8200
- if (ie && ie_version < 11) activeElt = function() {
8201
- try { return document.activeElement; }
8202
- catch(e) { return document.body; }
8203
- };
8204
-
8205
- function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); }
8206
- var rmClass = CodeMirror.rmClass = function(node, cls) {
8207
- var current = node.className;
8208
- var match = classTest(cls).exec(current);
8209
- if (match) {
8210
- var after = current.slice(match.index + match[0].length);
8211
- node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
8212
- }
8213
- };
8214
- var addClass = CodeMirror.addClass = function(node, cls) {
8215
- var current = node.className;
8216
- if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
8217
- };
8218
- function joinClasses(a, b) {
8219
- var as = a.split(" ");
8220
- for (var i = 0; i < as.length; i++)
8221
- if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
8222
- return b;
8223
- }
8224
-
8225
- // WINDOW-WIDE EVENTS
8226
-
8227
- // These must be handled carefully, because naively registering a
8228
- // handler for each editor will cause the editors to never be
8229
- // garbage collected.
8230
-
8231
- function forEachCodeMirror(f) {
8232
- if (!document.body.getElementsByClassName) return;
8233
- var byClass = document.body.getElementsByClassName("CodeMirror");
8234
- for (var i = 0; i < byClass.length; i++) {
8235
- var cm = byClass[i].CodeMirror;
8236
- if (cm) f(cm);
8237
- }
8238
- }
8239
-
8240
- var globalsRegistered = false;
8241
- function ensureGlobalHandlers() {
8242
- if (globalsRegistered) return;
8243
- registerGlobalHandlers();
8244
- globalsRegistered = true;
8245
- }
8246
- function registerGlobalHandlers() {
8247
- // When the window resizes, we need to refresh active editors.
8248
- var resizeTimer;
8249
- on(window, "resize", function() {
8250
- if (resizeTimer == null) resizeTimer = setTimeout(function() {
8251
- resizeTimer = null;
8252
- forEachCodeMirror(onResize);
8253
- }, 100);
8254
- });
8255
- // When the window loses focus, we want to show the editor as blurred
8256
- on(window, "blur", function() {
8257
- forEachCodeMirror(onBlur);
8258
- });
8259
- }
8260
-
8261
- // FEATURE DETECTION
8262
-
8263
- // Detect drag-and-drop
8264
- var dragAndDrop = function() {
8265
- // There is *some* kind of drag-and-drop support in IE6-8, but I
8266
- // couldn't get it to work yet.
8267
- if (ie && ie_version < 9) return false;
8268
- var div = elt('div');
8269
- return "draggable" in div || "dragDrop" in div;
8270
- }();
8271
-
8272
- var zwspSupported;
8273
- function zeroWidthElement(measure) {
8274
- if (zwspSupported == null) {
8275
- var test = elt("span", "\u200b");
8276
- removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
8277
- if (measure.firstChild.offsetHeight != 0)
8278
- zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
8279
- }
8280
- var node = zwspSupported ? elt("span", "\u200b") :
8281
- elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
8282
- node.setAttribute("cm-text", "");
8283
- return node;
8284
- }
8285
-
8286
- // Feature-detect IE's crummy client rect reporting for bidi text
8287
- var badBidiRects;
8288
- function hasBadBidiRects(measure) {
8289
- if (badBidiRects != null) return badBidiRects;
8290
- var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
8291
- var r0 = range(txt, 0, 1).getBoundingClientRect();
8292
- if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
8293
- var r1 = range(txt, 1, 2).getBoundingClientRect();
8294
- return badBidiRects = (r1.right - r0.right < 3);
8295
- }
8296
-
8297
- // See if "".split is the broken IE version, if so, provide an
8298
- // alternative way to split lines.
8299
- var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
8300
- var pos = 0, result = [], l = string.length;
8301
- while (pos <= l) {
8302
- var nl = string.indexOf("\n", pos);
8303
- if (nl == -1) nl = string.length;
8304
- var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
8305
- var rt = line.indexOf("\r");
8306
- if (rt != -1) {
8307
- result.push(line.slice(0, rt));
8308
- pos += rt + 1;
8309
- } else {
8310
- result.push(line);
8311
- pos = nl + 1;
8312
- }
8313
- }
8314
- return result;
8315
- } : function(string){return string.split(/\r\n?|\n/);};
8316
-
8317
- var hasSelection = window.getSelection ? function(te) {
8318
- try { return te.selectionStart != te.selectionEnd; }
8319
- catch(e) { return false; }
8320
- } : function(te) {
8321
- try {var range = te.ownerDocument.selection.createRange();}
8322
- catch(e) {}
8323
- if (!range || range.parentElement() != te) return false;
8324
- return range.compareEndPoints("StartToEnd", range) != 0;
8325
- };
8326
-
8327
- var hasCopyEvent = (function() {
8328
- var e = elt("div");
8329
- if ("oncopy" in e) return true;
8330
- e.setAttribute("oncopy", "return;");
8331
- return typeof e.oncopy == "function";
8332
- })();
8333
-
8334
- var badZoomedRects = null;
8335
- function hasBadZoomedRects(measure) {
8336
- if (badZoomedRects != null) return badZoomedRects;
8337
- var node = removeChildrenAndAdd(measure, elt("span", "x"));
8338
- var normal = node.getBoundingClientRect();
8339
- var fromRange = range(node, 0, 1).getBoundingClientRect();
8340
- return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
8341
- }
8342
-
8343
- // KEY NAMES
8344
-
8345
- var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
8346
- 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
8347
- 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
8348
- 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
8349
- 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
8350
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
8351
- 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
8352
- CodeMirror.keyNames = keyNames;
8353
- (function() {
8354
- // Number keys
8355
- for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
8356
- // Alphabetic keys
8357
- for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
8358
- // Function keys
8359
- for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
8360
- })();
8361
-
8362
- // BIDI HELPERS
8363
-
8364
- function iterateBidiSections(order, from, to, f) {
8365
- if (!order) return f(from, to, "ltr");
8366
- var found = false;
8367
- for (var i = 0; i < order.length; ++i) {
8368
- var part = order[i];
8369
- if (part.from < to && part.to > from || from == to && part.to == from) {
8370
- f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
8371
- found = true;
8372
- }
8373
- }
8374
- if (!found) f(from, to, "ltr");
8375
- }
8376
-
8377
- function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
8378
- function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
8379
-
8380
- function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
8381
- function lineRight(line) {
8382
- var order = getOrder(line);
8383
- if (!order) return line.text.length;
8384
- return bidiRight(lst(order));
8385
- }
8386
-
8387
- function lineStart(cm, lineN) {
8388
- var line = getLine(cm.doc, lineN);
8389
- var visual = visualLine(line);
8390
- if (visual != line) lineN = lineNo(visual);
8391
- var order = getOrder(visual);
8392
- var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
8393
- return Pos(lineN, ch);
8394
- }
8395
- function lineEnd(cm, lineN) {
8396
- var merged, line = getLine(cm.doc, lineN);
8397
- while (merged = collapsedSpanAtEnd(line)) {
8398
- line = merged.find(1, true).line;
8399
- lineN = null;
8400
- }
8401
- var order = getOrder(line);
8402
- var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
8403
- return Pos(lineN == null ? lineNo(line) : lineN, ch);
8404
- }
8405
- function lineStartSmart(cm, pos) {
8406
- var start = lineStart(cm, pos.line);
8407
- var line = getLine(cm.doc, start.line);
8408
- var order = getOrder(line);
8409
- if (!order || order[0].level == 0) {
8410
- var firstNonWS = Math.max(0, line.text.search(/\S/));
8411
- var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
8412
- return Pos(start.line, inWS ? 0 : firstNonWS);
8413
- }
8414
- return start;
8415
- }
8416
-
8417
- function compareBidiLevel(order, a, b) {
8418
- var linedir = order[0].level;
8419
- if (a == linedir) return true;
8420
- if (b == linedir) return false;
8421
- return a < b;
8422
- }
8423
- var bidiOther;
8424
- function getBidiPartAt(order, pos) {
8425
- bidiOther = null;
8426
- for (var i = 0, found; i < order.length; ++i) {
8427
- var cur = order[i];
8428
- if (cur.from < pos && cur.to > pos) return i;
8429
- if ((cur.from == pos || cur.to == pos)) {
8430
- if (found == null) {
8431
- found = i;
8432
- } else if (compareBidiLevel(order, cur.level, order[found].level)) {
8433
- if (cur.from != cur.to) bidiOther = found;
8434
- return i;
8435
- } else {
8436
- if (cur.from != cur.to) bidiOther = i;
8437
- return found;
8438
- }
8439
- }
8440
- }
8441
- return found;
8442
- }
8443
-
8444
- function moveInLine(line, pos, dir, byUnit) {
8445
- if (!byUnit) return pos + dir;
8446
- do pos += dir;
8447
- while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
8448
- return pos;
8449
- }
8450
-
8451
- // This is needed in order to move 'visually' through bi-directional
8452
- // text -- i.e., pressing left should make the cursor go left, even
8453
- // when in RTL text. The tricky part is the 'jumps', where RTL and
8454
- // LTR text touch each other. This often requires the cursor offset
8455
- // to move more than one unit, in order to visually move one unit.
8456
- function moveVisually(line, start, dir, byUnit) {
8457
- var bidi = getOrder(line);
8458
- if (!bidi) return moveLogically(line, start, dir, byUnit);
8459
- var pos = getBidiPartAt(bidi, start), part = bidi[pos];
8460
- var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
8461
-
8462
- for (;;) {
8463
- if (target > part.from && target < part.to) return target;
8464
- if (target == part.from || target == part.to) {
8465
- if (getBidiPartAt(bidi, target) == pos) return target;
8466
- part = bidi[pos += dir];
8467
- return (dir > 0) == part.level % 2 ? part.to : part.from;
8468
- } else {
8469
- part = bidi[pos += dir];
8470
- if (!part) return null;
8471
- if ((dir > 0) == part.level % 2)
8472
- target = moveInLine(line, part.to, -1, byUnit);
8473
- else
8474
- target = moveInLine(line, part.from, 1, byUnit);
8475
- }
8476
- }
8477
- }
8478
-
8479
- function moveLogically(line, start, dir, byUnit) {
8480
- var target = start + dir;
8481
- if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
8482
- return target < 0 || target > line.text.length ? null : target;
8483
- }
8484
-
8485
- // Bidirectional ordering algorithm
8486
- // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
8487
- // that this (partially) implements.
8488
-
8489
- // One-char codes used for character types:
8490
- // L (L): Left-to-Right
8491
- // R (R): Right-to-Left
8492
- // r (AL): Right-to-Left Arabic
8493
- // 1 (EN): European Number
8494
- // + (ES): European Number Separator
8495
- // % (ET): European Number Terminator
8496
- // n (AN): Arabic Number
8497
- // , (CS): Common Number Separator
8498
- // m (NSM): Non-Spacing Mark
8499
- // b (BN): Boundary Neutral
8500
- // s (B): Paragraph Separator
8501
- // t (S): Segment Separator
8502
- // w (WS): Whitespace
8503
- // N (ON): Other Neutrals
8504
-
8505
- // Returns null if characters are ordered as they appear
8506
- // (left-to-right), or an array of sections ({from, to, level}
8507
- // objects) in the order in which they occur visually.
8508
- var bidiOrdering = (function() {
8509
- // Character types for codepoints 0 to 0xff
8510
- var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
8511
- // Character types for codepoints 0x600 to 0x6ff
8512
- var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
8513
- function charType(code) {
8514
- if (code <= 0xf7) return lowTypes.charAt(code);
8515
- else if (0x590 <= code && code <= 0x5f4) return "R";
8516
- else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
8517
- else if (0x6ee <= code && code <= 0x8ac) return "r";
8518
- else if (0x2000 <= code && code <= 0x200b) return "w";
8519
- else if (code == 0x200c) return "b";
8520
- else return "L";
8521
- }
8522
-
8523
- var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
8524
- var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
8525
- // Browsers seem to always treat the boundaries of block elements as being L.
8526
- var outerType = "L";
8527
-
8528
- function BidiSpan(level, from, to) {
8529
- this.level = level;
8530
- this.from = from; this.to = to;
8531
- }
8532
-
8533
- return function(str) {
8534
- if (!bidiRE.test(str)) return false;
8535
- var len = str.length, types = [];
8536
- for (var i = 0, type; i < len; ++i)
8537
- types.push(type = charType(str.charCodeAt(i)));
8538
-
8539
- // W1. Examine each non-spacing mark (NSM) in the level run, and
8540
- // change the type of the NSM to the type of the previous
8541
- // character. If the NSM is at the start of the level run, it will
8542
- // get the type of sor.
8543
- for (var i = 0, prev = outerType; i < len; ++i) {
8544
- var type = types[i];
8545
- if (type == "m") types[i] = prev;
8546
- else prev = type;
8547
- }
8548
-
8549
- // W2. Search backwards from each instance of a European number
8550
- // until the first strong type (R, L, AL, or sor) is found. If an
8551
- // AL is found, change the type of the European number to Arabic
8552
- // number.
8553
- // W3. Change all ALs to R.
8554
- for (var i = 0, cur = outerType; i < len; ++i) {
8555
- var type = types[i];
8556
- if (type == "1" && cur == "r") types[i] = "n";
8557
- else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
8558
- }
8559
-
8560
- // W4. A single European separator between two European numbers
8561
- // changes to a European number. A single common separator between
8562
- // two numbers of the same type changes to that type.
8563
- for (var i = 1, prev = types[0]; i < len - 1; ++i) {
8564
- var type = types[i];
8565
- if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
8566
- else if (type == "," && prev == types[i+1] &&
8567
- (prev == "1" || prev == "n")) types[i] = prev;
8568
- prev = type;
8569
- }
8570
-
8571
- // W5. A sequence of European terminators adjacent to European
8572
- // numbers changes to all European numbers.
8573
- // W6. Otherwise, separators and terminators change to Other
8574
- // Neutral.
8575
- for (var i = 0; i < len; ++i) {
8576
- var type = types[i];
8577
- if (type == ",") types[i] = "N";
8578
- else if (type == "%") {
8579
- for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
8580
- var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
8581
- for (var j = i; j < end; ++j) types[j] = replace;
8582
- i = end - 1;
8583
- }
8584
- }
8585
-
8586
- // W7. Search backwards from each instance of a European number
8587
- // until the first strong type (R, L, or sor) is found. If an L is
8588
- // found, then change the type of the European number to L.
8589
- for (var i = 0, cur = outerType; i < len; ++i) {
8590
- var type = types[i];
8591
- if (cur == "L" && type == "1") types[i] = "L";
8592
- else if (isStrong.test(type)) cur = type;
8593
- }
8594
-
8595
- // N1. A sequence of neutrals takes the direction of the
8596
- // surrounding strong text if the text on both sides has the same
8597
- // direction. European and Arabic numbers act as if they were R in
8598
- // terms of their influence on neutrals. Start-of-level-run (sor)
8599
- // and end-of-level-run (eor) are used at level run boundaries.
8600
- // N2. Any remaining neutrals take the embedding direction.
8601
- for (var i = 0; i < len; ++i) {
8602
- if (isNeutral.test(types[i])) {
8603
- for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
8604
- var before = (i ? types[i-1] : outerType) == "L";
8605
- var after = (end < len ? types[end] : outerType) == "L";
8606
- var replace = before || after ? "L" : "R";
8607
- for (var j = i; j < end; ++j) types[j] = replace;
8608
- i = end - 1;
8609
- }
8610
- }
8611
-
8612
- // Here we depart from the documented algorithm, in order to avoid
8613
- // building up an actual levels array. Since there are only three
8614
- // levels (0, 1, 2) in an implementation that doesn't take
8615
- // explicit embedding into account, we can build up the order on
8616
- // the fly, without following the level-based algorithm.
8617
- var order = [], m;
8618
- for (var i = 0; i < len;) {
8619
- if (countsAsLeft.test(types[i])) {
8620
- var start = i;
8621
- for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
8622
- order.push(new BidiSpan(0, start, i));
8623
- } else {
8624
- var pos = i, at = order.length;
8625
- for (++i; i < len && types[i] != "L"; ++i) {}
8626
- for (var j = pos; j < i;) {
8627
- if (countsAsNum.test(types[j])) {
8628
- if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
8629
- var nstart = j;
8630
- for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
8631
- order.splice(at, 0, new BidiSpan(2, nstart, j));
8632
- pos = j;
8633
- } else ++j;
8634
- }
8635
- if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
8636
- }
8637
- }
8638
- if (order[0].level == 1 && (m = str.match(/^\s+/))) {
8639
- order[0].from = m[0].length;
8640
- order.unshift(new BidiSpan(0, 0, m[0].length));
8641
- }
8642
- if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
8643
- lst(order).to -= m[0].length;
8644
- order.push(new BidiSpan(0, len - m[0].length, len));
8645
- }
8646
- if (order[0].level != lst(order).level)
8647
- order.push(new BidiSpan(order[0].level, len, len));
8648
-
8649
- return order;
8650
- };
8651
- })();
8652
-
8653
- // THE END
8654
-
8655
- CodeMirror.version = "5.0.1";
8656
-
8657
- return CodeMirror;
8658
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/codemirror/old/codemirror.min.js DELETED
@@ -1,5 +0,0 @@
1
- !function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Oo(n):{},Oo(Kl,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new ps(i,n.mode)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!wl&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new So,keySeq:null,specialChars:null};var a=this;cl&&11>fl&&setTimeout(function(){a.display.input.reset(!0)},20),Rr(this),Vo(),mr(this),this.curOp.forceUpdate=!0,Vi(this,i),n.autofocus&&!wl||a.hasFocus()?setTimeout(Do(cn,this),20):fn(this);for(var c in jl)jl.hasOwnProperty(c)&&jl[c](this,n[c],Xl);C(this),n.finishInit&&n.finishInit(this);for(var f=0;f<ql.length;++f)ql[f](this);br(this),hl&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=zo("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=zo("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=zo("div",null,"CodeMirror-code"),n.selectionDiv=zo("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=zo("div",null,"CodeMirror-cursors"),n.measure=zo("div",null,"CodeMirror-measure"),n.lineMeasure=zo("div",null,"CodeMirror-measure"),n.lineSpace=zo("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=zo("div",[zo("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=zo("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=zo("div",null,null,"position: absolute; height: "+Ls+"px; width: 1px;"),n.gutters=zo("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=zo("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=zo("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),cl&&8>fl&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),hl||sl&&wl||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,zt(e,100),e.state.modeGen++,e.curOp&&Dr(e)}function i(e){e.options.lineWrapping?(Bs(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Rs(e.display.wrapper,"CodeMirror-wrap"),h(e)),l(e),Dr(e),ir(e),setTimeout(function(){y(e)},100)}function o(e){var t=gr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vr(e.display)-3);return function(i){if(gi(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&_i(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ir(e)}function a(e){u(e),Dr(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Eo(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(zo("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function f(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=ai(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=ui(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function h(e){var t=e.display,r=e.doc;t.maxLine=Ki(r,r.first),t.maxLineLength=f(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=f(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Mo(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Gt(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Vt(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=zo("div",[zo("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=zo("div",[zo("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),ws(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),ws(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,cl&&8>fl&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Rs(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),ws(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?Qr(t,e):Zr(t,e)},t),t.display.scrollbars.addClass&&Bs(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Bt(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=$i(t,n),l=$i(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=$i(t,qi(Ki(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=$i(t,qi(Ki(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(zo("div",[zo("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Kt(e),this.force=r,this.dims=H(e),this.events=[]}function T(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Vt(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Vt(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return Pr(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Fr(e))return!1;C(e)&&(Pr(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Ml&&(o=di(e.doc,o),l=pi(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Er(e,o,l),r.viewOffset=qi(Ki(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Fr(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Ro();return a>4&&(r.lineDiv.style.display="none"),P(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Ro()!=u&&u.offsetHeight&&u.focus(),Eo(r.cursorDiv),Eo(r.selectionDiv),r.gutters.style.height=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,zt(e,400)),r.updateLineNumbers=null,!0}function A(e,t){for(var r=t.force,n=t.viewport,i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Kt(e))r=!0;else if(r=!1,n&&null!=n.top&&(n={top:Math.min(e.doc.height+Gt(e.display)-jt(e),n.top)}),t.visible=w(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!M(e,t))break;O(e);var o=p(e);Ot(e),W(e,o),y(e,o)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function N(e,t){var r=new k(e,t);if(M(e,r)){O(e),A(e,r);var n=p(e);Ot(e),W(e,n),y(e,n),r.finish()}}function W(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Vt(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(cl&&8>fl){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=gr(t)),(a>.001||-.001>a)&&(_i(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function P(e,t,r){function n(t){var r=t.nextSibling;return hl&&xl&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var f=a[c];if(f.hidden);else if(f.node&&f.node.parentNode==l){for(;s!=f.node;)s=n(s);var h=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(Mo(f.changes,"gutter")>-1&&(h=!1),I(e,f,u,r)),h&&(Eo(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=f.node.nextSibling}else{var d=V(e,f,u,r);l.insertBefore(d,s)}u+=f.size}for(;s;)s=n(s)}function I(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function z(e){return e.node==e.text&&(e.node=zo("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),cl&&8>fl&&(e.node.style.zIndex=2)),e.node}function E(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=z(e);e.background=r.insertBefore(zo("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Oi(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){E(e),e.line.wrapClass?z(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=z(t),l=t.gutter=zo("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(zo("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=i.hasOwnProperty(a)&&i[a];u&&l.appendChild(zo("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=z(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=zo("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),mo(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function _(e){return Al(e.line,e.ch)}function Y(e,t){return Nl(e,t)<0?t:e}function $(e,t){return Nl(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),cn(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n){var i=e.doc;e.display.shift=!1,n||(n=i.sel);var o=Vs(t),l=null;e.state.pasteIncoming&&n.ranges.length>1&&(Wl&&Wl.join("\n")==t?l=n.ranges.length%Wl.length==0&&Ao(Wl,Vs):o.length==n.ranges.length&&(l=Ao(o,function(e){return[e]})));for(var s=n.ranges.length-1;s>=0;s--){var a=n.ranges[s],u=a.from(),c=a.to();a.empty()&&(r&&r>0?u=Al(u.line,u.ch-r):e.state.overwrite&&!e.state.pasteIncoming&&(c=Al(c.line,Math.min(Ki(i,c.line).text.length,c.ch+To(o).length))));var f=e.curOp.updateInput,h={from:u,to:c,text:l?l[s%l.length]:o,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};if(bn(e.doc,h),mo(e,"inputRead",e,h),t&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&a.head.ch<100&&(!s||n.ranges[s-1].head.line!=a.head.line)){var d=e.getModeAt(a.head),p=Vl(h);if(d.electricChars){for(var g=0;g<d.electricChars.length;g++)if(t.indexOf(d.electricChars.charAt(g))>-1){Hn(e,p.line,"smart");break}}else d.electricInput&&d.electricInput.test(Ki(i,p.line).text.slice(0,p.ch))&&Hn(e,p.line,"smart")}}On(e),e.curOp.updateInput=f,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:Al(i,0),head:Al(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function et(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function tt(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new So,this.inaccurateSelection=!1,this.hasSelection=!1}function rt(){var e=zo("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=zo("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return hl?e.style.width="1000px":e.setAttribute("wrap","off"),bl&&(e.style.border="1px solid black"),et(e),t}function nt(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new So,this.gracePeriod=!1}function it(e,t){var r=qt(e,t.line);if(!r||r.hidden)return null;var n=Ki(e.doc,t.line),i=_t(r,n,t.line),o=Zi(n),l="left";if(o){var s=nl(o,t.ch);l=s%2?"right":"left"}var a=Jt(i.map,t.ch,"left");return a.offset="right"==a.collapse?a.end:a.start,a}function ot(e,t){return t&&(e.bad=!0),e}function lt(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return ot(e.clipPos(Al(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return st(o,t,r)}}function st(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=Yi(0>i?e.line:e.rest[i]),f=o[l]+n;return(0>n||s!=t)&&(f=o[l+(n?1:0)]),Al(a,f)}}}var i=e.text.firstChild,o=!1;if(!t||!zs(i,t))return ot(Al(Yi(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?To(e.rest):e.line;return ot(Al(Yi(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,f=n(s,a,r);if(f)return ot(f,o);for(var h=a.nextSibling,d=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return ot(Al(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(f=n(p,p.firstChild,-1))return ot(Al(f.line,f.ch+d),o);d+=h.textContent.length}}function at(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,c=t.getAttribute("cm-marker");if(c){var f=e.findMarks(Al(n,0),Al(i+1,0),o(+c));return void(f.length&&(u=f[0].find())&&(s+=ji(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)l(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var d=t.nodeValue;if(!d)return;a&&(s+="\n",a=!1),s+=d}}for(var s="",a=!1;l(t),t!=r;)t=t.nextSibling;return s}function ut(e,t){this.ranges=e,this.primIndex=t}function ct(e,t){this.anchor=e,this.head=t}function ft(e,t){var r=e[t];e.sort(function(e,t){return Nl(e.from(),t.from())}),t=Mo(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Nl(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=Y(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new ct(a?s:l,a?l:s))}}return new ut(e,t)}function ht(e,t){return new ut([new ct(e,t||e)],0)}function dt(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pt(e,t){if(t.line<e.first)return Al(e.first,0);var r=e.first+e.size-1;return t.line>r?Al(r,Ki(e,r).text.length):gt(t,Ki(e,t.line).text.length)}function gt(e,t){var r=e.ch;return null==r||r>t?Al(e.line,t):0>r?Al(e.line,0):e}function vt(e,t){return t>=e.first&&t<e.first+e.size}function mt(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=pt(e,t[n]);return r}function yt(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Nl(r,i)<0;o!=Nl(n,i)<0?(i=r,r=n):o!=Nl(r,n)<0&&(r=n)}return new ct(i,r)}return new ct(n||r,r)}function bt(e,t,r,n){kt(e,new ut([yt(e,e.sel.primary(),t,r)],0),n)}function wt(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=yt(e,e.sel.ranges[i],t[i],null);var o=ft(n,e.sel.primIndex);kt(e,o,r)}function xt(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,kt(e,ft(i,e.sel.primIndex),n)}function Ct(e,t,r,n){kt(e,ht(t,r),n)}function St(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new ct(pt(e,t[r].anchor),pt(e,t[r].head))}};return Cs(e,"beforeSelectionChange",e,r),e.cm&&Cs(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?ft(r.ranges,r.ranges.length-1):t}function Lt(e,t,r){var n=e.history.done,i=To(n);i&&i.ranges?(n[n.length-1]=t,Tt(e,t,r)):kt(e,t,r)}function kt(e,t,r){Tt(e,t,r),io(e,e.sel,e.cm?e.cm.curOp.id:0/0,r)}function Tt(e,t,r){(xo(e,"beforeSelectionChange")||e.cm&&xo(e.cm,"beforeSelectionChange"))&&(t=St(e,t));var n=r&&r.bias||(Nl(t.primary().head,e.sel.primary().head)<0?-1:1);Mt(e,Nt(e,t,n,!0)),r&&r.scroll===!1||!e.cm||On(e.cm)}function Mt(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,wo(e.cm)),mo(e,"cursorActivity",e))}function At(e){Mt(e,Nt(e,e.sel,null,!1),Ts)}function Nt(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=Wt(e,l.anchor,r,n),a=Wt(e,l.head,r,n);(i||s!=l.anchor||a!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new ct(s,a))}return i?ft(i,t.primIndex):t}function Wt(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var s=Ki(e,o.line);if(s.markedSpans)for(var a=0;a<s.markedSpans.length;++a){var u=s.markedSpans[a],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Cs(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var f=c.find(0>l?-1:1);if(0==Nl(f,o)&&(f.ch+=l,f.ch<0?f=f.line>e.first?pt(e,Al(f.line-1)):null:f.ch>s.text.length&&(f=f.line<e.first+e.size-1?Al(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,Al(e.first,0)):Wt(e,t,r,!0);i=!0,f=t,l=-l}o=f;continue e}}return o}}function Ot(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Dt(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&Ht(e,s,i),a||Pt(e,s,o)}return n}function Ht(e,t,r){var n=cr(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(zo("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(zo("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Pt(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(zo("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ur(e,Al(t,r),"div",f,n)}var s,a,f=Ki(l,t),h=f.text.length;return Yo(Zi(f),r||0,null==i?h:i,function(e,t,l){var f,d,p,g=o(e,"left");if(e==t)f=g,d=p=g.left;else{if(f=o(t-1,"right"),"rtl"==l){var v=g;g=f,f=v}d=g.left,p=f.right}null==r&&0==e&&(d=u),f.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<f.top&&n(d,g.bottom,null,f.top)),null==i&&t==h&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||f.bottom>a.bottom||f.bottom==a.bottom&&f.right>a.right)&&(a=f),u+1>d&&(d=u),n(d,f.top,p-d,f.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Ut(e.display),u=a.left,c=Math.max(o.sizerWidth,Kt(e)-o.sizer.offsetLeft)-a.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Ki(l,f.line),p=Ki(l,h.line),g=fi(d)==fi(p),v=i(f.line,f.ch,g?d.text.length+1:null).end,m=i(h.line,g?0:null,h.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function It(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function zt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Do(Et,e))}function Et(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=Ql(t.mode,Rt(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=Mi(e,o,n,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),f=0;!c&&f<l.length;++f)c=l[f]!=o.styles[f];c&&i.push(t.frontier),o.stateAfter=Ql(t.mode,n)}else Ni(e,o.text,n),o.stateAfter=t.frontier%5==0?Ql(t.mode,n):null;return++t.frontier,+new Date>r?(zt(e,e.options.workDelay),!0):void 0}),i.length&&Tr(e,function(){for(var t=0;t<i.length;t++)Hr(e,i[t],"text")})}}function Ft(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Ki(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Ns(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Rt(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Ft(e,t,r),l=o>n.first&&Ki(n,o-1).stateAfter;return l=l?Ql(n.mode,l):Jl(n.mode),n.iter(o,t,function(r){Ni(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?Ql(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Bt(e){return e.lineSpace.offsetTop}function Gt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ut(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Fo(e.measure,zo("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Vt(e){return Ls-e.display.nativeBarWidth}function Kt(e){return e.display.scroller.clientWidth-Vt(e)-e.display.barWidth}function jt(e){return e.display.scroller.clientHeight-Vt(e)-e.display.barHeight}function Xt(e,t,r){var n=e.options.lineWrapping,i=n&&Kt(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function _t(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(Yi(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Yt(e,t){t=fi(t);var r=Yi(t),n=e.display.externalMeasured=new Wr(e.doc,t,r);n.lineN=r;var i=n.built=Oi(e,n);return n.text=i.pre,Fo(e.display.lineMeasure,i.pre),n}function $t(e,t,r,n){return Qt(e,Zt(e,t),r,n)}function qt(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ir(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Zt(e,t){var r=Yi(t),n=qt(e,r);n&&!n.text?n=null:n&&n.changes&&I(e,n,r,H(e)),n||(n=Yt(e,t));var i=_t(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qt(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Xt(e,t.view,t.rect),t.hasHeights=!0),o=er(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Jt(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function er(e,t,r,n){var i,o=Jt(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Io(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Io(t.line.text.charAt(o.coverStart+a));)++a;if(cl&&9>fl&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(cl&&e.options.lineWrapping){var f=Ds(l,s,a).getClientRects();i=f.length?f["right"==n?f.length-1:0]:Pl}else i=Ds(l,s,a).getBoundingClientRect()||Pl;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}cl&&11>fl&&(i=tr(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(cl&&9>fl&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+vr(e.display),top:h.top,bottom:h.bottom}:Pl}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,b.rbottom=p),b
2
- }function tr(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!_o(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rr(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nr(e){e.display.externalMeasure=null,Eo(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rr(e.display.view[t])}function ir(e){nr(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function or(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lr(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function sr(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=yi(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=qi(t);if("local"==n?l+=Bt(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:lr());var a=s.left+("window"==n?0:or());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function ar(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=or(),i-=lr();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ur(e,t,r,n,i){return n||(n=Ki(e.doc,t.line)),sr(e,n,$t(e,n,t.ch,i),r)}function cr(e,t,r,n,i,o){function l(t,l){var s=Qt(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,sr(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==$o(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=qo(r)-(r.level%2?0:1),n=!0):e==qo(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=$o(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Ki(e.doc,t.line),i||(i=Zt(e,n));var a=Zi(n),u=t.ch;if(!a)return l(u);var c=nl(a,u),f=s(u,c);return null!=Ys&&(f.other=s(u,Ys)),f}function fr(e,t){var r=0,t=pt(e.doc,t);e.options.lineWrapping||(r=vr(e.display)*t.ch);var n=Ki(e.doc,t.line),i=qi(n)+Bt(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function hr(e,t,r,n){var i=Al(e,t);return i.xRel=n,r&&(i.outside=!0),i}function dr(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return hr(n.first,0,!0,-1);var i=$i(n,r),o=n.first+n.size-1;if(i>o)return hr(n.first+n.size-1,Ki(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Ki(n,i);;){var s=pr(e,l,i,t,r),a=ui(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=Yi(l=u.to.line)}}function pr(e,t,r,n,i){function o(n){var i=cr(e,Al(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-qi(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Zt(e,t),c=Zi(t),f=t.text.length,h=Zo(t),d=Qo(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return hr(r,d,m,1);for(;;){if(c?d==h||d==ol(t,h,1):1>=d-h){for(var y=p>n||v-n>=n-p?h:d,b=n-(y==h?p:v);Io(t.text.charAt(y));)++y;var w=hr(r,y,y==h?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),C=h+x;if(c){C=h;for(var S=0;x>S;++S)C=ol(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),f=x):(h=C,p=L,g=s,f-=x)}}function gr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ol){Ol=zo("pre");for(var t=0;49>t;++t)Ol.appendChild(document.createTextNode("x")),Ol.appendChild(zo("br"));Ol.appendChild(document.createTextNode("x"))}Fo(e.measure,Ol);var r=Ol.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),Eo(e.measure),r||1}function vr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=zo("span","xxxxxxxxxx"),r=zo("pre",[t]);Fo(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function mr(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++zl},Il?Il.ops.push(e.curOp):e.curOp.ownsGroup=Il={ops:[e.curOp],delayedCallbacks:[]}}function yr(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r]();for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(r<t.length)}function br(e){var t=e.curOp,r=t.ownsGroup;if(r)try{yr(r)}finally{Il=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;wr(r)}}function wr(e){for(var t=e.ops,r=0;r<t.length;r++)xr(t[r]);for(var r=0;r<t.length;r++)Cr(t[r]);for(var r=0;r<t.length;r++)Sr(t[r]);for(var r=0;r<t.length;r++)Lr(t[r]);for(var r=0;r<t.length;r++)kr(t[r])}function xr(e){var t=e.cm,r=t.display;T(t),e.updateMaxLine&&h(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new k(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Cr(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function Sr(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$t(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Vt(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Kt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Lr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Qr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&W(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&It(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing)}function kr(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&A(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Kt(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Mn(t,pt(n,e.scrollToPos.from),pt(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Tn(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Cs(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Cs(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Cs(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Tr(e,t){if(e.curOp)return t();mr(e);try{return t()}finally{br(e)}}function Mr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mr(e);try{return t.apply(e,arguments)}finally{br(e)}}}function Ar(e){return function(){if(this.curOp)return e.apply(this,arguments);mr(this);try{return e.apply(this,arguments)}finally{br(this)}}}function Nr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mr(t);try{return e.apply(this,arguments)}finally{br(t)}}}function Wr(e,t,r){this.line=t,this.rest=hi(t),this.size=this.rest?Yi(To(this.rest))-r+1:1,this.node=this.text=null,this.hidden=gi(e,t)}function Or(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Wr(e.doc,Ki(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Dr(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ml&&di(e.doc,t)<i.viewTo&&Pr(e);else if(r<=i.viewFrom)Ml&&pi(e.doc,r+n)>i.viewFrom?Pr(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Pr(e);else if(t<=i.viewFrom){var o=zr(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Pr(e)}else if(r>=i.viewTo){var o=zr(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):Pr(e)}else{var l=zr(e,t,t,-1),s=zr(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Or(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):Pr(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function Hr(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Ir(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Mo(l,r)&&l.push(r)}}}function Pr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ir(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function zr(e,t,r,n){var i,o=Ir(e,t),l=e.display.view;if(!Ml||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;di(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Er(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Or(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Or(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Ir(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Or(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Ir(e,r)))),n.viewTo=r}function Fr(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rr(e){function t(){o.activeTouch&&(l=setTimeout(function(){o.activeTouch=null},1e3),s=o.activeTouch,s.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}function i(t){bo(e,t)||bs(t)}var o=e.display;ws(o.scroller,"mousedown",Mr(e,Vr)),cl&&11>fl?ws(o.scroller,"dblclick",Mr(e,function(t){if(!bo(e,t)){var r=Ur(e,t);if(r&&!Yr(e,t)&&!Gr(e.display,t)){ms(t);var n=e.findWordAt(r);bt(e.doc,n.anchor,n.head)}}})):ws(o.scroller,"dblclick",function(t){bo(e,t)||ms(t)}),kl||ws(o.scroller,"contextmenu",function(t){hn(e,t)});var l,s={end:0};ws(o.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(l);var t=+new Date;o.activeTouch={start:t,moved:!1,prev:t-s.end<=300?s:null},1==e.touches.length&&(o.activeTouch.left=e.touches[0].pageX,o.activeTouch.top=e.touches[0].pageY)}}),ws(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),ws(o.scroller,"touchend",function(r){var i=o.activeTouch;if(i&&!Gr(o,r)&&null!=i.left&&!i.moved&&new Date-i.start<300){var l,s=e.coordsChar(o.activeTouch,"page");l=!i.prev||n(i,i.prev)?new ct(s,s):!i.prev.prev||n(i,i.prev.prev)?e.findWordAt(s):new ct(Al(s.line,0),pt(e.doc,Al(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),ms(r)}t()}),ws(o.scroller,"touchcancel",t),ws(o.scroller,"scroll",function(){o.scroller.clientHeight&&(Zr(e,o.scroller.scrollTop),Qr(e,o.scroller.scrollLeft,!0),Cs(e,"scroll",e))}),ws(o.scroller,"mousewheel",function(t){Jr(e,t)}),ws(o.scroller,"DOMMouseScroll",function(t){Jr(e,t)}),ws(o.wrapper,"scroll",function(){o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),e.options.dragDrop&&(ws(o.scroller,"dragstart",function(t){qr(e,t)}),ws(o.scroller,"dragenter",i),ws(o.scroller,"dragover",i),ws(o.scroller,"drop",Mr(e,$r)));var a=o.input.getField();ws(a,"keyup",function(t){an.call(e,t)}),ws(a,"keydown",Mr(e,ln)),ws(a,"keypress",Mr(e,un)),ws(a,"focus",Do(cn,e)),ws(a,"blur",Do(fn,e))}function Br(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gr(e,t){for(var r=go(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Ur(e,t,r,n){var i=e.display;if(!r&&"true"==go(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=dr(e,o,l);if(n&&1==u.xRel&&(a=Ki(e.doc,u.line).text).length==u.ch){var c=Ns(a,a.length,e.options.tabSize)-a.length;u=Al(u.line,Math.max(0,Math.round((o-Ut(e.display).left)/vr(e.display))-c))}return u}function Vr(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||bo(t,e))){if(r.shift=e.shiftKey,Gr(r,e))return void(hl||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Yr(t,e)){var n=Ur(t,e);switch(window.focus(),vo(e)){case 1:n?Kr(t,e,n):go(e)==r.scroller&&ms(e);break;case 2:hl&&(t.state.lastMiddleDown=+new Date),n&&bt(t.doc,n),setTimeout(function(){r.input.focus()},20),ms(e);break;case 3:kl&&hn(t,e)}}}}function Kr(e,t,r){cl?setTimeout(Do(q,e),0):q(e);var n,i=+new Date;Hl&&Hl.time>i-400&&0==Nl(Hl.pos,r)?n="triple":Dl&&Dl.time>i-400&&0==Nl(Dl.pos,r)?(n="double",Hl={time:i,pos:r}):(n="single",Dl={time:i,pos:r});var o,l=e.doc.sel,s=xl?t.metaKey:t.ctrlKey;e.options.dragDrop&&Us&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&!l.ranges[o].empty()?jr(e,t,r,s):Xr(e,t,r,n,s)}function jr(e,t,r,n){var i=e.display,o=Mr(e,function(l){hl&&(i.scroller.draggable=!1),e.state.draggingText=!1,xs(document,"mouseup",o),xs(i.scroller,"drop",o),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(ms(l),n||bt(e.doc,r),hl||cl&&9==fl?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});hl&&(i.scroller.draggable=!0),e.state.draggingText=o,i.scroller.dragDrop&&i.scroller.dragDrop(),ws(document,"mouseup",o),ws(i.scroller,"drop",o)}function Xr(e,t,r,n,i){function o(t){if(0!=Nl(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Ns(Ki(u,r.line).text,r.ch,o),s=Ns(Ki(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Ki(u,p).text,y=Lo(m,a,o);a==d?i.push(new ct(Al(p,y),Al(p,y))):m.length>y&&i.push(new ct(Al(p,y),Al(p,Lo(m,d,o))))}i.length||i.push(new ct(r,r)),kt(u,ft(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new ct(Al(t.line,0),pt(u,Al(t.line+1,0)));Nl(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=Y(b.to(),C.head))}var i=h.ranges.slice(0);i[f]=new ct(pt(u,w),x),kt(u,ft(i,f),Ms)}}function l(t){var r=++y,i=Ur(e,t,!0,"rect"==n);if(i)if(0!=Nl(i,v)){q(e),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(Mr(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(Mr(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,ms(e),a.input.focus(),xs(document,"mousemove",b),xs(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;ms(t);var c,f,h=u.sel,d=h.ranges;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?d[f]:new ct(r,r)):c=u.sel.primary(),t.altKey)n="rect",i||(c=new ct(r,r)),r=Ur(e,t,!0,!0),f=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?yt(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new ct(Al(r.line,0),pt(u,Al(r.line+1,0)));c=e.display.shift||u.extend?yt(u,c,g.anchor,g.head):g}else c=yt(u,c,r);i?-1==f?(f=d.length,kt(u,ft(d.concat([c]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==n?(kt(u,ft(d.slice(0,f).concat(d.slice(f+1)),0)),h=u.sel):xt(u,f,c,Ms):(f=0,kt(u,new ut([c],0),Ms),h=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=Mr(e,function(e){vo(e)?l(e):s(e)}),x=Mr(e,s);ws(document,"mousemove",b),ws(document,"mouseup",x)}function _r(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&ms(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!xo(e,r))return po(t);l-=a.top-s.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=s.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=$i(e.doc,l),h=e.options.gutters[u];return i(e,r,e,f,h,t),po(t)}}}function Yr(e,t){return _r(e,t,"gutterClick",!0,mo)}function $r(e){var t=this;if(!bo(t,e)&&!Gr(t.display,e)){ms(e),cl&&(El=+new Date);var r=Ur(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){var s=new FileReader;s.onload=Mr(t,function(){if(o[n]=s.result,++l==i){r=pt(t.doc,r);var e={from:r,to:r,text:Vs(o.join("\n")),origin:"paste"};bn(t.doc,e),Lt(t.doc,ht(r,Vl(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(xl?e.metaKey:e.ctrlKey))var u=t.listSelections();if(Tt(t.doc,ht(r,r)),u)for(var a=0;a<u.length;++a)kn(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function qr(e,t){if(cl&&(!e.state.draggingText||+new Date-El<100))return void bs(t);if(!bo(e,t)&&!Gr(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!vl)){var r=zo("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",gl&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),gl&&r.parentNode.removeChild(r)}}function Zr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,sl||N(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),sl&&N(e),zt(e,100))}function Qr(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Jr(e,t){var r=Bl(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&xl&&hl)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;u<a.length;u++)if(a[u].node==s){e.display.currentWheelTarget=s;break e}if(n&&!sl&&!gl&&null!=Rl)return i&&Zr(e,Math.max(0,Math.min(l.scrollTop+i*Rl,l.scrollHeight-l.clientHeight))),Qr(e,Math.max(0,Math.min(l.scrollLeft+n*Rl,l.scrollWidth-l.clientWidth))),ms(t),void(o.wheelStartX=null);if(i&&null!=Rl){var c=i*Rl,f=e.doc.scrollTop,h=f+o.wrapper.clientHeight;0>c?f=Math.max(0,f+c-50):h=Math.min(e.doc.height,h+c+50),N(e,{top:f,bottom:h})}20>Fl&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Rl=(Rl*Fl+r)/(Fl+1),++Fl)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function en(e,t,r){if("string"==typeof t&&(t=es[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=ks}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function tn(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=rs(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&rs(t,e.options.extraKeys,r,e)||rs(t,e.options.keyMap,r,e)}function rn(e,t,r,n){var i=e.state.keySeq;if(i){if(ns(t))return"handled";Gl.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=tn(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&mo(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(ms(r),It(e)),i&&!o&&/\'$/.test(t)?(ms(r),!0):!!o}function nn(e,t){var r=is(t,!0);return r?t.shiftKey&&!e.state.keySeq?rn(e,"Shift-"+r,t,function(t){return en(e,t,!0)})||rn(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?en(e,t):void 0}):rn(e,r,t,function(t){return en(e,t)}):!1}function on(e,t,r){return rn(e,"'"+r+"'",t,function(t){return en(e,t,!0)})}function ln(e){var t=this;if(q(t),!bo(t,e)){cl&&11>fl&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=nn(t,e);gl&&(Ul=n?r:null,!n&&88==r&&!js&&(xl?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||sn(t)}}function sn(e){function t(e){18!=e.keyCode&&e.altKey||(Rs(r,"CodeMirror-crosshair"),xs(document,"keyup",t),xs(document,"mouseover",t))}var r=e.display.lineDiv;Bs(r,"CodeMirror-crosshair"),ws(document,"keyup",t),ws(document,"mouseover",t)}function an(e){16==e.keyCode&&(this.doc.sel.shift=!1),bo(this,e)}function un(e){var t=this;if(!(Gr(t.display,e)||bo(t,e)||e.ctrlKey&&!e.altKey||xl&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(gl&&r==Ul)return Ul=null,void ms(e);if(!gl||e.which&&!(e.which<10)||!nn(t,e)){var i=String.fromCharCode(null==n?r:n);on(t,e,i)||t.display.input.onKeyPress(e)}}}function cn(e){"nocursor"!=e.options.readOnly&&(e.state.focused||(Cs(e,"focus",e),e.state.focused=!0,Bs(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),hl&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),It(e))}function fn(e){e.state.focused&&(Cs(e,"blur",e),e.state.focused=!1,Rs(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function hn(e,t){Gr(e.display,t)||dn(e,t)||e.display.input.onContextMenu(t)}function dn(e,t){return xo(e,"gutterContextMenu")?_r(e,t,"gutterContextMenu",!1,Cs):!1}function pn(e,t){if(Nl(e,t.from)<0)return e;if(Nl(e,t.to)<=0)return Vl(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Vl(t).ch-t.to.ch),Al(r,n)}function gn(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new ct(pn(i.anchor,t),pn(i.head,t)))}return ft(r,e.sel.primIndex)}function vn(e,t,r){return e.line==t.line?Al(r.line,e.ch-t.ch+r.ch):Al(r.line+(e.line-t.line),e.ch)}function mn(e,t,r){for(var n=[],i=Al(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=vn(s.from,i,o),u=vn(Vl(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=Nl(c.head,c.anchor)<0;n[l]=new ct(f?u:a,f?a:u)}else n[l]=new ct(a,a)}return new ut(n,e.sel.primIndex)}function yn(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=pt(e,t)),r&&(this.to=pt(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Cs(e,"beforeChange",e,n),e.cm&&Cs(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function bn(e,t,r){if(e.cm){if(!e.cm.curOp)return Mr(e.cm,bn)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(xo(e,"beforeChange")||e.cm&&xo(e.cm,"beforeChange"))||(t=yn(e,t,!0))){var n=Tl&&!r&&ti(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)wn(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else wn(e,t)}}function wn(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Nl(t.from,t.to)){var r=gn(e,t);ro(e,t,r,e.cm?e.cm.curOp.id:0/0),Sn(e,t,r,Qn(e,t));var n=[];Ui(e,function(e,r){r||-1!=Mo(n,e.history)||(ho(e.history,t),n.push(e.history)),Sn(e,t,null,Qn(e,t))})}}function xn(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(oo(n,s),r&&!n.equals(e.sel))return void kt(e,n,{clearRedo:!1});o=n}var u=[];oo(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=xo(e,"beforeChange")||e.cm&&xo(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var f=n.changes[a];if(f.origin=t,c&&!yn(e,f,!1))return void(l.length=0);u.push(Ji(e,f));var h=a?gn(e,f):To(l);Sn(e,f,h,ei(e,f)),!a&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Vl(f)});var d=[];Ui(e,function(e,t){t||-1!=Mo(d,e.history)||(ho(e.history,f),d.push(e.history)),Sn(e,f,null,ei(e,f))})}}}}function Cn(e,t){if(0!=t&&(e.first+=t,e.sel=new ut(Ao(e.sel.ranges,function(e){return new ct(Al(e.anchor.line+t,e.anchor.ch),Al(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dr(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)Hr(e.cm,n,"gutter")}}function Sn(e,t,r,n){if(e.cm&&!e.cm.curOp)return Mr(e.cm,Sn)(e,t,r,n);if(t.to.line<e.first)return void Cn(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Cn(e,i),t={from:Al(e.first,0),to:Al(t.to.line+i,t.to.ch),text:[To(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Al(o,Ki(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ji(e,t.from,t.to),r||(r=gn(e,t)),e.cm?Ln(e.cm,t,n):Ri(e,t,n),Tt(e,r,Ts)}}function Ln(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=Yi(fi(Ki(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&wo(e),Ri(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),zt(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Dr(e):l.line!=s.line||1!=t.text.length||Fi(e.doc,t)?Dr(e,l.line,s.line+1,c):Hr(e,l.line,"text");var h=xo(e,"changes"),d=xo(e,"change");if(d||h){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&mo(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function kn(e,t,r,n,i){if(n||(n=r),Nl(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=Vs(t)),bn(e,{from:r,to:n,text:t,origin:i})}function Tn(e,t){if(!bo(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!yl){var o=zo("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-Bt(e.display))+"px; height: "+(t.bottom-t.top+Vt(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Mn(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=cr(e,t),s=r&&r!=t?cr(e,r):l,a=Nn(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Zr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(Qr(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function An(e,t,r,n,i){var o=Nn(e,t,r,n,i);null!=o.scrollTop&&Zr(e,o.scrollTop),null!=o.scrollLeft&&Qr(e,o.scrollLeft)}function Nn(e,t,r,n,i){var o=e.display,l=gr(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=jt(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Gt(o),f=l>r,h=i>c-l;if(s>r)u.scrollTop=f?0:r;else if(i>s+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Kt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Wn(e,t,r){(null!=t||null!=r)&&Dn(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function On(e){Dn(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?Al(t.line,t.ch-1):t,n=Al(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Dn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=fr(e,t.from),n=fr(e,t.to),i=Nn(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Hn(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Rt(e,t):r="prev");var l=e.options.tabSize,s=Ki(o,t),a=Ns(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==ks||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Ns(Ki(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)h+=l,f+=" ";if(u>h&&(f+=ko(u-h)),f!=c)kn(o,f,Al(t,0),Al(t,c.length),"+input");else for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var h=Al(t,c.length);xt(o,d,new ct(h,h));break}}s.stateAfter=null}function Pn(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Ki(e,dt(e,t)):i=Yi(t),null==i?null:(n(o,i)&&e.cm&&Hr(e.cm,i,r),o)}function In(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Nl(o.from,To(n).to)<=0;){var l=n.pop();if(Nl(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Tr(e,function(){for(var t=n.length-1;t>=0;t--)kn(e.doc,"",n[t].from,n[t].to,"+delete");On(e)})}function zn(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?f=!1:(s=t,c=Ki(e,t))}function l(e){var t=(i?ol:ll)(c,a,r,!0);if(null==t){if(e||!o())return f=!1;a=i?(0>r?Qo:Zo)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Ki(e,s),f=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var h=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Ho(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),h&&h!=m){0>r&&(r=1,l());break}if(m&&(h=m),r>0&&!l(!g))break}var y=Wt(e,Al(s,a),u,!0);return f||(y.hitSide=!0),y}function En(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(0>r?1.5:.5)*gr(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=dr(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Fn(t,r,n,i){e.defaults[t]=r,n&&(jl[t]=i?function(e,t,r){r!=Xl&&n(e,t,r)}:n)}function Rn(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Bn(e){return"string"==typeof e?ts[e]:e
3
- }function Gn(e,t,r,n,i){if(n&&n.shared)return Un(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Mr(e.cm,Gn)(e,t,r,n,i);var o=new ss(e,i),l=Nl(t,r);if(n&&Oo(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=zo("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(ci(e,t.line,t,r,o)||t.line!=r.line&&ci(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ml=!0}o.addToHistory&&ro(e,{from:t,to:r,origin:"markText"},e.sel,0/0);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&fi(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&_i(e,0),$n(e,new Xn(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){gi(e,t)&&_i(t,0)}),o.clearOnEnter&&ws(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Tl=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ls,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dr(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)Hr(u,c,"text");o.atomic&&At(u.doc),mo(u,"markerAdded",u,o)}return o}function Un(e,t,r,n,i){n=Oo(n),n.shared=!1;var o=[Gn(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Ui(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Gn(e,pt(e,t),pt(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=To(o)}),new as(o,l)}function Vn(e){return e.findMarks(Al(e.first,0),e.clipPos(Al(e.lastLine())),function(e){return e.parent})}function Kn(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Nl(o,l)){var s=Gn(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function jn(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];Ui(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Mo(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function Xn(e,t,r){this.marker=e,this.from=t,this.to=r}function _n(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function Yn(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function $n(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function qn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new Xn(l,o.from,a?null:o.to))}}return n}function Zn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new Xn(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Qn(e,t){if(t.full)return null;var r=vt(e,t.from.line)&&Ki(e,t.from.line).markedSpans,n=vt(e,t.to.line)&&Ki(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Nl(t.from,t.to),s=qn(r,i,l),a=Zn(n,o,l),u=1==t.text.length,c=To(t.text).length+(u?i:0);if(s)for(var f=0;f<s.length;++f){var h=s[f];if(null==h.to){var d=_n(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var f=0;f<a.length;++f){var h=a[f];if(null!=h.to&&(h.to+=c),null==h.from){var d=_n(s,h.marker);d||(h.from=c,u&&(s||(s=[])).push(h))}else h.from+=c,u&&(s||(s=[])).push(h)}s&&(s=Jn(s)),a&&a!=s&&(a=Jn(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var f=0;f<s.length;++f)null==s[f].to&&(g||(g=[])).push(new Xn(s[f].marker,null,null));for(var f=0;v>f;++f)p.push(g);p.push(a)}return p}function Jn(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function ei(e,t){var r=ao(e,t),n=Qn(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function ti(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Mo(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Nl(u.to,s.from)<0||Nl(u.from,s.to)>0)){var c=[a,1],f=Nl(u.from,s.from),h=Nl(u.to,s.to);(0>f||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(h>0||!l.inclusiveRight&&!h)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function ri(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function ni(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function ii(e){return e.inclusiveLeft?-1:0}function oi(e){return e.inclusiveRight?1:0}function li(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Nl(n.from,i.from)||ii(e)-ii(t);if(o)return-o;var l=Nl(n.to,i.to)||oi(e)-oi(t);return l?l:t.id-e.id}function si(e,t){var r,n=Ml&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||li(r,i.marker)<0)&&(r=i.marker);return r}function ai(e){return si(e,!0)}function ui(e){return si(e,!1)}function ci(e,t,r,n,i){var o=Ki(e,t),l=Ml&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Nl(u.from,r)||ii(a.marker)-ii(i),f=Nl(u.to,n)||oi(a.marker)-oi(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(Nl(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Nl(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function fi(e){for(var t;t=ai(e);)e=t.find(-1,!0).line;return e}function hi(e){for(var t,r;t=ui(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function di(e,t){var r=Ki(e,t),n=fi(r);return r==n?t:Yi(n)}function pi(e,t){if(t>e.lastLine())return t;var r,n=Ki(e,t);if(!gi(e,n))return t;for(;r=ui(n);)n=r.find(1,!0).line;return Yi(n)+1}function gi(e,t){var r=Ml&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&vi(e,t,n))return!0}}function vi(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return vi(e,n.line,_n(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&vi(e,t,i))return!0}function mi(e,t,r){qi(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Wn(e,null,r)}function yi(e){if(null!=e.height)return e.height;if(!zs(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.display.gutters.offsetWidth+"px;"),e.noHScroll&&(t+="width: "+e.cm.display.wrapper.clientWidth+"px;"),Fo(e.cm.display.measure,zo("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function bi(e,t,r,n){var i=new us(e,r,n);return i.noHScroll&&(e.display.alignWidgets=!0),Pn(e.doc,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,!gi(e.doc,t)){var n=qi(t)<e.doc.scrollTop;_i(t,t.height+yi(i)),n&&Wn(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function wi(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),ri(e),ni(e,r);var i=n?n(e):1;i!=e.height&&_i(e,i)}function xi(e){e.parent=null,ri(e)}function Ci(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function Si(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Li(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function ki(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?Ql(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=pt(l,t);var a,u=Ki(l,t.line),c=Rt(e,t.line,r),f=new os(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,o=Li(s,f,c),n&&a.push(i(!0));return n?a:i()}function Ti(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,f=new os(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&Ci(Si(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&Ni(e,t,n,f.pos),f.pos=t.length,a=null):a=Ci(Li(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<f.start;)u=Math.min(f.start,u+5e4),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);i(p,c),u=p}}function Mi(e,t,r,n){var i=[e.state.modeGen],o={};Ti(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Ti(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Ai(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Mi(e,t,t.stateAfter=Rt(e,Yi(t)));t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function Ni(e,t,r,n){var i=e.doc.mode,o=new os(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&Si(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Li(i,o,r),o.start=o.pos}function Wi(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?hs:fs;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Oi(e,t){var r=zo("span",null,null,hl?"padding-right: .1px":null),n={pre:zo("pre",[r]),content:r,col:0,pos:0,cm:e,splitSpaces:(cl||hl)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Hi,Xo(e.display.measure)&&(o=Zi(l))&&(n.addToken=Ii(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&Yi(l);Ei(l,n,Ai(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Go(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Go(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(jo(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return hl&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Cs(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Go(n.pre.className,n.textClass||"")),n}function Di(e){var t=zo("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Hi(e,t,r,n,i,o,l){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,Pi):t,a=e.cm.state.specialChars,u=!1;if(a.test(t))for(var c=document.createDocumentFragment(),f=0;;){a.lastIndex=f;var h=a.exec(t),d=h?h.index-f:t.length-f;if(d){var p=document.createTextNode(s.slice(f,f+d));c.appendChild(cl&&9>fl?zo("span",[p]):p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!h)break;if(f+=d+1," "==h[0]){var g=e.cm.options.tabSize,v=g-e.col%g,p=c.appendChild(zo("span",ko(v),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=v}else{var p=e.cm.options.specialCharPlaceholder(h[0]);p.setAttribute("cm-text",h[0]),c.appendChild(cl&&9>fl?zo("span",[p]):p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c),cl&&9>fl&&(u=!0),e.pos+=t.length}if(r||n||i||u||l){var m=r||"";n&&(m+=n),i&&(m+=i);var y=zo("span",[c],m,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function Pi(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}function Ii(e,t){return function(r,n,i,o,l,s,a){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var f=0;f<t.length;f++){var h=t[f];if(h.to>u&&h.from<=u)break}if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}function zi(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Ei(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=0;b<n.length;++b){var w=n[b],x=w.marker;w.from<=p&&(null==w.to||w.to>p)?(null!=w.to&&m>w.to&&(m=w.to,u=""),x.className&&(a+=" "+x.className),x.css&&(s=x.css),x.startStyle&&w.from==p&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(u+=" "+x.endStyle),x.title&&!f&&(f=x.title),x.collapsed&&(!h||li(h.marker,x)<0)&&(h=w)):w.from>p&&m>w.from&&(m=w.from),"bookmark"==x.type&&w.from==p&&x.widgetNode&&y.push(x)}if(h&&(h.from||0)==p&&(zi(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to))return;if(!h&&y.length)for(var b=0;b<y.length;++b)zi(t,0,y[b])}if(p>=d)break;for(var C=Math.min(d,m);;){if(v){var S=p+v.length;if(!h){var L=S>C?v.slice(0,C-p):v;t.addToken(t,L,l?l+a:a,c,p+L.length==m?u:"",f,s)}if(S>=C){v=v.slice(C-p),p=C;break}p=S,c=""}v=i.slice(o,o=r[g++]),l=Wi(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Wi(r[g+1],t.cm.options))}function Fi(e,t){return 0==t.from.ch&&0==t.to.ch&&""==To(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ri(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){wi(e,r,i,n),mo(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new cs(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Ki(e,s.line),f=Ki(e,a.line),h=To(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Fi(e,t)){var g=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==f)if(1==u.length)o(c,c.text.slice(0,s.ch)+h+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new cs(h+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+f.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(f,h+f.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}mo(e,"change",e,t)}function Bi(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function Gi(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function Ui(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function Vi(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,Dr(e)}function Ki(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function ji(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Xi(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function _i(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function Yi(e){if(null==e.parent)return null;for(var t=e.parent,r=Mo(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function $i(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function qi(e){e=fi(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function Zi(e){var t=e.order;return null==t&&(t=e.order=$s(e.text)),t}function Qi(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ji(e,t){var r={from:_(t.from),to:Vl(t),text:ji(e,t.from,t.to)};return lo(e,r,t.from.line,t.to.line+1),Ui(e,function(e){lo(e,r,t.from.line,t.to.line+1)},!0),r}function eo(e){for(;e.length;){var t=To(e);if(!t.ranges)break;e.pop()}}function to(e,t){return t?(eo(e.done),To(e.done)):e.done.length&&!To(e.done).ranges?To(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),To(e.done)):void 0}function ro(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=to(i,i.lastOp==n))){var s=To(o.changes);0==Nl(t.from,t.to)&&0==Nl(t.from,s.to)?s.to=Vl(t):o.changes.push(Ji(e,t))}else{var a=To(i.done);for(a&&a.ranges||oo(e.sel,i.done),o={changes:[Ji(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Cs(e,"historyAdded")}function no(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function io(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||no(e,o,To(i.done),t))?i.done[i.done.length-1]=t:oo(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&eo(i.undone)}function oo(e,t){var r=To(t);r&&r.ranges&&r.equals(e)||t.push(e)}function lo(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function so(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ao(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(so(r[n]));return i}function uo(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ut.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&Mo(t,Number(u[1]))>-1&&(To(s)[f]=c[f],delete c[f])}}}return i}function co(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function fo(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)co(o.ranges[s].anchor,t,r,n),co(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=Al(a.from.line+n,a.from.ch),a.to=Al(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function ho(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;fo(e.done,r,n,i),fo(e.undone,r,n,i)}function po(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function go(e){return e.target||e.srcElement}function vo(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),xl&&e.ctrlKey&&1==t&&(t=3),t}function mo(e,t){function r(e){return function(){e.apply(null,o)}}var n=e._handlers&&e._handlers[t];if(n){var i,o=Array.prototype.slice.call(arguments,2);Il?i=Il.delayedCallbacks:Ss?i=Ss:(i=Ss=[],setTimeout(yo,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function yo(){var e=Ss;Ss=null;for(var t=0;t<e.length;++t)e[t]()}function bo(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Cs(e,r||t.type,e,t),po(t)||t.codemirrorIgnore}function wo(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Mo(r,t[n])&&r.push(t[n])}function xo(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function Co(e){e.prototype.on=function(e,t){ws(this,e,t)},e.prototype.off=function(e,t){xs(this,e,t)}}function So(){this.id=null}function Lo(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function ko(e){for(;Ws.length<=e;)Ws.push(To(Ws)+" ");return Ws[e]}function To(e){return e[e.length-1]}function Mo(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Ao(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function No(){}function Wo(e,t){var r;return Object.create?r=Object.create(e):(No.prototype=e,r=new No),t&&Oo(t,r),r}function Oo(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Do(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Ho(e,t){return t?t.source.indexOf("\\w")>-1&&Ps(e)?!0:t.test(e):Ps(e)}function Po(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Io(e){return e.charCodeAt(0)>=768&&Is.test(e)}function zo(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function Eo(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Fo(e,t){return Eo(e).appendChild(t)}function Ro(){return document.activeElement}function Bo(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Go(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Bo(r[n]).test(t)&&(t+=" "+r[n]);return t}function Uo(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Vo(){Gs||(Ko(),Gs=!0)}function Ko(){var e;ws(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Uo(Br)},100))}),ws(window,"blur",function(){Uo(fn)})}function jo(e){if(null==Es){var t=zo("span","​");Fo(e,zo("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Es=t.offsetWidth<=1&&t.offsetHeight>2&&!(cl&&8>fl))}var r=Es?zo("span","​"):zo("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Xo(e){if(null!=Fs)return Fs;var t=Fo(e,document.createTextNode("AخA")),r=Ds(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Ds(t,1,2).getBoundingClientRect();return Fs=n.right-r.right<3}function _o(e){if(null!=Xs)return Xs;var t=Fo(e,zo("span","x")),r=t.getBoundingClientRect(),n=Ds(t,0,1).getBoundingClientRect();return Xs=Math.abs(r.left-n.left)>1}function Yo(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function $o(e){return e.level%2?e.to:e.from}function qo(e){return e.level%2?e.from:e.to}function Zo(e){var t=Zi(e);return t?$o(t[0]):0}function Qo(e){var t=Zi(e);return t?qo(To(t)):e.text.length}function Jo(e,t){var r=Ki(e.doc,t),n=fi(r);n!=r&&(t=Yi(n));var i=Zi(n),o=i?i[0].level%2?Qo(n):Zo(n):0;return Al(t,o)}function el(e,t){for(var r,n=Ki(e.doc,t);r=ui(n);)n=r.find(1,!0).line,t=null;var i=Zi(n),o=i?i[0].level%2?Zo(n):Qo(n):n.text.length;return Al(null==t?Yi(n):t,o)}function tl(e,t){var r=Jo(e,t.line),n=Ki(e.doc,r.line),i=Zi(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return Al(r.line,l?0:o)}return r}function rl(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function nl(e,t){Ys=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return rl(e,i.level,e[r].level)?(i.from!=i.to&&(Ys=r),n):(i.from!=i.to&&(Ys=n),r);r=n}}return r}function il(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Io(e.text.charAt(t)));return t}function ol(e,t,r,n){var i=Zi(e);if(!i)return ll(e,t,r,n);for(var o=nl(i,t),l=i[o],s=il(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return nl(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?il(e,l.to,-1,n):il(e,l.from,1,n)}}function ll(e,t,r,n){var i=t+r;if(n)for(;i>0&&Io(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var sl=/gecko\/\d/i.test(navigator.userAgent),al=/MSIE \d/.test(navigator.userAgent),ul=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),cl=al||ul,fl=cl&&(al?document.documentMode||6:ul[1]),hl=/WebKit\//.test(navigator.userAgent),dl=hl&&/Qt\/\d+\.\d+/.test(navigator.userAgent),pl=/Chrome\//.test(navigator.userAgent),gl=/Opera\//.test(navigator.userAgent),vl=/Apple Computer/.test(navigator.vendor),ml=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),yl=/PhantomJS/.test(navigator.userAgent),bl=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),wl=bl||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),xl=bl||/Mac/.test(navigator.platform),Cl=/win/i.test(navigator.platform),Sl=gl&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Sl&&(Sl=Number(Sl[1])),Sl&&Sl>=15&&(gl=!1,hl=!0);var Ll=xl&&(dl||gl&&(null==Sl||12.11>Sl)),kl=sl||cl&&fl>=9,Tl=!1,Ml=!1;g.prototype=Oo({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==n&&this.overlayHack(),this.checkedOverlay=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=xl&&!ml?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,r=function(e){go(e)!=t.vert&&go(e)!=t.horiz&&Mr(t.cm,Vr)(e)};ws(this.vert,"mousedown",r),ws(this.horiz,"mousedown",r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=Oo({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},k.prototype.signal=function(e,t){xo(e,t)&&this.events.push(arguments)},k.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Cs.apply(null,this.events[e])};var Al=e.Pos=function(e,t){return this instanceof Al?(this.line=e,void(this.ch=t)):new Al(e,t)},Nl=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Wl=null;tt.prototype=Oo({init:function(e){function t(e){if(n.somethingSelected())Wl=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Wl.join("\n"),Os(o));else{var t=J(n);Wl=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Ts):(r.prevInput="",o.value=t.text.join("\n"),Os(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=rt(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),bl&&(o.style.width="0px"),ws(o,"input",function(){cl&&fl>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),ws(o,"paste",function(){if(hl&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var e=o.selectionStart,t=o.selectionEnd;o.value+="$",o.selectionEnd=t,o.selectionStart=e,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,r.fastPoll()}),ws(o,"cut",t),ws(o,"copy",t),ws(e.scroller,"paste",function(t){Gr(e,t)||(n.state.pasteIncoming=!0,r.focus())}),ws(e.lineSpace,"selectstart",function(t){Gr(e,t)||ms(t)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=Dt(e);if(e.options.moveInputWithCursor){var i=cr(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Fo(r.cursorDiv,e.cursors),Fo(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=js&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Os(this.textarea),cl&&fl>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",cl&&fl>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!wl||Ro()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(!e.state.focused||Ks(t)&&!r||Z(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(cl&&fl>=9&&this.hasSelection===n||xl&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;8203!=n.charCodeAt(0)||e.doc.sel!=e.display.selForContextMenu||r||(r="​");for(var i=0,o=Math.min(r.length,n.length);o>i&&r.charCodeAt(i)==n.charCodeAt(i);)++i;var l=this;return Tr(e,function(){Q(e,n.slice(i),r.length-i),n.length>1e3||n.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=n
4
- }),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){cl&&fl>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=l.value="​"+(e?l.value:"");n.prevInput=e?"":"​",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,cl&&9>fl&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!cl||cl&&9>fl)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart?Mr(i,es.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Ur(i,e),a=o.scroller.scrollTop;if(s&&!gl){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&Mr(i,kt)(i.doc,ht(s),Ts);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(cl?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",hl)var f=window.scrollY;if(o.input.focus(),hl&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),cl&&fl>=9&&t(),kl){bs(e);var h=function(){xs(window,"mouseup",h),setTimeout(r,20)};ws(window,"mouseup",h)}else setTimeout(r,50)}},setUneditable:No,needsContentAttribute:!1},tt.prototype),nt.prototype=Oo({init:function(e){function t(e){if(n.somethingSelected())Wl=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{var t=J(n);Wl=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Ts),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!bl)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Wl.join("\n"));else{var r=rt(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Wl.join("\n");var o=document.activeElement;Os(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;i.contentEditable="true",et(i),ws(i,"paste",function(e){var t=e.clipboardData&&e.clipboardData.getData("text/plain");t&&(e.preventDefault(),n.replaceSelection(t,null,"paste"))}),ws(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=ht(Al(i.head.line,l),Al(i.head.line,l+t.length)))}}),ws(i,"compositionupdate",function(e){r.composing.data=e.data}),ws(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),ws(i,"touchstart",function(){r.forceCompositionEnd()}),ws(i,"input",function(){r.composing||r.pollContent()||Tr(r.cm,function(){Dr(n)})}),ws(i,"copy",t),ws(i,"cut",t)},prepareSelection:function(){var e=Dt(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=lt(this.cm,e.anchorNode,e.anchorOffset),n=lt(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Nl($(r,n),t.from())||0!=Nl(Y(r,n),t.to())){var i=it(this.cm,t.from()),o=it(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Ds(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode?e.addRange(s):sl&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Fo(this.cm.display.cursorDiv,e.cursors),Fo(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return zs(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Tr(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=lt(t,e.anchorNode,e.anchorOffset),n=lt(t,e.focusNode,e.focusOffset);r&&n&&Tr(t,function(){kt(t.doc,ht(r,n),Ts),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Ir(e,n.line)))var l=Yi(t.view[0].line),s=t.view[0].node;else var l=Yi(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Ir(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.view[a].node;else var u=Yi(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var f=Vs(at(e,s,c,l,u)),h=ji(e.doc,Al(l,0),Al(u,Ki(e.doc,u).text.length));f.length>1&&h.length>1;)if(To(f)==To(h))f.pop(),h.pop(),u--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,g=f[0],v=h[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=To(f),b=To(h),w=Math.min(y.length-(1==f.length?d:0),b.length-(1==h.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var x=Al(l,d),C=Al(u,h.length?To(h).length-p:0);return f.length>1||f[0]||Nl(x,C)?(kn(e.doc,f,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){e.data&&e.data!=e.startData&&Mr(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),Mr(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:No,resetPosition:No,needsContentAttribute:!0},nt.prototype),e.inputStyles={textarea:tt,contenteditable:nt},ut.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Nl(r.anchor,n.anchor)||0!=Nl(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ct(_(this.ranges[t].anchor),_(this.ranges[t].head));return new ut(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Nl(t,n.from())>=0&&Nl(e,n.to())<=0)return r}return-1}},ct.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return Y(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Ol,Dl,Hl,Pl={left:0,right:0,top:0,bottom:0},Il=null,zl=0,El=0,Fl=0,Rl=null;cl?Rl=-.53:sl?Rl=15:pl?Rl=-.7:vl&&(Rl=-1/3);var Bl=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Bl(e);return t.x*=Rl,t.y*=Rl,t};var Gl=new So,Ul=null,Vl=e.changeEnd=function(e){return e.text?Al(e.from.line+e.text.length-1,To(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,jl.hasOwnProperty(e)&&Mr(this,jl[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Bn(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Ar(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Dr(this)}),removeOverlay:Ar(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Dr(this)}}),indentLine:Ar(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),vt(this.doc,e)&&Hn(this,e,t,r)}),indentSelection:Ar(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Hn(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&On(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Hn(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&xt(this.doc,n,new ct(o,u[n].to()),Ts)}}}),getTokenAt:function(e,t){return ki(this,e,t)},getLineTokens:function(e,t){return ki(this,Al(e),t,!0)},getTokenTypeAt:function(e){e=pt(this.doc,e);var t,r=Ai(this,Ki(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Zl.hasOwnProperty(t))return r;var n=Zl[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Mo(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=dt(r,null==e?r.first+r.size-1:e),Rt(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?pt(this.doc,e):e?n.from():n.to(),cr(this,r,t||"page")},charCoords:function(e,t){return ur(this,pt(this.doc,e),t||"page")},coordsChar:function(e,t){return e=ar(this,e,t||"page"),dr(this,e.left,e.top)},lineAtHeight:function(e,t){return e=ar(this,{top:e,left:0},t||"page").top,$i(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r=!1,n=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>n&&(e=n,r=!0);var i=Ki(this.doc,e);return sr(this,i,{top:0,left:0},t||"page").top+(r?this.doc.height-qi(i):0)},defaultTextHeight:function(){return gr(this.display)},defaultCharWidth:function(){return vr(this.display)},setGutterMarker:Ar(function(e,t,r){return Pn(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Po(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Ar(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Hr(t,n,"gutter"),Po(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),addLineWidget:Ar(function(e,t,r){return bi(this,e,t,r)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if("number"==typeof e){if(!vt(this.doc,e))return null;var t=e;if(e=Ki(this.doc,e),!e)return null}else{var t=Yi(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=cr(this,pt(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&An(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Ar(ln),triggerOnKeyPress:Ar(un),triggerOnKeyUp:an,execCommand:function(e){return es.hasOwnProperty(e)?es[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=pt(this.doc,e);t>o&&(l=zn(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Ar(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?zn(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},As)}),deleteH:Ar(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):In(this,function(r){var i=zn(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=pt(this.doc,e);t>l;++l){var a=cr(this,s,"div");if(null==o?o=a.left:a.left=o,s=En(this,a,i,r),s.hitSide)break}return s},moveV:Ar(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=cr(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=En(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Wn(r,null,ur(r,a,"div").top-s.top),a},As),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Ki(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Ho(l,o)?function(e){return Ho(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Ho(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new ct(Al(e.line,n),Al(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Bs(this.display.cursorDiv,"CodeMirror-overwrite"):Rs(this.display.cursorDiv,"CodeMirror-overwrite"),Cs(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Ro()},scrollTo:Ar(function(e,t){(null!=e||null!=t)&&Dn(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Vt(this)-this.display.barHeight,width:e.scrollWidth-Vt(this)-this.display.barWidth,clientHeight:jt(this),clientWidth:Kt(this)}},scrollIntoView:Ar(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:Al(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Dn(this),this.curOp.scrollToPos=e;else{var r=Nn(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Ar(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&nr(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Hr(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Cs(n,"refresh",this)}),operation:function(e){return Tr(this,e)},refresh:Ar(function(){var e=this.display.cachedTextHeight;Dr(this),this.curOp.forceUpdate=!0,ir(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-gr(this.display))>.5)&&l(this),Cs(this,"refresh",this)}),swapDoc:Ar(function(e){var t=this.doc;return t.cm=null,Vi(this,e),ir(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,mo(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Co(e);var Kl=e.defaults={},jl=e.optionHandlers={},Xl=e.Init={toString:function(){return"CodeMirror.Init"}};Fn("value","",function(e,t){e.setValue(t)},!0),Fn("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Fn("indentUnit",2,r,!0),Fn("indentWithTabs",!1),Fn("smartIndent",!0),Fn("tabSize",4,function(e){n(e),ir(e),Dr(e)},!0),Fn("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,r,n){t.state.specialChars=new RegExp(r.source+(r.test(" ")?"":"| "),"g"),n!=e.Init&&t.refresh()}),Fn("specialCharPlaceholder",Di,function(e){e.refresh()},!0),Fn("electricChars",!0),Fn("inputStyle",wl?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Fn("rtlMoveVisually",!Cl),Fn("wholeLineUpdateBefore",!0),Fn("theme","default",function(e){s(e),a(e)},!0),Fn("keyMap","default",function(t,r,n){var i=Bn(r),o=n!=e.Init&&Bn(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Fn("extraKeys",null),Fn("lineWrapping",!1,i,!0),Fn("gutters",[],function(e){d(e.options),a(e)},!0),Fn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Fn("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Fn("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Fn("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Fn("firstLineNumber",1,a,!0),Fn("lineNumberFormatter",function(e){return e},a,!0),Fn("showCursorWhenSelecting",!1,Ot,!0),Fn("resetSelectionOnContextMenu",!0),Fn("readOnly",!1,function(e,t){"nocursor"==t?(fn(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),Fn("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Fn("dragDrop",!0),Fn("cursorBlinkRate",530),Fn("cursorScrollMargin",0),Fn("cursorHeight",1,Ot,!0),Fn("singleCursorHeightPerLine",!0,Ot,!0),Fn("workTime",100),Fn("workDelay",100),Fn("flattenSpans",!0,n,!0),Fn("addModeClass",!1,n,!0),Fn("pollInterval",100),Fn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Fn("historyEventDelay",1250),Fn("viewportMargin",10,function(e){e.refresh()},!0),Fn("maxHighlightLength",1e4,n,!0),Fn("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Fn("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Fn("autofocus",null);var _l=e.modes={},Yl=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),_l[t]=r},e.defineMIME=function(e,t){Yl[e]=t},e.resolveMode=function(t){if("string"==typeof t&&Yl.hasOwnProperty(t))t=Yl[t];else if(t&&"string"==typeof t.name&&Yl.hasOwnProperty(t.name)){var r=Yl[t.name];"string"==typeof r&&(r={name:r}),t=Wo(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=_l[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if($l.hasOwnProperty(r.name)){var o=$l[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var $l=e.modeExtensions={};e.extendMode=function(e,t){var r=$l.hasOwnProperty(e)?$l[e]:$l[e]={};Oo(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){ps.prototype[e]=t},e.defineOption=Fn;var ql=[];e.defineInitHook=function(e){ql.push(e)};var Zl=e.helpers={};e.registerHelper=function(t,r,n){Zl.hasOwnProperty(t)||(Zl[t]=e[t]={_global:[]}),Zl[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Zl[t]._global.push({pred:n,val:i})};var Ql=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},Jl=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var es=e.commands={selectAll:function(e){e.setSelection(Al(e.firstLine(),0),Al(e.lastLine()),Ts)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ts)},killLine:function(e){In(e,function(t){if(t.empty()){var r=Ki(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:Al(t.head.line+1,0)}:{from:t.head,to:Al(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){In(e,function(t){return{from:Al(t.from().line,0),to:pt(e.doc,Al(t.to().line+1,0))}})},delLineLeft:function(e){In(e,function(e){return{from:Al(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){In(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){In(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(Al(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(Al(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Jo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return tl(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return el(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},As)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},As)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?tl(e,t.head):n},As)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Ns(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Tr(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Ki(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new Al(i.line,i.ch-1)),i.ch>0)i=new Al(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Al(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Ki(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),Al(i.line-1,l.length-1),Al(i.line,1),"+transpose")}r.push(new ct(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Tr(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),On(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},ts=e.keyMap={};ts.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},ts.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},ts.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"},ts.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},ts["default"]=xl?ts.macDefault:ts.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Ao(r.split(" "),Rn),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=r,l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var rs=e.lookupKey=function(e,t,r,n){t=Bn(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return rs(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=rs(e,t.fallthrough[o],r,n);if(l)return l}}},ns=e.isModifierKey=function(e){var t="string"==typeof e?e:_s[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},is=e.keyName=function(e,t){if(gl&&34==e.keyCode&&e["char"])return!1;var r=_s[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(Ll?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(Ll?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?Oo(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=Ro();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(ws(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(xs(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var os=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};os.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);
5
- return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Ns(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Ns(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Ns(this.string,null,this.tabSize)-(this.lineStart?Ns(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ls=0,ss=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ls};Co(ss),ss.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&mr(e),xo(this,"clear")){var r=this.find();r&&mo(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=_n(l.markedSpans,this);e&&!this.collapsed?Hr(e,Yi(l),"text"):e&&(null!=s.to&&(i=Yi(l)),null!=s.from&&(n=Yi(l))),l.markedSpans=Yn(l.markedSpans,s),null==s.from&&this.collapsed&&!gi(this.doc,l)&&e&&_i(l,gr(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=fi(this.lines[o]),u=f(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Dr(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&At(e.doc)),e&&mo(e,"markerCleared",e,this),t&&br(e),this.parent&&this.parent.clear()}},ss.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=_n(o.markedSpans,this);if(null!=l.from&&(r=Al(t?o:Yi(o),l.from),-1==e))return r;if(null!=l.to&&(n=Al(t?o:Yi(o),l.to),1==e))return n}return r&&{from:r,to:n}},ss.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Tr(r,function(){var n=e.line,i=Yi(e.line),o=qt(r,i);if(o&&(rr(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!gi(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=yi(t)-l;s&&_i(n,n.height+s)}})},ss.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Mo(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ss.prototype.detachLine=function(e){if(this.lines.splice(Mo(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var ls=0,as=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};Co(as),as.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();mo(this,"clear")}},as.prototype.find=function(e,t){return this.primary.find(e,t)};var us=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.cm=e,this.node=t};Co(us),us.prototype.clear=function(){var e=this.cm,t=this.line.widgets,r=this.line,n=Yi(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=yi(this);Tr(e,function(){mi(e,r,-o),Hr(e,n,"widget"),_i(r,Math.max(0,r.height-o))})}},us.prototype.changed=function(){var e=this.height,t=this.cm,r=this.line;this.height=null;var n=yi(this)-e;n&&Tr(t,function(){t.curOp.forceUpdate=!0,mi(t,r,n),_i(r,r.height+n)})};var cs=e.Line=function(e,t,r){this.text=e,ni(this,t),this.height=r?r(this):1};Co(cs),cs.prototype.lineNo=function(){return Yi(this)};var fs={},hs={};Bi.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,xi(i),mo(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},Gi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Bi))){var s=[];this.collapse(s),this.children=[new Bi(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Bi(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Gi(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Mo(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Gi(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var ds=0,ps=e.Doc=function(e,t,r){if(!(this instanceof ps))return new ps(e,t,r);null==r&&(r=0),Gi.call(this,[new Bi([new cs("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=Al(r,0);this.sel=ht(n),this.history=new Qi(null),this.id=++ds,this.modeOption=t,"string"==typeof e&&(e=Vs(e)),Ri(this,{from:n,to:n,text:e}),kt(this,ht(n),Ts)};ps.prototype=Wo(Gi.prototype,{constructor:ps,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Xi(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:Nr(function(e){var t=Al(this.first,0),r=this.first+this.size-1;bn(this,{from:t,to:Al(r,Ki(this,r).text.length),text:Vs(e),origin:"setValue",full:!0},!0),kt(this,ht(t))}),replaceRange:function(e,t,r,n){t=pt(this,t),r=r?pt(this,r):t,kn(this,e,t,r,n)},getRange:function(e,t,r){var n=ji(this,pt(this,e),pt(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return vt(this,e)?Ki(this,e):void 0},getLineNumber:function(e){return Yi(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Ki(this,e)),fi(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return pt(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Nr(function(e,t,r){Ct(this,pt(this,"number"==typeof e?Al(e,t||0):e),null,r)}),setSelection:Nr(function(e,t,r){Ct(this,pt(this,e),pt(this,t||e),r)}),extendSelection:Nr(function(e,t,r){bt(this,pt(this,e),t&&pt(this,t),r)}),extendSelections:Nr(function(e,t){wt(this,mt(this,e,t))}),extendSelectionsBy:Nr(function(e,t){wt(this,Ao(this.sel.ranges,e),t)}),setSelections:Nr(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new ct(pt(this,e[n].anchor),pt(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),kt(this,ft(i,t),r)}}),addSelection:Nr(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new ct(pt(this,e),pt(this,t||e))),kt(this,ft(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=ji(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=ji(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:Nr(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:Vs(e[o]),origin:r}}for(var s=t&&"end"!=t&&mn(this,n,t),o=n.length-1;o>=0;o--)bn(this,n[o]);s?Lt(this,s):this.cm&&On(this.cm)}),undo:Nr(function(){xn(this,"undo")}),redo:Nr(function(){xn(this,"redo")}),undoSelection:Nr(function(){xn(this,"undo",!0)}),redoSelection:Nr(function(){xn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Qi(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:uo(this.history.done),undone:uo(this.history.undone)}},setHistory:function(e){var t=this.history=new Qi(this.history.maxGeneration);t.done=uo(e.done.slice(0),null,!0),t.undone=uo(e.undone.slice(0),null,!0)},addLineClass:Nr(function(e,t,r){return Pn(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Bo(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:Nr(function(e,t,r){return Pn(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Bo(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),markText:function(e,t,r){return Gn(this,pt(this,e),pt(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=pt(this,e),Gn(this,e,e,r,"bookmark")},findMarksAt:function(e){e=pt(this,e);var t=[],r=Ki(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=pt(this,e),t=pt(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),pt(this,Al(r,t))},indexFromPos:function(e){e=pt(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new ps(Xi(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new ps(Xi(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Kn(n,Vn(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),jn(Vn(this));break}}if(t.history==this.history){var i=[t.id];Ui(t,function(e){i.push(e.id)},!0),t.history=new Qi(null),t.history.done=uo(this.history.done,i),t.history.undone=uo(this.history.undone,i)}},iterLinkedDocs:function(e){Ui(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),ps.prototype.eachLine=ps.prototype.iter;var gs="iter insert remove copy getEditor".split(" ");for(var vs in ps.prototype)ps.prototype.hasOwnProperty(vs)&&Mo(gs,vs)<0&&(e.prototype[vs]=function(e){return function(){return e.apply(this.doc,arguments)}}(ps.prototype[vs]));Co(ps);var ms=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},ys=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},bs=e.e_stop=function(e){ms(e),ys(e)},ws=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},xs=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},Cs=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Ss=null,Ls=30,ks=e.Pass={toString:function(){return"CodeMirror.Pass"}},Ts={scroll:!1},Ms={origin:"*mouse"},As={origin:"+move"};So.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Ns=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Ws=[""],Os=function(e){e.select()};bl?Os=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:cl&&(Os=function(e){try{e.select()}catch(t){}});var Ds,Hs=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ps=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Hs.test(e))},Is=/[\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]/;Ds=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var zs=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};cl&&11>fl&&(Ro=function(){try{return document.activeElement}catch(e){return document.body}});var Es,Fs,Rs=e.rmClass=function(e,t){var r=e.className,n=Bo(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Bs=e.addClass=function(e,t){var r=e.className;Bo(t).test(r)||(e.className+=(r?" ":"")+t)},Gs=!1,Us=function(){if(cl&&9>fl)return!1;var e=zo("div");return"draggable"in e||"dragDrop"in e}(),Vs=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Ks=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},js=function(){var e=zo("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Xs=null,_s={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};e.keyNames=_s,function(){for(var e=0;10>e;e++)_s[e+48]=_s[e+96]=String(e);for(var e=65;90>=e;e++)_s[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)_s[e+111]=_s[e+63235]="F"+e}();var Ys,$s=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,f=[],h=0;c>h;++h)f.push(n=e(r.charCodeAt(h)));for(var h=0,d=u;c>h;++h){var n=f[h];"m"==n?f[h]=d:d=n}for(var h=0,p=u;c>h;++h){var n=f[h];"1"==n&&"r"==p?f[h]="n":l.test(n)&&(p=n,"r"==n&&(f[h]="R"))}for(var h=1,d=f[0];c-1>h;++h){var n=f[h];"+"==n&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=n||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=n}for(var h=0;c>h;++h){var n=f[h];if(","==n)f[h]="N";else if("%"==n){for(var g=h+1;c>g&&"%"==f[g];++g);for(var v=h&&"!"==f[h-1]||c>g&&"1"==f[g]?"1":"N",m=h;g>m;++m)f[m]=v;h=g-1}}for(var h=0,p=u;c>h;++h){var n=f[h];"L"==p&&"1"==n?f[h]="L":l.test(n)&&(p=n)}for(var h=0;c>h;++h)if(o.test(f[h])){for(var g=h+1;c>g&&o.test(f[g]);++g);for(var y="L"==(h?f[h-1]:u),b="L"==(c>g?f[g]:u),v=y||b?"L":"R",m=h;g>m;++m)f[m]=v;h=g-1}for(var w,x=[],h=0;c>h;)if(s.test(f[h])){var C=h;for(++h;c>h&&s.test(f[h]);++h);x.push(new t(0,C,h))}else{var S=h,L=x.length;for(++h;c>h&&"L"!=f[h];++h);for(var m=S;h>m;)if(a.test(f[m])){m>S&&x.splice(L,0,new t(1,S,m));var k=m;for(++m;h>m&&a.test(f[m]);++m);x.splice(L,0,new t(2,k,m)),S=m}else++m;h>S&&x.splice(L,0,new t(1,S,h))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==To(x).level&&(w=r.match(/\s+$/))&&(To(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),x[0].level!=To(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.0.1",e});
 
 
 
 
 
js/settings.js CHANGED
@@ -1917,9 +1917,13 @@ function UniteSettingsUC(){
1917
  var objDialogWrapper = jQuery("#"+dialogID);
1918
  if(objDialogWrapper.length){
1919
  g_iconsHash = jQuery("body").data("uc_icons_hash");
 
1920
  return(objDialogWrapper);
1921
  }
1922
 
 
 
 
1923
  //set "fa" template
1924
  if(type == "fa"){
1925
 
@@ -1933,6 +1937,17 @@ function UniteSettingsUC(){
1933
  return(html);
1934
  });
1935
 
 
 
 
 
 
 
 
 
 
 
 
1936
  }
1937
 
1938
  var objType = iconPicker_getObjIconsType(type);
1917
  var objDialogWrapper = jQuery("#"+dialogID);
1918
  if(objDialogWrapper.length){
1919
  g_iconsHash = jQuery("body").data("uc_icons_hash");
1920
+
1921
  return(objDialogWrapper);
1922
  }
1923
 
1924
+ if(type == "elementor" && g_ucFaIcons.length == 0)
1925
+ type = "fa";
1926
+
1927
  //set "fa" template
1928
  if(type == "fa"){
1929
 
1937
  return(html);
1938
  });
1939
 
1940
+ }else if(type == "elementor"){
1941
+
1942
+ t.iconPicker_addIconsType("elementor", g_ucElIcons, function(icon){ //icon to html functoin
1943
+
1944
+ var html = '<i class="'+icon+'"></i>';
1945
+
1946
+ return(html);
1947
+ });
1948
+
1949
+
1950
+
1951
  }
1952
 
1953
  var objType = iconPicker_getObjIconsType(type);
js/unitecreator_params_panel.js CHANGED
@@ -109,7 +109,7 @@ function UniteCreatorParamsPanel(){
109
  * add child params
110
  */
111
  function addChildParams(objParentParam, arrChildKeys, filter){
112
-
113
  var baseName = objParentParam.name;
114
  var parentName = baseName;
115
 
@@ -125,6 +125,7 @@ function UniteCreatorParamsPanel(){
125
  paramParent.visual = visual;
126
 
127
  addParam(paramParent, null, filter);
 
128
 
129
  //add child params:
130
  jQuery.each(arrChildKeys, function(index, objChildParam){
@@ -286,6 +287,15 @@ function UniteCreatorParamsPanel(){
286
  paramVisual = name + " wrapping code";
287
  }
288
 
 
 
 
 
 
 
 
 
 
289
  break;
290
  default:
291
 
109
  * add child params
110
  */
111
  function addChildParams(objParentParam, arrChildKeys, filter){
112
+
113
  var baseName = objParentParam.name;
114
  var parentName = baseName;
115
 
125
  paramParent.visual = visual;
126
 
127
  addParam(paramParent, null, filter);
128
+
129
 
130
  //add child params:
131
  jQuery.each(arrChildKeys, function(index, objChildParam){
287
  paramVisual = name + " wrapping code";
288
  }
289
 
290
+ break;
291
+ case "uc_image":
292
+
293
+ isTakeChildred = true;
294
+
295
+ var mediaType = g_ucAdmin.getVal(objParam, "media_type");
296
+ if(mediaType == "json")
297
+ isTakeChildred = false;
298
+
299
  break;
300
  default:
301
 
provider/core/plugins/unlimited_elements/copy_paste.class.php CHANGED
@@ -146,10 +146,7 @@ class UniteCreatorElementorCopyPaste{
146
  * on paste section ajax action
147
  */
148
  public function pasteSectionAjaxAction($data){
149
-
150
- if(GlobalsUC::$inDev == false && !defined("UC_ENABLE_COPYPASTE"))
151
- return(false);
152
-
153
  $paramsData = UniteFunctionsUC::getVal($data, "params_data");
154
  if(empty($paramsData))
155
  UniteFunctionsUC::throwError("no paste data found");
@@ -183,9 +180,7 @@ class UniteCreatorElementorCopyPaste{
183
  * get section zip from data
184
  */
185
  public function getSectionZipFromData($data){
186
-
187
- if(GlobalsUC::$inDev == false && !defined("UC_ENABLE_COPYPASTE"))
188
- return(null);
189
  try{
190
 
191
  $postID = UniteFunctionsUC::getVal($data, "postid");
146
  * on paste section ajax action
147
  */
148
  public function pasteSectionAjaxAction($data){
149
+
 
 
 
150
  $paramsData = UniteFunctionsUC::getVal($data, "params_data");
151
  if(empty($paramsData))
152
  UniteFunctionsUC::throwError("no paste data found");
180
  * get section zip from data
181
  */
182
  public function getSectionZipFromData($data){
183
+
 
 
184
  try{
185
 
186
  $postID = UniteFunctionsUC::getVal($data, "postid");
provider/core/plugins/unlimited_elements/dialog_param_elementor.class.php CHANGED
@@ -826,6 +826,41 @@ class UniteCreatorDialogParamElementor extends UniteCreatorDialogParam{
826
 
827
  }
828
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
829
 
830
  /**
831
  * put color picker default value
@@ -887,7 +922,8 @@ class UniteCreatorDialogParamElementor extends UniteCreatorDialogParam{
887
  <select name="unit" class='uc-select-unit' data-initval="px">
888
  <option value="px">px</option>
889
  <option value="ms">ms</option>
890
- <option value="%">ms</option>
 
891
  <option value="">[none]</option>
892
  <option value="other">[custom]</option>
893
  </select>
826
 
827
  }
828
 
829
+ /**
830
+ *
831
+ * function for override
832
+ */
833
+ protected function putSpecialAttribute(){
834
+
835
+ $arrTypes = array();
836
+ $arrTypes["refresh"] = __("Refresh Widget","unlimited-elements-for-elementor");
837
+
838
+ $optionsClass = "uc-special-attribute-options";
839
+
840
+ $htmlSelectTypes = HelperHtmlUC::getHTMLSelect($arrTypes, "", "name='attribute_type' xclass='uc-control' xdata-controlled-selector='.{$optionsClass}'", true, "refresh");
841
+
842
+ ?>
843
+
844
+ <?php esc_html_e("Special Attribute Type", "unlimited-elements-for-elementor"); ?>
845
+
846
+ <div class="vert_sap5"></div>
847
+
848
+ <?php echo $htmlSelectTypes?>
849
+
850
+ <div class="vert_sap10"></div>
851
+
852
+ <div class="<?php echo $optionsClass?>" data-control-value="refresh">
853
+
854
+ <p>
855
+ <?php _e("Choose attribute names comma separated, in this section that will trigger refresh","unlimited-elements-for-elementor")?>
856
+ </p>
857
+
858
+ <input type="text" name="refresh_attribute_names" value="">
859
+
860
+ </div>
861
+ <?php
862
+ }
863
+
864
 
865
  /**
866
  * put color picker default value
922
  <select name="unit" class='uc-select-unit' data-initval="px">
923
  <option value="px">px</option>
924
  <option value="ms">ms</option>
925
+ <option value="%">%</option>
926
+ <option value="em">em</option>
927
  <option value="">[none]</option>
928
  <option value="other">[custom]</option>
929
  </select>
provider/core/plugins/unlimited_elements/elementor/assets/template_library_admin.js CHANGED
@@ -14,8 +14,17 @@ function UniteCreatorElementorTemplateLibraryAdmin(){
14
 
15
  var objButtonCloned = objButton.clone();
16
 
17
- var objHeaderEnd = jQuery(".wp-header-end");
18
- objHeaderEnd.before(objButtonCloned);
 
 
 
 
 
 
 
 
 
19
 
20
  //set event
21
  objButtonCloned.click(onToggleButtonClick);
14
 
15
  var objButtonCloned = objButton.clone();
16
 
17
+ var objAdminBarButtonsNew = jQuery(".e-admin-top-bar__main-area-buttons");
18
+
19
+ if(objAdminBarButtonsNew.length){
20
+
21
+ objAdminBarButtonsNew.append(objButtonCloned);
22
+
23
+ }else{
24
+ var objHeaderEnd = jQuery(".wp-header-end");
25
+ objHeaderEnd.before(objButtonCloned);
26
+ }
27
+
28
 
29
  //set event
30
  objButtonCloned.click(onToggleButtonClick);
provider/core/plugins/unlimited_elements/elementor/assets/uc_editor_admin.css CHANGED
@@ -16,7 +16,17 @@
16
  }
17
 
18
 
19
- /* --- tooltip --- */
 
 
 
 
 
 
 
 
 
 
20
 
21
  .ue-widget-icon::after{
22
  xcontent:"UE";
@@ -39,7 +49,6 @@
39
  filter: brightness(4);
40
  }
41
 
42
-
43
  .ue-wi-svg::after{
44
  height:44px;
45
  background-size:auto 34px;
16
  }
17
 
18
 
19
+ /* --- icons --- */
20
+
21
+ .uc-default-widget-icon::after{
22
+ background-image:url('../images/widget-icon.svg');
23
+ }
24
+
25
+ .ue-widget-icon{
26
+ min-width:40px;
27
+ min-height:42px;
28
+ display:inline-block;
29
+ }
30
 
31
  .ue-widget-icon::after{
32
  xcontent:"UE";
49
  filter: brightness(4);
50
  }
51
 
 
52
  .ue-wi-svg::after{
53
  height:44px;
54
  background-size:auto 34px;
provider/core/plugins/unlimited_elements/elementor/assets/uc_editor_admin.js CHANGED
@@ -7,7 +7,7 @@ function UniteCreatorElementorEditorAdmin(){
7
  var g_objSettingsPanel;
8
  var g_objAddonParams, g_objAddonParamsItems, g_lastAddonName;
9
  var g_numRepeaterItems = 0;
10
- var g_windowFront, g_searchDataID, g_searchData;
11
  var g_temp = {};
12
 
13
 
@@ -178,7 +178,7 @@ function UniteCreatorElementorEditorAdmin(){
178
 
179
  var isCurrentTaxRelevant = objTax.hasOwnProperty(selectedTax);
180
  if(isCurrentTaxRelevant == false && firstVisibleOption){
181
-
182
  selectPostTaxonomy.val(firstVisibleOption).trigger("change");
183
  }
184
 
@@ -1493,9 +1493,12 @@ function UniteCreatorElementorEditorAdmin(){
1493
  window.ucLastElementorModel = model.attributes;
1494
 
1495
  window.lastWidgetType = getVal(model.attributes, "widgetType");
 
 
1496
 
1497
  }
1498
 
 
1499
  /**
1500
  * run ajax action
1501
  */
@@ -1555,12 +1558,18 @@ function UniteCreatorElementorEditorAdmin(){
1555
  return(false);
1556
  }
1557
 
 
 
1558
  g_windowFront = windowFront;
1559
 
 
 
1560
  if(typeof g_ucHasBackgrounds !== "undefined" && g_ucHasBackgrounds === true)
1561
  initBackgrounds();
1562
 
1563
  elementor.hooks.addAction("panel/open_editor/widget", onElementorOpenWidget);
 
 
1564
  }
1565
 
1566
 
@@ -1587,6 +1596,54 @@ function UniteCreatorElementorEditorAdmin(){
1587
 
1588
  }
1589
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1590
  var g_objUCElementorEditorAdmin = new UniteCreatorElementorEditorAdmin();
1591
 
1592
 
7
  var g_objSettingsPanel;
8
  var g_objAddonParams, g_objAddonParamsItems, g_lastAddonName;
9
  var g_numRepeaterItems = 0;
10
+ var g_windowFront, g_searchDataID, g_searchData, g_frontAPI;
11
  var g_temp = {};
12
 
13
 
178
 
179
  var isCurrentTaxRelevant = objTax.hasOwnProperty(selectedTax);
180
  if(isCurrentTaxRelevant == false && firstVisibleOption){
181
+
182
  selectPostTaxonomy.val(firstVisibleOption).trigger("change");
183
  }
184
 
1493
  window.ucLastElementorModel = model.attributes;
1494
 
1495
  window.lastWidgetType = getVal(model.attributes, "widgetType");
1496
+
1497
+ g_frontAPI.triggerEvent("open_widget_settings", window.ucLastElementorModel);
1498
 
1499
  }
1500
 
1501
+
1502
  /**
1503
  * run ajax action
1504
  */
1558
  return(false);
1559
  }
1560
 
1561
+ g_frontAPI = new UniteCreatorElementorFrontAPI();
1562
+
1563
  g_windowFront = windowFront;
1564
 
1565
+ g_windowFront.g_ueSettingsAPI = g_frontAPI;
1566
+
1567
  if(typeof g_ucHasBackgrounds !== "undefined" && g_ucHasBackgrounds === true)
1568
  initBackgrounds();
1569
 
1570
  elementor.hooks.addAction("panel/open_editor/widget", onElementorOpenWidget);
1571
+
1572
+
1573
  }
1574
 
1575
 
1596
 
1597
  }
1598
 
1599
+ /**
1600
+ * front api
1601
+ */
1602
+ function UniteCreatorElementorFrontAPI(){
1603
+
1604
+ var g_objAdmin;
1605
+
1606
+ /**
1607
+ * debug some string
1608
+ */
1609
+ function trace(str){
1610
+ console.log(str);
1611
+ }
1612
+
1613
+ /**
1614
+ * trigger event
1615
+ */
1616
+ this.triggerEvent = function(eventName, model, options){
1617
+
1618
+ var data = {};
1619
+ data.model = model;
1620
+
1621
+ jQuery(window).trigger("ue_event_"+eventName, data);
1622
+
1623
+ }
1624
+
1625
+
1626
+ /**
1627
+ * on event
1628
+ */
1629
+ this.onEvent = function(eventName, func){
1630
+
1631
+ jQuery(window).on("ue_event_"+eventName, func);
1632
+
1633
+ }
1634
+
1635
+
1636
+ /**
1637
+ * editor admin
1638
+ */
1639
+ this.initAPI = function(objAdmin){
1640
+
1641
+ g_objAdmin = objAdmin;
1642
+ }
1643
+
1644
+ }
1645
+
1646
+
1647
  var g_objUCElementorEditorAdmin = new UniteCreatorElementorEditorAdmin();
1648
 
1649
 
provider/core/plugins/unlimited_elements/elementor/assets/uc_editor_admin_temp.js DELETED
@@ -1,78 +0,0 @@
1
-
2
- /**
3
- * get select post type value
4
- */
5
- function getPostTypeValue(objSelectPostCategory){
6
-
7
- var objParent = objSelectPostCategory.parents("#elementor-controls");
8
- var objPostType = objParent.find(".unite-setting-post-type");
9
- if(objPostType.length == 0)
10
- throw new Error("Post type field not found");
11
-
12
- var postTypeValue = objPostType.val();
13
-
14
- return(postTypeValue);
15
- }
16
-
17
-
18
- /**
19
- * init post category
20
- */
21
- function initPostCategory(index, selectPostCategory){
22
-
23
- var objSelectCategory = jQuery(selectPostCategory);
24
- objSelectCategory.addClass("uc-isinited");
25
-
26
- var postType = getPostTypeValue(objSelectCategory);
27
-
28
- var htmlOptions = "";
29
- htmlOptions += "<option value=''>[All Categories]</option>"
30
- htmlOptions += "<option value='10' >cat1</option>"
31
- htmlOptions += "<option value='11' selected>ca2</option>"
32
-
33
- objSelectCategory.html(htmlOptions);
34
- }
35
-
36
-
37
- /**
38
- * check and init posts list
39
- */
40
- function checkInitPostsList(){
41
-
42
- var objSelectPostCategory = jQuery(".unite-setting-post-category").not(".uc-isinited");
43
- if(objSelectPostCategory.length){
44
- objSelectPostCategory.each(initPostCategory);
45
- }
46
-
47
- }
48
-
49
- /**
50
- * on post type change
51
- */
52
- function onPostTypeChange(){
53
- var objPostType = jQuery(this);
54
-
55
- var objPostCategory = jQuery(".unite-setting-post-category");
56
- var htmlOptions = "";
57
- htmlOptions += "<option value=''>[All Categories]</option>"
58
- htmlOptions += "<option value='12' >some cat</option>"
59
- htmlOptions += "<option value='13' selected>some cat2</option>"
60
-
61
- objPostCategory.html(htmlOptions);
62
- objPostCategory.val("13");
63
-
64
- }
65
-
66
-
67
- /**
68
- * init posts list control
69
- */
70
- function initPostsListControl(){
71
-
72
- setInterval(checkInitPostsList, 1000);
73
-
74
- var objPanel = jQuery("#elementor-panel");
75
-
76
- objPanel.on("change",".unite-setting-post-type", onPostTypeChange);
77
-
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
provider/core/plugins/unlimited_elements/elementor/assets/uc_front_admin.js CHANGED
@@ -1,4 +1,95 @@
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  function ucDocReady(fn) {
4
  // see if DOM is already available
@@ -10,9 +101,10 @@ function ucDocReady(fn) {
10
  }
11
  }
12
 
 
13
  ucDocReady(function(){
14
 
15
- window.parent.g_objUCElementorEditorAdmin.initFrontEndInteraction(window, elementorFrontend);
16
-
17
  });
18
 
1
 
2
+ window.g_ueSettingsAPI = null;
3
+
4
+ function UnlimitedElementsWidgetSettingsAPI(){
5
+
6
+ var g_id, g_frontAPI;
7
+
8
+ function trace(str){
9
+ console.log(str);
10
+ }
11
+
12
+
13
+ /**
14
+ * on event
15
+ */
16
+ this.on = function(name, func){
17
+
18
+ if(typeof func !== "function")
19
+ throw new Error("settings api error - second parameter of event: "+name+"should be a function");
20
+
21
+ g_frontAPI.onEvent(name, function(event, data){
22
+
23
+ if(!data)
24
+ return(false);
25
+
26
+ var model = data.model;
27
+
28
+ if(!model)
29
+ return(false);
30
+
31
+ if(model.id != g_id)
32
+ return(false);
33
+
34
+ var attributes = model.settings.attributes;
35
+
36
+ //run the event function
37
+ func(attributes);
38
+
39
+ });
40
+
41
+ }
42
+
43
+
44
+ /**
45
+ * init the api
46
+ */
47
+ this.init = function(objWidget){
48
+
49
+ if(!objWidget || objWidget.length == 0)
50
+ return(false);
51
+
52
+ var objParent = objWidget.parents(".elementor-element.elementor-element-edit-mode");
53
+
54
+ if(objParent.length == 0)
55
+ throw new Error("settings api error - parent element not found");
56
+
57
+ var elementType = objParent.data("element_type");
58
+
59
+ g_id = objParent.data("id");
60
+
61
+ if(elementType != "widget")
62
+ throw new Error("settings api error - wrong element type");
63
+
64
+ if(!window.g_ueSettingsAPI)
65
+ throw new Error("settings api error - main api not inited");
66
+
67
+ g_frontAPI = window.g_ueSettingsAPI;
68
+
69
+ }
70
+
71
+
72
+
73
+ }
74
+
75
+ /**
76
+ * get editor api by id
77
+ */
78
+ function ueGetEditorSettingsAPI(widgetID){
79
+
80
+ var objWidget = jQuery("#"+widgetID);
81
+
82
+ if(objWidget.length == 0)
83
+ throw new Error("settings api error, no widget found by id: "+widgetID);
84
+
85
+ var objWidgetAPI = new UnlimitedElementsWidgetSettingsAPI();
86
+
87
+ objWidgetAPI.init(objWidget);
88
+
89
+ return(objWidgetAPI);
90
+ }
91
+
92
+
93
 
94
  function ucDocReady(fn) {
95
  // see if DOM is already available
101
  }
102
  }
103
 
104
+
105
  ucDocReady(function(){
106
 
107
+ window.g_ueSettingsAPI = window.parent.g_objUCElementorEditorAdmin.initFrontEndInteraction(window, elementorFrontend);
108
+
109
  });
110
 
provider/core/plugins/unlimited_elements/elementor/elementor_controls.class.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use Elementor\Widget_Base;
3
+ use Elementor\Controls_Manager;
4
+ use Elementor\Repeater;
5
+ use \Elementor\Utils;
6
+
7
+ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
8
+
9
+
10
+ class UniteCreatorElementorControls{
11
+
12
+
13
+ /**
14
+ * add repeater control
15
+ */
16
+ public function addGalleryImageVideoRepeater($objControls, $textPrefix, $name){
17
+
18
+ $repeater = new Repeater();
19
+
20
+ $objControls->start_controls_section(
21
+ 'uc_section_listing_gallery_repeater', array(
22
+ 'label' => $textPrefix.__(" Items", "unlimited-elements-for-elementor"),
23
+ 'condition'=>array($name."_source"=>"image_video_repeater")
24
+ )
25
+ );
26
+
27
+ // ---- item type ---------
28
+
29
+ $repeater->add_control(
30
+ 'item_type',
31
+ array(
32
+ 'label' => __( 'Item Type', 'plugin-domain' ),
33
+ 'type' => Controls_Manager::SELECT,
34
+ 'default' => 'image',
35
+ 'options' => array(
36
+ 'image' => __( 'Image', 'unlimited-elements-for-elementor' ),
37
+ 'youtube' => __( 'Youtube', 'unlimited-elements-for-elementor' ),
38
+ 'vimeo' => __( 'Vimeo', 'unlimited-elements-for-elementor' ),
39
+ 'wistia' => __( 'Wistia', 'unlimited-elements-for-elementor' ),
40
+ 'html5' => __( 'HTML5 Video', 'unlimited-elements-for-elementor' )
41
+ )
42
+ )
43
+ );
44
+
45
+ //--------- image --------
46
+
47
+ $repeater->add_control(
48
+ 'image',
49
+ array(
50
+ 'label' => __( 'Choose Image', 'unlimited-elements-for-elementor' ),
51
+ 'type' => Controls_Manager::MEDIA,
52
+ 'default' => array(
53
+ 'url' => Utils::get_placeholder_image_src(),
54
+ ),
55
+ 'condition'=>array('item_type'=>'image')
56
+ )
57
+ );
58
+
59
+ //--------- youtube url --------
60
+
61
+ $repeater->add_control(
62
+ 'url_youtube',
63
+ array(
64
+ 'label' => __( 'Youtube Url or ID', 'unlimited-elements-for-elementor' ),
65
+ 'type' => Controls_Manager::TEXT,
66
+ 'default' => __( '', 'unlimited-elements-for-elementor' ),
67
+ 'description'=>'For example: https://www.youtube.com/watch?v=9bZkp7q19f0 or 9bZkp7q19f0',
68
+ 'label_block'=>true,
69
+ 'condition'=>array('item_type'=>'youtube')
70
+ )
71
+ );
72
+
73
+ //--------- vimeo id --------
74
+
75
+ $repeater->add_control(
76
+ 'vimeo_id',
77
+ array(
78
+ 'label' => __( 'Vimeo Video ID or Url', 'unlimited-elements-for-elementor' ),
79
+ 'type' => Controls_Manager::TEXT,
80
+ 'default' => __( '', 'unlimited-elements-for-elementor' ),
81
+ 'description'=>__('For example: 581014653, or https://vimeo.com/581014653','unlimited-elements-for-elementor'),
82
+ 'label_block'=>true,
83
+ 'condition'=>array('item_type'=>'vimeo')
84
+ )
85
+ );
86
+
87
+ //--------- wistia --------
88
+
89
+ $repeater->add_control(
90
+ 'wistia_id',
91
+ array(
92
+ 'label' => __( 'Wistia Video ID', 'unlimited-elements-for-elementor' ),
93
+ 'type' => Controls_Manager::TEXT,
94
+ 'default' => __( '', 'unlimited-elements-for-elementor' ),
95
+ 'description'=>__('For example: 9oedgxuciv','unlimited-elements-for-elementor'),
96
+ 'label_block'=>true,
97
+ 'condition'=>array('item_type'=>'wistia')
98
+ )
99
+ );
100
+
101
+ //--------- html5 video --------
102
+
103
+ $repeater->add_control(
104
+ 'url_html5',
105
+ array(
106
+ 'label' => __( 'MP4 Video Url', 'unlimited-elements-for-elementor' ),
107
+ 'type' => Controls_Manager::TEXT,
108
+ 'default' => __( '', 'unlimited-elements-for-elementor' ),
109
+ 'description'=>__('Enter url of the mp4 video in current or external site','unlimited-elements-for-elementor'),
110
+ 'label_block'=>true,
111
+ 'condition'=>array('item_type'=>'html5')
112
+ )
113
+ );
114
+
115
+ //--------- title --------
116
+
117
+ $repeater->add_control(
118
+ 'title',
119
+ array(
120
+ 'label' => __( 'Item Title', 'unlimited-elements-for-elementor' ),
121
+ 'type' => Controls_Manager::TEXT,
122
+ 'default' => __( '', 'unlimited-elements-for-elementor' ),
123
+ 'label_block'=>true,
124
+ 'separator'=>'before'
125
+ )
126
+ );
127
+
128
+ //--------- description --------
129
+
130
+ $repeater->add_control(
131
+ 'description',
132
+ array(
133
+ 'label' => __( 'Item Description', 'unlimited-elements-for-elementor' ),
134
+ 'type' => Controls_Manager::WYSIWYG,
135
+ 'default' => __( '', 'unlimited-elements-for-elementor' ),
136
+ 'label_block'=>true
137
+ )
138
+ );
139
+
140
+
141
+ $objControls->add_control(
142
+ $name.'_items',
143
+ array(
144
+ 'label' => __( 'Gallery Items', 'unlimited-elements-for-elementor' ),
145
+ 'type' => Controls_Manager::REPEATER,
146
+ 'fields' => $repeater->get_controls(),
147
+ 'default' => array(),
148
+ 'title_field' => '{{{ title }}}',
149
+ )
150
+ );
151
+
152
+ $objControls->end_controls_section();
153
+
154
+ }
155
+
156
+ }
provider/core/plugins/unlimited_elements/elementor/elementor_dynamic_visibility.class.php CHANGED
@@ -300,6 +300,8 @@ class UniteCreatorDynamicVisibility{
300
  ob_end_clean();
301
  }
302
 
 
 
303
 
304
  /**
305
  * add visibility controls section
@@ -314,48 +316,121 @@ class UniteCreatorDynamicVisibility{
314
  ]
315
  );
316
 
317
-
318
- $repeater = new \Elementor\Repeater();
319
-
320
  //condition type
321
 
322
  $prefix = self::PREFIX;
323
 
324
- $repeater->add_control(
325
  'condition_type',
326
  array(
327
- 'label' => __( 'Visibility By', 'unlimited-elements-for-elementor' ),
328
- 'type' => \Elementor\Controls_Manager::SELECT,
329
- 'default' => 'none',
330
- 'options' => array(
331
- 'none' => __( 'Always Visible', 'unlimited-elements-for-elementor' ),
332
- 'archive_terms' => __( 'Archive Page Terms', 'unlimited-elements-for-elementor' )
333
- ),
334
  'separator'=>"after"
335
  )
336
  );
337
 
338
- //------------- ARCHIVE TERMS --------------
339
-
340
- $conditionTerms = array('condition_type' => "archive_terms");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
 
342
- $repeater->add_control(
343
- 'terms_show',
344
- array(
345
- 'label' => __( 'Show or Hide', 'unlimited-elements-for-elementor' ),
346
- 'type' => \Elementor\Controls_Manager::SELECT,
347
- 'default' => 'show',
348
- 'options' => array(
349
- 'show' => __( 'Show', 'unlimited-elements-for-elementor' ),
350
- 'hide' => __( 'Hide', 'unlimited-elements-for-elementor' )
351
- ),
352
- 'condition'=>$conditionTerms
353
- )
354
- );
 
 
 
 
 
 
 
 
 
 
 
 
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  //--term heading
357
 
358
- $repeater->add_control(
359
  'by_terms_heading',
360
  array(
361
  'label' => __( 'When current page is archive and current term match the seleced', 'unlimited-elements-for-elementor' ),
@@ -364,17 +439,19 @@ class UniteCreatorDynamicVisibility{
364
  )
365
  );
366
 
 
 
367
  //--term ids
368
 
369
  $arrControl = HelperProviderCoreUC_EL::getElementorControl_TermsPickerControl(__("Select Term", "unlimited-elements-for-elementor"));
370
  $arrControl["condition"] = $conditionTerms;
371
-
372
- $repeater->add_control(
373
  'term_ids',
374
  $arrControl
375
  );
376
 
377
- $repeater->add_control(
378
  'terms_include_children',
379
  array(
380
  'label' => __( 'Or Their Children', 'unlimited-elements-for-elementor' ),
@@ -386,20 +463,7 @@ class UniteCreatorDynamicVisibility{
386
  'condition'=>$conditionTerms
387
  )
388
  );
389
-
390
- //------ add the repeater
391
-
392
- $objControls->add_control(
393
- $prefix.'conditions',
394
- [
395
- 'label' => __( 'Repeater List', 'unlimited-elements-for-elementor' ),
396
- 'type' => \Elementor\Controls_Manager::REPEATER,
397
- 'fields' => $repeater->get_controls(),
398
- 'default' => [],
399
- 'title_field' => '',
400
- ]
401
- );
402
-
403
 
404
  //------------- DEBUG --------------
405
 
300
  ob_end_clean();
301
  }
302
 
303
+ private function ___________ADD_CONTROLS_____________(){}
304
+
305
 
306
  /**
307
  * add visibility controls section
316
  ]
317
  );
318
 
319
+
 
 
320
  //condition type
321
 
322
  $prefix = self::PREFIX;
323
 
324
+ $objControls->add_control(
325
  'condition_type',
326
  array(
327
+ 'label' => __( 'Enable Visibility Conditions', 'unlimited-elements-for-elementor' ),
328
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
329
+ 'default' => '',
330
+ 'label_on' => __( 'Yes', 'unlimited-elements-for-elementor' ),
331
+ 'label_off' => __( 'No', 'unlimited-elements-for-elementor' ),
332
+ 'return_value'=>"yes",
 
333
  'separator'=>"after"
334
  )
335
  );
336
 
337
+ $objControls->add_control("hideby",[
338
+ 'label' => __( 'Hide By', 'unlimited-elements-for-elementor' ),
339
+ 'type' => \Elementor\Controls_Manager::SELECT2,
340
+ 'multiple' => true,
341
+ 'options' => [
342
+ 'hide_by_default' => __( 'Hide By Default', 'unlimited-elements-for-elementor' ),
343
+ 'archive_terms' => __( 'Archive Terms', 'unlimited-elements-for-elementor' ),
344
+ ],
345
+ 'default' => [ ],
346
+ ]);
347
+
348
+ //------ hide by default
349
+
350
+ $conditionHideDefalut = array("hideby"=>"hide_by_default");
351
+
352
+ $objControls->add_control(
353
+ 'hide_by_default_text',
354
+ [
355
+ 'label' => __( 'This section will be hidden by default if no other condition is chosen', 'unlimited-elements-for-elementor' ),
356
+ 'type' => \Elementor\Controls_Manager::HEADING,
357
+ 'separator' => 'before',
358
+ 'label_block'=>true,
359
+ 'condition' => $conditionHideDefalut
360
+ ]
361
+ );
362
+
363
+
364
+ //------ hide by terms text
365
+
366
+ $conditionTerms = array("hideby"=>"archive_terms");
367
+
368
+ $objControls->add_control(
369
+ 'by_terms_heading',
370
+ array(
371
+ 'label' => __( 'This hide by archive terms works only when current page is ARCHIVE type and current the term match the seleced', 'unlimited-elements-for-elementor' ),
372
+ 'type' => \Elementor\Controls_Manager::HEADING,
373
+ 'condition' => $conditionTerms,
374
+ 'separator' => 'before'
375
+ )
376
+ );
377
+
378
+ //------ terms to hide
379
+
380
+ $arrControl = HelperProviderCoreUC_EL::getElementorControl_TermsPickerControl(__("Hide When Has Those Terms", "unlimited-elements-for-elementor"));
381
+ $arrControl["condition"] = $conditionTerms;
382
 
383
+ $objControls->add_control(
384
+ 'term_ids_hide',
385
+ $arrControl
386
+ );
387
+
388
+ //------ terms to hide - children
389
+
390
+ $objControls->add_control(
391
+ 'terms_hide_include_children',
392
+ array(
393
+ 'label' => __( 'Or Their Children', 'unlimited-elements-for-elementor' ),
394
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
395
+ 'label_on' => __( 'Yes', 'unlimited-elements-for-elementor' ),
396
+ 'label_off' => __( 'No', 'unlimited-elements-for-elementor' ),
397
+ 'return_value' => 'yes',
398
+ 'default' => 'yes',
399
+ 'condition'=>$conditionTerms
400
+ )
401
+ );
402
+
403
+
404
+ //------ terms to show
405
+
406
+ $arrControl = HelperProviderCoreUC_EL::getElementorControl_TermsPickerControl(__("Show When Has Those Terms", "unlimited-elements-for-elementor"));
407
+ $arrControl["condition"] = $conditionTerms;
408
 
409
+ $objControls->add_control(
410
+ 'term_ids_show',
411
+ $arrControl
412
+ );
413
+
414
+ //------ terms to show - children
415
+
416
+ $objControls->add_control(
417
+ 'terms_show_include_children',
418
+ array(
419
+ 'label' => __( 'Or Their Children', 'unlimited-elements-for-elementor' ),
420
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
421
+ 'label_on' => __( 'Yes', 'unlimited-elements-for-elementor' ),
422
+ 'label_off' => __( 'No', 'unlimited-elements-for-elementor' ),
423
+ 'return_value' => 'yes',
424
+ 'default' => 'yes',
425
+ 'condition'=>$conditionTerms
426
+ )
427
+ );
428
+
429
+
430
+ /*
431
  //--term heading
432
 
433
+ $objControls->add_control(
434
  'by_terms_heading',
435
  array(
436
  'label' => __( 'When current page is archive and current term match the seleced', 'unlimited-elements-for-elementor' ),
439
  )
440
  );
441
 
442
+
443
+
444
  //--term ids
445
 
446
  $arrControl = HelperProviderCoreUC_EL::getElementorControl_TermsPickerControl(__("Select Term", "unlimited-elements-for-elementor"));
447
  $arrControl["condition"] = $conditionTerms;
448
+
449
+ $objControls->add_control(
450
  'term_ids',
451
  $arrControl
452
  );
453
 
454
+ $objControls->add_control(
455
  'terms_include_children',
456
  array(
457
  'label' => __( 'Or Their Children', 'unlimited-elements-for-elementor' ),
463
  'condition'=>$conditionTerms
464
  )
465
  );
466
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
467
 
468
  //------------- DEBUG --------------
469
 
provider/core/plugins/unlimited_elements/elementor/elementor_integrate.class.php CHANGED
@@ -12,7 +12,7 @@ class UniteCreatorElementorIntegrate{
12
  const ADDONS_CATEGORY_TITLE = "Unlimited Elements";
13
  const ADDONS_CATEGORY_NAME = "unlimited_elements";
14
  const ADDONS_TYPE = "elementor";
15
- const DEFAULT_ICON = "fa fa-gears";
16
  const TEMPLATE_TYPE_ARCHIVE = "archive";
17
  const CONTROL_BACKGROUND_TYPE = "uc_background_type";
18
 
@@ -207,7 +207,7 @@ class UniteCreatorElementorIntegrate{
207
  //$className .= "_no_memory";
208
 
209
  self::logMemoryUsage("Before Register Widget: ".$name. ", counter: ".self::$counterWidgets);
210
-
211
  $code = "class {$className} extends UniteCreatorElementorWidget{}";
212
  eval($code);
213
 
@@ -1050,6 +1050,8 @@ class UniteCreatorElementorIntegrate{
1050
 
1051
  $nonce = UniteProviderFunctionsUC::getNonce();
1052
 
 
 
1053
  ?>
1054
  <style>
1055
 
@@ -1071,10 +1073,11 @@ class UniteCreatorElementorIntegrate{
1071
  font-size: 18px;
1072
  }
1073
 
 
1074
  </style>
1075
 
1076
  <div style="display:none">
1077
-
1078
  <a id="uc_button_import_layout" href="javascript:void(0)" class="page-title-action"><?php esc_html_e("Import Template With Images", "unlimited-elements-for-elementor")?></a>
1079
 
1080
  <div id="uc_import_layout_area" style="display:none">
@@ -1090,7 +1093,6 @@ class UniteCreatorElementorIntegrate{
1090
  </div>
1091
 
1092
  </div>
1093
-
1094
  <?php
1095
  }
1096
 
@@ -1128,7 +1130,7 @@ class UniteCreatorElementorIntegrate{
1128
 
1129
  if(empty(self::$arrWidgetIcons))
1130
  return(null);
1131
-
1132
  $styles = "";
1133
  foreach(self::$arrWidgetIcons as $class => $arrWidget){
1134
 
@@ -1192,7 +1194,13 @@ class UniteCreatorElementorIntegrate{
1192
 
1193
  if(!empty($stylesIcons))
1194
  wp_add_inline_style($adminStyleHandle, $stylesIcons);
1195
-
 
 
 
 
 
 
1196
  $script = $this->getEditorPageCustomScripts();
1197
  UniteProviderFunctionsUC::printCustomScript($script, true);
1198
  }
@@ -1210,7 +1218,8 @@ class UniteCreatorElementorIntegrate{
1210
 
1211
  $arrTempFile = UniteFunctionsUC::getVal($_FILES, "file");
1212
  UniteFunctionsUC::validateNotEmpty($arrTempFile,"import file");
1213
-
 
1214
  $exporter = new UniteCreatorLayoutsExporterElementor();
1215
  $exporter->importElementorTemplateNew($arrTempFile);
1216
 
@@ -1430,32 +1439,14 @@ class UniteCreatorElementorIntegrate{
1430
  self::$enableEditHTMLButton = UniteFunctionsUC::strToBool(self::$enableEditHTMLButton);
1431
  }
1432
 
 
1433
  /**
1434
- * init copy paste functionality
1435
  */
1436
- private function initCopyPaste(){
1437
-
1438
- if(GlobalsUC::$inDev == false && !defined("UC_ENABLE_COPYPASTE"))
1439
- return(false);
1440
-
1441
- //check current user
1442
- $currentUserID = get_current_user_id();
1443
-
1444
- if(empty($currentUserID))
1445
- return(false);
1446
-
1447
- $isUserAdmin = current_user_can('administrator');
1448
- if($isUserAdmin == false)
1449
- return(false);
1450
-
1451
- self::$enableCopySectionButton = HelperProviderCoreUC_EL::getGeneralSetting("copy_mode_enable_copy");
1452
- self::$enableCopySectionButton = UniteFunctionsUC::strToBool(self::$enableCopySectionButton);
1453
-
1454
- self::$enablePasteSectionButton = HelperProviderCoreUC_EL::getGeneralSetting("copy_mode_enable_paste");
1455
- self::$enablePasteSectionButton = UniteFunctionsUC::strToBool(self::$enablePasteSectionButton);
1456
-
1457
- $this->objCopyPaste = new UniteCreatorElementorCopyPaste();
1458
- $this->objCopyPaste->init();
1459
 
1460
  }
1461
 
@@ -1505,9 +1496,7 @@ class UniteCreatorElementorIntegrate{
1505
  $this->enableExportTemplate = false;
1506
  $this->enableImportTemplate = false;
1507
  }
1508
-
1509
- $this->initCopyPaste();
1510
-
1511
  add_action('elementor/editor/init', array($this, 'onEditorInit'));
1512
 
1513
  add_action('elementor/widgets/widgets_registered', array($this, 'onWidgetsRegistered'));
@@ -1534,6 +1523,11 @@ class UniteCreatorElementorIntegrate{
1534
 
1535
  add_filter( 'pre_handle_404', array($this, 'checkAllowWidgetPagination' ), 11, 2 );
1536
 
 
 
 
 
 
1537
 
1538
  // ------ admin related only ----------
1539
 
12
  const ADDONS_CATEGORY_TITLE = "Unlimited Elements";
13
  const ADDONS_CATEGORY_NAME = "unlimited_elements";
14
  const ADDONS_TYPE = "elementor";
15
+ const DEFAULT_ICON = "uc-default-widget-icon ue-wi-svg";
16
  const TEMPLATE_TYPE_ARCHIVE = "archive";
17
  const CONTROL_BACKGROUND_TYPE = "uc_background_type";
18
 
207
  //$className .= "_no_memory";
208
 
209
  self::logMemoryUsage("Before Register Widget: ".$name. ", counter: ".self::$counterWidgets);
210
+
211
  $code = "class {$className} extends UniteCreatorElementorWidget{}";
212
  eval($code);
213
 
1050
 
1051
  $nonce = UniteProviderFunctionsUC::getNonce();
1052
 
1053
+ dmp("import layout!!!");
1054
+
1055
  ?>
1056
  <style>
1057
 
1073
  font-size: 18px;
1074
  }
1075
 
1076
+
1077
  </style>
1078
 
1079
  <div style="display:none">
1080
+
1081
  <a id="uc_button_import_layout" href="javascript:void(0)" class="page-title-action"><?php esc_html_e("Import Template With Images", "unlimited-elements-for-elementor")?></a>
1082
 
1083
  <div id="uc_import_layout_area" style="display:none">
1093
  </div>
1094
 
1095
  </div>
 
1096
  <?php
1097
  }
1098
 
1130
 
1131
  if(empty(self::$arrWidgetIcons))
1132
  return(null);
1133
+
1134
  $styles = "";
1135
  foreach(self::$arrWidgetIcons as $class => $arrWidget){
1136
 
1194
 
1195
  if(!empty($stylesIcons))
1196
  wp_add_inline_style($adminStyleHandle, $stylesIcons);
1197
+
1198
+ //include font awesome
1199
+ $urlFontAwesomeCSS = HelperUC::getUrlFontAwesome();
1200
+
1201
+ HelperUC::addStyleAbsoluteUrl($urlFontAwesomeCSS, "font-awesome");
1202
+
1203
+
1204
  $script = $this->getEditorPageCustomScripts();
1205
  UniteProviderFunctionsUC::printCustomScript($script, true);
1206
  }
1218
 
1219
  $arrTempFile = UniteFunctionsUC::getVal($_FILES, "file");
1220
  UniteFunctionsUC::validateNotEmpty($arrTempFile,"import file");
1221
+
1222
+
1223
  $exporter = new UniteCreatorLayoutsExporterElementor();
1224
  $exporter->importElementorTemplateNew($arrTempFile);
1225
 
1439
  self::$enableEditHTMLButton = UniteFunctionsUC::strToBool(self::$enableEditHTMLButton);
1440
  }
1441
 
1442
+
1443
  /**
1444
+ * check and add dynamic loop styles before render
1445
  */
1446
+ public function onBeforeRenderElement($element){
1447
+
1448
+ if(!empty(GlobalsUnlimitedElements::$renderingDynamicData))
1449
+ HelperProviderCoreUC_EL::putDynamicLoopElementStyle($element);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1450
 
1451
  }
1452
 
1496
  $this->enableExportTemplate = false;
1497
  $this->enableImportTemplate = false;
1498
  }
1499
+
 
 
1500
  add_action('elementor/editor/init', array($this, 'onEditorInit'));
1501
 
1502
  add_action('elementor/widgets/widgets_registered', array($this, 'onWidgetsRegistered'));
1523
 
1524
  add_filter( 'pre_handle_404', array($this, 'checkAllowWidgetPagination' ), 11, 2 );
1525
 
1526
+ //dynamic loop
1527
+ add_action( 'elementor/frontend/section/before_render', array($this, "onBeforeRenderElement") );
1528
+ add_action( 'elementor/frontend/column/before_render', array($this, 'onBeforeRenderElement') );
1529
+ add_action( 'elementor/frontend/widget/before_render', array($this, 'onBeforeRenderElement') );
1530
+
1531
 
1532
  // ------ admin related only ----------
1533
 
provider/core/plugins/unlimited_elements/elementor/elementor_layout_exporter.class.php CHANGED
@@ -355,7 +355,8 @@ class UniteCreatorLayoutsExporterElementor extends UniteCreatorLayoutsExporter{
355
  $this->prepareImportFolders();
356
 
357
  $this->extractImportLayoutFile($filepath);
358
-
 
359
  //prepare the content and the json file path after extracted before import
360
  $this->importElementorTemplateNew_prepareLayoutImportContent();
361
 
@@ -377,6 +378,7 @@ class UniteCreatorLayoutsExporterElementor extends UniteCreatorLayoutsExporter{
377
 
378
  $type = UniteFunctionsUC::getVal($this->importedLayoutContent, "type");
379
 
 
380
  if($type == "wp-post")
381
  $this->importedLayoutContent["type"] = "page";
382
 
355
  $this->prepareImportFolders();
356
 
357
  $this->extractImportLayoutFile($filepath);
358
+
359
+
360
  //prepare the content and the json file path after extracted before import
361
  $this->importElementorTemplateNew_prepareLayoutImportContent();
362
 
378
 
379
  $type = UniteFunctionsUC::getVal($this->importedLayoutContent, "type");
380
 
381
+
382
  if($type == "wp-post")
383
  $this->importedLayoutContent["type"] = "page";
384
 
provider/core/plugins/unlimited_elements/elementor/elementor_widget.class.php CHANGED
@@ -351,8 +351,31 @@ class UniteCreatorElementorWidget extends Widget_Base {
351
  * modify value before add by type
352
  */
353
  protected function modifyValueByTypeUC($type, $value){
354
-
355
  switch($type){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  case UniteCreatorDialogParam::PARAM_IMAGE:
357
 
358
  if(empty($value))
@@ -389,6 +412,7 @@ class UniteCreatorElementorWidget extends Widget_Base {
389
 
390
  $arrData = array();
391
 
 
392
  foreach($arrValues as $paramName=>$value){
393
 
394
  $type = UniteFunctionsUC::getVal($arrTypes, $paramName);
@@ -445,7 +469,8 @@ class UniteCreatorElementorWidget extends Widget_Base {
445
 
446
  return $arrItemsData;
447
  }
448
-
 
449
  /**
450
  * add items controls
451
  */
@@ -453,15 +478,42 @@ class UniteCreatorElementorWidget extends Widget_Base {
453
 
454
  if($itemsType == "image")
455
  return(false);
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
  $this->start_controls_section(
458
  'section_items', array(
459
- 'label' => esc_html__("Items", "unlimited-elements-for-elementor"),
460
  )
461
  );
462
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463
  $repeater = new Repeater();
464
-
465
  $paramsItems = $this->objAddon->getProcessedItemsParams();
466
  $paramsItems = $this->addDynamicAttributes($paramsItems);
467
 
@@ -474,14 +526,7 @@ class UniteCreatorElementorWidget extends Widget_Base {
474
 
475
  if($name == "title")
476
  $titleField = $name;
477
-
478
- if($name == "uc_filters_item_selector"){
479
-
480
- $param["type"] = "uc_filters_repeater_params";
481
- $this->addElementorParamUC($param, $repeater);
482
- continue;
483
- }
484
-
485
  switch($type){
486
  case UniteCreatorDialogParam::PARAM_TEMPLATE: //convert template to text param
487
 
@@ -715,6 +760,9 @@ class UniteCreatorElementorWidget extends Widget_Base {
715
  //$controlType = "uc_hr";
716
  $controlType = Controls_Manager::DIVIDER;
717
  break;
 
 
 
718
  case UniteCreatorDialogParam::PARAM_AUDIO:
719
  $controlType = "uc_mp3";
720
  break;
@@ -765,6 +813,11 @@ class UniteCreatorElementorWidget extends Widget_Base {
765
  case UniteCreatorDialogParam::PARAM_HOVER_ANIMATIONS:
766
  $controlType = Controls_Manager::SELECT;
767
  break;
 
 
 
 
 
768
 
769
  default:
770
 
@@ -792,6 +845,44 @@ class UniteCreatorElementorWidget extends Widget_Base {
792
 
793
  //add options
794
  switch($type){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
795
  case "uc_select_special":
796
 
797
  $addParams = UniteFunctionsUC::getVal($param, "addparams");
@@ -1374,8 +1465,6 @@ class UniteCreatorElementorWidget extends Widget_Base {
1374
  }
1375
 
1376
 
1377
-
1378
-
1379
  /**
1380
  * add typography control by param
1381
  */
@@ -1384,6 +1473,16 @@ class UniteCreatorElementorWidget extends Widget_Base {
1384
  $name = UniteFunctionsUC::getVal($param, "name");
1385
  $title = UniteFunctionsUC::getVal($param, "title");
1386
 
 
 
 
 
 
 
 
 
 
 
1387
  //get selectors
1388
  $selector1 = UniteFunctionsUC::getVal($param, "selector1");
1389
  $selector1 = trim($selector1);
@@ -1432,6 +1531,11 @@ class UniteCreatorElementorWidget extends Widget_Base {
1432
  if(!empty($title))
1433
  $arrControl["label"] = $title;
1434
 
 
 
 
 
 
1435
  $this->objControls->add_group_control(Group_Control_Typography::get_type(), $arrControl);
1436
 
1437
  }
@@ -1461,7 +1565,6 @@ class UniteCreatorElementorWidget extends Widget_Base {
1461
  call_user_func($function, $this->objControls, $param);
1462
 
1463
  break;
1464
- case "uc_filters_repeater_params":
1465
  case UniteCreatorDialogParam::PARAM_INSTAGRAM:
1466
  case UniteCreatorDialogParam::PARAM_POST_TERMS:
1467
  case UniteCreatorDialogParam::PARAM_WOO_CATS:
@@ -1705,8 +1808,10 @@ class UniteCreatorElementorWidget extends Widget_Base {
1705
  foreach($params as $index => $param){
1706
 
1707
  $type = UniteFunctionsUC::getVal($param, "type");
1708
-
1709
  switch($type){
 
 
1710
  case UniteCreatorDialogParam::PARAM_TEXTAREA:
1711
  case UniteCreatorDialogParam::PARAM_TEXTFIELD:
1712
  case UniteCreatorDialogParam::PARAM_LINK:
@@ -1719,6 +1824,13 @@ class UniteCreatorElementorWidget extends Widget_Base {
1719
  break;
1720
  }
1721
 
 
 
 
 
 
 
 
1722
  $param["add_dynamic"] = true;
1723
 
1724
  $params[$index] = $param;
@@ -1760,7 +1872,7 @@ class UniteCreatorElementorWidget extends Widget_Base {
1760
  'return_value' => 'true',
1761
  'default' => '',
1762
  'separator' => 'before',
1763
- 'description'=>__('Show widget data for debugging purposes. Please turn off this option when you releasing the widget', 'unlimited_elements')
1764
  )
1765
  );
1766
 
@@ -1961,15 +2073,7 @@ class UniteCreatorElementorWidget extends Widget_Base {
1961
 
1962
  if($isGeneralSection == true && $isItemsEnabled == true && $itemsType == "image")
1963
  $this->addGalleryControlUC();
1964
-
1965
- //$options = $this->objAddon->getOptions();
1966
-
1967
- //$isDynamicAddon = UniteFunctionsUC::getVal($options, "dynamic_addon");
1968
- //$isDynamicAddon = UniteFunctionsUC::strToBool($isDynamicAddon);
1969
-
1970
- //check and add dynamic
1971
- //if($isDynamicAddon == true)
1972
-
1973
  //add dynamic to all the addons, not only dynamic
1974
  $params = $this->addDynamicAttributes($params);
1975
 
@@ -2094,7 +2198,9 @@ class UniteCreatorElementorWidget extends Widget_Base {
2094
  * put listing sections
2095
  */
2096
  private function putListingSections($listingParam){
2097
-
 
 
2098
  $name = UniteFunctionsUC::getVal($listingParam, "name");
2099
 
2100
  $useFor = UniteFunctionsUC::getVal($listingParam, "use_for");
@@ -2125,6 +2231,7 @@ class UniteCreatorElementorWidget extends Widget_Base {
2125
 
2126
  $this->end_controls_section();
2127
 
 
2128
  //woocommerce
2129
 
2130
  $isWooActive = UniteCreatorWooIntegrate::isWooActive();
@@ -2151,30 +2258,12 @@ class UniteCreatorElementorWidget extends Widget_Base {
2151
 
2152
  $this->end_controls_section();
2153
 
2154
-
2155
-
2156
  }
2157
-
2158
 
 
 
 
2159
 
2160
- //add term section
2161
- /*
2162
- $this->start_controls_section(
2163
- 'uc_section_listing_terms_query', array(
2164
- 'label' => __("Terms Query", "unlimited-elements-for-elementor"),
2165
- 'condition'=>array($name."_source"=>"terms")
2166
- )
2167
- );
2168
-
2169
- $termsParam = $listingParam;
2170
-
2171
- $termsParam["type"] = UniteCreatorDialogParam::PARAM_POST_TERMS;
2172
- $termsParam["name"] = $name."_terms";
2173
-
2174
- $this->addElementorParamUC($termsParam);
2175
-
2176
- $this->end_controls_section();
2177
- */
2178
 
2179
  }
2180
 
@@ -2814,12 +2903,11 @@ class UniteCreatorElementorWidget extends Widget_Base {
2814
 
2815
  if(empty($arrItems))
2816
  return(array());
2817
-
2818
-
2819
  foreach($arrItems as $itemIndex => $arrItem){
2820
 
2821
  if($itemsType == "image"){ //modify image base
2822
-
2823
  try{
2824
  $imageValue = $this->modifyImageValueUC($arrItem);
2825
 
@@ -3037,7 +3125,7 @@ class UniteCreatorElementorWidget extends Widget_Base {
3037
  }
3038
 
3039
  $arrValues = $this->getSettingsValuesUC();
3040
-
3041
  HelperUC::addDebug("widget values", $arrValues);
3042
 
3043
  $arrFonts = $this->getArrFonts($arrValues);
@@ -3054,12 +3142,11 @@ class UniteCreatorElementorWidget extends Widget_Base {
3054
  $arrItems = UniteFunctionsUC::getVal($arrValues, "uc_items");
3055
 
3056
  $arrItems = $this->modifyArrItemsParamsValuesUC($arrItems, $itemsType);
3057
-
3058
  }
3059
-
3060
  $arrMainParamValues = $this->getArrMainParamValuesUC($arrValues, $objAddon);
3061
 
3062
-
3063
  $arrPostListParam = $objAddon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
3064
  if(!empty($arrPostListParam)){
3065
 
@@ -3071,13 +3158,13 @@ class UniteCreatorElementorWidget extends Widget_Base {
3071
 
3072
  //check if inside editor
3073
  $isEditMode = $this->isEditMode();
3074
-
3075
  $objAddon->setParamsValues($arrMainParamValues);
3076
  $objAddon->setArrFonts($arrFonts);
3077
 
3078
  if($hasItems == true)
3079
  $objAddon->setArrItems($arrItems);
3080
-
3081
  $output = new UniteCreatorOutput();
3082
 
3083
  //set show debug data
351
  * modify value before add by type
352
  */
353
  protected function modifyValueByTypeUC($type, $value){
354
+
355
  switch($type){
356
+ case "image_json":
357
+
358
+ //get json url
359
+
360
+ $arrEmpty = array("url"=>"");
361
+
362
+ $value = trim($value);
363
+
364
+ if(empty($value))
365
+ return($arrEmpty);
366
+
367
+ $urlAssets = $this->objAddon->getUrlAssets();
368
+
369
+ if(empty($urlAssets))
370
+ return($arrEmpty);
371
+
372
+ $value = $urlAssets.$value;
373
+
374
+ $arrOutput = array("url"=>$value);
375
+
376
+ return($arrOutput);
377
+
378
+ break;
379
  case UniteCreatorDialogParam::PARAM_IMAGE:
380
 
381
  if(empty($value))
412
 
413
  $arrData = array();
414
 
415
+
416
  foreach($arrValues as $paramName=>$value){
417
 
418
  $type = UniteFunctionsUC::getVal($arrTypes, $paramName);
469
 
470
  return $arrItemsData;
471
  }
472
+
473
+
474
  /**
475
  * add items controls
476
  */
478
 
479
  if($itemsType == "image")
480
  return(false);
481
+
482
+ $itemsLabel = esc_html__("Items", "unlimited-elements-for-elementor");
483
+
484
+ $itemsTitle = $this->objAddon->getOption("items_section_title");
485
+ $itemsTitle = trim($itemsTitle);
486
+
487
+ $itemsHeading = $this->objAddon->getOption("items_section_heading");
488
+ $itemsHeading = trim($itemsHeading);
489
+
490
+
491
+ if(!empty($itemsTitle))
492
+ $itemsLabel = $itemsTitle;
493
 
494
  $this->start_controls_section(
495
  'section_items', array(
496
+ 'label' => $itemsLabel,
497
  )
498
  );
499
+
500
+ //add heading label text
501
+ if(!empty($itemsHeading)){
502
+
503
+ $this->add_control(
504
+ 'uc_item_section_heading10',
505
+ array(
506
+ 'label' => $itemsHeading,
507
+ 'type' => Controls_Manager::HEADING,
508
+ 'separator' => 'after',
509
+ )
510
+ );
511
+
512
+
513
+ }
514
+
515
  $repeater = new Repeater();
516
+
517
  $paramsItems = $this->objAddon->getProcessedItemsParams();
518
  $paramsItems = $this->addDynamicAttributes($paramsItems);
519
 
526
 
527
  if($name == "title")
528
  $titleField = $name;
529
+
 
 
 
 
 
 
 
530
  switch($type){
531
  case UniteCreatorDialogParam::PARAM_TEMPLATE: //convert template to text param
532
 
760
  //$controlType = "uc_hr";
761
  $controlType = Controls_Manager::DIVIDER;
762
  break;
763
+ case UniteCreatorDialogParam::PARAM_HEADING:
764
+ $controlType = Controls_Manager::HEADING;
765
+ break;
766
  case UniteCreatorDialogParam::PARAM_AUDIO:
767
  $controlType = "uc_mp3";
768
  break;
813
  case UniteCreatorDialogParam::PARAM_HOVER_ANIMATIONS:
814
  $controlType = Controls_Manager::SELECT;
815
  break;
816
+ case UniteCreatorDialogParam::PARAM_SPECIAL:
817
+
818
+ $controlType = Controls_Manager::TEXT;
819
+
820
+ break;
821
 
822
  default:
823
 
845
 
846
  //add options
847
  switch($type){
848
+ case UniteCreatorDialogParam::PARAM_SPECIAL:
849
+
850
+ /*
851
+ $attributeType = UniteFunctionsUC::getVal($param, "attribute_type");
852
+
853
+ switch($attributeType){
854
+ case "refresh":
855
+
856
+ $strNames = UniteFunctionsUC::getVal($param, "refresh_attribute_names");
857
+
858
+ $arrControl["type"] = Controls_Manager::RAW_HTML;
859
+ $arrControl["label"] = "";
860
+ $arrControl["raw"] = "<div class='uc-refresh-widget-wrapper'>
861
+ <input type='text' class='uc-refresh-widget-input' data-setting='{$name}' value='' data-attribute-names='{$strNames}'>
862
+ names: $strNames
863
+ </div>";
864
+
865
+ break;
866
+ default:
867
+ break;
868
+ }
869
+ */
870
+
871
+ break;
872
+ case UniteCreatorDialogParam::PARAM_IMAGE:
873
+
874
+ $mediaType = UniteFunctionsUC::getVal($param, "media_type");
875
+
876
+ if($mediaType == "json"){
877
+
878
+ $defaultValue = UniteFunctionsUC::getVal($param, "default_value_json");
879
+ $defaultValue = $this->modifyValueByTypeUC("image_json", $defaultValue);
880
+
881
+ $arrControl['media_type'] = 'application/json';
882
+ $arrControl['default'] = $defaultValue;
883
+ }
884
+
885
+ break;
886
  case "uc_select_special":
887
 
888
  $addParams = UniteFunctionsUC::getVal($param, "addparams");
1465
  }
1466
 
1467
 
 
 
1468
  /**
1469
  * add typography control by param
1470
  */
1473
  $name = UniteFunctionsUC::getVal($param, "name");
1474
  $title = UniteFunctionsUC::getVal($param, "title");
1475
 
1476
+ $elementorCondition = UniteFunctionsUC::getVal($param, "elementor_condition");
1477
+ $enableCondition = UniteFunctionsUC::getVal($param, "enable_condition");
1478
+ $enableCondition = UniteFunctionsUC::strToBool($enableCondition);
1479
+
1480
+ //set condition
1481
+ if($enableCondition == true){
1482
+ $elementorCondition = $this->getControlArrayUC_getCondition($param, $elementorCondition);
1483
+ }
1484
+
1485
+
1486
  //get selectors
1487
  $selector1 = UniteFunctionsUC::getVal($param, "selector1");
1488
  $selector1 = trim($selector1);
1531
  if(!empty($title))
1532
  $arrControl["label"] = $title;
1533
 
1534
+ if(!empty($elementorCondition)){
1535
+ $arrControl["condition"] = $elementorCondition;
1536
+ }
1537
+
1538
+
1539
  $this->objControls->add_group_control(Group_Control_Typography::get_type(), $arrControl);
1540
 
1541
  }
1565
  call_user_func($function, $this->objControls, $param);
1566
 
1567
  break;
 
1568
  case UniteCreatorDialogParam::PARAM_INSTAGRAM:
1569
  case UniteCreatorDialogParam::PARAM_POST_TERMS:
1570
  case UniteCreatorDialogParam::PARAM_WOO_CATS:
1808
  foreach($params as $index => $param){
1809
 
1810
  $type = UniteFunctionsUC::getVal($param, "type");
1811
+
1812
  switch($type){
1813
+ case UniteCreatorDialogParam::PARAM_NUMBER:
1814
+ case UniteCreatorDialogParam::PARAM_SLIDER:
1815
  case UniteCreatorDialogParam::PARAM_TEXTAREA:
1816
  case UniteCreatorDialogParam::PARAM_TEXTFIELD:
1817
  case UniteCreatorDialogParam::PARAM_LINK:
1824
  break;
1825
  }
1826
 
1827
+ //skip selector enabled
1828
+ $selector = UniteFunctionsUC::getVal($param, "selector");
1829
+ $selector = trim($selector);
1830
+
1831
+ if(!empty($selector))
1832
+ continue;
1833
+
1834
  $param["add_dynamic"] = true;
1835
 
1836
  $params[$index] = $param;
1872
  'return_value' => 'true',
1873
  'default' => '',
1874
  'separator' => 'before',
1875
+ 'description'=>__('Show widget data for debugging purposes. Please turn off this option when you releasing the widget', 'unlimited-elements-for-elementor')
1876
  )
1877
  );
1878
 
2073
 
2074
  if($isGeneralSection == true && $isItemsEnabled == true && $itemsType == "image")
2075
  $this->addGalleryControlUC();
2076
+
 
 
 
 
 
 
 
 
2077
  //add dynamic to all the addons, not only dynamic
2078
  $params = $this->addDynamicAttributes($params);
2079
 
2198
  * put listing sections
2199
  */
2200
  private function putListingSections($listingParam){
2201
+
2202
+ $objUEControls = new UniteCreatorElementorControls();
2203
+
2204
  $name = UniteFunctionsUC::getVal($listingParam, "name");
2205
 
2206
  $useFor = UniteFunctionsUC::getVal($listingParam, "use_for");
2231
 
2232
  $this->end_controls_section();
2233
 
2234
+
2235
  //woocommerce
2236
 
2237
  $isWooActive = UniteCreatorWooIntegrate::isWooActive();
2258
 
2259
  $this->end_controls_section();
2260
 
 
 
2261
  }
 
2262
 
2263
+ //add the gallery repeater
2264
+ if($isForGallery == true)
2265
+ $objUEControls->addGalleryImageVideoRepeater($this, $textPrefix, $name);
2266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2267
 
2268
  }
2269
 
2903
 
2904
  if(empty($arrItems))
2905
  return(array());
2906
+
 
2907
  foreach($arrItems as $itemIndex => $arrItem){
2908
 
2909
  if($itemsType == "image"){ //modify image base
2910
+
2911
  try{
2912
  $imageValue = $this->modifyImageValueUC($arrItem);
2913
 
3125
  }
3126
 
3127
  $arrValues = $this->getSettingsValuesUC();
3128
+
3129
  HelperUC::addDebug("widget values", $arrValues);
3130
 
3131
  $arrFonts = $this->getArrFonts($arrValues);
3142
  $arrItems = UniteFunctionsUC::getVal($arrValues, "uc_items");
3143
 
3144
  $arrItems = $this->modifyArrItemsParamsValuesUC($arrItems, $itemsType);
3145
+
3146
  }
3147
+
3148
  $arrMainParamValues = $this->getArrMainParamValuesUC($arrValues, $objAddon);
3149
 
 
3150
  $arrPostListParam = $objAddon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST);
3151
  if(!empty($arrPostListParam)){
3152
 
3158
 
3159
  //check if inside editor
3160
  $isEditMode = $this->isEditMode();
3161
+
3162
  $objAddon->setParamsValues($arrMainParamValues);
3163
  $objAddon->setArrFonts($arrFonts);
3164
 
3165
  if($hasItems == true)
3166
  $objAddon->setArrItems($arrItems);
3167
+
3168
  $output = new UniteCreatorOutput();
3169
 
3170
  //set show debug data
provider/core/plugins/unlimited_elements/elementor/images/new2.svg DELETED
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <!-- Generator: Sketch 64 (93537) - https://sketch.com -->
4
- <title>Artboard</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs>
7
- <linearGradient x1="1.4609375%" y1="93.3752694%" x2="98.5390625%" y2="6.62473059%" id="linearGradient-1">
8
- <stop stop-color="#6F00D8" offset="0%"></stop>
9
- <stop stop-color="#1C6AFF" offset="100%"></stop>
10
- </linearGradient>
11
- </defs>
12
- <g id="Artboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
13
- <path d="M16,9.8125 C16,9.15670869 15.495423,8.625 14.8732589,8.625 L12.3767411,8.625 C11.754577,8.625 11.25,9.15670869 11.25,9.8125 C11.25,10.4682913 11.754577,11 12.3767411,11 L14.8732589,11 C15.495423,11 16,10.4682913 16,9.8125 M16,5.3125 C16,4.65688127 15.4955868,4.125 14.8730951,4.125 L12.3769049,4.125 C11.754577,4.125 11.25,4.65688127 11.25,5.3125 C11.25,5.96829131 11.754577,6.5 12.3769049,6.5 L14.8730951,6.5 C15.4955868,6.5 16,5.96829131 16,5.3125 M6.08906748,9.49285349 L6.08906748,5.06742919 C6.08906748,3.52164857 7.31894407,2.26412848 8.83054671,2.26412848 L14.8928858,2.26412848 C15.5042844,2.26412848 16,1.75720458 16,1.13214651 C16,0.506923905 15.5042844,0 14.8928858,0 L8.83054671,0 C6.09807756,0 3.875,2.27317776 3.875,5.06742919 L3.875,9.49285349 C3.875,10.1180761 4.37071557,10.625 4.98211419,10.625 C5.59351281,10.625 6.08906748,10.1180761 6.08906748,9.49285349 M5.06258218,15.125 C3.71014952,15.125 2.4389154,14.5848817 1.48277772,13.604136 C0.526640043,12.6230531 0,11.3188772 0,9.9313987 L0,5.28533542 C0,4.64454562 0.506422588,4.125 1.13102688,4.125 C1.75563118,4.125 2.26205377,4.64454562 2.26205377,5.28533542 L2.26205377,9.9313987 C2.26205377,10.6989974 2.55331661,11.4203918 3.08225783,11.9630396 C3.61103468,12.5056874 4.31437199,12.8044978 5.06258218,12.8044978 C6.60666975,12.8044978 7.86294623,11.5156672 7.86294623,9.9313987 L7.86294623,5.28533542 C7.86294623,4.64454562 8.36936882,4.125 8.99397312,4.125 C9.61857741,4.125 10.125,4.64454562 10.125,5.28533542 L10.125,9.9313987 C10.125,12.7952232 7.85390591,15.125 5.06258218,15.125" id="Fill-1" fill="url(#linearGradient-1)"></path>
14
- </g>
15
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
provider/core/plugins/unlimited_elements/elementor/images/widget-icon.svg ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 432 432" style="enable-background:new 0 0 432 432;" xml:space="preserve">
5
+ <desc>Created with Sketch.</desc>
6
+ <g id="_x34_0_x2C_000">
7
+ <g id="loading-copy" transform="translate(-188.000000, -88.000000)">
8
+ <g id="Combined-Shape">
9
+ <path d="M404,520c-57.7,0-111.9-22.5-152.7-63.3c-40.8-40.8-63.3-95-63.3-152.7s22.5-111.9,63.3-152.7
10
+ C292.1,110.5,346.3,88,404,88c57.7,0,111.9,22.5,152.7,63.3c40.8,40.8,63.3,95,63.3,152.7s-22.5,111.9-63.3,152.7
11
+ C515.9,497.5,461.7,520,404,520z M404,96c-114.7,0-208,93.3-208,208c0,114.7,93.3,208,208,208s208-93.3,208-208
12
+ C612,189.3,518.7,96,404,96z M352.1,438.8c-21.7,0-42.1-8.7-57.5-24.5c-15.3-15.8-23.8-36.8-23.8-59.1v-71.2
13
+ c0-12,9.5-21.8,21.3-21.8s21.3,9.8,21.3,21.8v71.2c0,10.7,4,20.8,11.4,28.4c7.3,7.5,17,11.7,27.3,11.7c21.4,0,38.7-18,38.7-40
14
+ v-71.2c0-12,9.5-21.8,21.3-21.8s21.3,9.8,21.3,21.8v71.2C433.3,401.3,396.9,438.8,352.1,438.8z M292.1,270.1
15
+ c-7.3,0-13.3,6.2-13.3,13.8v71.2c0,20.2,7.6,39.2,21.5,53.5c13.8,14.3,32.2,22.1,51.8,22.1c40.4,0,73.2-33.9,73.2-75.6v-71.2
16
+ c0-7.6-5.9-13.8-13.3-13.8s-13.3,6.2-13.3,13.8v71.2c0,26.5-21,48-46.7,48c-12.5,0-24.3-5-33.1-14.1
17
+ c-8.8-9.1-13.6-21.1-13.6-33.9v-71.2C305.4,276.3,299.4,270.1,292.1,270.1z M502.8,375.1h-38.4c-11.8,0-21.3-10-21.3-22.3
18
+ s9.6-22.3,21.3-22.3h38.4c11.8,0,21.3,10,21.3,22.3S514.6,375.1,502.8,375.1z M464.4,338.5c-7.4,0-13.3,6.4-13.3,14.3
19
+ s6,14.3,13.3,14.3h38.4c7.4,0,13.3-6.4,13.3-14.3s-6-14.3-13.3-14.3H464.4z M350.8,370.4c-11.6,0-21-9.6-21-21.5v-68.3
20
+ c0-45.3,36-82.2,80.2-82.2h93.2c11.6,0,21,9.6,21,21.5c0,11.8-9.4,21.5-21,21.5H410c-21,0-38.1,17.6-38.1,39.2v68.3
21
+ C371.8,360.7,362.4,370.4,350.8,370.4z M410,206.5c-39.8,0-72.2,33.3-72.2,74.2v68.3c0,7.4,5.8,13.5,13,13.5c7.2,0,13-6,13-13.5
22
+ v-68.3c0-26.1,20.7-47.2,46.1-47.2h93.2c7.2,0,13-6,13-13.5c0-7.4-5.8-13.5-13-13.5H410z M502.8,306.7h-38.4
23
+ c-11.8,0-21.3-10-21.3-22.3s9.6-22.3,21.3-22.3h38.4c11.8,0,21.3,10,21.3,22.3S514.6,306.7,502.8,306.7z M464.4,270.1
24
+ c-7.4,0-13.3,6.4-13.3,14.3s6,14.3,13.3,14.3h38.4c7.4,0,13.3-6.4,13.3-14.3s-6-14.3-13.3-14.3H464.4z"/>
25
+ </g>
26
+ </g>
27
+ </g>
28
+ </svg>
provider/core/plugins/unlimited_elements/elementor/pagination.class.php CHANGED
@@ -21,10 +21,19 @@ class UniteCreatorElementorPagination{
21
  $isFilterable = UniteFunctionsUC::getVal($postListParam, "is_filterable");
22
  $isFilterable = UniteFunctionsUC::strToBool($isFilterable);
23
 
 
 
 
 
 
 
24
  $textSection = esc_html__("Posts Pagination", "unlimited-elements-for-elementor");
25
  if($isFilterable == true)
26
  $textSection = esc_html__("Posts Pagination and Filter", "unlimited-elements-for-elementor");
27
 
 
 
 
28
  $widget->start_controls_section(
29
  'section_pagination', array(
30
  'label' => $textSection,
@@ -58,25 +67,40 @@ class UniteCreatorElementorPagination{
58
  //add filter enabled controls
59
 
60
  if($isFilterable == true){
61
-
62
- $paramName = UniteFunctionsUC::getVal($postListParam, "name");
63
-
64
  $widget->add_control(
65
  $paramName.'_filterable',
66
  [
67
  'label' => __( 'Filterable', "unlimited-elements-for-elementor"),
68
  'type' => \Elementor\Controls_Manager::SELECT,
69
  'default' => '',
 
70
  'options' => [
71
  '' => __( 'None', "unlimited-elements-for-elementor"),
72
  'using_widget' => __( 'Using Post Filters Widgets', "unlimited-elements-for-elementor"),
73
  ],
74
  ]
75
  );
76
-
77
 
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  $widget->end_controls_section();
82
  }
@@ -361,6 +385,7 @@ class UniteCreatorElementorPagination{
361
  $isDebug = UniteFunctionsUC::getVal($args, "debug_pagination_options");
362
  $isDebug = UniteFunctionsUC::strToBool($isDebug);
363
 
 
364
  //--------- prepare options
365
 
366
  $options = array();
@@ -398,13 +423,27 @@ class UniteCreatorElementorPagination{
398
  }else{ //on single
399
 
400
  //skip for home pages
401
- if(is_home() == true)
 
 
 
 
 
402
  return(false);
403
-
 
404
  $options = $this->getSinglePageOptions($options);
405
 
406
- if(isset($options["current"]) == false)
 
 
 
 
 
 
 
407
  return(false);
 
408
 
409
  if(empty($nextText))
410
  $options["next_text"] = _x( 'Next', 'next set of posts' );
21
  $isFilterable = UniteFunctionsUC::getVal($postListParam, "is_filterable");
22
  $isFilterable = UniteFunctionsUC::strToBool($isFilterable);
23
 
24
+ $enableAjax = UniteFunctionsUC::getVal($postListParam, "enable_ajax");
25
+ $enableAjax = UniteFunctionsUC::strToBool($enableAjax);
26
+
27
+ $paramName = UniteFunctionsUC::getVal($postListParam, "name");
28
+
29
+
30
  $textSection = esc_html__("Posts Pagination", "unlimited-elements-for-elementor");
31
  if($isFilterable == true)
32
  $textSection = esc_html__("Posts Pagination and Filter", "unlimited-elements-for-elementor");
33
 
34
+ if($enableAjax == true)
35
+ $textSection = esc_html__("Posts Pagination and Ajax", "unlimited-elements-for-elementor");
36
+
37
  $widget->start_controls_section(
38
  'section_pagination', array(
39
  'label' => $textSection,
67
  //add filter enabled controls
68
 
69
  if($isFilterable == true){
70
+
 
 
71
  $widget->add_control(
72
  $paramName.'_filterable',
73
  [
74
  'label' => __( 'Filterable', "unlimited-elements-for-elementor"),
75
  'type' => \Elementor\Controls_Manager::SELECT,
76
  'default' => '',
77
+ 'separator' => 'before',
78
  'options' => [
79
  '' => __( 'None', "unlimited-elements-for-elementor"),
80
  'using_widget' => __( 'Using Post Filters Widgets', "unlimited-elements-for-elementor"),
81
  ],
82
  ]
83
  );
 
84
 
85
  }
86
 
87
+ if($enableAjax == true){
88
+
89
+ $widget->add_control(
90
+ $paramName.'_isajax',
91
+ [
92
+ 'label' => __( 'Enable Ajax', "unlimited-elements-for-elementor"),
93
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
94
+ 'label_on' => __( 'Yes', 'unlimited-elements-for-elementor' ),
95
+ 'label_off' => __( 'No', 'unlimited-elements-for-elementor' ),
96
+ 'return_value' => 'true',
97
+ 'default' => '',
98
+ 'separator' => 'before',
99
+ 'description'=>__('When turn on, all the filters, all the filters interaction will be with ajax', 'unlimited-elements-for-elementor')
100
+ ]
101
+ );
102
+
103
+ }
104
 
105
  $widget->end_controls_section();
106
  }
385
  $isDebug = UniteFunctionsUC::getVal($args, "debug_pagination_options");
386
  $isDebug = UniteFunctionsUC::strToBool($isDebug);
387
 
388
+
389
  //--------- prepare options
390
 
391
  $options = array();
423
  }else{ //on single
424
 
425
  //skip for home pages
426
+ if(is_home() == true){
427
+
428
+ if($isDebug == true){
429
+ dmp("Pagination Debug - Home Page, Skip");
430
+ }
431
+
432
  return(false);
433
+ }
434
+
435
  $options = $this->getSinglePageOptions($options);
436
 
437
+ if(isset($options["current"]) == false){
438
+
439
+ if($isDebug == true){
440
+ dmp("<b>Pagination Options (custom) </b>: <br>");
441
+ dmp("No pagination found for the last query <br>");
442
+ dmp($options);
443
+ }
444
+
445
  return(false);
446
+ }
447
 
448
  if(empty($nextText))
449
  $options["next_text"] = _x( 'Next', 'next set of posts' );
provider/core/plugins/unlimited_elements/globals.class.php CHANGED
@@ -63,8 +63,8 @@ class GlobalsUnlimitedElements{
63
  const PREFIX_TEMPLATE_PERMALINK = "unlimited-";
64
 
65
  public static $enableCPT = false;
66
-
67
  public static $urlTemplatesList;
 
68
 
69
 
70
  /**
63
  const PREFIX_TEMPLATE_PERMALINK = "unlimited-";
64
 
65
  public static $enableCPT = false;
 
66
  public static $urlTemplatesList;
67
+ public static $renderingDynamicData;
68
 
69
 
70
  /**
provider/core/plugins/unlimited_elements/helper_provider_core.class.php CHANGED
@@ -404,6 +404,49 @@ class HelperProviderCoreUC_EL{
404
  return($arrControl);
405
  }
406
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  private static function ______LISTING________(){}
408
 
409
  /**
@@ -431,19 +474,33 @@ class HelperProviderCoreUC_EL{
431
  */
432
  public static function putElementorTemplate($templateID){
433
 
434
- if(empty($templateID) || is_numeric($templateID) == false)
435
- return(false);
436
 
437
- $output = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $templateID );
438
  echo $output;
 
 
 
 
 
 
 
 
 
 
439
 
 
 
 
440
  }
441
 
442
 
443
  /**
444
  * put the post listing template
445
  */
446
- public static function putListingItemTemplate_post($post, $templateID){
 
 
 
447
 
448
  if(empty($templateID))
449
  return(false);
@@ -465,21 +522,134 @@ class HelperProviderCoreUC_EL{
465
 
466
  $GLOBALS['post'] = $post;
467
 
468
- self::putElementorTemplate($templateID);
469
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  //restore the original queried object
471
  $wp_query->queried_object = $originalQueriedObject;
472
  $wp_query->queried_object_id = $originalQueriedObjectID;
473
  $GLOBALS['post'] = $originalPost;
474
 
 
 
 
 
 
 
 
 
 
 
475
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
  }
477
 
 
478
  /**
479
  * put listing loop
480
  */
481
- public static function putListingItemTemplate($item, $templateID){
482
-
483
  //set type
484
 
485
  $type = null;
@@ -505,12 +675,14 @@ class HelperProviderCoreUC_EL{
505
 
506
  //template output
507
  if($type == "post")
508
- self::putListingItemTemplate_post($item, $templateID);
509
  else
510
  echo "output term";
511
 
512
  }
513
 
 
 
514
  /**
515
  * global init
516
  */
404
  return($arrControl);
405
  }
406
 
407
+ /**
408
+ * get elementor data from post id
409
+ */
410
+ public static function getElementorContentByPostID($postID){
411
+
412
+ $postID = (int)$postID;
413
+
414
+ $strData = get_post_meta($postID,"_elementor_data",true);
415
+
416
+ if(empty($strData))
417
+ return(false);
418
+
419
+ $arrData = UniteFunctionsUC::jsonDecode($strData);
420
+
421
+ return($arrData);
422
+ }
423
+
424
+ /**
425
+ * get widget elementor from content
426
+ */
427
+ public static function getArrElementFromContent($arrContent, $elementID){
428
+
429
+ if(is_array($arrContent) == false)
430
+ return(null);
431
+
432
+ if(isset($arrContent["elType"]) && isset($arrContent["id"]) && $arrContent["id"] == $elementID)
433
+ return($arrContent);
434
+
435
+ foreach($arrContent as $child){
436
+
437
+ if(is_array($child) == false)
438
+ continue;
439
+
440
+ $arrElement = self::getArrElementFromContent($child, $elementID);
441
+
442
+ if(!empty($arrElement))
443
+ return($arrElement);
444
+ }
445
+
446
+ return(null);
447
+ }
448
+
449
+
450
  private static function ______LISTING________(){}
451
 
452
  /**
474
  */
475
  public static function putElementorTemplate($templateID){
476
 
477
+ $output = self::getElementorTemplate($templateID);
 
478
 
 
479
  echo $output;
480
+ }
481
+
482
+
483
+ /**
484
+ * put elementor template
485
+ */
486
+ public static function getElementorTemplate($templateID){
487
+
488
+ if(empty($templateID) || is_numeric($templateID) == false)
489
+ return("");
490
 
491
+ $output = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $templateID);
492
+
493
+ return($output);
494
  }
495
 
496
 
497
  /**
498
  * put the post listing template
499
  */
500
+ public static function putListingItemTemplate_post($post, $templateID, $widgetID){
501
+
502
+ if(empty($widgetID))
503
+ return(false);
504
 
505
  if(empty($templateID))
506
  return(false);
522
 
523
  $GLOBALS['post'] = $post;
524
 
525
+ GlobalsUnlimitedElements::$renderingDynamicData = array(
526
+ "post_id"=>$postID,
527
+ "template_id" => $templateID,
528
+ "widget_id"=>$widgetID);
529
+
530
+ $htmlTemplate = self::getElementorTemplate($templateID);
531
+
532
+ //add one more class
533
+
534
+ $source = "class=\"elementor elementor-{$templateID}";
535
+ $dest = "{$source} uc-post-$postID";
536
+
537
+ $htmlTemplate = str_replace($source, $dest, $htmlTemplate);
538
+
539
+ echo $htmlTemplate;
540
+
541
+ GlobalsUnlimitedElements::$renderingDynamicData = null;
542
+
543
  //restore the original queried object
544
  $wp_query->queried_object = $originalQueriedObject;
545
  $wp_query->queried_object_id = $originalQueriedObjectID;
546
  $GLOBALS['post'] = $originalPost;
547
 
548
+ }
549
+
550
+
551
+ /**
552
+ * put dynamic loop element style if exists
553
+ */
554
+ public static function putDynamicLoopElementStyle($element){
555
+
556
+ if(empty(GlobalsUnlimitedElements::$renderingDynamicData))
557
+ return(false);
558
 
559
+ $postID = UniteFunctionsUC::getVal(GlobalsUnlimitedElements::$renderingDynamicData, "post_id");
560
+ $templateID = UniteFunctionsUC::getVal(GlobalsUnlimitedElements::$renderingDynamicData, "template_id");
561
+ $widgetID = UniteFunctionsUC::getVal(GlobalsUnlimitedElements::$renderingDynamicData, "widget_id");
562
+
563
+
564
+ if(empty($postID))
565
+ return(false);
566
+
567
+ if(empty($templateID))
568
+ return(false);
569
+
570
+ $elementID = $element->get_ID();
571
+ $dynamicSettings = $element->get_settings( '__dynamic__' );
572
+
573
+ if(empty($dynamicSettings))
574
+ return(false);
575
+
576
+ $arrControls = $element->get_controls();
577
+ if(empty($arrControls))
578
+ return(false);
579
+
580
+ $arrControls = array_intersect_key($arrControls, $dynamicSettings);
581
+
582
+ if(empty($arrControls))
583
+ return(false);
584
+
585
+ $settings = @$element->parse_dynamic_settings( $dynamicSettings, $arrControls);
586
+
587
+ if(empty($settings))
588
+ return(false);
589
+
590
+ $strStyle = "";
591
+
592
+ $wrapperCssKey = "#{$widgetID} .uc-post-{$postID}.elementor-{$templateID} .elementor-element.elementor-element-{$elementID}";
593
+
594
+ foreach($arrControls as $controlName => $control){
595
+
596
+ $arrValues = UniteFunctionsUC::getVal($settings, $controlName);
597
+
598
+ if(empty($arrValues))
599
+ continue;
600
+
601
+ $url = UniteFunctionsUC::getVal($arrValues, "url");
602
+
603
+ if(empty($url))
604
+ continue;
605
+
606
+ $arrSelectors = UniteFunctionsUC::getVal($control, "selectors");
607
+ if(empty($arrSelectors))
608
+ continue;
609
+
610
+ //modify the selectors
611
+
612
+ foreach($arrSelectors as $cssKey=>$cssValue){
613
+
614
+ if(strpos($cssValue, "{{URL}}") === false)
615
+ continue;
616
+
617
+ $cssKey = str_replace("{{WRAPPER}}", $wrapperCssKey, $cssKey);
618
+
619
+ $cssValue = str_replace("{{URL}}", $url, $cssValue);
620
+
621
+ //clear other placeholders
622
+
623
+ $cssValue = str_replace("{{VALUE}}", "", $cssValue);
624
+ $cssValue = str_replace("{{UNIT}}", "", $cssValue);
625
+
626
+ if(!empty($strStyle))
627
+ $strStyle .= "\n";
628
+
629
+ $strStyle .= $cssKey."{{$cssValue}}\n";
630
+
631
+ }
632
+
633
+ }
634
+
635
+ if(empty($strStyle))
636
+ return(false);
637
+
638
+ //output the style
639
+
640
+ $strOutput = "<style type='text/css'>\n";
641
+ $strOutput .= $strStyle;
642
+ $strOutput .= "</style>";
643
+
644
+ echo $strOutput;
645
  }
646
 
647
+
648
  /**
649
  * put listing loop
650
  */
651
+ public static function putListingItemTemplate($item, $templateID, $widgetID){
652
+
653
  //set type
654
 
655
  $type = null;
675
 
676
  //template output
677
  if($type == "post")
678
+ self::putListingItemTemplate_post($item, $templateID, $widgetID);
679
  else
680
  echo "output term";
681
 
682
  }
683
 
684
+
685
+
686
  /**
687
  * global init
688
  */
provider/core/plugins/unlimited_elements/plugin.php CHANGED
@@ -87,7 +87,7 @@ class UnlimitedElementsPluginUC extends UniteCreatorPluginBase{
87
  require_once $this->pathPlugin . 'elementor/elementor_integrate.class.php';
88
  require_once $this->pathPlugin . 'elementor/pagination.class.php';
89
  require_once $this->pathPlugin . "elementor/elementor_dynamic_visibility.class.php";
90
- require_once $this->pathPlugin . "copy_paste.class.php";
91
 
92
  if(is_admin()){
93
  require_once $this->pathPlugin . 'elementor/elementor_layout_exporter.class.php';
87
  require_once $this->pathPlugin . 'elementor/elementor_integrate.class.php';
88
  require_once $this->pathPlugin . 'elementor/pagination.class.php';
89
  require_once $this->pathPlugin . "elementor/elementor_dynamic_visibility.class.php";
90
+ require_once $this->pathPlugin . "elementor/elementor_controls.class.php";
91
 
92
  if(is_admin()){
93
  require_once $this->pathPlugin . 'elementor/elementor_layout_exporter.class.php';
provider/core/plugins/unlimited_elements/settings/general_settings_el.xml CHANGED
@@ -157,23 +157,6 @@
157
  </field>
158
 
159
  </fieldset>
160
- <fieldset name="copy_paste_mode" label="Copy Paste Mode - Test" visibility="dev">
161
-
162
- <field name="copy_mode_enable_copy"
163
- type="boolean"
164
- default="false"
165
- label=" Enable Copy"
166
- description="">
167
- </field>
168
-
169
- <field name="copy_mode_enable_paste"
170
- type="boolean"
171
- default="false"
172
- label=" Enable Paste"
173
- description="">
174
- </field>
175
-
176
- </fieldset>
177
  <fieldset name="troubleshooting" label="Troubleshooting">
178
 
179
  <field name="memory_limit_text"
157
  </field>
158
 
159
  </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  <fieldset name="troubleshooting" label="Troubleshooting">
161
 
162
  <field name="memory_limit_text"
provider/freemius/assets/img/unlimited-elements-for-elementor.png DELETED
Binary file
provider/functions_wordpress.class.php CHANGED
@@ -634,6 +634,31 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
634
  return($arrDataOutput);
635
  }
636
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
  /**
638
  * get post terms titles
639
  */
@@ -1624,10 +1649,17 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
1624
  $categoryExcludeChildren = UniteFunctionsUC::strToBool($categoryExcludeChildren);
1625
 
1626
  $arrTax = self::getPosts_getTaxQuery($category, $categoryRelation, $categoryIncludeChildren, $excludeCategory, $categoryExcludeChildren);
 
1627
 
1628
  if($isTaxonly === true){
1629
- if(!empty($arrTax))
 
 
 
 
 
1630
  $args["tax_query"] = $arrTax;
 
1631
  return($args);
1632
  }
1633
 
@@ -2223,6 +2255,8 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2223
 
2224
  $title = wp_get_attachment_caption($thumbID);
2225
 
 
 
2226
  $item = array();
2227
  $item["image_id"] = $post->ID;
2228
  $item["image"] = $post->guid;
@@ -2230,6 +2264,8 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2230
  if(empty($title))
2231
  $title = $post->post_title;
2232
 
 
 
2233
  $urlThumb = self::getUrlAttachmentImage($thumbID,self::THUMB_MEDIUM_LARGE);
2234
  if(empty($urlThumb))
2235
  $urlThumb = $post->guid;
@@ -2239,6 +2275,9 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2239
  $item["title"] = $title;
2240
  $item["description"] = $post->post_content;
2241
 
 
 
 
2242
  self::$arrUrlAttachmentDataCache[$handle] = $item;
2243
 
2244
  return($item);
@@ -2338,7 +2377,7 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2338
  $attachment_id = 0;
2339
 
2340
  $dir = wp_upload_dir();
2341
-
2342
  if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory?
2343
 
2344
  $file = basename( $url );
@@ -2363,10 +2402,10 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
2363
  foreach ( $query->posts as $post_id ) {
2364
 
2365
  $meta = wp_get_attachment_metadata( $post_id );
2366
-
2367
  $original_file = basename( $meta['file'] );
2368
  $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
2369
-
2370
  if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
2371
  $attachment_id = $post_id;
2372
  break;
@@ -3136,6 +3175,55 @@ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
3136
  return($arrAllKeys);
3137
  }
3138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3139
 
3140
 
3141
  } //end of the class
634
  return($arrDataOutput);
635
  }
636
 
637
+ /**
638
+ * get post term
639
+ */
640
+ public static function getPostTerm($postID, $taxName, $termSlug){
641
+
642
+ $arrTerms = wp_get_post_terms($postID, $taxName);
643
+
644
+ if(empty($arrTerms))
645
+ return(null);
646
+
647
+ foreach($arrTerms as $term){
648
+
649
+ $slug = $term->slug;
650
+
651
+ if($slug != $termSlug)
652
+ continue;
653
+
654
+ $termData = self::getTermData($term);
655
+
656
+ return($termData);
657
+ }
658
+
659
+ return(null);
660
+ }
661
+
662
  /**
663
  * get post terms titles
664
  */
1649
  $categoryExcludeChildren = UniteFunctionsUC::strToBool($categoryExcludeChildren);
1650
 
1651
  $arrTax = self::getPosts_getTaxQuery($category, $categoryRelation, $categoryIncludeChildren, $excludeCategory, $categoryExcludeChildren);
1652
+
1653
 
1654
  if($isTaxonly === true){
1655
+ if(!empty($arrTax)){
1656
+
1657
+ if(count($arrTax) > 1){
1658
+ $arrTax = array($arrTax);
1659
+ }
1660
+
1661
  $args["tax_query"] = $arrTax;
1662
+ }
1663
  return($args);
1664
  }
1665
 
2255
 
2256
  $title = wp_get_attachment_caption($thumbID);
2257
 
2258
+ $rawCaption = $title;
2259
+
2260
  $item = array();
2261
  $item["image_id"] = $post->ID;
2262
  $item["image"] = $post->guid;
2264
  if(empty($title))
2265
  $title = $post->post_title;
2266
 
2267
+ $rawTitle = $post->post_title;
2268
+
2269
  $urlThumb = self::getUrlAttachmentImage($thumbID,self::THUMB_MEDIUM_LARGE);
2270
  if(empty($urlThumb))
2271
  $urlThumb = $post->guid;
2275
  $item["title"] = $title;
2276
  $item["description"] = $post->post_content;
2277
 
2278
+ $item["raw_caption"] = $rawCaption;
2279
+ $item["raw_title"] = $rawTitle;
2280
+
2281
  self::$arrUrlAttachmentDataCache[$handle] = $item;
2282
 
2283
  return($item);
2377
  $attachment_id = 0;
2378
 
2379
  $dir = wp_upload_dir();
2380
+
2381
  if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory?
2382
 
2383
  $file = basename( $url );
2402
  foreach ( $query->posts as $post_id ) {
2403
 
2404
  $meta = wp_get_attachment_metadata( $post_id );
2405
+
2406
  $original_file = basename( $meta['file'] );
2407
  $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
2408
+
2409
  if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
2410
  $attachment_id = $post_id;
2411
  break;
3175
  return($arrAllKeys);
3176
  }
3177
 
3178
+ /**
3179
+ * clean query args for debug
3180
+ */
3181
+ public static function cleanQueryArgsForDebug($args){
3182
+
3183
+ $argsNew = array();
3184
+
3185
+ foreach($args as $name=>$value){
3186
+
3187
+ //keep
3188
+ switch($name){
3189
+ case "ignore_sticky_posts":
3190
+ case "suppress_filters":
3191
+
3192
+ $argsNew[$name] = $value;
3193
+ continue(2);
3194
+ break;
3195
+ }
3196
+
3197
+ if(empty($value))
3198
+ continue;
3199
+
3200
+ $argsNew[$name] = $value;
3201
+ }
3202
+
3203
+
3204
+ return($argsNew);
3205
+ }
3206
+
3207
+
3208
+ /**
3209
+ * print current query
3210
+ */
3211
+ public static function printCurrentQuery($query = null){
3212
+
3213
+ if(empty($query)){
3214
+ global $wp_query;
3215
+ $query = $wp_query;
3216
+ }
3217
+
3218
+ $queryVars = $query->query_vars;
3219
+
3220
+ $queryVars = self::cleanQueryArgsForDebug($queryVars);
3221
+
3222
+
3223
+ dmp("Current Query Is: ");
3224
+ dmp($queryVars);
3225
+
3226
+ }
3227
 
3228
 
3229
  } //end of the class
provider/provider_dialog_param.class.php CHANGED
@@ -56,6 +56,7 @@ class UniteCreatorDialogParam extends UniteCreatorDialogParamWork{
56
  $this->arrParams[] = self::PARAM_BORDER_DIMENTIONS;
57
  $this->arrParams[] = self::PARAM_CSS_FILTERS;
58
  $this->arrParams[] = self::PARAM_HOVER_ANIMATIONS;
 
59
 
60
  $this->arrParams = $this->filterMainParams($this->arrParams);
61
  }
56
  $this->arrParams[] = self::PARAM_BORDER_DIMENTIONS;
57
  $this->arrParams[] = self::PARAM_CSS_FILTERS;
58
  $this->arrParams[] = self::PARAM_HOVER_ANIMATIONS;
59
+ //$this->arrParams[] = self::PARAM_SPECIAL;
60
 
61
  $this->arrParams = $this->filterMainParams($this->arrParams);
62
  }
provider/provider_functions.class.php CHANGED
@@ -314,6 +314,16 @@ class UniteProviderFunctionsUC{
314
  return($url);
315
  }
316
 
 
 
 
 
 
 
 
 
 
 
317
 
318
  public static function a_________SANITIZE________(){}
319
 
@@ -490,6 +500,7 @@ class UniteProviderFunctionsUC{
490
  * add jquery include
491
  */
492
  public static function addjQueryInclude($app="", $urljQuery = null){
 
493
  wp_enqueue_script("jquery");
494
  }
495
 
314
  return($url);
315
  }
316
 
317
+ /**
318
+ * get jquery migrate url include
319
+ */
320
+ public static function getUrlJQueryMigrateInclude(){
321
+
322
+ $url = GlobalsUC::$url_base."wp-includes/js/jquery/jquery-migrate".".js";
323
+
324
+ return($url);
325
+ }
326
+
327
 
328
  public static function a_________SANITIZE________(){}
329
 
500
  * add jquery include
501
  */
502
  public static function addjQueryInclude($app="", $urljQuery = null){
503
+
504
  wp_enqueue_script("jquery");
505
  }
506
 
provider/provider_helper.class.php CHANGED
@@ -476,4 +476,34 @@ class HelperProviderUC{
476
  return($response);
477
  }
478
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
  }
476
  return($response);
477
  }
478
 
479
+ /**
480
+ * get post term for template
481
+ //arg1 - postID
482
+ //arg2 - taxonomy
483
+ //arg3 - term slug
484
+ */
485
+ public static function getPostTermForTemplate($arg1, $arg2, $arg3){
486
+
487
+ if(is_numeric($arg1) == false)
488
+ return(false);
489
+
490
+ //no slug found
491
+ if(empty($arg3) || empty($arg2)){
492
+
493
+ dmp("get_post_term. please enter second or third parameter - taxonomy or slug ");
494
+
495
+ $post = get_post($arg1);
496
+ $arrTerms = UniteFunctionsWPUC::getPostTerms($post);
497
+
498
+ dmp("post terms: ");
499
+ dmp($arrTerms);
500
+
501
+ return(null);
502
+ }
503
+
504
+ $term = UniteFunctionsWPUC::getPostTerm($arg1,$arg2,$arg3);
505
+
506
+ return($term);
507
+ }
508
+
509
  }
provider/provider_library.class.php CHANGED
@@ -13,6 +13,9 @@ class UniteCreatorLibrary extends UniteCreatorLibraryWork{
13
  case "jquery":
14
  $urlInclude = UniteProviderFunctionsUC::getUrlJQueryInclude();
15
  break;
 
 
 
16
  }
17
 
18
  return($urlInclude);
@@ -24,11 +27,11 @@ class UniteCreatorLibrary extends UniteCreatorLibraryWork{
24
  * return true if library found and processed, and false if not
25
  */
26
  public function processProviderLibrary($name){
27
-
28
-
29
  switch($name){
30
  case "jquery":
31
  UniteProviderFunctionsUC::addjQueryInclude();
 
32
  break;
33
  default:
34
  return(false);
13
  case "jquery":
14
  $urlInclude = UniteProviderFunctionsUC::getUrlJQueryInclude();
15
  break;
16
+ case "jquery-migrate":
17
+ $urlInclude = UniteProviderFunctionsUC::getUrlJQueryMigrateInclude();
18
+ break;
19
  }
20
 
21
  return($urlInclude);
27
  * return true if library found and processed, and false if not
28
  */
29
  public function processProviderLibrary($name){
30
+
 
31
  switch($name){
32
  case "jquery":
33
  UniteProviderFunctionsUC::addjQueryInclude();
34
+
35
  break;
36
  default:
37
  return(false);
provider/provider_params_processor.class.php CHANGED
@@ -242,6 +242,25 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
242
  return($arrOutput);
243
  }
244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
  protected function z_______________POSTS____________(){}
247
 
@@ -907,7 +926,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
907
  $debugType = null;
908
  if($showDebugQuery == true)
909
  $debugType = UniteFunctionsUC::getVal($value, "{$name}_query_debug_type");
910
-
911
  $source = UniteFunctionsUC::getVal($value, "{$name}_source");
912
 
913
  $isForWoo = UniteFunctionsUC::getVal($param, "for_woocommerce_products");
@@ -1132,7 +1151,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1132
  if($isFilterable == true)
1133
  $filters = $this->getPostListData_getPostGetFilters_filters($filters);
1134
  }
1135
-
1136
  //add debug for further use
1137
  HelperUC::addDebug("Post Filters", $filters);
1138
 
@@ -1230,6 +1249,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1230
  $arrIDsPHPFunction = array();
1231
  $arrIDsPostMeta = array();
1232
  $arrIDsDynamicField = array();
 
1233
 
1234
 
1235
  $makePostINOrder = false;
@@ -1283,6 +1303,12 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1283
  'compare'=>'!='
1284
  );
1285
 
 
 
 
 
 
 
1286
  break;
1287
  case "author":
1288
 
@@ -1354,6 +1380,8 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1354
  $metaCompare = UniteFunctionsUC::getVal($value, "{$name}_includeby_metacompare");
1355
  $metaValue = UniteFunctionsUC::getVal($value, "{$name}_includeby_metavalue");
1356
 
 
 
1357
  if(!empty($metaKey)){
1358
 
1359
  $arrMetaQuery[] = array(
@@ -1452,6 +1480,11 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1452
  $makePostINOrder = true;
1453
  }
1454
 
 
 
 
 
 
1455
 
1456
  //make order as "post__id"
1457
 
@@ -1546,8 +1579,10 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1546
  //-------- show debug query --------------
1547
 
1548
  if($showDebugQuery == true){
 
 
1549
  dmp("The Query Is:");
1550
- dmp($args);
1551
  }
1552
 
1553
  $query = new WP_Query($args);
@@ -1592,6 +1627,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1592
 
1593
  if($showDebugQuery == true){
1594
  dmp("Found Posts: ".count($arrPosts));
 
1595
  }
1596
 
1597
 
@@ -1599,35 +1635,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1599
  }
1600
 
1601
 
1602
- /**
1603
- * clean query args for debug
1604
- */
1605
- private function cleanQueryArgsForDebug($args){
1606
-
1607
- $argsNew = array();
1608
-
1609
- foreach($args as $name=>$value){
1610
-
1611
- //keep
1612
- switch($name){
1613
- case "ignore_sticky_posts":
1614
- case "suppress_filters":
1615
-
1616
- $argsNew[$name] = $value;
1617
- continue(2);
1618
- break;
1619
- }
1620
-
1621
- if(empty($value))
1622
- continue;
1623
-
1624
- $argsNew[$name] = $value;
1625
- }
1626
-
1627
 
1628
- return($argsNew);
1629
- }
1630
-
1631
 
1632
  /**
1633
  * get current posts
@@ -1636,7 +1644,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1636
 
1637
  //add debug for further use
1638
  HelperUC::addDebug("Getting Current Posts");
1639
-
1640
  $orderBy = UniteFunctionsUC::getVal($value, $name."_orderby");
1641
  $orderDir = UniteFunctionsUC::getVal($value, $name."_orderdir1");
1642
  $orderByMetaKey = UniteFunctionsUC::getVal($value, $name."_orderby_meta_key1");
@@ -1671,10 +1679,19 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1671
  $showDebugQuery = UniteFunctionsUC::getVal($value, "{$name}_show_query_debug");
1672
  $showDebugQuery = UniteFunctionsUC::strToBool($showDebugQuery);
1673
 
 
 
1674
  if($showDebugQuery == true){
 
 
 
1675
  dmp("Current Posts. The Query Is:");
1676
- $argsForDebug = $this->cleanQueryArgsForDebug($currentQueryVars);
 
1677
  dmp($argsForDebug);
 
 
 
1678
  }
1679
 
1680
  $query = $wp_query;
@@ -1685,6 +1702,10 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1685
  $query = new WP_Query( $currentQueryVars );
1686
  }
1687
 
 
 
 
 
1688
  HelperUC::addDebug("Query Vars", $currentQueryVars);
1689
 
1690
  //save last query
@@ -1694,9 +1715,11 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1694
 
1695
  if(empty($arrPosts))
1696
  $arrPosts = array();
1697
-
1698
  if($showDebugQuery == true){
1699
  dmp("Found Posts: ".count($arrPosts));
 
 
1700
  }
1701
 
1702
  HelperUC::addDebug("Posts Found: ". count($arrPosts));
@@ -1777,7 +1800,99 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1777
 
1778
  }
1779
 
1780
- protected function z_______________LISTING_GALLERY____________(){}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1781
 
1782
  /**
1783
  * get gallery item title
@@ -1829,6 +1944,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1829
  */
1830
  private function getGalleryItem($id, $url = null, $arrParams = null){
1831
 
 
1832
  $data = array();
1833
 
1834
  $arrFilters = UniteFunctionsUC::getVal($arrParams, "size_filters");
@@ -1840,7 +1956,6 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1840
  $descriptionSource = UniteFunctionsUC::getVal($arrParams, "description_source");
1841
  $post = UniteFunctionsUC::getVal($arrParams, "post");
1842
 
1843
-
1844
  $name = "image";
1845
 
1846
  $param = array();
@@ -1849,18 +1964,40 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1849
  $param["no_attributes"] = true;
1850
 
1851
  //no extra data needed
1852
- if( strpos($titleSource,"post_") !== false && strpos($descriptionSource, "pots_") !== false)
1853
  $param["no_image_data"] = true;
1854
 
1855
  $value = $id;
1856
  if(empty($value))
1857
  $value = $url;
1858
 
1859
- if(empty($value))
1860
- return(array());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1861
 
1862
  $data = $this->getProcessedParamsValue_image($data, $value, $param);
1863
-
1864
  $arrItem = array();
1865
  $keyThumb = "{$name}_thumb_$thumbSize";
1866
  $keyImage = "{$name}_thumb_$imageSize";
@@ -1948,13 +2085,13 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
1948
  $content = $item->post_content;
1949
 
1950
  $featuredImageID = $this->getPostFeaturedImageID($postID, $content);
1951
-
1952
  $params["post"] = $item;
1953
 
1954
  $galleryItem = $this->getGalleryItem($featuredImageID,null,$params);
1955
 
1956
  $galleryItem["postid"] = $postID;
1957
-
1958
  break;
1959
  case "gallery":
1960
 
@@ -2098,7 +2235,6 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
2098
 
2099
  $data = $this->getPostListData($value, $paramProducts["name"], $processType, $paramProducts, $data);
2100
 
2101
-
2102
  break;
2103
  case "terms":
2104
 
@@ -2114,7 +2250,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
2114
  case "current_post_meta": //meta field with image id's
2115
 
2116
  $data[$name."_items"] = $this->getGroupedData_getArrImageIDsFromMeta($value, $name);
2117
-
2118
  break;
2119
  default:
2120
  UniteFunctionsUC::throwError("Wrong listing source: $source");
@@ -2126,7 +2262,7 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
2126
  $arrItems = $data[$name."_items"];
2127
 
2128
  $data[$name."_items"] = $this->getGroupedData_convertForGallery($arrItems, $source, $value, $param);
2129
-
2130
  return($data);
2131
  }
2132
 
@@ -2174,104 +2310,6 @@ class UniteCreatorParamsProcessor extends UniteCreatorParamsProcessorWork{
2174
 
2175
 
2176
 
2177
- /**
2178
- * get post list data
2179
- */
2180
- private function getPostListData($value, $name, $processType, $param, $data){
2181
-
2182
- if($processType != self::PROCESS_TYPE_OUTPUT && $processType != self::PROCESS_TYPE_OUTPUT_BACK)
2183
- return($data);
2184
-
2185
- HelperUC::addDebug("getPostList values", $value);
2186
- HelperUC::addDebug("getPostList param", $param);
2187
-
2188
- $source = UniteFunctionsUC::getVal($value, "{$name}_source");
2189
-
2190
- $arrPosts = array();
2191
-
2192
- switch($source){
2193
- case "manual":
2194
-
2195
- $arrPosts = $this->getPostListData_manualSelection($value, $name, $data);
2196
-
2197
- break;
2198
- case "current":
2199
-
2200
- $arrPosts = $this->getPostListData_currentPosts($value, $name, $data);
2201
-
2202
- break;
2203
- default: //custom
2204
-
2205
- $arrPosts = $this->getPostListData_custom($value, $name, $processType, $param, $data);
2206
-
2207
- $filters = array();
2208
- $arrPostsFromFilter = UniteProviderFunctionsUC::applyFilters("uc_filter_posts_list", $arrPosts, $value, $filters);
2209
-
2210
- if(!empty($arrPostsFromFilter))
2211
- $arrPosts = $arrPostsFromFilter;
2212
-
2213
- break;
2214
- }
2215
-
2216
-
2217
- if(empty($arrPosts))
2218
- $arrPosts = array();
2219
-
2220
- $useCustomFields = UniteFunctionsUC::getVal($param, "use_custom_fields");
2221
- $useCustomFields = UniteFunctionsUC::strToBool($useCustomFields);
2222
-
2223
- $useCategory = UniteFunctionsUC::getVal($param, "use_category");
2224
- $useCategory = UniteFunctionsUC::strToBool($useCategory);
2225
-
2226
- $arrPostAdditions = HelperProviderUC::getPostDataAdditions($useCustomFields, $useCategory);
2227
-
2228
- HelperUC::addDebug("post additions", $arrPostAdditions);
2229
-
2230
- //image sizes
2231
- $showImageSizes = UniteFunctionsUC::getVal($param, "show_image_sizes");
2232
- $showImageSizes = UniteFunctionsUC::strToBool($showImageSizes);
2233
-
2234
- $arrImageSizes = null;
2235
-
2236
- if($showImageSizes == true){
2237
-
2238
- $imageSize = UniteFunctionsUC::getVal($value, "{$name}_imagesize","medium_large");
2239
- $arrImageSizes["desktop"] = $imageSize;
2240
- }
2241
-
2242
- //add filterable params like uc_listing_addclass, uc_listing_attributes
2243
-
2244
- $isFilterable = UniteFunctionsUC::getVal($value, $name."_filterable");
2245
- $isFilterable = ($isFilterable == "using_widget");
2246
-
2247
- if($isFilterable == true){
2248
-
2249
- $objFilters = new UniteCreatorFiltersProcess();
2250
- $data = $objFilters->addWidgetFilterableVariables($data);
2251
- }
2252
-
2253
- //prepare listing output. no items prepare for the listing
2254
-
2255
- $useForListing = UniteFunctionsUC::getVal($param, "use_for_listing");
2256
- $useForListing = UniteFunctionsUC::strToBool($useForListing);
2257
-
2258
- if($useForListing == true){
2259
- $nameListing = UniteFunctionsUC::getVal($param, "name_listing");
2260
-
2261
- $data[$nameListing."_items"] = $arrPosts;
2262
- return($data);
2263
- }
2264
-
2265
- $arrData = array();
2266
- foreach($arrPosts as $post){
2267
-
2268
- $arrData[] = $this->getPostDataByObj($post, $arrPostAdditions, $arrImageSizes);
2269
- }
2270
-
2271
- $data[$name] = $arrData;
2272
-
2273
- return($data);
2274
- }
2275
 
2276
  protected function z_______________FILTERS____________(){}
2277
 
242
  return($arrOutput);
243
  }
244
 
245
+ /**
246
+ * modify the meta value, process the special keywords
247
+ */
248
+ private function modifyMetaValueForCompare($metaValue){
249
+
250
+ switch($metaValue){
251
+ case "{current_user_id}":
252
+ $userID = get_current_user_id();
253
+ if(empty($userID))
254
+ $userID = "0";
255
+
256
+ return($userID);
257
+ break;
258
+ }
259
+
260
+
261
+ return($metaValue);
262
+ }
263
+
264
 
265
  protected function z_______________POSTS____________(){}
266
 
926
  $debugType = null;
927
  if($showDebugQuery == true)
928
  $debugType = UniteFunctionsUC::getVal($value, "{$name}_query_debug_type");
929
+
930
  $source = UniteFunctionsUC::getVal($value, "{$name}_source");
931
 
932
  $isForWoo = UniteFunctionsUC::getVal($param, "for_woocommerce_products");
1151
  if($isFilterable == true)
1152
  $filters = $this->getPostListData_getPostGetFilters_filters($filters);
1153
  }
1154
+
1155
  //add debug for further use
1156
  HelperUC::addDebug("Post Filters", $filters);
1157
 
1249
  $arrIDsPHPFunction = array();
1250
  $arrIDsPostMeta = array();
1251
  $arrIDsDynamicField = array();
1252
+ $arrIDsFromContent = array();
1253
 
1254
 
1255
  $makePostINOrder = false;
1303
  'compare'=>'!='
1304
  );
1305
 
1306
+ break;
1307
+ case "products_from_post": //get products from post content
1308
+
1309
+ $objWoo = new UniteCreatorWooIntegrate();
1310
+ $arrIDsFromContent = $objWoo->getProductIDsFromCurrentPostContent();
1311
+
1312
  break;
1313
  case "author":
1314
 
1380
  $metaCompare = UniteFunctionsUC::getVal($value, "{$name}_includeby_metacompare");
1381
  $metaValue = UniteFunctionsUC::getVal($value, "{$name}_includeby_metavalue");
1382
 
1383
+ $metaValue = $this->modifyMetaValueForCompare($metaValue);
1384
+
1385
  if(!empty($metaKey)){
1386
 
1387
  $arrMetaQuery[] = array(
1480
  $makePostINOrder = true;
1481
  }
1482
 
1483
+ if(!empty($arrIDsFromContent)){
1484
+ $arrPostInIDs = $arrIDsFromContent;
1485
+ $makePostINOrder = true;
1486
+ }
1487
+
1488
 
1489
  //make order as "post__id"
1490
 
1579
  //-------- show debug query --------------
1580
 
1581
  if($showDebugQuery == true){
1582
+ echo "<div class='uc-debug-query-wrapper'>"; //start debug wrapper
1583
+
1584
  dmp("The Query Is:");
1585
+ dmp($args);
1586
  }
1587
 
1588
  $query = new WP_Query($args);
1627
 
1628
  if($showDebugQuery == true){
1629
  dmp("Found Posts: ".count($arrPosts));
1630
+ echo "</div>";
1631
  }
1632
 
1633
 
1635
  }
1636
 
1637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1638
 
 
 
 
1639
 
1640
  /**
1641
  * get current posts
1644
 
1645
  //add debug for further use
1646
  HelperUC::addDebug("Getting Current Posts");
1647
+
1648
  $orderBy = UniteFunctionsUC::getVal($value, $name."_orderby");
1649
  $orderDir = UniteFunctionsUC::getVal($value, $name."_orderdir1");
1650
  $orderByMetaKey = UniteFunctionsUC::getVal($value, $name."_orderby_meta_key1");
1679
  $showDebugQuery = UniteFunctionsUC::getVal($value, "{$name}_show_query_debug");
1680
  $showDebugQuery = UniteFunctionsUC::strToBool($showDebugQuery);
1681
 
1682
+ $debugType = null;
1683
+
1684
  if($showDebugQuery == true){
1685
+
1686
+ echo "<div class='uc-debug-query-wrapper'>"; //start debug wrapper
1687
+
1688
  dmp("Current Posts. The Query Is:");
1689
+
1690
+ $argsForDebug = UniteFunctionsWPUC::cleanQueryArgsForDebug($currentQueryVars);
1691
  dmp($argsForDebug);
1692
+
1693
+ $debugType = UniteFunctionsUC::getVal($value, "{$name}_query_debug_type");
1694
+
1695
  }
1696
 
1697
  $query = $wp_query;
1702
  $query = new WP_Query( $currentQueryVars );
1703
  }
1704
 
1705
+ if($debugType == "show_query")
1706
+ dmp($query->request);
1707
+
1708
+
1709
  HelperUC::addDebug("Query Vars", $currentQueryVars);
1710
 
1711
  //save last query
1715
 
1716
  if(empty($arrPosts))
1717
  $arrPosts = array();
1718
+
1719
  if($showDebugQuery == true){
1720
  dmp("Found Posts: ".count($arrPosts));
1721
+
1722
+ echo "</div>"; //close query wrapper div
1723
  }
1724
 
1725
  HelperUC::addDebug("Posts Found: ". count($arrPosts));
1800
 
1801
  }
1802
 
1803
+ /**
1804
+ * get post list data
1805
+ */
1806
+ private function getPostListData($value, $name, $processType, $param, $data){
1807
+
1808
+ if($processType != self::PROCESS_TYPE_OUTPUT && $processType != self::PROCESS_TYPE_OUTPUT_BACK)
1809
+ return($data);
1810
+
1811
+ HelperUC::addDebug("getPostList values", $value);
1812
+ HelperUC::addDebug("getPostList param", $param);
1813
+
1814
+ $source = UniteFunctionsUC::getVal($value, "{$name}_source");
1815
+
1816
+ $arrPosts = array();
1817
+
1818
+ switch($source){
1819
+ case "manual":
1820
+
1821
+ $arrPosts = $this->getPostListData_manualSelection($value, $name, $data);
1822
+
1823
+ break;
1824
+ case "current":
1825
+
1826
+ $arrPosts = $this->getPostListData_currentPosts($value, $name, $data);
1827
+
1828
+ break;
1829
+ default: //custom
1830
+
1831
+ $arrPosts = $this->getPostListData_custom($value, $name, $processType, $param, $data);
1832
+
1833
+ $filters = array();
1834
+ $arrPostsFromFilter = UniteProviderFunctionsUC::applyFilters("uc_filter_posts_list", $arrPosts, $value, $filters);
1835
+
1836
+ if(!empty($arrPostsFromFilter))
1837
+ $arrPosts = $arrPostsFromFilter;
1838
+
1839
+ break;
1840
+ }
1841
+
1842
+
1843
+ if(empty($arrPosts))
1844
+ $arrPosts = array();
1845
+
1846
+ $useCustomFields = UniteFunctionsUC::getVal($param, "use_custom_fields");
1847
+ $useCustomFields = UniteFunctionsUC::strToBool($useCustomFields);
1848
+
1849
+ $useCategory = UniteFunctionsUC::getVal($param, "use_category");
1850
+ $useCategory = UniteFunctionsUC::strToBool($useCategory);
1851
+
1852
+ $arrPostAdditions = HelperProviderUC::getPostDataAdditions($useCustomFields, $useCategory);
1853
+
1854
+ HelperUC::addDebug("post additions", $arrPostAdditions);
1855
+
1856
+ //image sizes
1857
+ $showImageSizes = UniteFunctionsUC::getVal($param, "show_image_sizes");
1858
+ $showImageSizes = UniteFunctionsUC::strToBool($showImageSizes);
1859
+
1860
+ $arrImageSizes = null;
1861
+
1862
+ if($showImageSizes == true){
1863
+
1864
+ $imageSize = UniteFunctionsUC::getVal($value, "{$name}_imagesize","medium_large");
1865
+ $arrImageSizes["desktop"] = $imageSize;
1866
+ }
1867
+
1868
+ $objFilters = new UniteCreatorFiltersProcess();
1869
+ $data = $objFilters->addWidgetFilterableVariables($data, $this->addon);
1870
+
1871
+ //prepare listing output. no items prepare for the listing
1872
+
1873
+ $useForListing = UniteFunctionsUC::getVal($param, "use_for_listing");
1874
+ $useForListing = UniteFunctionsUC::strToBool($useForListing);
1875
+
1876
+ if($useForListing == true){
1877
+ $nameListing = UniteFunctionsUC::getVal($param, "name_listing");
1878
+
1879
+ $data[$nameListing."_items"] = $arrPosts;
1880
+ return($data);
1881
+ }
1882
+
1883
+ $arrData = array();
1884
+ foreach($arrPosts as $post){
1885
+
1886
+ $arrData[] = $this->getPostDataByObj($post, $arrPostAdditions, $arrImageSizes);
1887
+ }
1888
+
1889
+ $data[$name] = $arrData;
1890
+
1891
+ return($data);
1892
+ }
1893
+
1894
+
1895
+ protected function z_______________DYNAMIC_LOOP_GALLERY____________(){}
1896
 
1897
  /**
1898
  * get gallery item title
1944
  */
1945
  private function getGalleryItem($id, $url = null, $arrParams = null){
1946
 
1947
+
1948
  $data = array();
1949
 
1950
  $arrFilters = UniteFunctionsUC::getVal($arrParams, "size_filters");
1956
  $descriptionSource = UniteFunctionsUC::getVal($arrParams, "description_source");
1957
  $post = UniteFunctionsUC::getVal($arrParams, "post");
1958
 
 
1959
  $name = "image";
1960
 
1961
  $param = array();
1964
  $param["no_attributes"] = true;
1965
 
1966
  //no extra data needed
1967
+ if( strpos($titleSource,"post_") !== false && strpos($descriptionSource, "post_") !== false)
1968
  $param["no_image_data"] = true;
1969
 
1970
  $value = $id;
1971
  if(empty($value))
1972
  $value = $url;
1973
 
1974
+ if(empty($value)){
1975
+
1976
+ $item["image"] = GlobalsUC::$url_no_image_placeholder;
1977
+ $item["thumb"] = GlobalsUC::$url_no_image_placeholder;
1978
+
1979
+ $item["image_width"] = 600;
1980
+ $item["image_height"] = 600;
1981
+ $item["thumb_width"] = 600;
1982
+ $item["thumb_height"] = 600;
1983
+
1984
+ $title = $this->getGalleryItem_title($titleSource, $data, $name, $post);
1985
+ $description = $this->getGalleryItem_title($descriptionSource, $data, $name, $post);
1986
+
1987
+ if(empty($title))
1988
+ $title = $post->post_title;
1989
+
1990
+ $item["title"] = $title;
1991
+ $item["description"] = $description;
1992
+
1993
+ $item["imageid"] = 0;
1994
+
1995
+ return($item);
1996
+ }
1997
+
1998
 
1999
  $data = $this->getProcessedParamsValue_image($data, $value, $param);
2000
+
2001
  $arrItem = array();
2002
  $keyThumb = "{$name}_thumb_$thumbSize";
2003
  $keyImage = "{$name}_thumb_$imageSize";
2085
  $content = $item->post_content;
2086
 
2087
  $featuredImageID = $this->getPostFeaturedImageID($postID, $content);
2088
+
2089
  $params["post"] = $item;
2090
 
2091
  $galleryItem = $this->getGalleryItem($featuredImageID,null,$params);
2092
 
2093
  $galleryItem["postid"] = $postID;
2094
+
2095
  break;
2096
  case "gallery":
2097
 
2235
 
2236
  $data = $this->getPostListData($value, $paramProducts["name"], $processType, $paramProducts, $data);
2237
 
 
2238
  break;
2239
  case "terms":
2240
 
2250
  case "current_post_meta": //meta field with image id's
2251
 
2252
  $data[$name."_items"] = $this->getGroupedData_getArrImageIDsFromMeta($value, $name);
2253
+
2254
  break;
2255
  default:
2256
  UniteFunctionsUC::throwError("Wrong listing source: $source");
2262
  $arrItems = $data[$name."_items"];
2263
 
2264
  $data[$name."_items"] = $this->getGroupedData_convertForGallery($arrItems, $source, $value, $param);
2265
+
2266
  return($data);
2267
  }
2268
 
2310
 
2311
 
2312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2313
 
2314
  protected function z_______________FILTERS____________(){}
2315
 
provider/provider_settings.class.php CHANGED
@@ -1118,7 +1118,10 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
1118
 
1119
  $maxPostsPerPage = get_option("posts_per_page");
1120
 
1121
- $this->addStaticText("The current posts are being used in archive pages. Posts per page: {$maxPostsPerPage}. Set this option in Settings -> Reading ", $name."_currenttext", $params);
 
 
 
1122
 
1123
  //-------- add static text - related --------
1124
 
@@ -1216,6 +1219,7 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
1216
  $arrIncludeBy["cross_sells"] = __("Cross Sells Products (woo)","unlimited-elements-for-elementor");
1217
  $arrIncludeBy["out_of_stock"] = __("Out Of Stock Products Only (woo)", "unlimited-elements-for-elementor");
1218
  $arrIncludeBy["recent"] = __("Recently Viewed Produts (woo)", "unlimited-elements-for-elementor");
 
1219
  }
1220
 
1221
  $addPostsText = sprintf(__("Add Specific %s", "unlimited-elements-for-elementor"), $textPosts);
@@ -1349,7 +1353,7 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
1349
 
1350
  $params = array();
1351
  $params["origtype"] = UniteCreatorDialogParam::PARAM_DROPDOWN;
1352
- $params["description"] = __("Get only those terms that has the meta key/value. For IN, NOT IN, BETWEEN, NOT BETWEEN compares, use coma saparated values");
1353
  $params["elementor_condition"] = $arrConditionIncludeMeta;
1354
 
1355
  $arrItems = HelperProviderUC::getArrMetaCompareSelect();
@@ -1364,8 +1368,11 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
1364
  $params["origtype"] = UniteCreatorDialogParam::PARAM_TEXTFIELD;
1365
  $params["placeholder"] = __("Meta Value","unlimited-elements-for-elementor");
1366
  $params["add_dynamic"] = true;
 
 
1367
  $params["elementor_condition"] = $arrConditionIncludeMeta;
1368
 
 
1369
  $this->addTextBox($name."_includeby_metavalue", "", esc_html__("Include by Meta Value", "unlimited-elements-for-elementor"), $params);
1370
 
1371
  // --------- include by PHP Function -------------
@@ -1408,7 +1415,7 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
1408
  $params["elementor_condition"] = $arrConditionIncludePostMeta;
1409
 
1410
  $this->addTextBox($name."_includeby_postmeta_metafield", "", esc_html__("Meta Field Name", "unlimited-elements-for-elementor"), $params);
1411
-
1412
  //----- include id's from dynamic field -------
1413
 
1414
  $arrConditionIncludeDynamic = $arrConditionIncludeBy;
@@ -1951,7 +1958,7 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
1951
  $params["origtype"] = UniteCreatorDialogParam::PARAM_RADIOBOOLEAN;
1952
  $params["description"] = __("Show the current post meta fields, turn off it after choose the right one", "unlimited-elements-for-elementor");
1953
  $params["elementor_condition"] = $conditionCurrentMeta;
1954
-
1955
  $this->addRadioBoolean($name."_show_metafields", __("Debug - Show Meta Fields", "unlimited-elements-for-elementor"), false, "Yes", "No", $params);
1956
 
1957
  //=========== GALLERY TITLE AND DESCRIPTION SOURCE =================
@@ -2019,6 +2026,7 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
2019
  $arrSizes = array_flip($arrSizes);
2020
  $this->addSelect($name."_image_size", $arrSizes, __("Big Image Size", "unlimited-elements-for-elementor"), "large", $params);
2021
 
 
2022
  }
2023
 
2024
 
@@ -2064,6 +2072,7 @@ class UniteCreatorSettings extends UniteCreatorSettingsWork{
2064
 
2065
  if($isForGallery == true){
2066
  $arrSource["current_post_meta"] = __("Current Post Metafield", "unlimited-elements-for-elementor");
 
2067
  }
2068
 
2069
  //$arrSource["terms"] = __("Terms", "unlimited-elements-for-elementor");
1118
 
1119
  $maxPostsPerPage = get_option("posts_per_page");
1120
 
1121
+ if($isForWooProducts == true)
1122
+ $maxPostsPerPage = UniteCreatorWooIntegrate::getDefaultCatalogNumPosts();
1123
+
1124
+ $this->addStaticText("The current $textPosts are being used in archive pages. Posts per page: {$maxPostsPerPage}. Set this option in Settings -> Reading ", $name."_currenttext", $params);
1125
 
1126
  //-------- add static text - related --------
1127
 
1219
  $arrIncludeBy["cross_sells"] = __("Cross Sells Products (woo)","unlimited-elements-for-elementor");
1220
  $arrIncludeBy["out_of_stock"] = __("Out Of Stock Products Only (woo)", "unlimited-elements-for-elementor");
1221
  $arrIncludeBy["recent"] = __("Recently Viewed Produts (woo)", "unlimited-elements-for-elementor");
1222
+ $arrIncludeBy["products_from_post"] = __("Products From Post Content (woo)", "unlimited-elements-for-elementor");
1223
  }
1224
 
1225
  $addPostsText = sprintf(__("Add Specific %s", "unlimited-elements-for-elementor"), $textPosts);
1353
 
1354
  $params = array();
1355
  $params["origtype"] = UniteCreatorDialogParam::PARAM_DROPDOWN;
1356
+ $params["description"] = __("Get only those terms that has the meta key/value. For IN, NOT IN, BETWEEN, NOT BETWEEN compares, use coma saparated values","unlimited-elements-for-elementor");
1357
  $params["elementor_condition"] = $arrConditionIncludeMeta;
1358
 
1359
  $arrItems = HelperProviderUC::getArrMetaCompareSelect();
1368
  $params["origtype"] = UniteCreatorDialogParam::PARAM_TEXTFIELD;
1369
  $params["placeholder"] = __("Meta Value","unlimited-elements-for-elementor");
1370
  $params["add_dynamic"] = true;
1371
+ $params["description"] = "Special keywords you can use: {current_user_id}";
1372
+
1373
  $params["elementor_condition"] = $arrConditionIncludeMeta;
1374
 
1375
+
1376
  $this->addTextBox($name."_includeby_metavalue", "", esc_html__("Include by Meta Value", "unlimited-elements-for-elementor"), $params);
1377
 
1378
  // --------- include by PHP Function -------------
1415
  $params["elementor_condition"] = $arrConditionIncludePostMeta;
1416
 
1417
  $this->addTextBox($name."_includeby_postmeta_metafield", "", esc_html__("Meta Field Name", "unlimited-elements-for-elementor"), $params);
1418
+
1419
  //----- include id's from dynamic field -------
1420
 
1421
  $arrConditionIncludeDynamic = $arrConditionIncludeBy;
1958
  $params["origtype"] = UniteCreatorDialogParam::PARAM_RADIOBOOLEAN;
1959
  $params["description"] = __("Show the current post meta fields, turn off it after choose the right one", "unlimited-elements-for-elementor");
1960
  $params["elementor_condition"] = $conditionCurrentMeta;
1961
+
1962
  $this->addRadioBoolean($name."_show_metafields", __("Debug - Show Meta Fields", "unlimited-elements-for-elementor"), false, "Yes", "No", $params);
1963
 
1964
  //=========== GALLERY TITLE AND DESCRIPTION SOURCE =================
2026
  $arrSizes = array_flip($arrSizes);
2027
  $this->addSelect($name."_image_size", $arrSizes, __("Big Image Size", "unlimited-elements-for-elementor"), "large", $params);
2028
 
2029
+
2030
  }
2031
 
2032
 
2072
 
2073
  if($isForGallery == true){
2074
  $arrSource["current_post_meta"] = __("Current Post Metafield", "unlimited-elements-for-elementor");
2075
+ $arrSource["image_video_repeater"] = __("Image And Video Items", "unlimited-elements-for-elementor");
2076
  }
2077
 
2078
  //$arrSource["terms"] = __("Terms", "unlimited-elements-for-elementor");
provider/woocommerce_integrate.class.php CHANGED
@@ -454,6 +454,20 @@ class UniteCreatorWooIntegrate{
454
  }
455
 
456
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  /**
458
  * put filters js
459
  */
@@ -511,6 +525,45 @@ class UniteCreatorWooIntegrate{
511
  }
512
 
513
  }
514
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
 
516
  }
454
  }
455
 
456
 
457
+ /**
458
+ * get default number of posts in catalog
459
+ */
460
+ public static function getDefaultCatalogNumPosts(){
461
+
462
+ if(function_exists("wc_get_default_products_per_row") == false)
463
+ return(16);
464
+
465
+ $numProducts = wc_get_default_products_per_row() * wc_get_default_product_rows_per_page();
466
+
467
+ return($numProducts);
468
+ }
469
+
470
+
471
  /**
472
  * put filters js
473
  */
525
  }
526
 
527
  }
528
+
529
+
530
+
531
+ /**
532
+ * get product ids from current post content
533
+ */
534
+ public function getProductIDsFromCurrentPostContent(){
535
+
536
+ if(is_singular() == false)
537
+ return(false);
538
+
539
+ $post = get_post();
540
+
541
+ if(empty($post))
542
+ return(false);
543
+
544
+ $content = $post->post_content;
545
+
546
+ if(empty($content))
547
+ return(false);
548
+
549
+ $arrLinks = UniteFunctionsUC::parseHTMLGetLinks($content);
550
+
551
+ if(empty($arrLinks))
552
+ return(false);
553
+
554
+ $arrPostIDs = array();
555
+
556
+ foreach($arrLinks as $link){
557
+
558
+ $postID = url_to_postid($link);
559
+
560
+ if(empty($postID))
561
+ continue;
562
+
563
+ $arrPostIDs[] = $postID;
564
+ }
565
+
566
+ return($arrPostIDs);
567
+ }
568
 
569
  }
readme.txt CHANGED
@@ -91,368 +91,373 @@ Fully compatible and integrated with Toolset custom post types and fields.
91
 
92
  <h3>Creative Widgets for Elementor</h3>
93
  <ol>
94
- <li><a href="https://unlimited-elements.com/blob-shape-widget-for-elementor/">Blob Shapes for Elementor (Free)</a> - Create Blob Shapes with animated morphing effects. This free Elementor widget will help you make your images into random, unique, and organic-looking blob shapes. </li>
95
- <li><a href="https://unlimited-elements.com/timeline-bullets-widget-for-elementor/">Timeline Bullets for Elementor (Free)</a> - List your features or services using bullet points in a timeline layout to make it easier for users to read the important information.</li>
96
- <li><a href="https://unlimited-elements.com/animated-hamburger-icon-for-elementor/">Animated Hamburger Icon for Elementor (Free)</a> - Use the animated hamburger icon widget to toggle Elementor pro popus. You can even put a menu in a popup and create a full screen menu.</li>
97
- <li><a href="https://unlimited-elements.com/flip-box-widget-for-elementor/">Flip Box for Elementor (Free)</a> - Make your content more interesting with the Elementor Flip Box widget. Use the animated Flip Boxes to highlight any content inside your page with a flip effect.</li>
98
- <li><a href="https://unlimited-elements.com/image-tooltip-widget-for-elementor/">Image Tooltip for Elementor (Free)</a> - The easiest way to set a tooltip to any Image on the page with a short text description or any HTML code.</li>
99
- <li><a href="https://unlimited-elements.com/material-bullets-widget-for-elementor">Material Bullets for Elementor (Free)</a> - Display feature lists with custom icons and styles. Each list item can have its own icon title and text. Use the bullets widget to display features and highlights on your Elementor website.</li>
100
- <li><a href="https://unlimited-elements.com/number-box-widget-widget-for-elementor/">Number Box for Elementor (Free)</a> - Create stunning number blocks with various styles. The Number Box widget for Elementor helps you display content for step by step diagrams and instructions.</li>
101
- <li><a href="https://unlimited-elements.com/svg-animation-widget-for-elementor">SVG Animation for Elementor (Free)</a> - The SVG animation widget for Elementor makes it easy -to create impressive SVG animations for your websitet, without any coding skills just copy paste your SVG code and your animated icon is ready.</li>
102
- <li><a href="https://unlimited-elements.com/animated-mouse-scroll-icon-widget-for-elementor/">Animated Mouse Scroll Icon for Elementor (Free)</a> - The Animated Mouse Scroll Icon is a small micro animation that indicates to user they needs to scroll the page. You can make the icon an anchor point which scroll down to any section when clicked on.
103
  </li>
104
- <li><a href="https://unlimited-elements.com/icon-accordion-widget-for-elementor/">Icon Accordion for Elementor (Pro)</a> - Advanced accordion addon for Elementor page builder offers multiple styles to create interactive collapsable content with multiple layouts on your page.</li>
105
- <li><a href="https://unlimited-elements.com/image-shapes-for-elementor-page-builder/">Image Shapes for Elementor (Pro)</a> - The Image Shapes Elementor Widget allows you to make complex shape addons by clipping images using CSS to make various element layouts: circle, ellipse, polygon and more.</li>
106
- <li><a href="https://unlimited-elements.com/image-particle-widget-for-elementor/">Particle Image for Elementor (Pro)</a> - Create a dispersion interactive mouse aware distortion effect for any image using the Particle Image widget for Elementor.</li>
107
- <li><a href="https://unlimited-elements.com/image-zoom-magnifier-widget-for-elementor/">Image Zoom Magnifier for Elementor (Pro)</a> - Image Zoom Magnifier is a Elmentor Widget for creating a direction-aware magnifying glass effect to provide an inner zoom functionality on any given image. Enlarge images on touch, click, or mouseover.</li>
108
- <li><a href="https://unlimited-elements.com/background-switcher-widget-for-elementor/">Background Switcher for Elementor (Pro)</a> - The background switcher addon lets you set up cool content boxes. When you hover over a box it will change the background for the whole section. </li>
109
- <li><a href="https://unlimited-elements.com/before-after-image-comparison-widget-for-elementor/">Before After for Elementor (Pro)</a> - The Before After widget is an image comparison addon for Elementor. This widget allows you to create the effect for comparing two before and after images.</li>
110
- <li><a href="https://unlimited-elements.com/audio-player-widget-for-elementor/">Audio Player for Elementor (Pro)</a> - MP3 Music Player is a very easy to use Audio Player for Elementor. It gives you the ability to add unlimited audio tracks to any page using our Elementor addon let users listen to music on your website. </li>
111
- <li><a href="https://unlimited-elements.com/interactive-circle-infographic-widget-for-elementor/">Interactive Circle Infographic for Elementor (Pro)</a> - The Circle Infographic widget for Elementor is a simple and engaging way to present data, processes, concepts, structures and more. Helps your audience understand an entire cycle using a circular interactive tab layout.
112
 
113
  </li>
114
- <li><a href="https://unlimited-elements.com/hotspots-for-elementor-page-builder/">Hotspots for Elementor (Pro)</a> - Add hotspots to your images with a tooltip an option for opening a built in popup. Each hotspot popup can contain and image and description text.</li>
115
- <li><a href="https://unlimited-elements.com/icon-tabs-widget-for-elementor">Icon Tabs for Elementor (Pro)</a> - The Tab Widget for Elementor will help you show your text on your page divided into horizontal or vertical tabs. Customize your tabs using icons and make the content on your website interactive and fun to read.</li>
116
- <li><a href="https://unlimited-elements.com/image-accordion-widget-for-elementor/">Image Accordion for Elementor (Pro)</a> - Our image accordion addon for Elementor highlights your images with amazing hover effects and interactive layouts.</li>
117
- <li><a href="https://unlimited-elements.com/shape-bullets-widget-for-elementor/">Shape Bullets for Elementor (Pro)</a> - The Shape Bullets Widget for Elementor, creates an easy-to-manage bulleted list of items. Each item can be highlighted by its own icon.
118
  </li>
119
- <li><a href="https://unlimited-elements.com/audio-playlist-widget-for-elementor">Audio Playlist for Elementor (Pro)</a> - Create MP3 Audio Playlists inside of Elementor. Use this widget to add the ability to create unlimited numbers of playlists, albums, and audio tracks.</li>
120
- <li><a href="https://unlimited-elements.com/image-reveal-on-scroll-widget-for-elementor">Image Reveal On Scroll for Elementor (Pro)</a> - The Image Reveal on Scroll widget adds an awesome reveal on scroll effect to your images to spice up your Elementor website design.</li>
121
  </ol>
122
 
123
  <h3>Post Widgets for Elementor</h3>
124
  <ol>
125
- <li><a href="https://unlimited-elements.com/post-accordions-for-elementor/">Post Accordion for Elementor (Free)</a></li>
126
- <li><a href="https://unlimited-elements.com/post-pagination-widget-for-elementor/">Post Pagination for Elementor (Free)</a></li>
127
- <li><a href="https://unlimited-elements.com/post-blocks-widget-for-elementor">Post Blocks for Elementor (Free)</a></li>
128
- <li><a href="https://unlimited-elements.com/post-list-widget-for-elementor">Post List for Elementor (Free)</a></li>
129
- <li><a href="https://unlimited-elements.com/post-news-ticker-widget-for-elementor">Post Ticker for Elementor (Free)</a></li>
130
- <li><a href="https://unlimited-elements.com/post-tabs-for-elementor/">Post Tabs for Elementor (Free)</a></li>
131
- <li><a href="https://unlimited-elements.com/card-post-carousel-widget-for-elementor">Card Post Carousel for Elementor (Free)</a></li>
132
- <li><a href="https://unlimited-elements.com/post-gallery-widget-for-elementor">Post Gallery for Elementor (Pro)</a></li>
133
- <li><a href="https://unlimited-elements.com/elementor-author-list-widget/">Author List for Elementor (Pro)</a></li>
134
- <li><a href="https://unlimited-elements.com/masonry-post-grid-widget-for-elementor">Masonry Post Grid for Elementor (Pro)</a></li>
135
- <li><a href="https://unlimited-elements.com/taxonomy-terms-widget-for-elementor/">Taxonomy Terms for Elementor (Pro)</a></li>
136
- <li><a href="https://unlimited-elements.com/post-tiles-widget-for-elementor">Post Tile for Elementor (Pro)</a></li>
137
- <li><a href="https://unlimited-elements.com/post-magazine-grid-widget-for-elementor/">Post Magazine Grid for Elementor (Pro)</a></li>
138
- <li><a href="https://unlimited-elements.com/post-timeline-widget-for-elementor/">Post Timeline for Elementor (Pro)</a></li>
139
- <li><a href="https://unlimited-elements.com/post-sliders/">Post Slider for Elementor (Pro)</a></li>
140
- <li><a href="https://unlimited-elements.com/blog-card-slider-widget-for-elementor">Post Card Slider for Elementor (Pro)</a></li>
141
- <li><a href="https://unlimited-elements.com/post-carousels-for-elementor/">Post Carousel for Elementor (Pro)</a></li>
142
- <li><a href="https://unlimited-elements.com/post-scroll-widget-for-elementor">Post Scroll for Elementor (Pro)</a></li>
143
- <li><a href="https://unlimited-elements.com/post-grid">Post Grid for Elementor (Pro)</a></li>
144
- <li><a href="https://unlimited-elements.com/post-horizontal-timeline-widget-for-elementor/">Post Horizontal Timeline for Elementor (Pro)</a></li>
145
  </ol>
146
 
147
  <h3>Marketing Widgets for Elementor</h3>
148
  <ol>
149
- <li><a href="https://unlimited-elements.com/unlimited-timeline-widget-for-elementor">Unlimited Timeline for Elementor (Free)</a></li>
150
- <li><a href="https://unlimited-elements.com/timer-countdowns-for-elementor-page-builder/">Timer Countdown for Elementor (Free)</a></li>
151
- <li><a href="https://unlimited-elements.com/review-box-widget-for-elementor">Review Box for Elementor (Free)</a></li>
152
- <li><a href="https://unlimited-elements.com/business-hours-widget-for-elementor">Business Hours for Elementor (Free)</a></li>
153
- <li><a href="https://unlimited-elements.com/pricing-table-widget-for-elementor/">Pricing Table for Elementor (Free)</a></li>
154
- <li><a href="https://unlimited-elements.com/notification-widget-for-elementor">Notification for Elementor (Free)</a></li>
155
- <li><a href="https://unlimited-elements.com/event-box-widget-for-elementor">Event Box for Elementor (Free)</a></li>
156
- <li><a href="https://unlimited-elements.com/price-list-widget-for-elementor/">Price List for Elementor (Free)</a></li>
157
- <li><a href="https://unlimited-elements.com/statistic-counters-for-elementor">Counter for Elementor (Free)</a></li>
158
- <li><a href="https://unlimited-elements.com/call-to-action-button-widget-for-elementor/">Call To Action Button for Elementor (Free)</a></li>
159
- <li><a href="https://unlimited-elements.com/timer-countdown-banner-widget-for-elementor">Timer Countdown Banner for Elementor (Pro)</a></li>
160
- <li><a href="https://unlimited-elements.com/card-testimonial-review-carousel-widget-for-elementor">Review Carousel for Elementor (Pro)</a></li>
161
- <li><a href="https://unlimited-elements.com/list-marquee-widget-for-elementor/">List Marquee for Elementor (Pro)</a></li>
162
- <li><a href="https://unlimited-elements.com/pricing-flip-box-widget-for-elementor/">Pricing Table Flip Box for Elementor (Pro)</a></li>
163
- <li><a href="https://unlimited-elements.com/event-list-widget-for-elementor/">Event List for Elementor (Pro)</a></li>
164
- <li><a href="https://unlimited-elements.com/mobile-conversion-menu-for-elementor">Mobile Conversion Menu for Elementor (Pro)</a></li>
165
- <li><a href="https://unlimited-elements.com/price-box-widget-for-elementor/">Price Box for Elementor (Pro)</a></li>
166
- <li><a href="https://unlimited-elements.com/icon-mobile-menu-for-elementor">Icon Mobile Menu for Elementor (Pro)</a></li>
167
- <li><a href="https://unlimited-elements.com/whatsapp-chat-widget-for-elementor">Whatsapp Chat for Elementor (Pro)</a></li>
168
- <li><a href="https://unlimited-elements.com/product-bullets-widget-for-elementor">Product Bullets for Elementor (Pro)</a></li>
169
- <li><a href="https://unlimited-elements.com/two-column-product-bullets-widget-for-elementor/">Product Highlights for Elementor (Pro)</a></li>
170
- <li><a href="https://unlimited-elements.com/step-process-widget-for-elementor">Step Process for Elementor (Pro)</a></li>
171
- <li><a href="https://unlimited-elements.com/copy-coupon-code-widget-for-elementor">Copy Coupon Code for Elementor (Pro)</a></li>
 
 
 
172
  </ol>
173
 
174
  <h3>Woocommerce for Elementor</h3>
175
  <ol>
176
- <li><a href="https://unlimited-elements.com/woocommerce-product-list-widget-for-elementor/">Woocommerce Product List for Elementor (Free)</a></li>
177
- <li><a href="https://unlimited-elements.com/woocommerce-product-carousel-widget-for-elementor">Woocommerce Product Carousel for Elementor (Pro)</a></li>
178
- <li><a href="https://unlimited-elements.com/woocommerce-product-slider-widget-for-elementor">Woocommerce Product Slider for Elementor (Pro)</a></li>
179
- <li><a href="https://unlimited-elements.com/woocommerce-product-grid-widget-for-elementor/">Woocommerce Product Grid for Elementor (Pro)</a></li>
180
- <li><a href="https://unlimited-elements.com/woocommerce-category-grid-for-elemenetor/">Woocommerce Category Grid for Elementor (Pro)</a></li>
181
- <li><a href="https://unlimited-elements.com/woocommerce-category-carousel-widget-for-elementor/">Woocommerce Category Carousel for Elementor (Pro)</a></li>
182
  </ol>
183
 
184
  <h3>Dynamic Loops for Elementor</h3>
185
  <ol>
186
- <li><a href="https://unlimited-elements.com/dynamic-template-grid-widget-for-elementor/">Dynamic Template Grid for Elementor (Pro)</a></li>
187
- <li><a href="https://unlimited-elements.com/dynamic-template-carousel-widget-for-elementor/">Dynamic Template Carousel for Elementor (Pro)</a></li>
188
- <li><a href="https://unlimited-elements.com/dynamic-template-tabs-widget-for-elementor/">Dynamic Template Tabs for Elementor (Pro)</a></li>
189
- <li><a href="https://unlimited-elements.com/dynamic-template-slider-widget-for-elementor">Dynamic Template Slider for Elementor (Pro)</a></li>
190
- <li><a href="https://unlimited-elements.com/dynamic-template-accordion-widget-for-elementor/">Dynamic Template Accordion for Elementor (Pro)</a></li>
191
  </ol>
192
 
193
  <h3>Testimonials for Elementor</h3>
194
  <ol>
195
- <li><a href="https://unlimited-elements.com/box-testimonial-widget-for-elementor/">Testimonial Box for Elementor (Free)</a></li>
196
- <li><a href="https://unlimited-elements.com/logo-card-testimonial-widget-for-elementor">Testimonial Card for Elementor (Free)</a></li>
197
- <li><a href="https://unlimited-elements.com/testimonial-carousel-widget-for-elementor/">Testimonial Carousel for Elementor (Pro)</a></li>
198
- <li><a href="https://unlimited-elements.com/3d-testimonial-card-carousel-widget-for-elementor">Testimonial Card Carousel for Elementor (Pro)</a></li>
199
  </ol>
200
 
201
  <h3>Team Members for Elementor</h3>
202
  <ol>
203
- <li><a href="http://unlimited-elements.com/team-member-card-widget-for-elementor/">Team Member Card for Elementor (Free)</a></li>
204
- <li><a href="https://unlimited-elements.com/team-member-box-overlay-widget-for-elementor">Team Member Box for Elementor (Free)</a></li>
205
- <li><a href="http://unlimited-elements.com/team-member-carousel-widget-for-elementor/">Team Member Carousel for Elementor (Pro)</a></li>
206
- <li><a href="https://unlimited-elements.com/icon-team-member-widget-for-elementor">Team Member Icon Effect for Elementor (Pro)</a></li>
207
- <li><a href="http://unlimited-elements.com/team-member-grid-widget-for-elementor/">Team Member Grid for Elementor (Pro)</a></li>
208
- <li><a href="https://unlimited-elements.com/sliding-effect-team-member-widget-for-elementor">Team Member Sliding Effect for Elementor (Pro)</a></li>
209
  </ol>
210
 
211
  <h3>Menu Widgets for Elementor</h3>
212
  <ol>
213
- <li><a href="https://unlimited-elements.com/simple-fullscreen-navigation-menu-widget-for-elementor/">Fullscreen Navigation Menu for Elementor (Free)</a></li>
214
- <li><a href="https://unlimited-elements.com/simple-list-menu-widget-for-elementor">List Menu for Elementor (Free)</a></li>
215
- <li><a href="http://unlimited-elements.com/side-menu-widget-for-elementor">Side Menu for Elementor (Pro)</a></li>
216
- <li><a href="https://unlimited-elements.com/liquid-fullscreen-menu-widget-for-elementor">Liquid Full Screen Menu for Elementor (Pro)</a> - Code Credit:
217
  https://github.com/ykob/shape-overlays</li>
218
- <li><a href="https://unlimited-elements.com/one-page-scroll-navigation-widget-for-elementor">One Page Scroll Navigation for Elementor (Pro)</a></li>
219
- <li><a href="http://unlimited-elements.com/circle-menu-widget-for-elementor">Circle Menu for Elementor (Pro)</a></li>
220
- <li><a href="https://unlimited-elements.com/accordion-menu-widget-for-elementor">Accordion Menu for Elementor (Pro)</a></li>
221
  </ol>
222
 
223
  <h3>Carousel Widgets for Elementor</h3>
224
  <ol>
225
- <li><a href="https://unlimited-elements.com/card-carousel-widget-for-elementor/">Card Carousel for Elementor (Free)</a></li>
226
- <li><a href="https://unlimited-elements.com/coverflow-carousel-widget-for-elementor/">Cover Flow Carousel for Elementor (Pro)</a></li>
227
- <li><a href="https://unlimited-elements.com/icon-carousel-widget-for-elementor/">Icon Carousel for Elementor (Pro)</a></li>
228
- <li><a href="https://unlimited-elements.com/image-card-carousel-widget-for-elementor">Image Card Carousel for Elementor (Pro)</a></li>
229
- <li><a href="https://unlimited-elements.com/justified-image-carousel-widget-for-elementor/">Justified Image Carousel for Elementor (Pro)</a></li>
230
- <li><a href="https://unlimited-elements.com/material-carousel-widget-for-elementor/">Material Carousel for Elementor (Pro)</a></li>
231
- <li><a href="https://unlimited-elements.com/overlay-carousel-widget-for-elementor">Overlay Carousel for Elementor (Pro)</a></li>
232
- <li><a href="https://unlimited-elements.com/swipe-css-carousel-widget-for-elementor/">Swipe Css Carousel for Elementor (Pro)</a></li>
233
- <li><a href="https://unlimited-elements.com/portfolio-carousel-widget-for-elementor/">Portfolio Carousel for Elementor (Pro)</a></li>
234
  </ol>
235
 
236
  <h3>Slider Widgets for Elementor</h3>
237
  <ol>
238
- <li><a href="https://unlimited-elements.com/simple-slider-widget-for-elementor/">Simple Slider for Elementor (Free)</a></li>
239
- <li><a href="https://unlimited-elements.com/image-video-content-slider-widget-for-elementor">Image and Video Content Slider for Elementor (Pro)</a></li>
240
- <li><a href="https://unlimited-elements.com/thumbnail-slider-widget-for-elementor/">Thumbnail Slider for Elementor (Pro)</a></li>
241
  </ol>
242
 
243
  <h3>Content Boxes for Elementor</h3>
244
  <ol>
245
- <li><a href="https://unlimited-elements.com/image-zoom-content-box-widget-for-elementor/">Content Box Image Zoom for Elementor (Free)</a></li>
246
- <li><a href="https://unlimited-elements.com/image-card-content-box-widget-for-elementor/">Content Box Image Card for Elementor (Free)</a></li>
247
- <li><a href="https://unlimited-elements.com/hover-text-reveal-content-box-widget-for-elementor/">Content Box Hover Text Reveal for Elementor (Free)</a></li>
248
- <li><a href="https://unlimited-elements.com/icon-image-content-box-widget-for-elementor">Content Box Icon Image for Elementor (Free)</a></li>
249
- <li><a href="https://unlimited-elements.com/icon-content-box-widget-for-elementor">Icon Content Box for Elementor (Free)</a></li>
250
- <li><a href="https://unlimited-elements.com/zoom-caption-reveal-content-box-widget-for-elementor">Content Box Zoom Caption Reveal for Elementor (Pro)</a></li>
251
- <li><a href="https://unlimited-elements.com/subtle-overlay-content-box-widget-for-elementor/">Content Box Overlay for Elementor (Pro)</a></li>
252
- <li><a href="https://unlimited-elements.com/animated-border-content-box-widget-for-elementor">Animated Border Content Box for Elementor (Pro)</a></li>
253
- <li><a href="https://unlimited-elements.com/sliding-content-box-widget-for-elementor/">Content Box Sliding Effect for Elementor (Pro)</a></li>
254
  </ol>
255
 
256
  <h3>Instagram Widgets for Elementor</h3>
257
  <ol>
258
- <li><a href="https://unlimited-elements.com/latest-instagram-image-widget-for-elementor">Instagram Latest Image for Elementor (Free)</a></li>
259
- <li><a href="https://unlimited-elements.com/grid-instagram-widget-for-elementor">Instagram Grid for Elementor (Pro)</a></li>
260
- <li><a href="https://unlimited-elements.com/instagram-teaser-box-for-elementor/">Instagram Box for Elementor (Pro)</a></li>
261
- <li><a href="https://unlimited-elements.com/instagram-card-widget-for-elementor/">Instagram Card for Elementor (Pro)</a></li>
262
- <li><a href="https://unlimited-elements.com/metro-instagram-widget-for-elementor">Instagram Metro Grid for Elementor (Pro)</a></li>
263
  </ol>
264
 
265
  <h3>Logo Widgets for Elementor</h3>
266
  <ol>
267
- <li><a href="https://unlimited-elements.com/logo-grid-widget-for-elementor/">Logo Grid for Elementor (Free)</a></li>
268
- <li><a href="https://unlimited-elements.com/logo-card-widget-for-elementor">Logo Card for Elementor (Free)</a></li>
269
- <li><a href="https://unlimited-elements.com/logo-carousel-widget-for-elementor/">Logo Carousel for Elementor (Pro)</a></li>
270
- <li><a href="https://unlimited-elements.com/logo-marquee-widget-for-elementor">Logo Marquee for Elementor (Pro)</a></li>
271
  </ol>
272
 
273
  <h3>Hover Effects for Elementor</h3>
274
  <ol>
275
- <li><a href="https://unlimited-elements.com/link-hover-effects/">Link Hover Effects for Elementor (Free)</a></li>
276
- <li><a href="https://unlimited-elements.com/icon-hover-effects-for-elementor/">Icon Hover Effects for Elementor (Free)</a></li>
277
- <li><a href="https://unlimited-elements.com/creative-button-hover-widget-for-elementor/">Creative Button Hovers for Elementor (Free)</a></li>
278
- <li><a href="https://unlimited-elements.com/banner-hover-effect-widgets-for-elementor/">Banner Hover Effects for Elementor (Pro)</a></li>
279
- <li><a href="https://unlimited-elements.com/scrolling-screenshot-widget-for-elementor">Scrolling Screenshot for Elementor (Pro)</a> - Add a long screenshot that will scroll when you hover over it.</li>
280
- <li><a href="https://unlimited-elements.com/ihover-for-elementor/">iHover Effect for Elementor (Pro)</a></li>
281
- <li><a href="https://unlimited-elements.com/caption-hover-effects/">Caption Hover Effects for Elementor (Pro)</a></li>
282
- <li><a href="https://unlimited-elements.com/border-link-hover-effects-widget-for-elementor/">Border Link Hover Effects for Elementor (Pro)</a></li>
283
  </ol>
284
 
285
  <h3>Button Widgets for Elementor</h3>
286
  <ol>
287
- <li><a href="https://unlimited-elements.com/video-play-button-popup-widget-for-elementor/">Video Play Button for Elementor (Free)</a></li>
288
- <li><a href="https://unlimited-elements.com/toggle-text-button-widget-for-elementor/">Toggle Text Button for Elementor (Free)</a></li>
289
- <li><a href="https://unlimited-elements.com/parellogram-button-widget-for-elementor/">Parallelogram Button for Elementor (Free)</a></li>
290
- <li><a href="https://unlimited-elements.com/gradient-button-widget-for-elementor/">Gradient Button for Elementor (Free)</a></li>
291
- <li><a href="https://unlimited-elements.com/overlay-button-widget-for-elementor/">Overlay Button for Elementor (Free)</a></li>
292
- <li><a href="https://unlimited-elements.com/icon-pointer-button-widget-for-elementor/">Icon Pointer Button for Elementor (Free)</a></li>
293
- <li><a href="https://unlimited-elements.com/multi-line-button-widget-for-elementor/">Multi Line Button for Elementor (Free)</a></li>
294
- <li><a href="https://unlimited-elements.com/underline-animated-button-widget-for-elementor/">Underline Animated Button for Elementor (Free)</a></li>
295
- <li><a href="https://unlimited-elements.com/button-group-widget-for-elementor/">Button Group for Elementor (Free)</a></li>
296
- <li><a href="https://unlimited-elements.com/simple-artistic-button-widget-for-elementor/">Simple Artistic Button for Elementor (Pro)</a></li>
297
- <li><a href="https://unlimited-elements.com/neon-glowing-button-effect-widget-for-elementor/">Neon Glowing Button Effect for Elementor (Pro)</a></li>
298
- <li><a href="https://unlimited-elements.com/border-button-effect-widget-for-elementor/">Border Button Effect for Elementor (Pro)</a></li>
299
- <li><a href="https://unlimited-elements.com/liquid-button-widget-for-elementor/">Liquid Button for Elementor (Pro)</a></li>
300
- <li><a href="https://unlimited-elements.com/gradient-hover-effect-button-widget-for-elementor/">Gradient Hover Effect Button for Elementor (Pro)</a></li>
301
- <li><a href="https://unlimited-elements.com/glare-effect-button-widget-for-elementor/">Glare Button Effect for Elementor (Pro)</a></li>
302
- <li><a href="http://unlimited-elements.com/underline-link-hover-effect-widget-for-elementor">Underline Link Hover Effect for Elementor (Pro)</a></li>
303
- <li><a href="https://unlimited-elements.com/icon-hover-effect-button-widget-for-elementor/">Button Icon Hover Effect for Elementor (Pro)</a></li>
304
  </ol>
305
 
306
  <h3>Typography for Elementor</h3>
307
  <ol>
308
- <li><a href="https://unlimited-elements.com/text-rotator-for-elementor-page-builder/">Text Rotator for Elementor (Free)</a></li>
309
- <li><a href="https://unlimited-elements.com/3d-text-effect-for-elementor/">3D Text for Elementor (Free)</a></li>
310
- <li><a href="https://unlimited-elements.com/gradient-underline-text-effect-widget-for-elementor/">Gradient Underline Text Effect for Elementor (Free)</a></li>
311
- <li><a href="https://unlimited-elements.com/dual-color-heading-widget-for-elementor/">Dual Color Heading for Elementor (Free)</a></li>
312
- <li><a href="https://unlimited-elements.com/stroke-text-effect-widget-for-elementor/">Stroke Text Effect for Elementor (Free)</a></li>
313
- <li><a href="https://unlimited-elements.com/gradient-text-effect-for-elementor/">Gradient Text Effect for Elementor (Free)</a></li>
314
- <li><a href="https://unlimited-elements.com/text-marquee-for-elementor/">Text Marquee Effect for Elementor (Free)</a></li>
315
- <li><a href="https://unlimited-elements.com/futuristic-typing-text-effect-widget-for-elementor/">Futuristic Typing Text Effect for Elementor (Pro)</a></li>
316
- <li><a href="https://unlimited-elements.com/animated-split-text-widget-for-elementor/">Animated Split Text for Elementor (Pro)</a></li>
317
- <li><a href="https://unlimited-elements.com/sideways-vertical-text-widget-for-elementor">Sideways Vertical Text for Elementor (Pro)</a></li>
318
- <li><a href="https://unlimited-elements.com/scroll-reveal-text-widget-for-elementor/">Scroll Reveal Text for Elementor (Pro)</a></li>
319
- <li><a href="https://unlimited-elements.com/image-background-text-effect-widget-for-elementor/">Image Background Text Effect for Elementor (Pro)</a></li>
320
- <li><a href="https://unlimited-elements.com/typewriter-text-effect-for-elementor/">Typewriter Text Effect for Elementor (Pro)</a></li>
321
- <li><a href="https://unlimited-elements.com/side-line-heading-widget-for-elementor/">Side Line Heading for Elementor (Pro)</a></li>
322
  </ol>
323
 
324
  <h3>Content Widgets for Elementor</h3>
325
  <ol>
326
- <li><a href="https://unlimited-elements.com/content-tabs-widget-for-elementor/">Content Tabs for Elementor (Free)</a></li>
327
- <li><a href="https://unlimited-elements.com/content-accordion-widget-for-elementor/">Content Accordion for Elementor (Free)</a></li>
328
- <li><a href="https://unlimited-elements.com/content-timeline-widget-for-elementor/">Content Timeline for Elementor (Free)</a></li>
329
- <li><a href="https://unlimited-elements.com/content-carousel-widget-for-elementor/">Content Carousel for Elementor (Pro)</a></li>
330
- <li><a href="https://unlimited-elements.com/content-grid-widget-for-elementor/">Content Grid for Elementor (Pro)</a></li>
331
- <li><a href="https://unlimited-elements.com/content-ticker-widget-for-elementor/">Content Ticker for Elementor (Pro)</a></li>
332
- <li><a href="https://unlimited-elements.com/content-slider-widget-for-elementor">Content Slider for Elementor (Pro)</a></li>
333
- <li><a href="https://unlimited-elements.com/content-toggle-widget-for-elementor/">Content Toggle for Elementor (Pro)</a></li>
334
  </ol>
335
 
336
  <h3>Icon Boxes for Elementor</h3>
337
  <ol>
338
- <li><a href="https://unlimited-elements.com/icon-box-widget-for-elementor/">Icon Box for Elementor (Free)</a></li>
339
- <li><a href="https://unlimited-elements.com/material-footer-card-widget-for-elementor">Icon Card for Elementor (Free)</a></li>
340
- <li><a href="https://unlimited-elements.com/icon-button-number-box-widget-for-elementor">Icon Number Box for Elementor (Free)</a></li>
341
- <li><a href="https://unlimited-elements.com/twist-hover-icon-box-widget-for-elementor/">Twist Hover Icon Box for Elementor (Free)</a></li>
342
- <li><a href="https://unlimited-elements.com/solid-color-icon-box-widget-for-elementor">Sliding Icon Box for Elementor (Free)</a></li>
343
- <li><a href="https://unlimited-elements.com/animated-icon-box-widget-for-elementor/">Animated Icon Box for Elementor (Pro)</a></li>
344
- <li><a href="https://unlimited-elements.com/icon-box-hover-effect-widget-for-elementor/">Icon Box Hover Effect for Elementor (Pro)</a></li>
345
- <li><a href="https://unlimited-elements.com/animated-border-icon-box-widget-for-elementor/">Animated Border Icon Box for Elementor (Pro)</a></li>
346
- <li><a href="https://unlimited-elements.com/content-reveal-icon-box-widget-for-elementor/">Icon Box Content Reveal for Elementor (Pro)</a></li>
347
- <li><a href="https://unlimited-elements.com/solid-color-overlay-icon-box-widget-for-elementor">Overlay Icon Box for Elementor (Pro)</a></li>
348
  </ol>
349
 
350
  <h3>Progress Bar for Elementor</h3>
351
  <ol>
352
- <li><a href="https://unlimited-elements.com/linear-progress-bar-widget-for-elementor">Linear Progress Bar for Elementor (Free)</a></li>
353
- <li><a href="https://unlimited-elements.com/circle-progress-bar-widget-for-elementor/">Circle Progress Bar for Elementor (Pro)</a></li>
354
- <li><a href="https://unlimited-elements.com/semi-circle-progress-bar-widget-for-elementor/">Semi Circle Progress Bar for Elementor (Pro)</a></li>
355
- <li><a href="https://unlimited-elements.com/vertical-progress-bar-widget-for-elementor">Vertical Progress Bar for Elementor (Pro)</a></li>
356
  </ol>
357
 
358
  <h3>Image Galleries for Elementor</h3>
359
  <ol>
360
- <li><a href="https://unlimited-elements.com/minimalistic-image-gallery-for-elementor/">Minimalistic Image Gallery for Elementor (Free)</a></li>
361
- <li><a href="https://unlimited-elements.com/tile-grid-image-gallery-for-elementor/">Tile Grid Image Gallery for Elementor (Free)</a></li>
362
- <li><a href="https://unlimited-elements.com/slider-image-gallery-for-elementor/">Slider Image Gallery for Elementor (Free)</a></li>
363
- <li><a href="https://unlimited-elements.com/justified-columns-image-gallery-for-elementor">Justified Columns Image Gallery for Elementor (Pro)</a></li>
364
- <li><a href="https://unlimited-elements.com/grid-panel-image-gallery-for-elementor">Grid Panel Image Gallery for Elementor (Pro)</a></li>
365
- <li><a href="https://unlimited-elements.com/video-and-image-gallery-grid-panel-widget-for-elementor/">Video and Image Gallery Grid for Elementor (Pro)</a></li>
366
- <li><a href="https://unlimited-elements.com/carousel-image-gallery-for-elementor">Carousel Image Gallery for Elementor (Pro)</a></li>
367
- <li><a href="https://unlimited-elements.com/basic-image-gallery-for-elementor/">Basic Image Gallery for Elementor (Pro)</a></li>
368
  </ol>
369
 
370
  <h3>Video Galleries for Elementor</h3>
371
  <ol>
372
- <li><a href="https://unlimited-elements.com/slider-video-gallery-widget-for-elementor/">Slider Video Gallery for Elementor (Free)</a></li>
373
- <li><a href="https://unlimited-elements.com/minimalistic-video-gallery-widget-for-elementor/">Minimalistic Video Gallery for Elementor (Free)</a></li>
374
- <li><a href="https://unlimited-elements.com/thumb-list-video-gallery-widget-for-elementor/">Play List Video Gallery for Elementor (Pro)</a></li>
375
- <li><a href="https://unlimited-elements.com/carousel-video-gallery-widget-for-elementor/">Carousel Video Gallery for Elementor (Pro)</a></li>
376
- <li><a href="https://unlimited-elements.com/tile-columns-video-gallery-widget-for-elementor">Tile Columns Video Gallery for Elementor (Pro)</a></li>
377
- <li><a href="https://unlimited-elements.com/basic-video-gallery-widget-for-elementor/">Basic Video Gallery for Elementor (Pro)</a></li>
378
- <li><a href="https://unlimited-elements.com/grid-panel-video-gallery-widget-for-elementor/">Grid Panel Video Gallery for Elementor (Pro)</a></li>
379
- <li><a href="https://unlimited-elements.com/tiles-grid-video-gallery-widget-for-elementor/">Tiles Grid Video Gallery for Elementor (Pro)</a></li>
380
  </ol>
381
 
382
  <h3>Block Quotes for Elementor</h3>
383
  <ol>
384
- <li><a href="https://unlimited-elements.com/block-quote-box-widget-for-elementor">Block Quote Box for Elementor (Free)</a></li>
385
- <li><a href="https://unlimited-elements.com/material-block-quote-widget-for-elementor/">Block Quote Card for Elementor (Free)</a></li>
386
- <li><a href="https://unlimited-elements.com/block-quote-carousel-box-widget-for-elementor">Block Quote Carousel Box for Elementor (Free)</a></li>
387
- <li><a href="https://unlimited-elements.com/block-quote-carousel-widget-for-elementor/">Block Quote Carousel for Elementor (Pro)</a></li>
388
- <li><a href="https://unlimited-elements.com/block-quote-slider-widget-for-elementor">Block Quote Slider for Elementor (Pro)</a></li>
389
  </ol>
390
 
391
  <h3>Product Boxes for Elementor</h3>
392
  <ol>
393
- <li><a href="https://unlimited-elements.com/price-label-product-box-widget-for-elementor/">Product Box for Elementor (Free)</a></li>
394
- <li><a href="https://unlimited-elements.com/overlay-product-box-widget-for-elementor/">Overlay Product Box for Elementor (Free)</a></li>
395
- <li><a href="https://unlimited-elements.com/diagonal-product-box-widget-for-elementor">Diagonal Product Box for Elementor (Free)</a></li>
396
- <li><a href="https://unlimited-elements.com/slide-up-product-box-widget-for-elementor">Slide Up Product Box for Elementor (Pro)</a></li>
397
- <li><a href="https://unlimited-elements.com/button-overlay-product-box-widget-for-elementor">Button Overlay Product Box for Elementor (Pro)</a></li>
398
- <li><a href="https://unlimited-elements.com/overlay-slide-product-box-widget-for-elementor">Overlay Slide Product Box for Elementor (Pro)</a></li>
399
  </ol>
400
 
401
  <h3>Social Network Icons for Elementor</h3>
402
  <ol>
403
- <li><a href="https://unlimited-elements.com/glare-social-icons-widget-for-elementor/">Social Icons Glare Effect for Elementor (Free)</a></li>
404
- <li><a href="https://unlimited-elements.com/3d-social-icon-buttons-widget-for-elementor">3d Social Icon Buttons for Elementor (Free)</a></li>
405
- <li><a href="https://unlimited-elements.com/square-to-circle-social-icon-button-widgets-for-elementor">Square to Circle Social Icons for Elementor (Free)</a></li>
406
- <li><a href="https://unlimited-elements.com/rotating-social-icon-button-widgets-for-elementor">Rotating Social Icons for Elementor (Free)</a></li>
407
- <li><a href="https://unlimited-elements.com/label-social-icon-button-widgets-for-elementor">Social Icons With Label for Elementor (Free)</a></li>
408
- <li><a href="https://unlimited-elements.com/shape-social-icon-button-widgets-for-elementor">Shape Social Icons for Elementor (Pro)</a></li>
409
- <li><a href="https://unlimited-elements.com/circle-fill-social-icon-button-widgets-for-elementor">Social Icons With Circle Fill Effect for Elementor (Pro)</a></li>
410
  </ol>
411
 
412
  <h3>Separators and Dividers for Elementor</h3>
413
  <ol>
414
- <li><a href="https://unlimited-elements.com/unlimited-separator-divider-widgets-for-elementor/">Unlimited Separator Divider for Elementor (Free)</a></li>
415
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Line Diamond Separator for Elementor (Free)</a></li>
416
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Line Text Divider for Elementor (Free)</a></li>
417
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Triangle Separator for Elementor (Pro)</a></li>
418
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Zigzag Wave Seperator for Elementor (Pro)</a></li>
419
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Three Icons Separator for Elementor (Pro)</a></li>
420
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Christmas Candy Separator for Elementor (Pro)</a></li>
421
- <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Animated Wave Separator for Elementor (Pro)</a></li>
422
  </ol>
423
 
424
  <h3>Google Charts for Elementor</h3>
425
  <ol>
426
- <li><a href="https://unlimited-elements.com/pie-chart-for-elementor">Pie chart for Elementor (Free)</a></li>
427
- <li><a href="https://unlimited-elements.com/line-chart-for-elementor">Line Chart for Elementor (Free)</a></li>
428
- <li><a href="https://unlimited-elements.com/donut-chart-for-elementor">Donut Chart for Elementor (Pro)</a></li>
429
- <li><a href="https://unlimited-elements.com/line-chart-for-elementor">Comparison Line Chart for Elementor (Pro)</a></li>
430
- <li><a href="https://unlimited-elements.com/area-chart-for-elementor">Area Chart for Elementor (Pro)</a></li>
431
  </ol>
432
 
433
  <h3>Hero Widgets for Elementor</h3>
434
  <ol>
435
- <li><a href="https://unlimited-elements.com/title-hero-widget-for-elementor">Title Hero for Elementor (Free)</a></li>
436
- <li><a href="https://unlimited-elements.com/box-hero-widget-for-elementor/">Box Hero for Elementor (Free)</a></li>
437
- <li><a href="https://unlimited-elements.com/split-hero-widget-for-elementor">Split Hero for Elementor (Free)</a></li>
438
- <li><a href="https://unlimited-elements.com/transparent-split-hero-widget-for-elementor">Transparent Split Hero for Elementor (Free)</a></li>
439
- <li><a href="https://unlimited-elements.com/border-hero-widget-for-elementor">Border Hero for Elementor (Free)</a></li>
440
- <li><a href="https://unlimited-elements.com/video-hero-widget-for-elementor/">Video Hero for Elementor (Pro)</a></li>
441
- <li><a href="https://unlimited-elements.com/split-video-hero-widget-for-elementor">Split Video Hero for Elementor (Pro)</a></li>
442
- <li><a href="https://unlimited-elements.com/diagonal-hero-widget-for-elementor/">Diagonal Hero for Elementor (Pro)</a></li>
443
- <li><a href="https://unlimited-elements.com/quote-hero-widget-for-elementor">Quote Hero for Elementor (Pro)</a></li>
444
- <li><a href="https://unlimited-elements.com/persona-hero-widget-for-elementor">Persona Hero for Elementor (Pro)</a></li>
445
- <li><a href="https://unlimited-elements.com/service-box-hero-widget-for-elementor">Service Box Hero for Elementor (Pro)</a></li>
446
- <li><a href="https://unlimited-elements.com/solid-color-hero-widget-for-elementor">Solid Color Hero for Elementor (Pro)</a></li>
447
  </ol>
448
 
449
  <h3>Restaurant Widgets for Elementor</h3>
450
  <ol>
451
- <li><a href="http://unlimited-elements.com/food-menu-box-widget-for-elementor/">Food Menu Box for Elementor (Free)</a></li>
452
- <li><a href="https://unlimited-elements.com/food-menu-widget-for-elementor/">Food Menu for Elementor (Pro)</a></li>
453
- <li><a href="https://unlimited-elements.com/food-menu-list-widget-for-elementor">Food Menu List for Elementor (Pro)</a></li>
454
- <li><a href="https://unlimited-elements.com/food-menu-carousel-widget-for-elementor">Food Menu Carousel for Elementor (Pro)</a></li>
455
  </ol>
 
 
456
 
457
 
458
 
@@ -466,6 +471,36 @@ Note : This plugin works with Elementor. Make sure you have [Elementor](https://
466
 
467
  == Changelog ==
468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  version 1.4.79 = 2021-07-13
470
 
471
  * Fix: fixed scripts output in preview widget page
91
 
92
  <h3>Creative Widgets for Elementor</h3>
93
  <ol>
94
+ <li><a href="https://unlimited-elements.com/blob-shape-widget-for-elementor/">Blob Shapes Widget for Elementor (Free)</a> - Create Blob Shapes with animated morphing effects. This free Elementor widget will help you make your images into random, unique, and organic-looking blob shapes. </li>
95
+ <li><a href="https://unlimited-elements.com/timeline-bullets-widget-for-elementor/">Timeline Bullets Widget for Elementor (Free)</a> - List your features or services using bullet points in a timeline layout to make it easier for users to read the important information.</li>
96
+ <li><a href="https://unlimited-elements.com/animated-hamburger-icon-for-elementor/">Animated Hamburger Icon Widget for Elementor (Free)</a> - Use the animated hamburger icon widget to toggle Elementor pro popus. You can even put a menu in a popup and create a full screen menu.</li>
97
+ <li><a href="https://unlimited-elements.com/flip-box-widget-for-elementor/">Flip Box Widget for Elementor (Free)</a> - Make your content more interesting with the Elementor Flip Box widget. Use the animated Flip Boxes to highlight any content inside your page with a flip effect.</li>
98
+ <li><a href="https://unlimited-elements.com/image-tooltip-widget-for-elementor/">Image Tooltip Widget for Elementor (Free)</a> - The easiest way to set a tooltip to any Image on the page with a short text description or any HTML code.</li>
99
+ <li><a href="https://unlimited-elements.com/material-bullets-widget-for-elementor">Material Bullets Widget for Elementor (Free)</a> - Display feature lists with custom icons and styles. Each list item can have its own icon title and text. Use the bullets widget to display features and highlights on your Elementor website.</li>
100
+ <li><a href="https://unlimited-elements.com/number-box-widget-widget-for-elementor/">Number Box Widget for Elementor (Free)</a> - Create stunning number blocks with various styles. The Number Box widget for Elementor helps you display content for step by step diagrams and instructions.</li>
101
+ <li><a href="https://unlimited-elements.com/svg-animation-widget-for-elementor">SVG Animation Widget for Elementor (Free)</a> - The SVG animation widget for Elementor makes it easy -to create impressive SVG animations for your websitet, without any coding skills just copy paste your SVG code and your animated icon is ready.</li>
102
+ <li><a href="https://unlimited-elements.com/animated-mouse-scroll-icon-widget-for-elementor/">Animated Mouse Scroll Icon Widget for Elementor (Free)</a> - The Animated Mouse Scroll Icon is a small micro animation that indicates to user they needs to scroll the page. You can make the icon an anchor point which scroll down to any section when clicked on.
103
  </li>
104
+ <li><a href="https://unlimited-elements.com/icon-accordion-widget-for-elementor/">Icon Accordion Widget for Elementor (Pro)</a> - Advanced accordion addon for Elementor page builder offers multiple styles to create interactive collapsable content with multiple layouts on your page.</li>
105
+ <li><a href="https://unlimited-elements.com/image-shapes-for-elementor-page-builder/">Image Shapes Widget for Elementor (Pro)</a> - The Image Shapes Elementor Widget allows you to make complex shape addons by clipping images using CSS to make various element layouts: circle, ellipse, polygon and more.</li>
106
+ <li><a href="https://unlimited-elements.com/image-particle-widget-for-elementor/">Particle Image Widget for Elementor (Pro)</a> - Create a dispersion interactive mouse aware distortion effect for any image using the Particle Image widget for Elementor.</li>
107
+ <li><a href="https://unlimited-elements.com/image-zoom-magnifier-widget-for-elementor/">Image Zoom Magnifier Widget for Elementor (Pro)</a> - Image Zoom Magnifier is a Elmentor Widget for creating a direction-aware magnifying glass effect to provide an inner zoom functionality on any given image. Enlarge images on touch, click, or mouseover.</li>
108
+ <li><a href="https://unlimited-elements.com/background-switcher-widget-for-elementor/">Background Switcher Widget for Elementor (Pro)</a> - The background switcher addon lets you set up cool content boxes. When you hover over a box it will change the background for the whole section. </li>
109
+ <li><a href="https://unlimited-elements.com/before-after-image-comparison-widget-for-elementor/">Before After Widget for Elementor (Pro)</a> - The Before After widget is an image comparison addon for Elementor. This widget allows you to create the effect for comparing two before and after images.</li>
110
+ <li><a href="https://unlimited-elements.com/audio-player-widget-for-elementor/">Audio Player Widget for Elementor (Pro)</a> - MP3 Music Player is a very easy to use Audio Player for Elementor. It gives you the ability to add unlimited audio tracks to any page using our Elementor addon let users listen to music on your website. </li>
111
+ <li><a href="https://unlimited-elements.com/interactive-circle-infographic-widget-for-elementor/">Interactive Circle Infographic Widget for Elementor (Pro)</a> - The Circle Infographic widget for Elementor is a simple and engaging way to present data, processes, concepts, structures and more. Helps your audience understand an entire cycle using a circular interactive tab layout.
112
 
113
  </li>
114
+ <li><a href="https://unlimited-elements.com/hotspots-for-elementor-page-builder/">Hotspots Widget for Elementor (Pro)</a> - Add hotspots to your images with a tooltip an option for opening a built in popup. Each hotspot popup can contain and image and description text.</li>
115
+ <li><a href="https://unlimited-elements.com/icon-tabs-widget-for-elementor">Icon Tabs Widget for Elementor (Pro)</a> - The Tab Widget for Elementor will help you show your text on your page divided into horizontal or vertical tabs. Customize your tabs using icons and make the content on your website interactive and fun to read.</li>
116
+ <li><a href="https://unlimited-elements.com/image-accordion-widget-for-elementor/">Image Accordion Widget for Elementor (Pro)</a> - Our image accordion addon for Elementor highlights your images with amazing hover effects and interactive layouts.</li>
117
+ <li><a href="https://unlimited-elements.com/shape-bullets-widget-for-elementor/">Shape Bullets Widget for Elementor (Pro)</a> - The Shape Bullets Widget for Elementor, creates an easy-to-manage bulleted list of items. Each item can be highlighted by its own icon.
118
  </li>
119
+ <li><a href="https://unlimited-elements.com/audio-playlist-widget-for-elementor">Audio Playlist Widget for Elementor (Pro)</a> - Create MP3 Audio Playlists inside of Elementor. Use this widget to add the ability to create unlimited numbers of playlists, albums, and audio tracks.</li>
120
+ <li><a href="https://unlimited-elements.com/image-reveal-on-scroll-widget-for-elementor">Image Reveal On Scroll Widget for Elementor (Pro)</a> - The Image Reveal on Scroll widget adds an awesome reveal on scroll effect to your images to spice up your Elementor website design.</li>
121
  </ol>
122
 
123
  <h3>Post Widgets for Elementor</h3>
124
  <ol>
125
+ <li><a href="https://unlimited-elements.com/post-accordions-for-elementor/">Post Accordion Widget for Elementor (Free)</a></li>
126
+ <li><a href="https://unlimited-elements.com/post-pagination-widget-for-elementor/">Post Pagination Widget for Elementor (Free)</a></li>
127
+ <li><a href="https://unlimited-elements.com/post-blocks-widget-for-elementor">Post Blocks Widget for Elementor (Free)</a></li>
128
+ <li><a href="https://unlimited-elements.com/post-list-widget-for-elementor">Post List Widget for Elementor (Free)</a></li>
129
+ <li><a href="https://unlimited-elements.com/post-news-ticker-widget-for-elementor">Post Ticker Widget for Elementor (Free)</a></li>
130
+ <li><a href="https://unlimited-elements.com/post-tabs-for-elementor/">Post Tabs Widget for Elementor (Free)</a></li>
131
+ <li><a href="https://unlimited-elements.com/card-post-carousel-widget-for-elementor">Card Post Carousel Widget for Elementor (Free)</a></li>
132
+ <li><a href="https://unlimited-elements.com/post-gallery-widget-for-elementor">Post Gallery Widget for Elementor (Pro)</a></li>
133
+ <li><a href="https://unlimited-elements.com/elementor-author-list-widget/">Author List Widget for Elementor (Pro)</a></li>
134
+ <li><a href="https://unlimited-elements.com/masonry-post-grid-widget-for-elementor">Masonry Post Grid Widget for Elementor (Pro)</a></li>
135
+ <li><a href="https://unlimited-elements.com/taxonomy-terms-widget-for-elementor/">Taxonomy Terms Widget for Elementor (Pro)</a></li>
136
+ <li><a href="https://unlimited-elements.com/post-tiles-widget-for-elementor">Post Tile Widget for Elementor (Pro)</a></li>
137
+ <li><a href="https://unlimited-elements.com/post-magazine-grid-widget-for-elementor/">Post Magazine Grid Widget for Elementor (Pro)</a></li>
138
+ <li><a href="https://unlimited-elements.com/post-timeline-widget-for-elementor/">Post Timeline Widget for Elementor (Pro)</a></li>
139
+ <li><a href="https://unlimited-elements.com/post-sliders/">Post Slider Widget for Elementor (Pro)</a></li>
140
+ <li><a href="https://unlimited-elements.com/blog-card-slider-widget-for-elementor">Post Card Slider Widget for Elementor (Pro)</a></li>
141
+ <li><a href="https://unlimited-elements.com/post-carousels-for-elementor/">Post Carousel Widget for Elementor (Pro)</a></li>
142
+ <li><a href="https://unlimited-elements.com/post-scroll-widget-for-elementor">Post Scroll Widget for Elementor (Pro)</a></li>
143
+ <li><a href="https://unlimited-elements.com/post-grid">Post Grid Widget for Elementor (Pro)</a></li>
144
+ <li><a href="https://unlimited-elements.com/post-horizontal-timeline-widget-for-elementor/">Post Horizontal Timeline Widget for Elementor (Pro)</a></li>
145
  </ol>
146
 
147
  <h3>Marketing Widgets for Elementor</h3>
148
  <ol>
149
+ <li><a href="https://unlimited-elements.com/unlimited-timeline-widget-for-elementor">Unlimited Timeline Widget for Elementor (Free)</a> - Showcase your story or company history in a vertical timeline layout using the powerful Unlimited Timeline addon for Elementor.</li>
150
+ <li><a href="https://unlimited-elements.com/timer-countdowns-for-elementor-page-builder/">Timer Countdown Widget for Elementor (Free)</a> - Instantly create a beautiful, animated countdown clock addon, to share on your Elementor website. Count down to a date with your own unique timer.
151
+
152
+ </li>
153
+ <li><a href="https://unlimited-elements.com/review-box-widget-for-elementor">Review Box Widget for Elementor (Free)</a> - Simply create and display reviews on your Elementor website to build customers� trust and increase SEO.</li>
154
+ <li><a href="https://unlimited-elements.com/business-hours-widget-for-elementor">Business Hours Widget for Elementor (Free)</a></li>
155
+ <li><a href="https://unlimited-elements.com/pricing-table-widget-for-elementor/">Pricing Table Widget for Elementor (Free)</a> - Present the available pricing plans in an easy to read format. Use the Pricing Table widget to help your customers make purchasing decisions.</li>
156
+ <li><a href="https://unlimited-elements.com/notification-widget-for-elementor">Notification Widget for Elementor (Free)</a> - The Notification widget enables you to display a colored alert box and draw attention to important messages on your Elementor website.</li>
157
+ <li><a href="https://unlimited-elements.com/event-box-widget-for-elementor">Event Box Widget for Elementor (Free)</a> - Showcase events & special occasions on your websites using this unique Elementor addon.</li>
158
+ <li><a href="https://unlimited-elements.com/price-list-widget-for-elementor/">Price List Widget for Elementor (Free)</a> - A powerful addon that allows displaying a list of items, products, services or features for your business with easy styling options.</li>
159
+ <li><a href="https://unlimited-elements.com/statistic-counters-for-elementor">Counter Widget for Elementor (Free)</a> - Showcasing your business statistics and show fun facts and figures on your Elementor website.</li>
160
+ <li><a href="https://unlimited-elements.com/call-to-action-button-widget-for-elementor/">Call To Action Button Widget for Elementor (Free)</a> - The Call to Action Button Widget is a tool for creating beautiful buttons that combine an icon, some text, and message notification.</li>
161
+ <li><a href="https://unlimited-elements.com/timer-countdown-banner-widget-for-elementor">Timer Countdown Banner Widget for Elementor (Pro)</a> - An awesome countdown banner with a a call to action button.</li>
162
+ <li><a href="https://unlimited-elements.com/card-testimonial-review-carousel-widget-for-elementor">Review Carousel Widget for Elementor (Pro)</a> - The Reviews Carousel increases the visibility reviews you want to highlight to your users by letting you display them throughout your site in an interactive carousel format. </li>
163
+ <li><a href="https://unlimited-elements.com/list-marquee-widget-for-elementor/">List Marquee Widget for Elementor (Pro)</a></li>
164
+ <li><a href="https://unlimited-elements.com/pricing-flip-box-widget-for-elementor/">Pricing Table Flip Box Widget for Elementor (Pro)</a> - The Pricing Table Flip Box allows you to showcase the prices for your products, services, or packages in a beautiful flip box pricing table.</li>
165
+ <li><a href="https://unlimited-elements.com/event-list-widget-for-elementor/">Event List Widget for Elementor (Pro)</a> - The event list widget is a way to easily show your recent events like concerts, conferences, parties or special occasions.
166
+ </li>
167
+ <li><a href="https://unlimited-elements.com/mobile-conversion-menu-for-elementor">Mobile Conversion Menu Widget for Elementor (Pro)</a> - Floating action buttons that display the primary actions in your Elementor website. Provide quick access to social icons or any important or common actions to increase conversions.</li>
168
+ <li><a href="https://unlimited-elements.com/price-box-widget-for-elementor/">Price Box Widget for Elementor (Pro)</a></li>
169
+ <li><a href="https://unlimited-elements.com/icon-mobile-menu-for-elementor">Icon Mobile Menu Widget for Elementor (Pro)</a> - A perfect way to add an icon menu for making your CTA buttons stand out for website visitors using mobile devices.</li>
170
+ <li><a href="https://unlimited-elements.com/whatsapp-chat-widget-for-elementor">Whatsapp Chat Widget for Elementor (Pro)</a> - A floating WhatsApp button that allows your website visitors to start a chat conversation from your website directly to your WhatsApp phone number with just one click.</li>
171
+ <li><a href="https://unlimited-elements.com/product-bullets-widget-for-elementor">Product Bullets Widget for Elementor (Pro)</a></li>
172
+ <li><a href="https://unlimited-elements.com/two-column-product-bullets-widget-for-elementor/">Product Highlights Widget for Elementor (Pro)</a> - Design a visually attractive product feature lists that will help your potential buyers to make purchase decision and learn more about your products. </li>
173
+ <li><a href="https://unlimited-elements.com/step-process-widget-for-elementor">Step Process Widget for Elementor (Pro)</a> - Showcase process/steps with unique layout variations. Create visual diagrams of step by step instructions to simplify processes to your website visitors.</li>
174
+ <li><a href="https://unlimited-elements.com/copy-coupon-code-widget-for-elementor">Copy Coupon Code Widget for Elementor (Pro)</a> - Click to copy coupon code to the clipboard. This widgets makes it easy for users to redeem your promotions coupon codes.</li>
175
  </ol>
176
 
177
  <h3>Woocommerce for Elementor</h3>
178
  <ol>
179
+ <li><a href="https://unlimited-elements.com/woocommerce-product-list-widget-for-elementor/">Woocommerce Product List Widget for Elementor (Free)</a></li>
180
+ <li><a href="https://unlimited-elements.com/woocommerce-product-carousel-widget-for-elementor">Woocommerce Product Carousel Widget for Elementor (Pro)</a></li>
181
+ <li><a href="https://unlimited-elements.com/woocommerce-product-slider-widget-for-elementor">Woocommerce Product Slider Widget for Elementor (Pro)</a></li>
182
+ <li><a href="https://unlimited-elements.com/woocommerce-product-grid-widget-for-elementor/">Woocommerce Product Grid Widget for Elementor (Pro)</a></li>
183
+ <li><a href="https://unlimited-elements.com/woocommerce-category-grid-for-elemenetor/">Woocommerce Category Grid Widget for Elementor (Pro)</a></li>
184
+ <li><a href="https://unlimited-elements.com/woocommerce-category-carousel-widget-for-elementor/">Woocommerce Category Carousel Widget for Elementor (Pro)</a></li>
185
  </ol>
186
 
187
  <h3>Dynamic Loops for Elementor</h3>
188
  <ol>
189
+ <li><a href="https://unlimited-elements.com/dynamic-template-grid-widget-for-elementor/">Dynamic Template Grid Widget for Elementor (Pro)</a></li>
190
+ <li><a href="https://unlimited-elements.com/dynamic-template-carousel-widget-for-elementor/">Dynamic Template Carousel Widget for Elementor (Pro)</a></li>
191
+ <li><a href="https://unlimited-elements.com/dynamic-template-tabs-widget-for-elementor/">Dynamic Template Tabs Widget for Elementor (Pro)</a></li>
192
+ <li><a href="https://unlimited-elements.com/dynamic-template-slider-widget-for-elementor">Dynamic Template Slider Widget for Elementor (Pro)</a></li>
193
+ <li><a href="https://unlimited-elements.com/dynamic-template-accordion-widget-for-elementor/">Dynamic Template Accordion Widget for Elementor (Pro)</a></li>
194
  </ol>
195
 
196
  <h3>Testimonials for Elementor</h3>
197
  <ol>
198
+ <li><a href="https://unlimited-elements.com/box-testimonial-widget-for-elementor/">Testimonial Box Widget for Elementor (Free)</a></li>
199
+ <li><a href="https://unlimited-elements.com/logo-card-testimonial-widget-for-elementor">Testimonial Card Widget for Elementor (Free)</a></li>
200
+ <li><a href="https://unlimited-elements.com/testimonial-carousel-widget-for-elementor/">Testimonial Carousel Widget for Elementor (Pro)</a></li>
201
+ <li><a href="https://unlimited-elements.com/3d-testimonial-card-carousel-widget-for-elementor">Testimonial Card Carousel Widget for Elementor (Pro)</a></li>
202
  </ol>
203
 
204
  <h3>Team Members for Elementor</h3>
205
  <ol>
206
+ <li><a href="http://unlimited-elements.com/team-member-card-widget-for-elementor/">Team Member Card Widget for Elementor (Free)</a></li>
207
+ <li><a href="https://unlimited-elements.com/team-member-box-overlay-widget-for-elementor">Team Member Box Widget for Elementor (Free)</a></li>
208
+ <li><a href="http://unlimited-elements.com/team-member-carousel-widget-for-elementor/">Team Member Carousel Widget for Elementor (Pro)</a></li>
209
+ <li><a href="https://unlimited-elements.com/icon-team-member-widget-for-elementor">Team Member Icon Effect Widget for Elementor (Pro)</a></li>
210
+ <li><a href="http://unlimited-elements.com/team-member-grid-widget-for-elementor/">Team Member Grid Widget for Elementor (Pro)</a></li>
211
+ <li><a href="https://unlimited-elements.com/sliding-effect-team-member-widget-for-elementor">Team Member Sliding Effect Widget for Elementor (Pro)</a></li>
212
  </ol>
213
 
214
  <h3>Menu Widgets for Elementor</h3>
215
  <ol>
216
+ <li><a href="https://unlimited-elements.com/simple-fullscreen-navigation-menu-widget-for-elementor/">Fullscreen Navigation Menu Widget for Elementor (Free)</a></li>
217
+ <li><a href="https://unlimited-elements.com/simple-list-menu-widget-for-elementor">List Menu Widget for Elementor (Free)</a></li>
218
+ <li><a href="http://unlimited-elements.com/side-menu-widget-for-elementor">Side Menu Widget for Elementor (Pro)</a></li>
219
+ <li><a href="https://unlimited-elements.com/liquid-fullscreen-menu-widget-for-elementor">Liquid Full Screen Menu Widget for Elementor (Pro)</a> - Code Credit:
220
  https://github.com/ykob/shape-overlays</li>
221
+ <li><a href="https://unlimited-elements.com/one-page-scroll-navigation-widget-for-elementor">One Page Scroll Navigation Widget for Elementor (Pro)</a></li>
222
+ <li><a href="http://unlimited-elements.com/circle-menu-widget-for-elementor">Circle Menu Widget for Elementor (Pro)</a></li>
223
+ <li><a href="https://unlimited-elements.com/accordion-menu-widget-for-elementor">Accordion Menu Widget for Elementor (Pro)</a></li>
224
  </ol>
225
 
226
  <h3>Carousel Widgets for Elementor</h3>
227
  <ol>
228
+ <li><a href="https://unlimited-elements.com/card-carousel-widget-for-elementor/">Card Carousel Widget for Elementor (Free)</a></li>
229
+ <li><a href="https://unlimited-elements.com/coverflow-carousel-widget-for-elementor/">Coverflow Carousel Widget for Elementor (Pro)</a></li>
230
+ <li><a href="https://unlimited-elements.com/icon-carousel-widget-for-elementor/">Icon Carousel Widget for Elementor (Pro)</a></li>
231
+ <li><a href="https://unlimited-elements.com/image-card-carousel-widget-for-elementor">Image Card Carousel Widget for Elementor (Pro)</a></li>
232
+ <li><a href="https://unlimited-elements.com/material-carousel-widget-for-elementor/">Material Carousel Widget for Elementor (Pro)</a></li>
233
+ <li><a href="https://unlimited-elements.com/overlay-carousel-widget-for-elementor">Overlay Carousel Widget for Elementor (Pro)</a></li>
234
+ <li><a href="https://unlimited-elements.com/swipe-css-carousel-widget-for-elementor/">Swipe Carousel Widget for Elementor (Pro)</a></li>
235
+ <li><a href="https://unlimited-elements.com/portfolio-carousel-widget-for-elementor/">Portfolio Carousel Widget for Elementor (Pro)</a></li>
236
+ <li><a href="https://unlimited-elements.com/justified-image-carousel-widget-for-elementor/">Justified Image Carousel Widget for Elementor (Pro)</a></li>
237
  </ol>
238
 
239
  <h3>Slider Widgets for Elementor</h3>
240
  <ol>
241
+ <li><a href="https://unlimited-elements.com/simple-slider-widget-for-elementor/">Simple Slider Widget for Elementor (Free)</a></li>
242
+ <li><a href="https://unlimited-elements.com/image-video-content-slider-widget-for-elementor">Image and Video Content Slider Widget for Elementor (Pro)</a></li>
243
+ <li><a href="https://unlimited-elements.com/thumbnail-slider-widget-for-elementor/">Thumbnail Slider Widget for Elementor (Pro)</a></li>
244
  </ol>
245
 
246
  <h3>Content Boxes for Elementor</h3>
247
  <ol>
248
+ <li><a href="https://unlimited-elements.com/image-zoom-content-box-widget-for-elementor/">Content Box Image Zoom Widget for Elementor (Free)</a></li>
249
+ <li><a href="https://unlimited-elements.com/image-card-content-box-widget-for-elementor/">Content Box Image Card Widget for Elementor (Free)</a></li>
250
+ <li><a href="https://unlimited-elements.com/hover-text-reveal-content-box-widget-for-elementor/">Content Box Hover Text Reveal Widget for Elementor (Free)</a></li>
251
+ <li><a href="https://unlimited-elements.com/icon-image-content-box-widget-for-elementor">Content Box Icon Image Widget for Elementor (Free)</a></li>
252
+ <li><a href="https://unlimited-elements.com/icon-content-box-widget-for-elementor">Icon Content Box Widget for Elementor (Free)</a></li>
253
+ <li><a href="https://unlimited-elements.com/zoom-caption-reveal-content-box-widget-for-elementor">Content Box Zoom Caption Reveal Widget for Elementor (Pro)</a></li>
254
+ <li><a href="https://unlimited-elements.com/subtle-overlay-content-box-widget-for-elementor/">Content Box Overlay Widget for Elementor (Pro)</a></li>
255
+ <li><a href="https://unlimited-elements.com/animated-border-content-box-widget-for-elementor">Animated Border Content Box Widget for Elementor (Pro)</a></li>
256
+ <li><a href="https://unlimited-elements.com/sliding-content-box-widget-for-elementor/">Content Box Sliding Effect Widget for Elementor (Pro)</a></li>
257
  </ol>
258
 
259
  <h3>Instagram Widgets for Elementor</h3>
260
  <ol>
261
+ <li><a href="https://unlimited-elements.com/latest-instagram-image-widget-for-elementor">Instagram Latest Image Widget for Elementor (Free)</a></li>
262
+ <li><a href="https://unlimited-elements.com/grid-instagram-widget-for-elementor">Instagram Grid Widget for Elementor (Pro)</a></li>
263
+ <li><a href="https://unlimited-elements.com/instagram-teaser-box-for-elementor/">Instagram Box Widget for Elementor (Pro)</a></li>
264
+ <li><a href="https://unlimited-elements.com/instagram-card-widget-for-elementor/">Instagram Card Widget for Elementor (Pro)</a></li>
265
+ <li><a href="https://unlimited-elements.com/metro-instagram-widget-for-elementor">Instagram Metro Grid Widget for Elementor (Pro)</a></li>
266
  </ol>
267
 
268
  <h3>Logo Widgets for Elementor</h3>
269
  <ol>
270
+ <li><a href="https://unlimited-elements.com/logo-grid-widget-for-elementor/">Logo Grid Widget for Elementor (Free)</a></li>
271
+ <li><a href="https://unlimited-elements.com/logo-card-widget-for-elementor">Logo Card Widget for Elementor (Free)</a></li>
272
+ <li><a href="https://unlimited-elements.com/logo-carousel-widget-for-elementor/">Logo Carousel Widget for Elementor (Pro)</a></li>
273
+ <li><a href="https://unlimited-elements.com/logo-marquee-widget-for-elementor">Logo Marquee Widget for Elementor (Pro)</a></li>
274
  </ol>
275
 
276
  <h3>Hover Effects for Elementor</h3>
277
  <ol>
278
+ <li><a href="https://unlimited-elements.com/link-hover-effects/">Link Hover Effects Widget for Elementor (Free)</a></li>
279
+ <li><a href="https://unlimited-elements.com/icon-hover-effects-for-elementor/">Icon Hover Effects Widget for Elementor (Free)</a></li>
280
+ <li><a href="https://unlimited-elements.com/creative-button-hover-widget-for-elementor/">Creative Button Hovers Widget for Elementor (Free)</a></li>
281
+ <li><a href="https://unlimited-elements.com/banner-hover-effect-widgets-for-elementor/">Banner Hover Effects Widget for Elementor (Pro)</a></li>
282
+ <li><a href="https://unlimited-elements.com/scrolling-screenshot-widget-for-elementor">Scrolling Screenshot Widget for Elementor (Pro)</a> - Add a long screenshot that will scroll when you hover over it.</li>
283
+ <li><a href="https://unlimited-elements.com/ihover-for-elementor/">iHover Effect Widget for Elementor (Pro)</a></li>
284
+ <li><a href="https://unlimited-elements.com/caption-hover-effects/">Caption Hover Effects Widget for Elementor (Pro)</a></li>
285
+ <li><a href="https://unlimited-elements.com/border-link-hover-effects-widget-for-elementor/">Border Link Hover Effects Widget for Elementor (Pro)</a></li>
286
  </ol>
287
 
288
  <h3>Button Widgets for Elementor</h3>
289
  <ol>
290
+ <li><a href="https://unlimited-elements.com/video-play-button-popup-widget-for-elementor/">Video Play Button Widget for Elementor (Free)</a></li>
291
+ <li><a href="https://unlimited-elements.com/toggle-text-button-widget-for-elementor/">Toggle Text Button Widget for Elementor (Free)</a></li>
292
+ <li><a href="https://unlimited-elements.com/parellogram-button-widget-for-elementor/">Parallelogram Button Widget for Elementor (Free)</a></li>
293
+ <li><a href="https://unlimited-elements.com/gradient-button-widget-for-elementor/">Gradient Button Widget for Elementor (Free)</a></li>
294
+ <li><a href="https://unlimited-elements.com/overlay-button-widget-for-elementor/">Overlay Button Widget for Elementor (Free)</a></li>
295
+ <li><a href="https://unlimited-elements.com/icon-pointer-button-widget-for-elementor/">Icon Pointer Button Widget for Elementor (Free)</a></li>
296
+ <li><a href="https://unlimited-elements.com/multi-line-button-widget-for-elementor/">Multi Line Button Widget for Elementor (Free)</a></li>
297
+ <li><a href="https://unlimited-elements.com/underline-animated-button-widget-for-elementor/">Underline Animated Button Widget for Elementor (Free)</a></li>
298
+ <li><a href="https://unlimited-elements.com/button-group-widget-for-elementor/">Button Group Widget for Elementor (Free)</a></li>
299
+ <li><a href="https://unlimited-elements.com/simple-artistic-button-widget-for-elementor/">Simple Artistic Button Widget for Elementor (Pro)</a></li>
300
+ <li><a href="https://unlimited-elements.com/neon-glowing-button-effect-widget-for-elementor/">Neon Glowing Button Effect Widget for Elementor (Pro)</a></li>
301
+ <li><a href="https://unlimited-elements.com/border-button-effect-widget-for-elementor/">Border Button Effect Widget for Elementor (Pro)</a></li>
302
+ <li><a href="https://unlimited-elements.com/liquid-button-widget-for-elementor/">Liquid Button Widget for Elementor (Pro)</a></li>
303
+ <li><a href="https://unlimited-elements.com/gradient-hover-effect-button-widget-for-elementor/">Gradient Hover Effect Button Widget for Elementor (Pro)</a></li>
304
+ <li><a href="https://unlimited-elements.com/glare-effect-button-widget-for-elementor/">Glare Button Effect Widget for Elementor (Pro)</a></li>
305
+ <li><a href="http://unlimited-elements.com/underline-link-hover-effect-widget-for-elementor">Underline Link Hover Effect Widget for Elementor (Pro)</a></li>
306
+ <li><a href="https://unlimited-elements.com/icon-hover-effect-button-widget-for-elementor/">Button Icon Hover Effect Widget for Elementor (Pro)</a></li>
307
  </ol>
308
 
309
  <h3>Typography for Elementor</h3>
310
  <ol>
311
+ <li><a href="https://unlimited-elements.com/text-rotator-for-elementor-page-builder/">Text Rotator Widget for Elementor (Free)</a></li>
312
+ <li><a href="https://unlimited-elements.com/3d-text-effect-for-elementor/">3D Text Widget for Elementor (Free)</a></li>
313
+ <li><a href="https://unlimited-elements.com/gradient-underline-text-effect-widget-for-elementor/">Gradient Underline Text Effect Widget for Elementor (Free)</a></li>
314
+ <li><a href="https://unlimited-elements.com/dual-color-heading-widget-for-elementor/">Dual Color Heading Widget for Elementor (Free)</a></li>
315
+ <li><a href="https://unlimited-elements.com/stroke-text-effect-widget-for-elementor/">Stroke Text Effect Widget for Elementor (Free)</a></li>
316
+ <li><a href="https://unlimited-elements.com/gradient-text-effect-for-elementor/">Gradient Text Effect Widget for Elementor (Free)</a></li>
317
+ <li><a href="https://unlimited-elements.com/text-marquee-for-elementor/">Text Marquee Effect Widget for Elementor (Free)</a></li>
318
+ <li><a href="https://unlimited-elements.com/futuristic-typing-text-effect-widget-for-elementor/">Futuristic Typing Text Effect Widget for Elementor (Pro)</a></li>
319
+ <li><a href="https://unlimited-elements.com/animated-split-text-widget-for-elementor/">Animated Split Text Widget for Elementor (Pro)</a></li>
320
+ <li><a href="https://unlimited-elements.com/sideways-vertical-text-widget-for-elementor">Sideways Vertical Text Widget for Elementor (Pro)</a></li>
321
+ <li><a href="https://unlimited-elements.com/scroll-reveal-text-widget-for-elementor/">Scroll Reveal Text Widget for Elementor (Pro)</a></li>
322
+ <li><a href="https://unlimited-elements.com/image-background-text-effect-widget-for-elementor/">Image Background Text Effect Widget for Elementor (Pro)</a></li>
323
+ <li><a href="https://unlimited-elements.com/typewriter-text-effect-for-elementor/">Typewriter Text Effect Widget for Elementor (Pro)</a></li>
324
+ <li><a href="https://unlimited-elements.com/side-line-heading-widget-for-elementor/">Side Line Heading Widget for Elementor (Pro)</a></li>
325
  </ol>
326
 
327
  <h3>Content Widgets for Elementor</h3>
328
  <ol>
329
+ <li><a href="https://unlimited-elements.com/content-tabs-widget-for-elementor/">Content Tabs Widget for Elementor (Free)</a></li>
330
+ <li><a href="https://unlimited-elements.com/content-accordion-widget-for-elementor/">Content Accordion Widget for Elementor (Free)</a></li>
331
+ <li><a href="https://unlimited-elements.com/content-timeline-widget-for-elementor/">Content Timeline Widget for Elementor (Free)</a></li>
332
+ <li><a href="https://unlimited-elements.com/content-carousel-widget-for-elementor/">Content Carousel Widget for Elementor (Pro)</a></li>
333
+ <li><a href="https://unlimited-elements.com/content-grid-widget-for-elementor/">Content Grid Widget for Elementor (Pro)</a></li>
334
+ <li><a href="https://unlimited-elements.com/content-ticker-widget-for-elementor/">Content Ticker Widget for Elementor (Pro)</a></li>
335
+ <li><a href="https://unlimited-elements.com/content-slider-widget-for-elementor">Content Slider Widget for Elementor (Pro)</a></li>
336
+ <li><a href="https://unlimited-elements.com/content-toggle-widget-for-elementor/">Content Toggle Widget for Elementor (Pro)</a></li>
337
  </ol>
338
 
339
  <h3>Icon Boxes for Elementor</h3>
340
  <ol>
341
+ <li><a href="https://unlimited-elements.com/icon-box-widget-for-elementor/">Icon Box Widget for Elementor (Free)</a></li>
342
+ <li><a href="https://unlimited-elements.com/material-footer-card-widget-for-elementor">Icon Card Widget for Elementor (Free)</a></li>
343
+ <li><a href="https://unlimited-elements.com/icon-button-number-box-widget-for-elementor">Icon Number Box Widget for Elementor (Free)</a></li>
344
+ <li><a href="https://unlimited-elements.com/twist-hover-icon-box-widget-for-elementor/">Twist Hover Icon Box Widget for Elementor (Free)</a></li>
345
+ <li><a href="https://unlimited-elements.com/solid-color-icon-box-widget-for-elementor">Sliding Icon Box Widget for Elementor (Free)</a></li>
346
+ <li><a href="https://unlimited-elements.com/animated-icon-box-widget-for-elementor/">Animated Icon Box Widget for Elementor (Pro)</a></li>
347
+ <li><a href="https://unlimited-elements.com/icon-box-hover-effect-widget-for-elementor/">Icon Box Hover Effect Widget for Elementor (Pro)</a></li>
348
+ <li><a href="https://unlimited-elements.com/animated-border-icon-box-widget-for-elementor/">Animated Border Icon Box Widget for Elementor (Pro)</a></li>
349
+ <li><a href="https://unlimited-elements.com/content-reveal-icon-box-widget-for-elementor/">Icon Box Content Reveal Widget for Elementor (Pro)</a></li>
350
+ <li><a href="https://unlimited-elements.com/solid-color-overlay-icon-box-widget-for-elementor">Overlay Icon Box Widget for Elementor (Pro)</a></li>
351
  </ol>
352
 
353
  <h3>Progress Bar for Elementor</h3>
354
  <ol>
355
+ <li><a href="https://unlimited-elements.com/linear-progress-bar-widget-for-elementor">Linear Progress Bar Widget for Elementor (Free)</a></li>
356
+ <li><a href="https://unlimited-elements.com/circle-progress-bar-widget-for-elementor/">Circle Progress Bar Widget for Elementor (Pro)</a></li>
357
+ <li><a href="https://unlimited-elements.com/semi-circle-progress-bar-widget-for-elementor/">Semi Circle Progress Bar Widget for Elementor (Pro)</a></li>
358
+ <li><a href="https://unlimited-elements.com/vertical-progress-bar-widget-for-elementor">Vertical Progress Bar Widget for Elementor (Pro)</a></li>
359
  </ol>
360
 
361
  <h3>Image Galleries for Elementor</h3>
362
  <ol>
363
+ <li><a href="https://unlimited-elements.com/tile-grid-image-gallery-for-elementor/">Tile Grid Image Gallery Widget for Elementor (Free)</a></li>
364
+ <li><a href="https://unlimited-elements.com/minimalistic-image-gallery-for-elementor/">Minimalistic Image Gallery Widget for Elementor (Free)</a></li>
365
+ <li><a href="https://unlimited-elements.com/slider-image-gallery-for-elementor/">Slider Image Gallery Widget for Elementor (Free)</a></li>
366
+ <li><a href="https://unlimited-elements.com/justified-columns-image-gallery-for-elementor">Justified Columns Image Gallery Widget for Elementor (Pro)</a></li>
367
+ <li><a href="https://unlimited-elements.com/grid-panel-image-gallery-for-elementor">Grid Panel Image Gallery Widget for Elementor (Pro)</a></li>
368
+ <li><a href="https://unlimited-elements.com/video-and-image-gallery-grid-panel-widget-for-elementor/">Video and Image Gallery Grid Widget for Elementor (Pro)</a></li>
369
+ <li><a href="https://unlimited-elements.com/carousel-image-gallery-for-elementor">Carousel Image Gallery Widget for Elementor (Pro)</a></li>
370
+ <li><a href="https://unlimited-elements.com/basic-image-gallery-for-elementor/">Basic Image Gallery Widget for Elementor (Pro)</a></li>
371
  </ol>
372
 
373
  <h3>Video Galleries for Elementor</h3>
374
  <ol>
375
+ <li><a href="https://unlimited-elements.com/slider-video-gallery-widget-for-elementor/">Slider Video Gallery Widget for Elementor (Free)</a></li>
376
+ <li><a href="https://unlimited-elements.com/minimalistic-video-gallery-widget-for-elementor/">Minimalistic Video Gallery Widget for Elementor (Free)</a></li>
377
+ <li><a href="https://unlimited-elements.com/thumb-list-video-gallery-widget-for-elementor/">Play List Video Gallery Widget for Elementor (Pro)</a></li>
378
+ <li><a href="https://unlimited-elements.com/carousel-video-gallery-widget-for-elementor/">Carousel Video Gallery Widget for Elementor (Pro)</a></li>
379
+ <li><a href="https://unlimited-elements.com/tile-columns-video-gallery-widget-for-elementor">Tile Columns Video Gallery Widget for Elementor (Pro)</a></li>
380
+ <li><a href="https://unlimited-elements.com/basic-video-gallery-widget-for-elementor/">Basic Video Gallery Widget for Elementor (Pro)</a></li>
381
+ <li><a href="https://unlimited-elements.com/grid-panel-video-gallery-widget-for-elementor/">Grid Panel Video Gallery Widget for Elementor (Pro)</a></li>
382
+ <li><a href="https://unlimited-elements.com/tiles-grid-video-gallery-widget-for-elementor/">Tiles Grid Video Gallery Widget for Elementor (Pro)</a></li>
383
  </ol>
384
 
385
  <h3>Block Quotes for Elementor</h3>
386
  <ol>
387
+ <li><a href="https://unlimited-elements.com/block-quote-box-widget-for-elementor">Block Quote Box Widget for Elementor (Free)</a></li>
388
+ <li><a href="https://unlimited-elements.com/material-block-quote-widget-for-elementor/">Block Quote Card Widget for Elementor (Free)</a></li>
389
+ <li><a href="https://unlimited-elements.com/block-quote-carousel-box-widget-for-elementor">Block Quote Carousel Box Widget for Elementor (Free)</a></li>
390
+ <li><a href="https://unlimited-elements.com/block-quote-carousel-widget-for-elementor/">Block Quote Carousel Widget for Elementor (Pro)</a></li>
391
+ <li><a href="https://unlimited-elements.com/block-quote-slider-widget-for-elementor">Block Quote Slider Widget for Elementor (Pro)</a></li>
392
  </ol>
393
 
394
  <h3>Product Boxes for Elementor</h3>
395
  <ol>
396
+ <li><a href="https://unlimited-elements.com/price-label-product-box-widget-for-elementor/">Product Box Widget for Elementor (Free)</a></li>
397
+ <li><a href="https://unlimited-elements.com/overlay-product-box-widget-for-elementor/">Overlay Product Box Widget for Elementor (Free)</a></li>
398
+ <li><a href="https://unlimited-elements.com/diagonal-product-box-widget-for-elementor">Diagonal Product Box Widget for Elementor (Free)</a></li>
399
+ <li><a href="https://unlimited-elements.com/slide-up-product-box-widget-for-elementor">Slide Up Product Box Widget for Elementor (Pro)</a></li>
400
+ <li><a href="https://unlimited-elements.com/button-overlay-product-box-widget-for-elementor">Button Overlay Product Box Widget for Elementor (Pro)</a></li>
401
+ <li><a href="https://unlimited-elements.com/overlay-slide-product-box-widget-for-elementor">Overlay Slide Product Box Widget for Elementor (Pro)</a></li>
402
  </ol>
403
 
404
  <h3>Social Network Icons for Elementor</h3>
405
  <ol>
406
+ <li><a href="https://unlimited-elements.com/glare-social-icons-widget-for-elementor/">Social Icons Glare Effect Widget for Elementor (Free)</a></li>
407
+ <li><a href="https://unlimited-elements.com/3d-social-icon-buttons-widget-for-elementor">3d Social Icon Buttons Widget for Elementor (Free)</a></li>
408
+ <li><a href="https://unlimited-elements.com/square-to-circle-social-icon-button-widgets-for-elementor">Square to Circle Social Icons Widget for Elementor (Free)</a></li>
409
+ <li><a href="https://unlimited-elements.com/rotating-social-icon-button-widgets-for-elementor">Rotating Social Icons Widget for Elementor (Free)</a></li>
410
+ <li><a href="https://unlimited-elements.com/label-social-icon-button-widgets-for-elementor">Social Icons With Label Widget for Elementor (Free)</a></li>
411
+ <li><a href="https://unlimited-elements.com/shape-social-icon-button-widgets-for-elementor">Shape Social Icons Widget for Elementor (Pro)</a></li>
412
+ <li><a href="https://unlimited-elements.com/circle-fill-social-icon-button-widgets-for-elementor">Social Icons With Circle Fill Effect Widget for Elementor (Pro)</a></li>
413
  </ol>
414
 
415
  <h3>Separators and Dividers for Elementor</h3>
416
  <ol>
417
+ <li><a href="https://unlimited-elements.com/unlimited-separator-divider-widgets-for-elementor/">Unlimited Separator Divider Widget for Elementor (Free)</a></li>
418
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Line Diamond Separator Widget for Elementor (Free)</a></li>
419
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Line Text Divider Widget for Elementor (Free)</a></li>
420
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Triangle Separator Widget for Elementor (Pro)</a></li>
421
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Zigzag Wave Seperator Widget for Elementor (Pro)</a></li>
422
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Three Icons Separator Widget for Elementor (Pro)</a></li>
423
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Christmas Candy Separator Widget for Elementor (Pro)</a></li>
424
+ <li><a href="https://unlimited-elements.com/separator-and-dividers-widgets-for-elementor/">Animated Wave Separator Widget for Elementor (Pro)</a></li>
425
  </ol>
426
 
427
  <h3>Google Charts for Elementor</h3>
428
  <ol>
429
+ <li><a href="https://unlimited-elements.com/pie-chart-for-elementor">Pie chart Widget for Elementor (Free)</a></li>
430
+ <li><a href="https://unlimited-elements.com/line-chart-for-elementor">Line Chart Widget for Elementor (Free)</a></li>
431
+ <li><a href="https://unlimited-elements.com/donut-chart-for-elementor">Donut Chart Widget for Elementor (Pro)</a></li>
432
+ <li><a href="https://unlimited-elements.com/line-chart-for-elementor">Comparison Line Chart Widget for Elementor (Pro)</a></li>
433
+ <li><a href="https://unlimited-elements.com/area-chart-for-elementor">Area Chart Widget for Elementor (Pro)</a></li>
434
  </ol>
435
 
436
  <h3>Hero Widgets for Elementor</h3>
437
  <ol>
438
+ <li><a href="https://unlimited-elements.com/title-hero-widget-for-elementor">Title Hero Widget for Elementor (Free)</a></li>
439
+ <li><a href="https://unlimited-elements.com/box-hero-widget-for-elementor/">Box Hero Widget for Elementor (Free)</a></li>
440
+ <li><a href="https://unlimited-elements.com/split-hero-widget-for-elementor">Split Hero Widget for Elementor (Free)</a></li>
441
+ <li><a href="https://unlimited-elements.com/transparent-split-hero-widget-for-elementor">Transparent Split Hero Widget for Elementor (Free)</a></li>
442
+ <li><a href="https://unlimited-elements.com/border-hero-widget-for-elementor">Border Hero Widget for Elementor (Free)</a></li>
443
+ <li><a href="https://unlimited-elements.com/video-hero-widget-for-elementor/">Video Hero Widget for Elementor (Pro)</a></li>
444
+ <li><a href="https://unlimited-elements.com/split-video-hero-widget-for-elementor">Split Video Hero Widget for Elementor (Pro)</a></li>
445
+ <li><a href="https://unlimited-elements.com/diagonal-hero-widget-for-elementor/">Diagonal Hero Widget for Elementor (Pro)</a></li>
446
+ <li><a href="https://unlimited-elements.com/quote-hero-widget-for-elementor">Quote Hero Widget for Elementor (Pro)</a></li>
447
+ <li><a href="https://unlimited-elements.com/persona-hero-widget-for-elementor">Persona Hero Widget for Elementor (Pro)</a></li>
448
+ <li><a href="https://unlimited-elements.com/service-box-hero-widget-for-elementor">Service Box Hero Widget for Elementor (Pro)</a></li>
449
+ <li><a href="https://unlimited-elements.com/solid-color-hero-widget-for-elementor">Solid Color Hero Widget for Elementor (Pro)</a></li>
450
  </ol>
451
 
452
  <h3>Restaurant Widgets for Elementor</h3>
453
  <ol>
454
+ <li><a href="http://unlimited-elements.com/food-menu-box-widget-for-elementor/">Food Menu Box Widget for Elementor (Free)</a></li>
455
+ <li><a href="https://unlimited-elements.com/food-menu-widget-for-elementor/">Food Menu Widget for Elementor (Pro)</a></li>
456
+ <li><a href="https://unlimited-elements.com/food-menu-list-widget-for-elementor">Food Menu List Widget for Elementor (Pro)</a></li>
457
+ <li><a href="https://unlimited-elements.com/food-menu-carousel-widget-for-elementor">Food Menu Carousel Widget for Elementor (Pro)</a></li>
458
  </ol>
459
+
460
+
461
 
462
 
463
 
471
 
472
  == Changelog ==
473
 
474
+ version 1.4.81 = 2021-08-17:
475
+
476
+ * Feature: added json select (lottie) for image attribute type
477
+ * Feature: made option for ajax in widgets with post list attribute
478
+ * Feature: made the ajax pagination work with pagination widget
479
+ * Feature: added dynamic options for number and slider attribute types
480
+ * Feature: added new owl carousel sources in assets chooser
481
+ * Feature: added heading attribute
482
+ * Change: added more types of debug for pagination widget
483
+ * Change: changed widget icons chooser for elementor icon instead of font awesome icon
484
+ * Fix: fixed import with template button dissapear in the new bar
485
+ * Fix: fixed widgets icons
486
+
487
+
488
+ version 1.4.80 = 2021-08-09:
489
+
490
+ * Feature: added option to change items section label
491
+ * Feature: added js snippet with code that works in elementor popup
492
+ * Feature: added option to add {current_user_id} keyword in post meta query
493
+ * Feature: added option for block label inside each attribute
494
+ * Feature: added heading text option for items section
495
+ * Feature: added extra fields to image base gallery options
496
+ * Feature: added php filter option for variable
497
+ * Feature: added twig functions "get_post_term" and "is_post_has_term". The examples visible when you click on item.posts.putPostTerm placeholder
498
+ * Fix: fixed some test widgets output relate bugs
499
+ * Fix: conditions settings was not affected typography controls
500
+ * Fix: fixed template dynamic background image didn't displayed bug in dynamic loops
501
+ * Change: added some instructions for api connectivity test in general settings - troubleshooting
502
+
503
+
504
  version 1.4.79 = 2021-07-13
505
 
506
  * Fix: fixed scripts output in preview widget page
release_log.txt CHANGED
@@ -1,4 +1,37 @@
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  version 1.4.79:
3
 
4
  -bug fix: fixed scripts output in preview widget page
1
 
2
+
3
+ version 1.4.81:
4
+
5
+ -feature: added json select (lottie) for image attribute type
6
+ -feature: made option for ajax in widgets with post list attribute
7
+ -feature: made the ajax pagination work with pagination widget
8
+ -change: added more types of debug for pagination widget
9
+ -bug fix: fixed import with template button dissapear in the new bar
10
+ -bug fix: fixed widgets icons
11
+ -change: changed widget icons chooser for elementor icon instead of font awesome icon
12
+ -feature: added dynamic options for number and slider attribute types
13
+ -feature: added new owl carousel sources in assets chooser
14
+ -feature: added heading attribute
15
+
16
+
17
+
18
+ version 1.4.80:
19
+
20
+ -bug fix: fixed some test widgets output relate bugs
21
+ -feature: added option to change items section label
22
+ -feature: added js snippet with code that works in elementor popup
23
+ -bug fix: conditions settings was not affected typography controls
24
+ -feature: added option to add {current_user_id} keyword in post meta query
25
+ -feature: added option for block label inside each attribute
26
+ -feature: added heading text option for items section
27
+ -change: added some instructions for api connectivity test in general settings - troubleshooting
28
+ -feature: added extra fields to image base gallery options
29
+ -feature: added php filter option for variable
30
+ -feature: added twig functions "get_post_term" and "is_post_has_term". The examples visible when you click on item.posts.putPostTerm placeholder
31
+ -feature: added current_user_id to include by meta field in post query selector
32
+ -bug fix: fixed template dynamic background image didn't displayed bug in dynamic loops
33
+
34
+
35
  version 1.4.79:
36
 
37
  -bug fix: fixed scripts output in preview widget page
settings/addon_fields.xml CHANGED
@@ -6,6 +6,7 @@
6
  <field name="addon_icon"
7
  type="icon"
8
  default=""
 
9
  label="Icon"
10
  description="The Icon that will be shown on Elementor Panel. If not set, it will show category default icon">
11
  </field>
6
  <field name="addon_icon"
7
  type="icon"
8
  default=""
9
+ icons_type = "elementor"
10
  label="Icon"
11
  description="The Icon that will be shown on Elementor Panel. If not set, it will show category default icon">
12
  </field>
settings/library.xml CHANGED
@@ -7,10 +7,10 @@
7
  </item>
8
  <item name="mootools" title="Mootools">
9
  <js>
10
- <include handle="mootools" local="MooTools-Core-1.5.2.js"></include>
11
  </js>
12
  </item>
13
- <item name="font-awsome" title="Font Awsome">
14
  <css>
15
  <include handle="font-awesome" local="font-awsome/css/font-awesome.min.css" condition="fa4"></include>
16
  <include handle="font-awesome" local="font-awesome5/css/fontawesome-all.min.css" condition="fa5"></include>
@@ -22,9 +22,18 @@
22
  <include handle="owl-carousel" local="owl-carousel/assets/owl.carousel.css"></include>
23
  </css>
24
  <js>
 
25
  <include handle="owl-carousel" local="owl-carousel/owl.carousel.min.js"></include>
26
  </js>
27
  </item>
 
 
 
 
 
 
 
 
28
  <item name="bxslider" title="BX-Slider">
29
  <css>
30
  <include handle="bx-slider" local="bxslider/jquery.bxslider.min.css"></include>
7
  </item>
8
  <item name="mootools" title="Mootools">
9
  <js>
10
+ <include handle="mootools" hidden="true" local="MooTools-Core-1.5.2.js"></include>
11
  </js>
12
  </item>
13
+ <item name="font-awsome" title="Font Awesome">
14
  <css>
15
  <include handle="font-awesome" local="font-awsome/css/font-awesome.min.css" condition="fa4"></include>
16
  <include handle="font-awesome" local="font-awesome5/css/fontawesome-all.min.css" condition="fa5"></include>
22
  <include handle="owl-carousel" local="owl-carousel/assets/owl.carousel.css"></include>
23
  </css>
24
  <js>
25
+ <include handle="jquery-migrate" local="jquery-migrate.js"></include>
26
  <include handle="owl-carousel" local="owl-carousel/owl.carousel.min.js"></include>
27
  </js>
28
  </item>
29
+ <item name="owl-carousel-new" title="Owl Carousel New">
30
+ <css>
31
+ <include handle="owl-carousel" local="owl-carousel-new/assets/owl.carousel.css"></include>
32
+ </css>
33
+ <js>
34
+ <include handle="owl-carousel" local="owl-carousel-new/owl.carousel.min.js"></include>
35
+ </js>
36
+ </item>
37
  <item name="bxslider" title="BX-Slider">
38
  <css>
39
  <include handle="bx-slider" local="bxslider/jquery.bxslider.min.css"></include>
temp/index.html DELETED
File without changes
unlimited_elements.php CHANGED
@@ -2,14 +2,14 @@
2
  /*
3
  Plugin Name: Unlimited Elements for Elementor
4
  Plugin URI: http://unlimited-elements.com
5
- Description: Unlimited Elements - Huge Widgets Pack for Elementor Page Builder, with html/css/js widget creator and editor
6
  Author: Unlimited Elements
7
- Version: 1.4.79
8
  Author URI: http://unlimited-elements.com
9
  Text Domain: unlimited-elements-for-elementor
10
  Domain Path: /languages
11
- Elementor tested up to: 3.2.5
12
- Elementor Pro tested up to: 3.3.1
13
  */
14
 
15
  if(!defined("UNLIMITED_ELEMENTS_INC"))
2
  /*
3
  Plugin Name: Unlimited Elements for Elementor
4
  Plugin URI: http://unlimited-elements.com
5
+ Description: Unlimited Elements - Huge Widgets Pack for Elementor Website Builder, with html/css/js widget creator and editor
6
  Author: Unlimited Elements
7
+ Version: 1.4.81
8
  Author URI: http://unlimited-elements.com
9
  Text Domain: unlimited-elements-for-elementor
10
  Domain Path: /languages
11
+ Elementor tested up to: 3.4.0
12
+ Elementor Pro tested up to: 3.3.7
13
  */
14
 
15
  if(!defined("UNLIMITED_ELEMENTS_INC"))
views/objects/addon_view.class.php CHANGED
@@ -100,7 +100,20 @@ class UniteCreatorAddonView{
100
  //items editor - settings
101
  $settingsItem = new UniteCreatorSettings();
102
  $settingsItem->addRadioBoolean("enable_items", esc_html__("Enable Items", "unlimited-elements-for-elementor"), false);
103
-
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  $settingsItem->setStoredValues($options);
105
 
106
  $this->settingsItemOutput = new UniteSettingsOutputInlineUC();
100
  //items editor - settings
101
  $settingsItem = new UniteCreatorSettings();
102
  $settingsItem->addRadioBoolean("enable_items", esc_html__("Enable Items", "unlimited-elements-for-elementor"), false);
103
+
104
+
105
+ $params = array();
106
+ $params["placeholder"] = __("Default is 'Items'","unlimited-elements-for-elementor");
107
+ $settingsItem->addTextBox("items_section_title", "", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".esc_html__("Section Label", "unlimited-elements-for-elementor"), $params);
108
+
109
+ $settingsItem->addControl("enable_items", "items_section_title", "show", "true");
110
+
111
+ //heading
112
+ $params = array();
113
+ $settingsItem->addTextBox("items_section_heading", "", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".esc_html__("Section Heading", "unlimited-elements-for-elementor"), $params);
114
+ $settingsItem->addControl("enable_items", "items_section_heading", "show", "true");
115
+
116
+
117
  $settingsItem->setStoredValues($options);
118
 
119
  $this->settingsItemOutput = new UniteSettingsOutputInlineUC();
views/objects/addon_view_childparams.class.php CHANGED
@@ -101,23 +101,22 @@ class UniteCreatorAddonViewChildParams{
101
  {# This functionality exists only in the PRO version #}
102
  {# apply any WordPress filters, and any custom PHP function. Use apply_filters to create the actions. \n The function support up to 2 custom params #}
103
  \n
104
- {% set myValue = apply_filters('my_filter') }}
105
- {% set myValue = apply_filters('my_filter',value, param2, param3) }}
106
 
107
  ";
108
  $arrParams[] = $this->createChildParam_code($key, $text);
109
 
110
  //-------- run php get functoin -------------
111
 
112
- $arrParams[] = $this->createChildParam_code($key, $text);
113
 
114
  $key = "getByPHPFunction(pro)";
115
  $text = "
116
  {# Run any custom php function that starts with \"get_\". #}
117
  {# Can take any number of arguments. Look the examples #}
118
 
119
- {% set postData = getByPHPFunction('get_post') }}
120
- {% set postMeta = getByPHPFunction('get_post_meta',15) }}
121
 
122
  ";
123
  $arrParams[] = $this->createChildParam_code($key, $text);
@@ -385,6 +384,25 @@ jQuery(document).ready(function(){
385
  $arrParams[] = $this->createChildParam_code($key, $text);
386
 
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  return($arrParams);
389
  }
390
 
@@ -793,7 +811,21 @@ jQuery(document).ready(function(){
793
  $strCode .= " {% set meta_fields = getTermMeta(term.id) %} \n";
794
  $strCode .= " {{meta_fields.fieldname}} \n\n";
795
 
796
- $strCode .= "{% endfor %}\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
797
 
798
  $arrParams[] = $this->createChildParam("putPostTerms", null, array("raw_insert_text"=>$strCode));
799
 
101
  {# This functionality exists only in the PRO version #}
102
  {# apply any WordPress filters, and any custom PHP function. Use apply_filters to create the actions. \n The function support up to 2 custom params #}
103
  \n
104
+ {% set myValue = apply_filters('my_filter') %}
105
+ {% set myValue = apply_filters('my_filter',value, param2, param3) %}
106
 
107
  ";
108
  $arrParams[] = $this->createChildParam_code($key, $text);
109
 
110
  //-------- run php get functoin -------------
111
 
 
112
 
113
  $key = "getByPHPFunction(pro)";
114
  $text = "
115
  {# Run any custom php function that starts with \"get_\". #}
116
  {# Can take any number of arguments. Look the examples #}
117
 
118
+ {% set postData = getByPHPFunction('get_post') %}
119
+ {% set postMeta = getByPHPFunction('get_post_meta',15) %}
120
 
121
  ";
122
  $arrParams[] = $this->createChildParam_code($key, $text);
384
  $arrParams[] = $this->createChildParam_code($key, $text);
385
 
386
 
387
+ //----- code wrapper for popup --------
388
+
389
+ $key = "Code Wrapper for Elementor Popup";
390
+ $text = "jQuery(document).ready(function(){
391
+ function {{uc_id}}_start(){
392
+
393
+ /* Your code should start from this function
394
+ make sure you have some element with {{uc_id}} in html, example: <div id=\"{{uc_id}}\">
395
+ */
396
+
397
+ console.log(\"This code works!\");
398
+
399
+ }if(jQuery(\"#{{uc_id}}\").length) {{uc_id}}_start(); else
400
+ jQuery( document ).on( 'elementor/popup/show', () => { if(jQuery(\"#{{uc_id}}\").length) {{uc_id}}_start();});
401
+ });";
402
+ $arrParams[] = $this->createChildParam_code($key, $text);
403
+
404
+
405
+
406
  return($arrParams);
407
  }
408
 
811
  $strCode .= " {% set meta_fields = getTermMeta(term.id) %} \n";
812
  $strCode .= " {{meta_fields.fieldname}} \n\n";
813
 
814
+ $strCode .= "{% endfor %}\n\n";
815
+
816
+ //single term
817
+
818
+ $strCode .= "{# get single term. arg1 - posid, arg2 - taxonomy, arg3 - slug #}\n";
819
+
820
+ $strCode .= "{% set single_term = ucfunc(\"get_post_term\",item.posts.id,\"category\",\"termslug\") %}\n\n";
821
+
822
+ $strCode .= "{# return \"yes\" / \"no\" string #} \n\n";
823
+ $strCode .= "{% set isExists = ucfunc(\"is_post_has_term\",item.posts.id,\"category\",\"single_term\") %} \n\n";
824
+
825
+ $strCode .= "{{printVar(single_term)}} \n";
826
+ $strCode .= "{{isExists}} \n\n";
827
+
828
+
829
 
830
  $arrParams[] = $this->createChildParam("putPostTerms", null, array("raw_insert_text"=>$strCode));
831
 
views/test_settings.php CHANGED
@@ -15,10 +15,12 @@ $data["term"] = "a";
15
  $data["q"] = "a";
16
  $data["_type"] = "query";
17
 
 
 
18
 
19
- //$response = $operations->getTermsListForSelectFromData($data);
20
-
21
- //dmp($response);
22
  exit();
23
 
24
  //$font = new UniteFontManagerUC();
15
  $data["q"] = "a";
16
  $data["_type"] = "query";
17
 
18
+ /*
19
+ dmp("test settings");
20
 
21
+ $manager = new UniteFontManagerUC();
22
+ $manager->fetchIcons();
23
+ */
24
  exit();
25
 
26
  //$font = new UniteFontManagerUC();
views/troubleshooting-api-access.php DELETED
@@ -1,101 +0,0 @@
1
-
2
- <h1>Unlimited Elements - API Access Test</h1>
3
-
4
- <br>
5
-
6
- <?php
7
-
8
- /**
9
- * check zip file request
10
- */
11
- function checkZipFile(){
12
-
13
- //request single file
14
- $urlAPI = GlobalsUC::URL_API;
15
-
16
- $arrPost = array(
17
- "action"=>"get_addon_zip",
18
- "name"=>"blox_particles_logo",
19
- "cat"=>"Extras",
20
- "type"=>"addons",
21
- "catalog_date"=>"1563618449",
22
- "code"=>""
23
- );
24
-
25
-
26
- dmp("requesting widget zip from API");
27
-
28
- $response = UniteFunctionsUC::getUrlContents($urlAPI, $arrPost);
29
-
30
- if(empty($response))
31
- UniteFunctionsUC::throwError("Empty server response");
32
-
33
- $len = strlen($response);
34
-
35
- print_r("api response OK, recieve string size: $len");
36
-
37
- }
38
-
39
-
40
- /**
41
- * check zip file request
42
- */
43
- function checkCatalogRequest(){
44
-
45
- //request single file
46
- $urlAPI = GlobalsUC::URL_API;
47
-
48
- $arrPost = array(
49
- "action"=>"check_catalog",
50
- "catalog_date"=>"1563618449",
51
- "include_pages"=>false,
52
- "domain"=>"localhost",
53
- "platform"=>"wp"
54
- );
55
-
56
- dmp("requesting catalog check");
57
-
58
- $response = UniteFunctionsUC::getUrlContents($urlAPI, $arrPost);
59
-
60
- if(empty($response))
61
- UniteFunctionsUC::throwError("Empty server response");
62
-
63
- $len = strlen($response);
64
-
65
- print_r("api response OK, recieve string size: $len");
66
-
67
- }
68
-
69
- /**
70
- * various
71
- */
72
- function checkVariousOptions(){
73
-
74
- dmp("checking file get contents");
75
-
76
- $urlAPI = GlobalsUC::URL_API;
77
- $response = file_get_contents($urlAPI);
78
-
79
- $len = strlen($response);
80
-
81
- dmp("file get contents OK, recieve string size: $len");
82
-
83
- }
84
-
85
- try{
86
-
87
- checkVariousOptions();
88
-
89
- echo "<br><br>";
90
-
91
- //checkCatalogRequest();
92
-
93
- echo "<br><br>";
94
-
95
- //checkZipFile();
96
-
97
-
98
- }catch(Exception $e){
99
- echo $e->getMessage();
100
- }
101
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/troubleshooting-connectivity.php CHANGED
@@ -55,14 +55,28 @@ function checkCatalogRequest(){
55
 
56
  dmp("requesting catalog check");
57
 
58
- $response = UniteFunctionsUC::getUrlContents($urlAPI, $arrPost);
59
-
60
- if(empty($response))
61
- UniteFunctionsUC::throwError("Empty server response");
62
-
63
- $len = strlen($response);
64
-
65
- dmp("api response OK, recieve string size: $len");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  }
68
 
55
 
56
  dmp("requesting catalog check");
57
 
58
+ try{
59
+
60
+ $response = UniteFunctionsUC::getUrlContents($urlAPI, $arrPost);
61
+
62
+ if(empty($response))
63
+ UniteFunctionsUC::throwError("Empty server response");
64
+
65
+ $len = strlen($response);
66
+
67
+ dmp("api response OK, recieve string size: $len");
68
+
69
+ }catch(Exception $e){
70
+
71
+ $message = $e->getMessage()."\n<br>";
72
+
73
+ $message .= "The request to the catalog url has failed. \n<br>";
74
+ $message .= "Please contact your hosting provider and request to open firewall access to this address: \n<br>";
75
+ $message .= "http://api.unlimited-elements.com/";
76
+
77
+ UniteFunctionsUC::throwError($message);
78
+ }
79
+
80
 
81
  }
82